Commit graph

965 commits

Author SHA1 Message Date
bunnie
3f869ca389 bump utralib version for publication 2026-01-29 19:12:00 +08:00
bunnie
88ccc7e042 fully specify the bao1x target on blitstr2 for bao1x builds 2026-01-29 18:58:55 +08:00
bunnie
5267335346 in practice, we never want to kill the HAL service, so remove the option 2026-01-29 00:10:09 +08:00
bunnie
b2cf705c59 bump ticktimer version to drop susres dependency 2026-01-28 20:53:57 +08:00
bunnie
75f75ebffa add hooks for oem-baosec-lite in the clock and power management 2026-01-28 15:04:06 +08:00
bunnie
45632385d5 downgrade susres to a common api
doesn't make sense to push this to crates.io because it's not
common across all platforms, I think.
2026-01-28 00:36:05 +08:00
bunnie
ece9b9943c add module 2026-01-27 22:20:56 +08:00
bunnie
f288a18040 add a first whack at an lis2dh12 accelerometer driver
This is a ball of Claude-generated code which was guided by
the datasheets, some trait APIs and other prompt info.
The prompt used to generate the code is appended to this file.

The result is structurally pretty similar to the accelerometer
driver templates I've seen provided by the vendor, except in Rust
and with Xous idioms, so I think this is a pretty reasonable
whack at reducing boilerplate. There's way more features in these
accelerometers than I have time to write getters/setters for.

The few functions I have used look good insofar as getter/setters,
but there are some oddly specific defaults in the file that should
probably be corrected, probably due to over-prompting of the code
generator. I'll work through these over time.
2026-01-27 22:10:14 +08:00
bunnie
1db717a63f add put_pixel_unchecked() trait in API
this is for implementing checked, higher-performance loops
like blits.
2026-01-27 22:09:37 +08:00
bunnie
b34f4a4c6f remove failure case in Drop implementation
this is some technical debt - Drop doesn't coordinate across
all instances of an object and so the disconnect isn't able
to know exactly when to disconnect. This will require some
guru meditation later on to correct this in a "proper" fashion.
2026-01-27 22:08:28 +08:00
bunnie
385c356801 refactor clock computations & add routine to determine fd
this is a prelude to clock tuning the internal bus networks
for bandwidth. The "trivial" thing of just cranking the speed
up to the edge and letting the dividers didn't seem to help
performance much, though; this could be due to the clock synchronizers
beating against each other.
2026-01-27 22:07:07 +08:00
bunnie
f7c00eb985 fix some rendering artifacts and add todo's on the QR code rendering 2026-01-27 22:04:51 +08:00
bunnie
ac20b43aaa update gc2145 comments 2026-01-27 22:02:24 +08:00
bunnie
1cb23dd4a2 change power-on order of display and add unchecked variant of put pixel
- remove bounds checking for accelerating blits that are already checked
- fix the command ordering for display power-on to remove "noise"
during power-on of the display.
2026-01-27 21:51:50 +08:00
bunnie
d6a5c636bb "best" config with current lens 2026-01-27 17:33:22 +08:00
bunnie
9d5851bd98 adjust attack threshold trip for recording attack
in practice we're seeing multiple trips to the glitch detector
when power down discharge is slow.
2026-01-25 18:32:24 +08:00
bunnie
84e276f712 add BIO sketch for qspi to 8080 converter
quick feasibility study to confirm that BIO can convert
a QSPI video stream into 8080-style display stream support.
One of those quirky weird applications that I think BIO is
kind of perfect for.

I think it should work, at the speeds required, but nothing
compares to actual hardware testing.
2026-01-24 23:55:22 +08:00
bunnie
4523fea62c add support for more board options
- oem-baosec-lite board support
- more flash memory types
- transparent polarity switching on reset line

The reset line in particular is having its polarity switched
because the I/Os pull-up by default, and we'd like the reset
line for peripherals to be asserted on reset (this prevents
glitching on e.g. displays while the CPU boots).
2026-01-24 23:49:19 +08:00
bunnie
42a55cc238 add support for more flash memory types 2026-01-24 23:48:57 +08:00
bunnie
27250c65dc move anti-rollback check to after the signature has been validated
I decided i feel too uncomfortable doing any state changes based
on unvalidated data. I can't see a downside to moving the check
to only after the signature has been verified.
2026-01-22 23:15:53 +08:00
bunnie
04dd447745 add anti-rollback checking to the signature check routine
one minor issue with this implemnetation is it requires dev
images to have an anti-rollback counter that matches or exceed
the last signed image seen.

This is more of a developr ergonomics issue - this will certainly
lead to some surprise by developers who are trying to take
production devices and "downgrade" them to an old dev tree
that has an old anti-rollback firmware number in it.

However, I think this is navigable and probably the simplicity
of not having an "escape" path for dev-signed imgaes is worth it.
All a developer has to do is to set the anti-rollback version
number to be equal to or greater than what was reported in
the device.
2026-01-22 19:48:37 +08:00
bunnie
23b7bc0142 add an upper limit for counter increments
this is a sanity check number that can be used by firmware
to vet a counter value before incrementing to it. it's particularly
useful to thwart wear-out attacks agaisnt anti-rollback firmware
versions, i.e. by specifying an extremely high anti-rollback number
one might be able to cause a reset-to-0 failure and this prevents
that from happening by limiting the maximum value of the the
counter that can be requested.
2026-01-22 19:46:07 +08:00
bunnie
9d972f59d5 add specifications for anti-rollback and receipt tracking
anti-rollback is a number that is stored in a monatomic counter
inside the device that is compared against the firmware images
presented to the device. If the image version is lower than the
anti-rollback counter, the image is rejected. If the image is
higher, the anti-rollback counter is incremented until it equals
the vesrion in the image.

the receipt mechanism is a method for ensuring that cross-third
party signed images can't be used to dump keys on other third party
images. Every time a boot1 is accepted, a copy of the key block
that was used to accept the third party image is stored in the
receipt block.

If those keys rotate, then the collateral keys are rotated. this
prevents a rotation of third-party images from being used to
dump other third party images.

it does mean that third party signers have to be careful to not
rotate any of their signing keys uninitentially.
2026-01-22 19:42:51 +08:00
bunnie
97df81de44 fix permissible function code on altboot
this allows recovery from revoked keys and trying to load
a dev-boot signed image from alt-boot loader
2026-01-19 03:34:55 +08:00
bunnie
18a58c7d18 add more graceful handling of erase inconsistencies 2026-01-19 00:18:13 +08:00
bunnie
763a2c290d make boot more forgiving of inconsistent initial values 2026-01-18 22:37:08 +08:00
bunnie
6b7ff11b4e
add collateral erasure and checking of IFR copy of pubkeys
The IFR copy of pubkeys is truly actually indelible because
of the no-exceptions write inhibit byte. Add code to check
against that copy.

Note that the IFR region's downside is the presence of
the write-inhibit byte means the check is complicated
as the full key is striped across two locations, but
this code handles that.
2026-01-18 02:56:14 +08:00
bunnie
491a1c14dc add key range for collateral 2026-01-18 02:17:25 +08:00
bunnie
2b19c4bd21 add a command for setting the bootwait flag
The keystore is a sensitive server, and the one-way counters
have security-critical propoerties. So instead of revealing a
generic one-way counter API to the world, specific, limited
requests to do things are going to be created for the keystore.

In this case, the bootwait flag would be convenient to be able
to set from userspace. The motivation for this requirement is
actually continuous integration - a normal human could just
hold down a button while turning on power, but in CI, I don't
have a robotic thumb (or an alternative electrical signal) to
simulate the nerve-pinch on boot.

Previously I was "cheating" and simulating this by nuking the
loader, which effectively forces a bootwait.

However, in production, this is *not possible* because the JTAG
port is sealed off. Thus, this may be the first of a series
of small PRs to incorporate CI tooling that clears up tech
debt like nuking the loader to get into boot wait.
2026-01-16 17:32:12 +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
a5a6cc8e48
Fix comments in production key 2 slot 2026-01-15 16:57:27 +08:00
bunnie
3e5b62aab3
Add production public key to the first key slot 2026-01-15 16:56:43 +08:00
bunnie
29d25c13a1 refactor UDMA UART to use "poll" mode to receive data
The prior implementation tried to use the UDMA streaming mode
to get Rx data out of the UART.

The problem is that with streaming mode, it's hard to tell how much
data is actually available. This is because the thing that sets up
the stream sets "some number of bytes" as the fetch depth of the
DMA Rx, but all you can read is "number of bytes remaining" out
of the DMA interface.

So when 0 bytes are remaining, you can fetch some data, but you don't
know *how much* to fetch. And if someone else fetched partial data
before you, you don't know how much partial data was fetched. This
could be resolved with some gnarly, highly concurrent state that
gets incremented on every fetch.

Or, we could use poll mode. There's a reason i think it's in the
block, because the Rx DMA mode is more or less not usable. Poll
mode you read a config register, see if there's valid data, and if
so, when you read the data register, it's pulled out of a FIFO.
The FIFO is in hardware and it's 4-deep. As long as you don't
need more than a depth of 4, you're rock solid.

This is a lot easier than the UDMA Rx mode, so I've just gone ahead
and deprecated the Rx mode. I could only ever get the Rx mode
to work to receive a single character *anyways*, so despite its
potential to receive thousands of bytes without CPU intervention,
it was only ever used as a 1-deep buffer because of the inability
to know exactly how much was in the buffer. Thus, the poll mode
is actually an improvement over the DMA mode, in practice.

More importantly, it means the Rx link is much more stable in
GDB kernel mode, if the baud rate is cranked down to 115200 (at
1M baud, the kernel still can't respond quite fast enough to
reliably drain it).
2026-01-14 03:21:06 +08:00
bunnie
24105e7b22 add the default perclk speed as a public constant
instead of just hard-coding it in the clock setting routine
2026-01-14 03:20:27 +08:00
bunnie
fba011db3a commit version bump so that we may publish our packages 2026-01-08 03:04:19 +08:00
bunnie
079ec33134 improve formatting & timing slightly 2026-01-06 15:43:50 +08:00
bunnie
d1a3eb4b58 handle clock counter rollover case & fix bug in assembly register naming
t3 doesn't actually exist
2026-01-06 15:40:14 +08:00
bunnie
08cfe2d724 cleanup warning 2026-01-06 13:41:24 +08:00
bunnie
1087405eb9 add compatibility for APS6064L SRAM parts 2026-01-06 12:14:20 +08:00
bunnie
b49856ce7b change the pin set API to something more usable 2026-01-05 21:55:14 +08:00
bunnie
dd18ddf97c convert avalanche TRNG interface into the Xous BIO API 2026-01-05 21:53:39 +08:00
bunnie
b02f1563ae don't put pin snapping into ws2812 implementation
the pin snapping makes the application not composable with
other applications that don't use the exact same snapping mode.
2026-01-05 08:56:38 +08:00
bunnie
40e740d869 implementation for the composeable I/O modes 2026-01-05 08:56:20 +08:00
bunnie
d647e41822 fix API to allow for composition of IO configurations
the main issue is that if the IO configuration fully replaces
a previous configuration, two apps can't be loaded at the same
time because the later one replaces the previous one's configuration.
now the I/O settings take an option for a configuration mode,
which is somewhat clumsily expressed as either replacing the
I/O configuration, setting bits only, or clearing bits only.

This maybe could use a cleaner API but not quite sure how to
do it yet.
2026-01-05 08:54:29 +08:00
bunnie
9a94ea48ad add captouch demo
some basic APIs in place to help make touch a little easier
to use.
2026-01-05 08:53:13 +08:00
bunnie
6398415265 update lib refs 2026-01-03 22:55:47 +08:00
bunnie
e2097f171e add demo for doing multiply instructions 2026-01-03 22:55:20 +08:00
bunnie
e0fddfbe04 improve readme slightly 2026-01-03 22:55:04 +08:00
bunnie
c81911e498 move readme to a customary location 2026-01-02 12:54:01 +08:00
bunnie
f1b9212b75 re-organize code so that the APIs are up top 2026-01-02 12:45:40 +08:00