Commit graph

609 commits

Author SHA1 Message Date
bunnie
66131a59bf add speed-up setting for dabao
the boot1 loader on alpha0 release is conservative
2025-10-25 22:12:42 +08:00
bunnie
569e9526eb fix comment 2025-10-25 01:31:48 +08:00
bunnie
4a12668751 only check the flash ID after going to QPI mode
handles more cases of flash mode switching
2025-10-25 01:31:20 +08:00
bunnie
dab13d5b70 turn on the AV generator in loader
the kernel should rely on the AV generator for random numbers,
and so it should be on and operational by the time the kernel
boots
2025-10-24 21:12:31 +08:00
bunnie
9c9c6f67a7 fixup tag return API
returns a [u8;4] instead of a u32
2025-10-06 15:20:56 +08:00
bunnie
3c68eea714
Merge branch 'main' into signing 2025-10-06 13:45:29 +08:00
bunnie
dbb0a75118 bump versions
have to absorb a version change due to xous-semver change

might as well also update the utra/svd generator dependencies
since that's been held off for a long time now.
2025-10-06 13:23:18 +08:00
bunnie
6d4f8004d3 fix breakage associated with changes to xous-semver 2025-10-06 13:17:21 +08:00
bunnie
3c341d0f8e handle return codes that include tags 2025-10-06 03:49:55 +08:00
bunnie
b665e799ee add detached-app handling
"detached-apps" are Xous applications loaded into a region
of memory-mapped FLASH (and thus memory-mapped applications)
that are separate from the main xous.img image.

This allows developers to work on "just their app" instead
of having to upload the whole Xous ball.

Currently the only configuration that supports this is the
dabao configuration.
2025-10-05 17:08:42 +08:00
bunnie
ee1f3f3cb7 add detached-app handling in argument copy
also add some extra debugging to argument extensions.
2025-10-05 17:08:09 +08:00
bunnie
ac7a1b86e0 fixup bugs in arg extension processing.
Turns out we 'just got lucky' with our previous success
in getting arg extension to work (scary!!): the arg format
is pretty uhh...flexible...in terms of what it will accept
for arguments.

This fixes those bugs, the arg copy looks clean now, and
also removed the over-allocation problem by descending
the new argument list twice, once to sum the space needed,
and once to actually do the copy.
2025-10-05 17:06:33 +08:00
bunnie
0f98c3bea1 implement signature checking on the off-chip swap image
Swap can be "secured" in two ways:

1) it can be re-encrypted to a secure, locally generated key

2) it can be signature-checked with a public key.

(2) is provided as a path to receive updates. Updates are distributed
as "encrypted" (with the "0" key), but signed with a public key.
Once the update is validated, it's meant to be re-encrypted
with a per-device unique key.

A big reason for the re-encryption is because the swap is already
encrypted, we can rely on the AEAD for validation, and skip the
signature check (saves time on boot). Recall that the reason
we don't just do a sig-check and run is that is a TOCTOU:
it's pretty trivial to execute a mux that swaps out the FLASH
memory after the signature check with another version that has
malicious stuff in it. So we go with a sector-by-sector
AEAD that's ideally encrypted to a locally generated key.

It also offers the possibility to prevent malleability of the
swap data between devices, as many public-key signed images
could be floating around, including old versions that include
insecurities (e.g. prevents downgrade attack by replacing
an up to date image with an older signed image with an insecurity).

However, this latter possibility requires the user interface
to be correctly setup to prevent malleability by asking users
to opt-in to partition re-encryption. Need to consider this user
experience flow - kicking the can down the line, but that time
is coming soon.
2025-10-04 18:55:36 +08:00
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
86f0c60d95 refactor argument merging
the original rather unsafe version is replaced with a more readable
version that has a number of safety checks applied.

in the process of doing this, we now support merging of multiple
argument regions and a variable number of tags to merge.

tested to work on at least the base case of one swap region to
merge into the list.
2025-10-02 16:35:16 +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
a1c1c85a5f add signature check to kernel 2025-10-01 23:53:44 +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
634ccd6c38 add adjustable signature block offsets based on the target
bao1x has a smaller, more efficient signature block that
folds more data into the signed region.
2025-10-01 23:38:48 +08:00
bunnie
4c84fc523d remove deprecated testing feature 2025-10-01 23:38:28 +08:00
bunnie
0437a1263b remove deprecated loader features 2025-10-01 23:38:05 +08:00
bunnie
60d6e37b7d remove unused assembly code 2025-10-01 23:37:03 +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
ad38080484 refactor dependencies to allow for critical_section in loader 2025-09-11 00:55:01 +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
236fd4341a fix asm stub
broke precursor target with some cleaning up of the asm stub
2025-09-07 14:22:40 +08:00
bunnie
75a9373fea fix AES dependencies so that the correct acceleration is enabled
This relies on a trick I was not aware of previously, which is
that transitive dependencies absorb the additive set of features
enabled within a crate.

see

https://doc.rust-lang.org/cargo/reference/features.html#feature-unification

for the full description. but basically by referring to the feature
required in "aes" despite not being used in the crate but pulled
in by aes-gcm-siv, i can ensure that the transitive dependency
is in fact used.

I think this was always there but previously I just didn't understand
it correctly or didn't use it right when I tried to deploy it, but
this time I think I got it right.
2025-09-07 11:50:12 +08:00
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