Commit graph

264 commits

Author SHA1 Message Date
bunnie
7ff1e438ff make decrypt_page_at fallible
previously we just panic'd (which is actually the right behavior
for this type of error) but because we now have a reason for it
to fail (e.g. testing the encryption key) we make this fallible.

in all other places we just unwrap() - there is no fallback if
decryption fails, boot should just halt.

but this allows us to check which decryption key is deployed
in phase 1.
2025-10-04 18:54:15 +08:00
bunnie
9b11361256 fixup loader heap; move signature validation; fixup swap structures
- loader heap is now fixed in a "throw-away" region of memory.
this means the heap should only be used sparingly, and somewhat
dangerously, because the values can't persist beyond the lifetime
of the loader.

- signature validation moved earlier

- fixup swap structures to refer to the API so that image creation
is easier/consistent
2025-10-04 00:56:18 +08:00
bunnie
e1537328fa light refactoring of kernel arguments structure
this is a fairly complicated bit of legacy code that we're
trying to make slightly better/more readable.

some docs are added, as well as getting rid of a bunch of
"magic" constants, instead preferring to map things into
structured data where possible.

also fixed the location of the heap allocation relative to
the boot flow. It's now in a spot where I think we can
safely put dynamically allocated kernel arguments.
2025-10-02 02:17:45 +08:00
bunnie
76e22e3d0a cleanup warnings 2025-10-01 23:58:49 +08:00
bunnie
9d2311f9ce add remaining pin setups in the loader
this simplifies the kernel's boot job a little bit by
having all the I/O resources set up by the loader.
2025-10-01 23:39:43 +08:00
bunnie
4c84fc523d remove deprecated testing feature 2025-10-01 23:38:28 +08:00
bunnie
483e8f3508 the great loader culling
The loader grew a lot of hair over the past few months as it
was abused as a baremetal environment for chip bring-up.

A baremetal environment was explicitly created to help with that,
so we don't have to pollute the loader with lots of unused features
and ancilliary code.

Furthermore, a decision was made to eliminate updates from the
loader code base - the loader is just for setting up Xous. This
allows the loader to be more platform-agnostic.

Boot1 instead contains all the platform-specific code for doing updates.

For completeness, we note that boot0 is a minimal piece of code that is the
first step in the chain of trust and is intended to be a read-only
segment of code that has public keys baked into it that are used
to bootstrap the rest of the ecosystem.

At this point, the loader is now slimmed down and runs. Still needs
testing to make sure the culling wasn't too aggressive, but I am
much happier with where this is landing as the loader is once again
just focused on getting Xous up and running.
2025-10-01 14:57:40 +08:00
bunnie
ed935c66cb loader tracking api changes; needs refinement still. 2025-10-01 02:57:32 +08:00
bunnie
a8f90dd71b cleanup fonts out of the loader for bao1x target 2025-09-25 16:12:26 +08:00
bunnie
ff6ff8841a fix missing api in precursor target from previous PR
also fixup some warnings from the new rustc.
2025-09-21 23:33:37 +08:00
bunnie
110d39936d convert loader to use autostatics 2025-09-21 21:52:24 +08:00
bunnie
4b99406277 cleanup warnings and errors for verilator target in loader 2025-09-20 22:12:54 +08:00
bunnie
1255bf12d9 FLAG DAY: fix all names to harmonize around 'bao1x'
The code base had evolved through several code names, interim
names, company names and chip names that alternatively did or did
not exist.

Baochip is the definitive name of the company, and the Baochip1x
(full part number BAO1X2S4F-WA) is the definitivey part number of
the SoC. For convenience, the part number is shortened to 'bao1x'
in most feature flags and variable references.

This commit fixes all of the odd names and removes some unmaintained
early targets.
2025-09-18 21:25:51 +08:00
bunnie
d02268e24c some test code for debugging power-off states 2025-09-18 20:19:22 +08:00
bunnie
2050672b85 propagate name change to loader 2025-09-14 02:14:26 +08:00
bunnie
3bd79d0328 make loader windows-friendly for usb serial 2025-09-13 01:08:31 +08:00
bunnie
5835d52815 fix default baud rate to something higher for the app uart 2025-09-12 02:50:04 +08:00
bunnie
6054092d40 refactor to add in usb-serial support in loader path
this will eventually be extended to support large file
writes but for now it just does an echo loopback
2025-09-11 00:54:25 +08:00
bunnie
af465ce563 add always-update flag
useful for fast debug loops
2025-09-09 22:24:24 +08:00
bunnie
d9bdcbcc3b stash some test code for checking memory sizes 2025-09-09 18:40:32 +08:00
bunnie
b4ba69bad2 ux improvements on update
actually use only the two buttons listed for initiating updates
2025-09-08 10:32:28 +08:00
bunnie
0ed6ae30c3 fixes for disk sizing etc. 2025-09-08 09:52:53 +08:00
bunnie
9ec18eb045 fixes for USB HS in loader 2025-09-08 09:51:57 +08:00
bunnie
71815c0a1a update PLL setting code 2025-09-08 09:51:02 +08:00
bunnie
d04202c9a9 fix antiquated hack 2025-09-08 09:50:46 +08:00
bunnie
2211cd7e1b change baud rate on serial port to a higher speed 2025-08-19 22:23:56 +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
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
508c38cfdd refer cache flush to hal version 2025-08-05 23:01:03 +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
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
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
75fbcd5be8 fix some bit-rotted constant locations in the precursor target 2025-05-15 11:54:02 +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
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