Commit graph

663 commits

Author SHA1 Message Date
bunnie
2211cd7e1b change baud rate on serial port to a higher speed 2025-08-19 22:23:56 +08:00
bunnie
ffc226b9a8
Merge branch 'main' into nto-bringup 2025-08-19 19:51:16 +08:00
bunnie
54648161ab fix more rustc warnings 2025-08-19 19:48:16 +08:00
bunnie
baa9380123 add 25MHz pwm output generator to the boot sequence 2025-08-19 19:01:53 +08:00
bunnie
a31978edab move sys clock frequency to lib so other crates can depend on it 2025-08-10 17:55:06 +08:00
bunnie
2cb22e6b10 remember usb debug print option 2025-08-10 16:09:33 +08:00
bunnie
1c15828391 fix clock gating & .data/.bss init
- helps to ungate the USB clock to make USB work
- helps to initialize .data/.bss correctly for Rust to work.
2025-08-10 15:50:13 +08:00
bunnie
2f4cf44503 upgrade loader to use NTO write method for kernel
~~*super fast*~~
2025-08-10 15:49:18 +08:00
bunnie
3c5240401f fix loader for NTO 2025-08-10 02:03:10 +08:00
bunnie
a00fbf6da6 fix key mappings for NTO baosec layout 2025-08-10 01:57:02 +08:00
bunnie
9fcdc7e726 fix pin maps for nto 2025-08-10 01:56:36 +08:00
bunnie
3eb0cf5891 remove MPW ram init work-around
NTO boots clean, phew...
2025-08-10 01:51:12 +08:00
bunnie
508c38cfdd refer cache flush to hal version 2025-08-05 23:01:03 +08:00
bunnie
7db16f6cf8 cleanup dependencies in loader for vexii on cram-soc 2025-07-24 00:29:42 +08:00
bunnie
45e1fa306e fix linker script for the simulation target
no need to include fonts in the verilator target environment
2025-07-23 01:23:22 +08:00
bunnie
a0a2d1728c loader changes for vexii
primarily modify the loading method to mark pages with A/D flags
as needed to work around lack of A/D handling in the trap handler
of Xous.

Also inside main.rs is a todo list for polishing off the vex-ii
port and turning into something actually sustainable for Denarius
once we have more of a full SoC model available.
2025-07-22 00:46:04 +08:00
bunnie
54dc0d9183 fix typo 2025-07-10 14:57:58 +08:00
bunnie
cfe9b3c845 modify base API for GlobalConfig to auto-infer the API address
the switch based on target is now absorbed into the new() function.
This paves the way for us to add more CSR ranges into the global
configuration object, i.e. IRQ csrs for I2C.
2025-06-07 01:52:25 +08:00
bunnie
fa3ab1dea1 cleanup dependencies a bit
cramium-soc i think should be deprecated everywhere because
it is redundant with the board targets: anywhere you see a board
target that includes the crossbar soc it should also transitively
pull in the cramium-soc dependency equivalents.

we'll chase this out more later, but for now we're just trying
to get the PDDB to compile
2025-05-20 14:35:42 +08:00
bunnie
640ee93820 cleanup loader
add a note about the dirty flag - it's not "dead" per se, I
think it is helpful to leave a bread crumb for future hw revs
that might have hardware-enforced dirty bit setting on the PTE.
2025-05-18 04:27:26 +08:00
bunnie
3a8e00eb3c map in the SPIM FLASH IFRAM pages to the swapper 2025-05-17 16:28:02 +08:00
bunnie
250bf4553e add routines for manipulating the dirty field 2025-05-16 19:03:02 +08:00
bunnie
769616e266 fix the FLG_DIRTY field so that it's not sitting in the PID area 2025-05-16 19:02:37 +08:00
bunnie
c8b3fa9aad if swap is turned on bodge a extra page buffer on the memory clear
this prevents some key loader constants from being zeroed out
2025-05-15 11:54:26 +08:00
bunnie
75fbcd5be8 fix some bit-rotted constant locations in the precursor target 2025-05-15 11:54:02 +08:00
bunnie
e2379821e6 republish xous-rs to fix cargo test 2025-05-11 15:36:17 +08:00
bunnie
8a4959056b bump version for xous crate update - commit so we can publish crates 2025-05-11 14:45:24 +08:00
bunnie
6d858e9fce cleanup out of place/duplicated constant definitions 2025-05-11 14:42:08 +08:00
bunnie
ad4a3ef3f2 KB_C2 pin just died?
KB_C2 pin on this test board just got shorted to ground internally
in the chip. I think it may have been due to power glitches
when the ammeter was switching modes feeding through and causing
trouble for the system.

Anyawys, disable that row and remap some keys so we can continue
with testing. MPW boards will hopefully be retired soon enough...
2025-05-06 19:07:25 +08:00
bunnie
51b103d674 add cam-test target to the loader 2025-05-01 16:44:43 +08:00
bunnie
3f2c4e396a cleanup the camera/QR testing loop in bootloader
This loop was useful in bringing up the GC2145 camera, so
we should keep this code around. had to be refactored/shuffled
around a bit to compensate for e.g. bitrot.
2025-05-01 16:43:53 +08:00
bunnie
bb6820419f sanity check AXP2101 e-fuse settings 2025-04-27 15:12:07 +08:00
bunnie
e22997874d add DCDC5 configuration 2025-04-21 02:42:40 +08:00
bunnie
92427822a1 add todo 2025-04-21 00:41:07 +08:00
bunnie
993836cb4e some test code for battery fet disconnect / leakage measurements
put into the commit log just in case i need to refer to it again in
the future...
2025-03-05 22:43:33 +08:00
bunnie
845e40884b add pwm mode setting to loader start 2025-03-04 01:25:02 +08:00
bunnie
e6a85c5573 add note about safety 2025-02-28 16:46:24 +08:00
bunnie
98bfc724aa remove outdated todo list 2025-02-28 16:46:08 +08:00
bunnie
55592afaaf try to isolate dependencies better 2025-02-28 16:45:48 +08:00
bunnie
a21dd3572d try to eliminate floating point debug prints
for some reason the loader has a lot of code devoted to formatting
debug prints of floating point numbers. In the version of the loader
that's being built for production I think we shouldn't need any
of this?
2025-02-28 16:34:51 +08:00
bunnie
dde034c101 document the safety issue vs USB static mut in the loader
I think we're OK to get away with this, but, it's a pretty big
set of assumptions we're making so let's write it up in a location
that we're likely to look at if/when things break.
2025-02-28 16:31:17 +08:00
bunnie
420800f329 fix text location with fb rotations 2025-02-27 21:37:08 +08:00
bunnie
836ccacf64 change polarity of dark color in fill 2025-02-27 21:36:43 +08:00
bunnie
729a0ca6b9 remove buffer swap calls
we now go between a ram-based compositing buffer and the hw
buffer which effectively gives us our double buffer
2025-02-27 03:14:45 +08:00
bunnie
216ff46e29 fix font rendering due to fb orientation adjustments 2025-02-27 03:14:21 +08:00
bunnie
1646b2913e add feature flag to gate out sh1107 bit ordering routine 2025-02-27 03:13:58 +08:00
bunnie
89b39303f1 add a routine for characterizing bit order in frame buffer 2025-02-27 03:13:33 +08:00
bunnie
c2714dca12 note fontmap hard-coded location inside link file 2025-02-24 02:29:41 +08:00
bunnie
96811143fd use the blit routine in the library for the loader logo 2025-02-24 00:58:09 +08:00
bunnie
20f96f189a fix typo 2025-02-23 16:52:59 +08:00
bunnie
c3051c0332 fix dangling reference to dependency 2025-02-23 12:14:46 +08:00
bunnie
1429944ff3 remove interim boot logo 2025-02-23 12:02:11 +08:00
bunnie
28122b764e point bootloader at the new logo 2025-02-23 12:01:22 +08:00
bunnie
e27f468acd adjust native pixel api change in loader 2025-02-21 17:45:47 +08:00
bunnie
130571b0f4 bring loader up to latest API spec 2025-02-20 15:05:23 +08:00
bunnie
5fd75ec373 update maintenance notes 2025-02-17 18:27:17 +08:00
bunnie
e4f1f8e15d update generated artifacts in the loader 2025-02-17 18:26:55 +08:00
bunnie
adad07262e fix warning about missing feature in compilation 2025-02-17 18:26:30 +08:00
bunnie
6e18096247 ux-api needs to have the board specified when cramium features are selected 2025-02-11 16:25:22 +08:00
bunnie
25dfc4723d refactor loader to use ux-api 2025-02-02 07:02:35 +08:00
bunnie
0d1a137597 restore the missing font section
this goes missing every now and then because i comment it out for
faster load times during dev
2025-01-20 15:37:00 +08:00
bunnie
cb60120bb2 add some prelim coreuser test routines
these currently only make sense in a simulation environment,
but they allow us to work the significant configuration test
cases for practical execution to make sure we haven't missed
something in the coreuser spec.
2025-01-12 00:55:43 +08:00
bunnie
71ac106ee7 add the CGU perclk divider for the NTO target 2025-01-03 04:06:11 +08:00
bunnie
201decd4ca more feature flag bitrot in loader 2025-01-01 22:47:59 +08:00
bunnie
f3517603e9 cleanup some feature flag bitrot 2025-01-01 22:47:19 +08:00
bunnie
8c0cfd9eab clean up unused args in API 2024-12-23 01:15:49 +08:00
bunnie
6dcb23a53b add flags for configuring uart 2024-12-22 00:32:14 +08:00
bunnie
44f50a992a add irq disabling routine 2024-12-22 00:31:54 +08:00
bunnie
c66a7c47fb another spot where the irq enable has to be moved 2024-12-22 00:31:32 +08:00
bunnie
e07ab36984 fixup IRQ handling
- disable IRQs on departure
- put EV enable outside of the HAL function
this is necessary because we need all HAL calls to be finished
before an interrupt happens to avoid locking problems
2024-12-22 00:30:27 +08:00
bunnie
b66b60497b make the app uart configurable
so processes other than swap can use it
2024-12-22 00:29:50 +08:00
bunnie
c8e4392a95 pass a handle to udma_global to i2c init 2024-12-06 03:33:39 +08:00
bunnie
76ffbf6e27 loader feature for mpw 2024-12-06 03:33:10 +08:00
bunnie
c9865e11c2 remove pio dep from loader 2024-12-02 01:01:22 +08:00
bunnie
189611f3c4 add updates, verilator-only, and simulation-only feature gates
- updates enables or disables updates in the loader
- verilator-only will turn off routines that access hardware not
present in verilator (e.g. leads to a bus lockup)
- simulation-only turns of features that take a long amount of time
and aren't necessary in simulation, such as bulk clearing of
all RAM - in simulation, we can configure the simulator to do this
for us prior to boot; but in HW, of course, RAM is just random,
or worse, has the previous session's secrets in it.
2024-11-30 02:27:35 +08:00
bunnie
1710fb7ee2 cleanup the cramium hw implementation feature flags
this re-oragnizes the feature matrix of the loader to
reflect the chip/board division of feature flags better.
2024-11-30 02:26:56 +08:00
bunnie
43988bde05 cleanup warning on a debug routine
this is not used under certain combinations of e.g. printing
and swap
2024-11-30 02:25:58 +08:00
bunnie
b85b9d2dc2 improve assert message 2024-11-30 02:25:40 +08:00
bunnie
d3eda68b42 move features from cramium-soc into specific boards
cramium-soc is moving closer to the platonic SoC specifier,
and the board-* features are for the specific boards that use
cramium-soc

This division of feature flags feels a lot nicer and cleaner -
if it holds up to further development, I think this style might
become the new standard for Xous (as opposed to a single level
of feature flag where both SoC and board target are conflated in
terms of meaning - which kind of made sense when the CPU was
an FPGA and could actually have different features for different
boards, but for ASICs this wouldn't happen).
2024-11-30 02:23:35 +08:00
bunnie
a527b3a300 gate RAM clearing behind not(simulation-only) feature flag
RAM clearing takes a lot of time in simulation and is not necessary,
hence the feature gate option.
2024-11-30 02:22:47 +08:00
bunnie
861b7ae3ff compromise on oscillator setting
I felt uncomfortable leaving the oscillator setting entirely
outside the PLL routine, so as a compromise I defer the oscillator
switch-over until after the initial PLL settings are loaded.

This makes both the simulation model and the actual hardware
happy. I think probably what the simulation model *should* have
done is consider the "powerdown" pin when checking the validity
of the signals going into the PLL model - but this is impossible
to modify/check because the PLL is provided as an encrypted blob :(
2024-11-28 15:32:19 +08:00
bunnie
6e8bff749c eliminate invalid PLL transition
this transition was in the reference C code, but in verilog simulation
it turns out it activates the PLL in an invalid mode which can lead
to glitching. Removing this makes both the simulation happy and
presumably the PLL happier as well.
2024-11-28 15:07:43 +08:00
bunnie
ec3d8b5042 handle swap image burning 2024-11-22 00:55:29 +08:00
bunnie
a7619e55a8 add progress bar to burn 2024-11-21 22:03:06 +08:00
bunnie
b944c51474 a simple update with verified image now working 2024-11-21 18:23:55 +08:00
bunnie
89fb9b4df6 add reference to the presign module 2024-11-21 02:22:39 +08:00
bunnie
30cb5f84f7 make more space in the cramium loader
need code space to handle image verification.

getting kind of heavy, but I think we're almost done.
2024-11-21 02:22:08 +08:00
bunnie
2437712b7b add some basic image integrity checking code
this doesn't protect against malicious tampering (because
the public key is the developer key) but it will at least
catch correctness errors in USB upload and filesystem
behavior.
2024-11-21 02:20:40 +08:00
bunnie
8aa633641f add new dependencies for image checking in loader 2024-11-21 02:20:10 +08:00
bunnie
3bf8598509 make slice cursor peekable 2024-11-21 02:19:45 +08:00
bunnie
fb0efbce3b add helper type for pre-hash digests 2024-11-21 02:19:21 +08:00
bunnie
ed085f2c83 UX improvements for loader update interface 2024-11-20 21:41:41 +08:00
bunnie
9c1186022f quiet debug 2024-11-20 21:41:23 +08:00
bunnie
8b571561f8 cleanup warning 2024-11-20 21:41:08 +08:00
bunnie
60dcd906ed include slice_cursor in mod list 2024-11-20 21:40:50 +08:00
bunnie
3b567fb3e2 modularize SliceCursor 2024-11-20 21:40:25 +08:00
bunnie
b68abf1d2b change volume label 2024-11-20 20:43:39 +08:00
bunnie
6d3a58ccea cleanup warnings 2024-11-20 20:41:10 +08:00
bunnie
9a839e3fe6 add keypress handling and no_std Cursor implementation 2024-11-20 20:40:48 +08:00
bunnie
d9709997fb add template disk image
this is a pre-initialized, FAT12 image that is compatible with
Windows (which is the harder of the OSes to please)
2024-11-20 20:40:05 +08:00
bunnie
e181c0d460 use global allocator for simple-fatfs
also initialize the disk image with some default data
2024-11-20 20:39:27 +08:00
bunnie
8cc80741ac cleanup warning 2024-11-20 20:39:06 +08:00
bunnie
51717fd7d9 move to simple-fatfs 2024-11-20 20:38:31 +08:00
bunnie
6c79441ee1 add boot option to loader 2024-11-20 01:45:56 +08:00
bunnie
bb594a5c40 try to improve the pmic detection code
we can now recover from an I2C timeout and get the PMIC data
out, but mysteriously, when we leave the routine, the CPU hangs.

I think fundamentally the I2C instability is due to something
very wonky inside the chip itself, so the recovery only papers
over an issue that is only fixed with a reboot...
2024-11-20 01:44:58 +08:00
bunnie
f14cf1948c gfx is now used as part of the update routine 2024-11-20 01:44:28 +08:00
bunnie
d4f209c0b2 add ghostfat to dependencies
in anticipation of starting to emulate the FS
2024-11-20 01:43:46 +08:00
bunnie
391fb84f00 update api to inclued perclk_freq 2024-11-20 01:43:25 +08:00
bunnie
64520cf5a3 add note about failing option for pl230 2024-11-18 18:38:15 +08:00
bunnie
626d997868 move pl230 test to an easier place for checking 2024-11-18 18:37:33 +08:00
bunnie
aba5d25e36 cleanup warnings when boardbringup is not selected 2024-11-05 19:41:12 +08:00
bunnie
0463629a0a cleanup warnings when board-bringup target is not selected 2024-11-05 19:40:28 +08:00
bunnie
ec801ca716 add nalgebra dependency 2024-11-05 01:46:03 +08:00
bunnie
dc20c84785 refer to new modules 2024-11-05 01:45:13 +08:00
bunnie
08f7252791 integrate new qr finding code 2024-11-05 01:44:53 +08:00
bunnie
16c9b2c7e2 insert refactored qr code
code alignment and finding now works *great*. Near real-time
performance!
2024-11-05 01:44:12 +08:00
bunnie
f6d6db566a add homography searching routines 2024-11-05 01:43:59 +08:00
bunnie
8ce400dde3 add more feature flags 2024-10-27 23:28:38 +08:00
bunnie
6c4cd3bc67 add qr option 2024-10-27 23:28:08 +08:00
bunnie
8625dae0db add more swap sram support and change resolution api name 2024-10-27 23:27:26 +08:00
bunnie
4f85deaecb change api name for resolutions to dimensions 2024-10-27 23:26:45 +08:00
bunnie
bceb08afb8 recognize 8MiB swap chip 2024-10-27 23:24:42 +08:00
bunnie
38ad0363ce fix capacity units 2024-10-26 18:45:36 +08:00
bunnie
1a90df9d53 add descriptor chaining for large bulk transfers 2024-10-26 03:06:37 +08:00
bunnie
2a92932850 cleanup some debug 2024-10-26 03:06:10 +08:00
bunnie
f9e99a4ff3 add assembly stub for cramium boot
this fixes a stability issue observed at boot
2024-10-24 01:29:04 +08:00
bunnie
e7f706e9cd revert statics clearing routine
this turns out to be a bad idea because it corrupts systems
that have suspend/resume.
2024-10-21 03:28:58 +08:00
bunnie
9647202366 cleanup testing code for QR code
now it will overlay crosshairs on finder patterns and do affine
correction when the finders are found.
2024-10-21 01:18:12 +08:00
bunnie
5d49d2dbb7 add libraries for math and make usb a feature 2024-10-21 01:17:41 +08:00
bunnie
2fd59a1f87 tweaks for platform agnostic API 2024-10-21 01:16:59 +08:00
bunnie
b3f038ca06 add affine skew correction step 2024-10-21 01:16:37 +08:00
bunnie
c0b942b801 platform-specific implementations for graphics 2024-10-21 01:14:04 +08:00
bunnie
5c6be58056 revise camera code - capture 256x240 frames
this improves decoding for e.g. type 5 codes, which is
a bit too tight with a 128x120 frame.
2024-10-20 17:05:45 +08:00
bunnie
f16e3721be add some QR code debugging stuffs 2024-10-20 17:03:50 +08:00
bunnie
b6fbc4ef36 clean up some gross static mut state stuff
still have to resolve the static mut issue of getting the USB
controller state into the interrupt controller.

I'm not sure there *is* a good way to do it - this might actually
be "the" use case for static mut's - but the point of this
exercise was to just diff out the driver in machine mode versus
OS mode to try and figure out if there's a hardware problem
causing instability or if it's a driver issue

the conclusion so far is that the USB stack requires extremely
tight interrupt handling timing, and so, for better stability
we may have to mirgate away from the heavily user-space dependent
implementation currently in use.
2024-10-19 00:15:12 +08:00
bunnie
37ceefef21 add usb mass storage command handlers
disk enumerates now, and initiates r/w transactions but
the reference driver does not match the implementation in that
the USB stack can't access all of RAM, so we have to add
an intermediate stage that splits the command requests into
smaller chunks
2024-10-19 00:14:12 +08:00
bunnie
dabd87aa3a add usb mass storage command handling 2024-10-19 00:13:52 +08:00
bunnie
ed9759f524 remove a debug statement 2024-10-18 17:18:06 +08:00
bunnie
90d7f45f0a adjust locations of memory for USB loader
and document the rationale
2024-10-18 17:17:29 +08:00
bunnie
452ba4adff cleanup area for statics used by the loader 2024-10-18 17:16:21 +08:00
bunnie
6c655e9358 re-enable interrupts immediately in the handler
we need to catch an interrupt that gets issued while we
are still handling the pending interrupt.
2024-10-18 17:15:24 +08:00
bunnie
a6e7459cdd re-organize the USB subsystem into modules 2024-10-18 14:45:15 +08:00
bunnie
e4f5c32ff3 update link locations to make space in loader for USB stack
this is in preparation for loader-based updates

may have to increase space even more when we pull in e.g.
firmware signing and verification primitives.
2024-10-18 04:17:36 +08:00
bunnie
d8cd9ba5c5 add hook to USB testing, and also move the kernel to make space for loader USB 2024-10-18 04:16:31 +08:00
bunnie
3a4ae8f09f add usb to cramium platform 2024-10-18 04:16:08 +08:00
bunnie
8b14494a15 fix some bugs in gpio twiddle code 2024-10-18 04:15:47 +08:00
bunnie
af6f4766ff translated reference USB stack into Rust
implements mass storage; needs debugging
2024-10-18 04:13:57 +08:00
bunnie
3b61a60a2c remove boot delay, add reset-debug feature targets 2024-10-16 03:06:41 +08:00
bunnie
4c810ec447 add various debugging assembly routines for the loader 2024-10-16 03:05:54 +08:00
bunnie
778af25414 add handler for pmic open failure; add test case for self-powerdown 2024-10-12 00:46:47 +08:00