Commit graph

216 commits

Author SHA1 Message Date
bunnie
41f09420cd
clean out some old debug, and activate erase_secrets on dev boot
this has only been lightly tested - much, much more testing
is needed.
2025-10-21 23:47:51 +08:00
bunnie
11c23c3b1c
refactor coreuser setting and boot flow
this accommodates the notion of erasing secret keys when
a developer key is detected. Some hackery in the API is
required, because I'm trying to use the same signature
routine for both boot0 and boot1, but coreuser settings
should not be set until boot1.

Boot0 has *no* coreuser settings, whereas boot1 starts
to lay them in - this interferes with key erasure, and
so the nice clean "boot or die" abstraction disappears
because we have to now just check if a key matches a criteria
and then return because we have to handle the environment
dependent case of coreuser settings.
2025-10-21 19:06:12 +08:00
bunnie
e1c07cbf0b cleanup some debug output & fix ref link 2025-10-21 04:16:45 +08:00
bunnie
2559ddd02d
stash state on some issues in ACL setup
the key setup seems to work correctly
but the data ACL setting doesn't "stick". The region
could be write-protected by some other element in the
CP/IFR config, need to dig a lot more. For now we need
to move on and crank out something to stick on the alpha
dabao boards...
2025-10-21 02:19:40 +08:00
bunnie
4affb7e979
add the code for initializing keys & setting up ACLs
this code audits the status of the data/key slots,
initializes them according to the platform, and sets
the permissions on them to prevent read-out later on.

A TRNG routine is built into boot1 now, I think it's
reasonably conservatively coded but more testing/inspection
is always good.
2025-10-20 23:39:04 +08:00
bunnie
1eeaa23516
Realizing that the permission level settings could change
Not locking them down in boot0: allowing them to be set up
in boot1. this is less hermetic, but already I have thought
of a couple of reasons to modify the tables; for example,
the dabao configuraiton if someone wanted to make a secured
version, you might not want PID 3 to be the trusted PID;
or if you wanted to have two different sets of keys for
different purposes, you can use the other permission levels
to separate them.

So, leaving it configurable. for now.
2025-10-20 23:36:34 +08:00
bunnie
1d5cc0806b
update boot1 to use slotmanager API
also add the hook for setting up/checking all the other slots
2025-10-20 02:20:45 +08:00
bunnie
356ab47c3c
add coreuser table setup to boot0
I think it belongs here, because this "should" be a "baked in"
setting. Maybe I'll regret that, because it really enforces
a hardware one-way door on changing/updating the coreuser maps,
but also, I think it makes it a bit stronger if there is no
easy way to bypass/override that setting.
2025-10-20 02:18:28 +08:00
bunnie
972450e306
propagate flag changes to crates that can configure it 2025-10-19 01:20:53 +08:00
bunnie
7383bd5356 move boot1 to also use the lower boot frequency
this does not seem to have a large effect on update times and
allows us to operate over more platform configurations absent
specific power-on control code
2025-10-19 01:04:21 +08:00
bunnie
7bd43d6499 change s/n readout API to use the new SlotManager API 2025-10-19 01:03:55 +08:00
bunnie
92a3b05627 reduce boot freq / voltage even lower
this allows boot on extremely "weak" systems where very little
power is available.
2025-10-19 01:02:43 +08:00
bunnie
b864445dff version generators should not be checked in 2025-10-19 01:02:20 +08:00
bunnie
a5704d292d
Merge branch 'main' into protected-rram 2025-10-18 01:19:50 +08:00
bunnie
201c143762
Merge pull request #701 from betrusted-io/db-selfstest
Add selftest feature for dabao
2025-10-18 01:19:37 +08:00
bunnie
464d26e7b0 adjust default voltages & freqs to be in-line with validation numbers 2025-10-18 01:15:52 +08:00
bunnie
59c3ca5c7e
Merge branch 'main' into protected-rram 2025-10-16 23:39:35 +08:00
bunnie
36b1868fc4 add ram zeorization to top of boot
this slows down boot a little bit but I think this is a good
idea from a security perspective.
2025-10-16 23:37:35 +08:00
bunnie
0bd4de961a I think I won't regret putting a semver into the boot0 stage too
Even though boot0 DUART output may be inaccessible, the string
could still be found by looking in the binary and searching
for it.
2025-10-16 23:25:44 +08:00
bunnie
254780b382 add some artifacts for an early sample run
These are a bit rushed but wanted to be able to have some
serialization/tracking in the earliest samples sent to
'alpha-zero' developers.
2025-10-16 23:21:07 +08:00
bunnie
e80a3dadfb cleanup some testing code that should have been eliminated from boot 1
also remove an unused dependency
2025-10-08 02:56:26 +08:00
bunnie
dbcf346ffb add security audit & lockdown features to the boot1 stage 2025-10-06 23:24:01 +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
3c341d0f8e handle return codes that include tags 2025-10-06 03:49:55 +08:00
bunnie
d1f5aa19a8 map clock sources to API files, cleanup irqs on boot
- clock freq/voltage now in API definitions
- IRQ is disabled (or re-disabled) on all exit paths
2025-10-05 17:00:39 +08:00
bunnie
46b5c6f17d missing command option in help 2025-10-05 17:00:20 +08:00
bunnie
07ec63a1b3 add better loading feedback in various configs 2025-10-05 16:59:55 +08:00
bunnie
2fb72be487 update signature check api in boot0/boot1
pass `None` for the spim field as these are direct RRAM checks.
2025-10-04 18:53:13 +08:00
bunnie
6da0482831 add screen feedback for baosec target on updates 2025-10-04 16:21:06 +08:00
bunnie
1b36c34341 add swap/spim writing to boot1 2025-10-04 00:48:23 +08:00
bunnie
73192dc2d8 cleanup on boot1
main thing in this commit is remembering to activate PWM
mode on DCDC2 for a quieter power supply. the chip draws
so little power that the power-saving regulator hiccups
and has too much ripple.
2025-10-01 23:33:35 +08:00
bunnie
faa13e71f3 speedup firmware update writes by eliminating debug print 2025-10-01 23:32:54 +08:00
bunnie
444ae53a11 add cleanup for USB stack
have to shut it down gracefully or the next stage won't run.
2025-10-01 23:32:21 +08:00
bunnie
1d9c8e8121 cleanup unused code and make ifram mappings extremely clear 2025-10-01 14:57:10 +08:00
bunnie
e95550cb52 add oled ui for baosec board targets on boot1 2025-10-01 14:27:51 +08:00
bunnie
b85ed18cd8 boot1 improvements
- add boardtype setting
- work around usb serial tx timeout hangs - not sure why they happen,
but let's not hang the repl on them.
- various cleanup code & comments
- note boot frequency
2025-10-01 02:48:36 +08:00
bunnie
4e2fc04d5d cleanup legacy code 2025-10-01 00:42:02 +08:00
bunnie
91232fd57b cleanup comments on boot1 code 2025-09-30 23:47:50 +08:00
bunnie
c1544ca5e7 fix initialization bug in statics
this unstucks the console when USB comes up.
2025-09-30 21:51:54 +08:00
bunnie
a6769c46ba track change in statics struct 2025-09-30 21:51:28 +08:00
bunnie
52e9cd0630 make trailing whitespace CI happy 2025-09-30 17:35:19 +08:00
bunnie
d9ff07a32f redo the fat emulation layer
present a 128MiB FAT32 disk based on a dumped image that was
clean-initialized on a windows machine (windows is the most
picky so it is used as the template maker).

add hooks for emulating sparse reads of file system structures
that are well outside our available memory range.

add hooks for writing uf2 files when valid sectors are encountered.

this basically works, you can whack a uf2 file into the disk
and the update happens.

the problem now is that something breaks in the repl loop
when USB disk traffic happens, this commit gives us a checkpoint
to work against.
2025-09-30 17:29:06 +08:00
bunnie
7ec9457854 cleanup the boot-wait code, and add autoboot toggle command 2025-09-30 00:38:19 +08:00
bunnie
6b8d8f09f7 cleanup functional code specifiers for boot partitions 2025-09-29 22:17:38 +08:00
bunnie
01cf1df330 u2f serial upload now working
works over both physical serial port and USB serial port.
2025-09-29 21:58:01 +08:00
bunnie
a511e3c591 add uf2 over serial protocol for writing e.g. baremetal images 2025-09-29 18:40:57 +08:00
bunnie
fa875158e3 add uf2 file sender that works over the serial port 2025-09-29 18:40:33 +08:00
bunnie
54b16cdf64 fix public key origin for signature checks
in general the public key should come from a trusted block, not
the image itself. The initial prototype of the image was written
for self-checking of boot0; but for other images, the public key
should "chain" from the trusted image (i.e. boot0's key should check
boot1, boot1's key should check baremetal/loader, etc.)
2025-09-29 16:18:21 +08:00
bunnie
d0bd60d93c fix USB handling
- statics origin set correctly
- debug prints on USB stack go to DUART to avoid a Tx storm
when debugging e.g. Tx packets on USB
2025-09-29 14:49:06 +08:00
bunnie
59ae767741 fix statics origin in boot0 2025-09-29 14:48:48 +08:00
bunnie
7b5c4e1cd8 add a draft boot1
boot1 contains all the ideas up to and including the console.

however, the actual file transfer bits are yet to be implemented.

onward!
2025-09-29 13:52:38 +08:00
bunnie
75022f0b63 track API change for location of combohash bits 2025-09-29 13:51:00 +08:00
bunnie
4375bf43d0 remove debug as a default option for ed25519 2025-09-29 13:49:39 +08:00
bunnie
8cbdb75dc8 cleanup boot0 code
remove things that we don't need in boot0. Boot0 originated from
a much larger, more featureful space and needs to be whittled down
to remove attack surface and space for bugs.

Some further cleanup to do would include:

- hardening the PLL setting. Right now it's done computationally
based on the demanded frequency. But in practice, because the
target frequency is hard-coded, we could just compute the actual PLL value
results and jam them into the register and lose a whole bunch of
code.

Actually I think that's all that needs to be cleaned up off the
top of my head.
2025-09-29 13:46:42 +08:00
bunnie
728072ebae add documentation of the boot0/boot1 flows 2025-09-29 13:39:37 +08:00
bunnie
63e2834e9d return the key index that passed from sigcheck 2025-09-27 00:31:24 +08:00
bunnie
6768f87ce8 vendor in the curve25519-dalek for bao1x boot
The *only* change is to make fiat-crypto a non-optional dependency.
For some reason the .cargo/config.toml only half-activates the
feature, in that in the .rs code files the feature is included
but in the Cargo.toml file the dependency is, for some reason,
not enabled.
2025-09-27 00:30:10 +08:00
bunnie
2d0c456929 add vendored-in ed25519-dalek crate for boot environment
Light-fingered changes include:

- debug UART integration for debugging things
- patching the sha2 crate to use hardware acceleration

Most changes are in Cargo.toml, with the exception of the debug.rs
module that was introduced for print-debugging.
2025-09-27 00:29:09 +08:00
bunnie
2f3cf06c16 helps to actually copy the data into the hash engine 2025-09-26 22:57:10 +08:00
bunnie
f76b85c95e signature checking now works
also some light benchmarking code.
2025-09-26 22:56:49 +08:00
bunnie
afba3040b3 cleanup print debugs in sha2 for bootloader 2025-09-25 16:13:25 +08:00
bunnie
a035bb669c add initial signature check code on bao1x 2025-09-25 16:13:09 +08:00
bunnie
c1ab8972fa update boot offsets to handle embedded signature block 2025-09-25 00:00:13 +08:00
bunnie
39142b4c18 add scaffolding for bao1x-boot and also the sha2 implementation for baremetal 2025-09-24 01:02:07 +08:00