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
- 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.
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.
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.
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! 🤦
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.
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.
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.
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.
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.
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.
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.
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.
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.