Commit graph

9690 commits

Author SHA1 Message Date
bunnie
4c0245fa41 update target on signer script 2025-12-18 02:23:32 +08:00
bunnie
d6c662b378 memoize some common clock settings
this reduces boot time because the space to search for
an arbitrary clock setting is pretty big.
2025-12-18 02:22:38 +08:00
bunnie
fdb0da2399 update two spots where the /2 on perclk was missed 2025-12-18 02:22:02 +08:00
bunnie
dd7929f912 bump pins on the signing crate 2025-12-18 02:21:38 +08:00
bunnie
cd075729c4 quite down a debug statement 2025-12-18 02:21:20 +08:00
bunnie
87dc26d832 update the keystore to ignore the deprecated board type checks 2025-12-18 02:20:44 +08:00
bunnie
5b8c4990d7 bump the pins on the verifiers - forgot to do this earlier 2025-12-18 02:20:22 +08:00
bunnie
9093bb4ed7 simplify keystore setup
The TL;DR is this now treats dabao exactly the same as
baosec in terms of keystore setup from the security flow perspective.

baosec & dabao were different originally because baosec would
rely upon the Avalanche generator TRNG as supplemental randomness
and dabao would not. This special case had to be handled in the
bootloader and propagated through.

However, in a previous commit, the keystore setup was moved to
the OS *anyways* - thus making this difference moot.

This patch backs out the one-way counters that would track the
dabao initialization state.

It also doesn't fail the boot on the erase key proof check
failing if the keystores aren't initialized yet. This creates
yet another condition that could be glitched over to bypass
the erase check but it is checked twice indepedently.
2025-12-18 02:16:50 +08:00
bunnie
bcc4702602
Merge pull request #754 from betrusted-io/wfi
Power management
2025-12-16 02:34:51 +08:00
bunnie
5d1db9d27d add version bump so we're no longer patched
this enables susres in production release
2025-12-16 02:13:02 +08:00
bunnie
d874c3e5c2 commit for version bump 2025-12-16 02:02:37 +08:00
bunnie
6424f85210 remove deprecated wfi routines in baremetal
we're now doing wfi testing directly in xous, so these routines
are no longer relevant.
2025-12-16 01:49:23 +08:00
bunnie
f56af4f60d commit patched susres so we can publish updated API 2025-12-16 01:17:56 +08:00
bunnie
cf1d37e387 update susres api 2025-12-16 01:17:42 +08:00
bunnie
21d508f64b add susres dependency 2025-12-16 01:16:10 +08:00
bunnie
b0b72bc28b remove wfi api - using susres manager instead 2025-12-16 01:15:30 +08:00
bunnie
257bafcc5f structural rework of the main loop to allow for deferred blocking scalars
also invoke the susres thread manager
2025-12-16 01:14:45 +08:00
bunnie
8536b4fda4 rework power management scheme to use susres API 2025-12-16 01:10:30 +08:00
bunnie
b0ec2929d7 cleanup warning in rtc 2025-12-16 01:09:12 +08:00
bunnie
5ebc40453c add suspend/resume manager to the HAL
this gives us a clean API for power savings mode entry/exit
2025-12-16 01:08:41 +08:00
bunnie
e4eeb4603f rework ticktimer to use the susres interface 2025-12-16 01:08:17 +08:00
bunnie
9b9948e8da fix hosted mode warning 2025-12-16 01:07:49 +08:00
bunnie
e1cde0328c cleanup broken alt-target builds 2025-12-16 01:07:35 +08:00
bunnie
d261090f31 convert test routine to use susres api to enter sleep 2025-12-16 01:07:16 +08:00
bunnie
934d6e1082 remove more /2 errors now that peri clock is correct 2025-12-16 01:06:46 +08:00
bunnie
534e99216a cleanup the erase-check key code to reflect new APIs for managing buram 2025-12-16 01:05:57 +08:00
bunnie
b31c7d411d major rework to clock settings
this is a big, ugly, multi-file commit but it turns out when
you start shaking one part of the clock tree everything rattles
along with it.

Basically this updates the clock tree to use a search for an
optimal setting instead of a hueristic/table lookup, and then
a bunch of small bugs in the clock settings were found that had
to be proopagated to dependent crates.

i2c clock set now seems ... more correct, the frequency is
not overclocking the bus (was at 600khz before, now just below 400khz)

the uart equations finally sees sane

the spi clocks check out

the only inconsistency left is that i can't seem to get a fractional
division on peri clk. it would be really nice to be able to do a
fractional divide and get a little more peformance out of the spi
busses but i think it just doesn't work that way - the "fractional"
division is actually more of a "time-average frequency is correct"
but when you go into fractional mode it's spending some time pulsing
at 2x the rate and some time at 1x the rate to get to the time average
frequency, and when you're at the 2x rate things break.
2025-12-16 01:02:00 +08:00
bunnie
679ece9b19 major rework of the clock-set routines
the routines provided in the reference crossbar libraries are
not great and the recco of their team is to just use hard-coded
table lookups. Replaced this with a computational method that can
find arbitrary clocks; however, the computation *is* somewhat expensive
because you have to iterate through a fairly large solution space
to find an "optimal" solution.

That being said, these solutions can be memoized if they are
frequently re-used. I rather prefer this method than just an undocumented
table lookup.

More testing is needed but the initial results look pretty good.

Also peripheral clock setting is reworked to be more clear as to what
is going on. I think I finally have some clarity on why a mysterious
"divide by 2" was ending up in everything; other dependencies have
been reworked to clean that up. I think actually I may have been
overclocking the peripheral bus by a factor of 2 prior to now :-/
2025-12-16 00:58:37 +08:00
bunnie
021cf609e4 remove wfi apis from hal
this is now in the susres crate
2025-12-16 00:58:10 +08:00
bunnie
b509fffc51 cleanup perclk setting 2025-12-16 00:57:24 +08:00
bunnie
fb7da782cf cleanup perclk setting on boot0 2025-12-16 00:56:10 +08:00
bunnie
5cd165fe8e fix doc comments & safety on std::env manipulation 2025-12-15 18:00:40 +08:00
bunnie
582d02af33 fix i2c lib ref 2025-12-15 18:00:22 +08:00
bunnie
6a77a301fb enable susres API in bao1x
this will require a version bump in production
2025-12-15 17:59:45 +08:00
bunnie
8dc1e9c837 rework backup RAM hashing to ignore the erase proof slice
a slice of key material is written to backup RAM from boot0
all the way to the loader, to prove to the loader that secret
keys were erased in a higher privilege state (loader then erases
the key, and this key is considered leakable without harm to
security).

The problem is that writing the key to backup RAM in boot0
was fixing the hash on the backup block, which is before
the check happens to see if it was a cold power-on. This would
defeat the RTC setting & backup setup logic.

THe solution to this is to exclude that one key from the hashing
area and special case it. A set of routines and API names were
added to help enforce this case.
2025-12-15 15:19:01 +08:00
bunnie
a94595ca9f RTC: rework to give milliseconds time
The original RTC was set to a 1Hz tick, which isn't sufficient
for the time API

This has been reworked to give a 1/1024 second increment.
Rollover logic is implemented in the RTC. Requires the system
to be powered on at least once every 48 days to capture the
rollover, otherwise it could miss a rollover event. This is
fine because the backup battery doesn't last that long, and
scans of QR codes for password login always reset the RTC anyways.

The RTC offset randomization code is now gone because we're
not tracking long-term power-on information in the RTC.
2025-12-15 15:16:10 +08:00
bunnie
074b0429d3 add timing dither to ticktimer
add a little bit of timing dither to one of the core delay routines
this hardens the OS against glitch attacks by making the timing of
concurrent tasks less predictable
2025-12-14 16:05:12 +08:00
bunnie
6635770530 add the rv-only config line for ifr 180 2025-12-11 02:28:54 +08:00
bunnie
3fd9087b7f commit a partially working wfi cycle 2025-12-11 02:28:37 +08:00
bunnie
5f1b769822 cleanup warnings 2025-12-11 02:27:56 +08:00
bunnie
def8da571b add a wfi api 2025-12-11 02:22:01 +08:00
bunnie
df3529d595 add power down/up opcodes to the gfx layer 2025-12-11 02:21:40 +08:00
bunnie
e2d15e26e6 expand test routines 2025-12-11 02:21:02 +08:00
bunnie
9d8fae3f0a update dependencies 2025-12-11 02:19:32 +08:00
bunnie
7edbeed07c fix apis in baremetal 2025-12-11 02:19:18 +08:00
bunnie
261ea7a880 update apis in hal-service 2025-12-11 02:18:44 +08:00
bunnie
577efdfdd2 ignore binary objects not meant to be checked in 2025-12-11 02:14:41 +08:00
bunnie
8950a24327 move i2c in bao1x-hal-services into bao1x-hal
this makes i2c accessible without having to rely explicitly
on the server itself, making the library callable in more contexts.
necessitated avoiding a name space collision and moving the
I2C hardware drivers to a stucture named I2cDriver; the I2C
object now unambiguously refers to the userspace interface
to I2C.
2025-12-11 02:13:21 +08:00
bunnie
8269f9f759 update apis to accommodate power savings mode 2025-12-11 02:10:25 +08:00
bunnie
0a47620da2 add powerdown api to sh1107 2025-12-11 02:09:15 +08:00