Commit graph

216 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
1a43540037
minor improvements across boot0 flow
- improve bollards to include "die" jumps where appropriate
- cleanup warnings in unsafe-dev feature
- panic handler calls die repeatedly
- upgrade jump api
2026-02-15 03:34:35 +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
59bd74a01c
panic directly on illegal instruction
the original stub for illegal instruction handling advances
the program counter - this was copypasta from the kernel
irq routine, where this behavior is needed to handle syscalls.

However, this behavior is contra-indicated for the purpose
of dying on a bollard - you don't want to skip past the
bollard for any reason.
2026-02-15 03:29:50 +08:00
bunnie
f462e3dc3c repl code in boot0 is not used in production
strip out old stuff that doesn't work anymore -- eventually this
code may be entirely struck since it's not even been compiled
for many months.
2026-02-15 03:28:50 +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
8ef78f592f add notes about how bootloader releases will work 2026-02-10 03:31:39 +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
0bb693449b
boot0 improvements
- rcrr register multiply-written on boot to glitch harden
the register. I only realize now that the top-line ECO had
an asterisk on it which means that setting the register is
still critical
- correctness comparison of boot1 keys to IFR copy introduced
this is yet another check to prevent tampering with the key block.
2026-02-08 12:47:09 +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
56c1230b2e add error printing on boot0 signature failure
this will at least give us a hint as to why a boot1 failed to
boot. It does hand an attacker some information, but we also
need information to debug e.g. RMA and field failures.
2026-02-03 03:23:07 +08:00
bunnie
3f869ca389 bump utralib version for publication 2026-01-29 19:12:00 +08:00
Sylvain Bellemare
63b5c92b5c
Refactor dockerfiles and ci docker.yml 2026-01-29 02:49:19 +09: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
dce0bac16e add receipt processing to boot0 2026-01-22 23:17:26 +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
24c76b077e
update boot0 to implement collateral protocol
this also makes boot0 erase secret keys in the case that the
signing public keys on boot0 or boot1 don't match the indelible
values expected in IFR.
2026-01-18 02:54:08 +08:00
bunnie
26636561f5 add collateral check to audit 2026-01-18 02:52:42 +08:00