Commit graph

104 commits

Author SHA1 Message Date
bunnie
509bf08c0a make application slot range explicit
also start tracking application slot usage in dabao target
2026-06-08 23:47:19 +08:00
bunnie
50dcf7880f add a wfi specifier to the bio clock change api
this indicates if we're going into or out of wfi - this matters
because the clock rate asymmetry can be quite great, and the
calling function can have different optimizations for each mode
of operation
2026-05-08 03:13:30 +08:00
bunnie
a0609ebc88 add puya device support 2026-05-06 23:35:18 +08:00
bunnie
e785257711 api moves for I2C into its own dedicated thread
moving I2C into its own thread mitigates lockup conditions
where I2C is blocking progress on e.g. gpio pin sets and
interrupt handlings
2026-05-05 23:56:58 +08:00
bunnie
b78a5619b0 add register interpretation for reset reason 2026-05-05 23:56:05 +08:00
bunnie
8521d698d7 add hooks for pre-clock transition on bio
this hook allows the application logic to warn the BIO
app that a clock transition is coming so that glitches can be
suppressed.
2026-04-21 16:27:10 +08:00
bunnie
70543731d1 add keyboard remapping that also tracks screen flipping 2026-04-07 00:37:15 +08:00
bunnie
245040cfb9 add opcode for irq config update 2026-04-07 00:34:59 +08:00
bunnie
445ea9db44 expand iox api to allow for switching of interrupt levels
this allows us to trigger on both rising and falling edges
alternately
2026-04-07 00:34:24 +08:00
bunnie
44a53e590a move error definition to api crate, fixes hosted ci 2026-04-04 00:08:39 +08:00
bunnie
b7826c2ebc flesh out backup register interfaces
- adds API for retrieving & setting the ephemeral key. This is
a key that is erased by a power-on reset, but is preserved between
deep-sleep sleep/wake cycles. It is intended for securing a lock
PIN, and can be up to 192 bits long.

- adds API for checking the warm boot flags, which are also stored
in the backup registers.
2026-03-29 18:04:09 +08:00
bunnie
c38214865f add a routine to initialize the ioconfig from the resource spec
in particular this makes sure the io config masks are extracted.
2026-02-28 23:20:04 +08:00
bunnie
e704477f79 api changes for ADC service 2026-02-24 01:34:32 +08:00
bunnie
302b7b65bf add std opcodes for ADC operations 2026-02-23 18:53:19 +08:00
bunnie
29437c1ae8 Add an aligned bio_code macro
This macro introduces page-level padding around the BIO code
regions, so that the rust assembler/linker computes relative
offsets correctly. This is necessary for code that is
autogenerated from C that uses `statics`

It's not recommended to be used *everywhere* because even
tiny BIO snippets of a few bytes would be blow up to 4k each.
2026-02-20 20:57:10 +08:00
bunnie
b991a54b52 add debug call for bio 2026-02-20 02:09:09 +08:00
bunnie
da895b2c1f
extend sealed data to contain a toolchain hash field
the sealed data records are laid out with some extra space
at the end for future expansion.

The first such expansion added is a toolchain hash, which allows
us to note which toolchain is required to reproduce the current
image.

The change is backward compatible so the version field of
the record is *not* incremented.
2026-02-16 18:10:08 +08:00
bunnie
c71f472743
fix in-line directive on hardened bool
this prevents there being a single "hot spot" to attack for
hardened bool testing
2026-02-15 03:20:54 +08:00
bunnie
58d17f1423
refactor the key ordering specification
this makes it much easier to check for errors - and one was found,
the erase coupon was accidentally off by one, and equal to the
master key slot. oops! 🤦
2026-02-10 22:49:17 +08:00
bunnie
c1b7612e7e
add one-way counter offset for auto-audit
for the first few boots (3 in this case), automatically
print an audit to the console. This is used to verify that
the chip was programmed correctly in chip probe.
2026-02-10 03:28:31 +08:00
bunnie
f6bf8f9bf1 modify pddb size on key testing
this allows for faster reboots through CI cycles as a state
transition from secure->insecure always triggers a PDDB format
2026-02-04 15:57:09 +08:00
bunnie
8bc480994c remove disconnect idiom from HAL API
the implementation is flawed - because multiple APIs hit
a single server, the reference count can reach zeoro for
a given interface, and trigger a disconnect, while another
API is still using it.

the long-term fix for this, if we wanted auto-disconnect,
would be to wrap the connection query into a helper that
uses an Arc to ensure the count is maintained across all
possible interfaces.

However, for the HAL, it's likely that pretty much every
server is going to want this connection, and want it to
stay around so - we'll just remove the auto-disconnect
idiom for now and figure something out if we end up
hitting a connection resource limit on a service that
truly only needs the HAL connection early on in its
lifecycle and never needs it again.
2026-02-02 01:17:24 +08:00
bunnie
4a7ed1315e add maintenance notes 2026-01-30 04:26:15 +08:00
bunnie
d44caab9ec update api for publishing 2026-01-30 04:22:33 +08:00
bunnie
3f869ca389 bump utralib version for publication 2026-01-29 19:12:00 +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
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
42a55cc238 add support for more flash memory types 2026-01-24 23:48:57 +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
491a1c14dc add key range for collateral 2026-01-18 02:17:25 +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
fba011db3a commit version bump so that we may publish our packages 2026-01-08 03:04:19 +08:00
bunnie
1087405eb9 add compatibility for APS6064L SRAM parts 2026-01-06 12:14: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
f1b9212b75 re-organize code so that the APIs are up top 2026-01-02 12:45:40 +08:00
bunnie
785daf253c update comments 2026-01-02 12:30:10 +08:00
bunnie
8d84345444 add resource tracking 2026-01-02 11:25:18 +08:00
bunnie
06501a9032 fix handle API to reflect actual implementation
I had a bit of a brain fart while drafting the original code
2025-12-31 23:32:39 +08:00
bunnie
5be682b37f cleanup apis after std implementation 2025-12-26 21:03:19 +08:00
bunnie
c239d79ead cleanup the API after running through an implementation 2025-12-26 20:17:34 +08:00
bunnie
9eb40aceb0 move comments to the correct file 2025-12-26 01:06:10 +08:00
bunnie
60b18303ed define the BIO API in the abstract API
this is a fully abstracted API that should be fully hardware
independent. This is meant to supercede the xous-bio-bdma library.
The xous-bio-bdma library will stick around, but its main purpose
is as an experimental, baremetal library that contains low
level code and test code for developing the hardware. We could
try to merge this into the abstract APIs but I think it doesn't
make sense from a methodology standpoint - hardware development has
a different tempo and flow from the software development process,
and so by keeping these two separate we end up with potentially
diverging APIs - but actually, this is a good thing. It allows
us to develop e.g. v2 of the hardware without having to roll
uncertain/experimental v2 hardware APIs into the abstract APIs
right away.

there is one hairy point in all of this, which is I'm trying to
get fancy and have a hardware "handle" be dropped automatically
when it goes out of scope. This requires me to pass around
a phantom lifetime parameter, something I haven't done before.
If this works, it could be a good template for dealing with other
abstract hardware APIs that will help remove some unsafe code.
2025-12-26 00:55:00 +08:00
bunnie
a5303a707f define backup flags 2025-12-22 02:05:46 +08:00
bunnie
b195447fcb add swap key to the list of keys managed on baosec
not sure why this wasn't added earlier....
2025-12-19 16:42:04 +08:00
bunnie
0c690d8be4
add boot1 pubkey integrity checking
this should erase the secret keys if the boot1 pubkeys don't match

this enables OEM-signed boot1 images. the policy is that all OEM
images signed by baochip are considered to be untrusted, and thus
loading them onto a device would wipe any secret keys, making
them less useful for extracting secrets.

There are 2048 keys and about 500 keys are used by baochip,
so there are still plenty of keyslots available for OEMs to
use to implement their own version of security.
2025-12-19 01:14:51 +08:00
bunnie
36b103ef6c
remove the developer function from the function code list
The developer function was decided to be overly-broad: the
issue is you could slot that in to *any* boot position and
it'd be accepted, and we already have a mechanism to deal
with developer mode (developer-signed images). Thus eliminate
the extra case and simplify the code base to reduce
potential bugs.
2025-12-19 01:09:44 +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