Commit graph

157 commits

Author SHA1 Message Date
bunnie
3220e48015
add some more debug output on acl adjustment 2025-10-28 21:53:57 +08:00
bunnie
09309eb3ae
better altboot support
for updating boot1 on dabao
2025-10-28 21:37:55 +08:00
bunnie
28f7a8d6b2 remove default feature used for testing 2025-10-28 18:54:37 +08:00
bunnie
28e5484c57
expand audit and add boot0 key indelibility test
audit is now expanded to track one way counters and
summarizes security state

boot0 key indelibility test added as a feature, to be
used in the future for CI
2025-10-28 03:37:28 +08:00
bunnie
fb3c89949c fix boot delay calibrations 2025-10-27 19:07:33 +08:00
bunnie
763c0e8193 make boardtype return the current boardtype when no args given 2025-10-27 19:06:15 +08:00
bunnie
e6bef77b5f
change boot1 default behavior
The motivation for this is to make the tester configuration
exactly identical to that used in production. Right now a
"cheater" step is used to set the board type to dabao and
enable boot waiting because in the test environment there
isn't a physical switch anyone can press to invoke that
behavior.

So, in order to get the test environment to work just like
production, the behavior goes from insta-die if no valid
image is found on the next stage, to "wait for new image".
This is slightly less secure of a default, but only slightly
so. Basically the previous scheme required someone to be
physically present to press the "give me a new image" button,
this one causes the system to automatically accept a new image.
I suppose the main downside is this does allow the possibility
of say, a fully remote, automated exploit to be delivered
if an adversary can damage the loader image such that it
doesn't pass signature check and then it will automatically
go into a mode looking for a new image, at which point
an arbitrary image could be potentially loaded (although
because the image would need to be signed, and there is
a trap that destroys secrets if a developer image is
presented, it wouldn't instantly lead to secret disclosure,
but it would be a denial of service).

The flip side is that with the paranoid default, developers
are "confused" by the silent failure of a brand new chip that
has no code loaded in it (because it goes catatonic until
the developer knows to press the load button).

The loader image is protected from writes after boot, so
in theory there isn't a direct path to "spoil" the loader
image and trigger this path, so it's not like we're just
hanging in the wind. It just means that there isn't a
full human-presence requirement as a defense in depth against
a potential denial of service if an adversary could find
a way to spoil the loader image.

If the DoS path is a concern, one option is to configure
the system such that the developer key is revoked. This
would disallow that from being recognized as a valid
image, and would also prevent the DoS from happening,
as it would require the adversary to present a valid,
signed image which presumably they can't as long as
the signing keys are kept safe.
2025-10-27 18:22:00 +08:00
bunnie
2f957d3f35 improve error messages 2025-10-26 19:30:18 +08:00
bunnie
72e8c1a6fa
print errors on slot initialization instead of crashing
these errors mostly trigger when transitioning between
board types during testing
2025-10-26 19:29:11 +08:00
bunnie
392cd64493
cleanup options in slot management code
- feature gate some unsafe-debug
- tie akey_id to 0xff which should disable key chaining, which
is not used in our scheme because authentication is not hmac-based,
uses public keys instead
2025-10-25 22:27:50 +08:00
bunnie
b4502854f1 adjust dabao default frequency to full speed
latest rev of the board seems to handle the heat load OK.

board gets a little warm to touch when the system is clocked
at max frequency, but not unpleasantly so.
2025-10-25 21:37:38 +08:00
bunnie
d11d2f8cd5 modify default voltages; normalize the setting location 2025-10-25 01:37:21 +08:00
bunnie
e1f685f70d fix missing path 2025-10-25 01:32:22 +08:00
bunnie
0d369f8a9f add feature for printing the ifr in boot 2025-10-24 21:15:12 +08:00
bunnie
04d46b9549 update location of system timer interval definition 2025-10-24 21:12:00 +08:00
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
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
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
b864445dff version generators should not be checked in 2025-10-19 01:02:20 +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
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
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
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
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