Commit graph

157 commits

Author SHA1 Message Date
bunnie
53c92df8a5 add uf2-spim feature to bootloader
All the changes here (except one print statement change) are
intended to be feature-gated behind `uf2-spim` in the bootloader.
So, in theory, this should have no boot1 regressions.

The uf2-spim feature is intended for alt-boot and alternate
compiled boot1's and extend the serial-only upload path with
the following features:

1. ability to write SPIM (spi flash memory) using the same
.uf2 files as the USB path
2. requirement of CRC's on blocks
3. a quick test to determine if CRC has been enabled or not
via the `has-crc` command (returns `true` if required, an
error/unknown command message if not).

The CRC makes long/large file uploads reliable, allowing
full device provisioning to happen via serial only, in
cases where USB for whatever reason is not present or available.
2026-06-24 15:08:12 +08:00
bunnie
97b2d2b0da modify alt-boot uf2 path to allow for updating of boot1 over uf2 serial 2026-06-23 18:00:38 +08:00
bunnie
0dc2c133f5 add pddb erase on altboot for oem mode 2026-06-15 23:03:20 +08:00
bunnie
97fe7f45b9
Re-instate review comments
These were comments added during review, re-constructed.
2026-06-03 03:04:09 +08:00
bunnie
214ccb6dd5 reconstruct #882 based on file diffs from gh 2026-06-03 02:53:35 +08:00
bunnie
e4db467d9a update the descriptive name
moving towards a 0.10.1 release, instead of the original
release name
2026-05-12 22:13:31 +08:00
bunnie
3e19e7bfd0 add test routine for debugging QE mode 2026-05-08 22:20:32 +08:00
bunnie
85fc3d70f9 add WDT reboot on oem mode in bootloader
prevents device from running down battery if accidentally
left unattended in bootloader while on battery
2026-05-05 23:55:15 +08:00
bunnie
b1870e51ea make it so that bootwait option is skipped if warm boot
this prevents warm boot hold-up in case of latent key press
during wakeup option: for warm boot it's assumed that when
the user presses a key the intention is to wake up and go
to normal operation, not wake up and wait for an update.
2026-04-07 18:03:16 +08:00
bunnie
bec3dd00c3 add option to fully reformat a swap partition in repl 2026-04-05 23:23:32 +08:00
bunnie
65b2040cdf fix bootloader regressions 2026-03-30 23:59:31 +08:00
bunnie
cc7b4740ac cleanup baosec-lite forming routine 2026-03-06 19:18:37 +08:00
bunnie
f0b0c038f2 chore: fix out of date comment 2026-02-28 23:19:53 +08:00
bunnie
eb2e370632
update audit print to facilitate build checking
- include the toolchain hash for reproduction iff it is
specified
- for the code hash, report *only* the code region, none of
the signature headers. This should match exactly what is
reported by the *_presign.img artifacts.
2026-02-16 18:11:34 +08:00
Sylvain Bellemare
3ea92d3bad
Add --baobit-commit flag for build provenance
Adds BAOBIT_COMMIT constant to boot0/boot1 version.rs, allowing
the Guix build channel commit to be embedded in firmware for
reproducibility verification.

- Add --baobit-commit CLI flag to xtask
- Generate BAOBIT_COMMIT in boot version files
- Display in audit command output
- Simplify versioning.rs to always write files
2026-02-16 08:24:55 +09:00
bunnie
b8206c2cfc
minor boot1 improvements
- improve bollards to use the die call
- fix panic to call die
2026-02-15 03:37:48 +08:00
bunnie
f079a1480b
fix more bounds checks in USB handler
- CBW block only derived after length is validated
- write offset to disk uses checked_add, necessary
since we're compiling in release mode
2026-02-15 03:36:32 +08:00
bunnie
6d77efc02e
upgrade jump api in boot1 to use asked jump format 2026-02-15 03:35:54 +08:00
bunnie
df10c50c14
add bounds checking on payload size in UF2
if the magic numbers match, the payload size field must also
pass the sanity check for the packet to be considered for
further processing.
2026-02-15 03:33:04 +08:00
bunnie
9780fe3ea4
same fix as previous commit but for boot1 2026-02-15 03:32:30 +08:00
bunnie
575efa6129
refactor function call to use macro
the macro will give relevant positional information when the
assert fails, whereas the function always fails in the same place
and we lose that valuable debugging info
2026-02-14 19:35:45 +08:00
bunnie
703a56b925
add pointer checks on USB hardware interfaces
The USB engine passes raw pointers around for DMA purposes;
most importantly, it passes *back* raw pointers and lengths.
There's no really good way to check these, and I suspect that
there may be USB protocol exploits that can be used to manipulate
these values. Thus, an assert is added on the touch points where
the raw pointers go to and from the USB hardware to check that,
at the very least, the entire buffer being referenced is strictly
within the USB hardware's memory space.
2026-02-14 18:31:31 +08:00
bunnie
f106d39d03
add die stepping detection code
It occurs to me that the same boot1 code will be on both
die steppings, so adding a piece of code that *should* be
able to detect A0/A1 stepping - assuming the A1 stepping
behaves as intended.
2026-02-13 02:05:53 +08:00
bunnie
68400551c5 cleanup warnings 2026-02-13 02:05:09 +08:00
bunnie
54894e852b suppress a debug message
this will help improve boot time by some milliseconds
2026-02-12 02:32:45 +08:00
bunnie
0d934e1078 alphabetize the help message in boot1 2026-02-11 14:10:48 +08:00
bunnie
a2330e8911
add optionality to turn on clock skipping manually
this is off by default, because it doesn't seem to be entirely
stable. For now, the default configuration when it is turned on,
only activates it for the PKE block. When the CPU block clock
skipping is enabled, instability is occasionally observed.
2026-02-10 22:56:14 +08:00
bunnie
7588d8bf43
add auto-audit capability; add boot hashes
the "audit" command is moved to its own file, as it has
turned into A Thing.

auto-audit now happens on the first few boots to help
verify chip probe infrastructure.

hashes of the boot regions are also printed as a diagnostic
in the audit code.
2026-02-10 03:29:41 +08:00
bunnie
bc35c9b014 update release name 2026-02-08 17:04:05 +08:00
bunnie
0529a10eb8 modify audit to leak information about the erase coupons
this helps verify the erase state by implication of secret keys
2026-02-04 15:54:20 +08:00
bunnie
293a445944 add test command to generate collateral keys
this allows us to simulate a third party firmware's behavior
so we can test that collateral key states go through the right
set of state transitions in various test cases.

the collateral test is also made more precise and can now
report unititialized/permission denied state
2026-02-03 22:07:14 +08:00
bunnie
33b35fb054
remove avalanche TRNG code from bootloader
Now that the sensitive keys are provisioned in Xous and not in
boot1, there is no need to have a dependency on the avalanche
generator (and in fact, in practice, it's never used because
the random data that is collected is always collected before
the board type is set to even allow usage of the avalanche generator).

To wit: The only bits that are created using the ring oscillator
are public random identifiers such as the UUID, which are not
security critical pieces of data.

Removing this unused path simplifies the bootloader code.
2026-02-03 18:16:11 +08:00
bunnie
3f869ca389 bump utralib version for publication 2026-01-29 19:12:00 +08:00
bunnie
e8219cda58 adjust boot delays to make screen-up a bit faster 2026-01-27 21:38:19 +08:00
bunnie
955c85b22e move statics initialization to top, adjust oled power-on timing
- statics need to be initialized before IRQs are turned on.
- oled power-on sequence is adjusted to clean up display on "rough"
power-on transients
2026-01-25 18:34:43 +08:00
bunnie
026ba8654a remember debug-countermeasures option as a comment 2026-01-25 18:33:14 +08:00
bunnie
b6e85f551d add oem-baosec-lite to boot1 2026-01-24 23:48:35 +08:00
bunnie
013a4e8771 add anti-rollback and receipt processing to security audit command 2026-01-22 23:17:50 +08:00
bunnie
6bb94a148e when usb is disconnected, toggle the correct flag
was turning off console altogether
we actually just want to turn off printing to USB.
2026-01-19 02:41:47 +08:00
bunnie
32397a8d9f upgrade tag message to beta-0 2026-01-18 21:41:40 +08:00
bunnie
26636561f5 add collateral check to audit 2026-01-18 02:52:42 +08:00
bunnie
341c2353ab add audit of boot mode to audit and security assessment
Turns out we *can* check this at run-time. I thought originally
once the chip was sealed these became hidden. I was wrong.
So, this means we can actually test to confirm that production
was done correctly and in fact the CM7 and debug ports are sealed
off.

this adds that test.
2026-01-16 00:52:01 +08:00
bunnie
b06c124b3e
add a routine to print the info region
The info region is a region of RRAM that is used to configure
the chip - boot security, what CPUs can run, access control
lists, etc. There's no secrets in here, but it's very helpful
to inspect for audits and correctness of configuration, so
a routine is added to print it in boot1.
2026-01-15 17:04:11 +08:00
bunnie
bf721e3b5c
adjust permissions on serial number; make chip init more permissive
It is not clear if I can get the factory to burn the serial number
(wafer lot, ID, x/y location) into the location I want it to be.
So, I am allowing this to be updated by the firmware on boot,
thus necessitating the permissions to be writeable for the serial
number field.

Furthermore, if there is any error in initializing the chip's
identity in the factory, right now the chip goes into a mode
where it has crashed and can't run diagnostic code. Write errors
in this stage are thus turned into .ok() instead of .unwrap()
because we want to allow the chip to go through the whole flow
and then diagnose any issues later on.
2026-01-15 16:58:22 +08:00
bunnie
7b697c0918 add note to serial console that console has moved to USB
this makes it clear that when USB is plugged in, the console
session on the hard serial port migrates to the USB serial port.
2026-01-14 03:08:41 +08:00
bunnie
fba011db3a commit version bump so that we may publish our packages 2026-01-08 03:04:19 +08:00
bunnie
e676ccbed8 cleanup dead code warnings found by latest rustc 2026-01-06 13:41:04 +08:00
bunnie
a6320ef290 fix missing csw update - maybe this resolves some of the debian issues?
this was found by the latest version of rustc
2026-01-06 13:40:17 +08:00
bunnie
9248804d81 fix api change that propagates into boot1 2026-01-05 22:00:59 +08:00
bunnie
544a0368fc setup the security dependency to pull in sigcheck in crates that use it 2025-12-22 16:18:21 +08:00