- 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
the data section is generally pretty small, a few k, and there
are cases where we need more initialization entries. This keeps
the structure from growing beyond 256 bytes.
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.
this puts a domain separator in every signature block
a domain separator meaning, even though the same private key
maybe be used to sign multiple blocks, because a functional code
is embedded in the block that is tied to the block's function, you
can't take a pre-signed block and shove it into another block's slot
and expect it to work.
the top of memory is reserved for various security structures
the security structures do have some hardware protection
but life is better when we also help programmers avoid triggering
the protections by accident and then just being confused.
just pulled it out of a uuid generator, checked it has no
collisions. At some point, maybe some official repo will allow
us to be "real" but ain't nobody got time for those politics
today.
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.)
remove things that we don't need in boot0. Boot0 originated from
a much larger, more featureful space and needs to be whittled down
to remove attack surface and space for bugs.
Some further cleanup to do would include:
- hardening the PLL setting. Right now it's done computationally
based on the demanded frequency. But in practice, because the
target frequency is hard-coded, we could just compute the actual PLL value
results and jam them into the register and lose a whole bunch of
code.
Actually I think that's all that needs to be cleaned up off the
top of my head.
- combohash constants are moved to API: these need to be in a
dependency-free library so that we can refer to these values in
any context without creating circular dependencies
- sigcheck code is now put into the HAL layer, instead of in the
individual bootloaders. This is because the sigcheck code is re-usable
between boot0/boot1.
- sram timing trimming data has been entered from the XLS file
and put into an array for easy access
- more board initialization functions have been adedd, and cleaned
up to adhere to the rule that pin allocations don't change the state
of the pins, allowing pin allocation calls to be idemptoent (e.g.
you can call it several times without negative effects - the reason
being that the pin setups also return the pin maps, which can then
be passed to the functions of interest to manipulate the pin states)
A macro is added, a bit like this one:
```
encode_oneway! {
#[offset = 80]
pub enum BootWaitCoding {
Disable,
Enable,
}
}
```
Which encodes possible one-way counter states along with their
offset in the one-way counter array.
The states in the enum correspond to the evolution of the counter,
modulo the number of elements in the enume.
The macro also creates a getter for the states, and an incrementer
to try and make this whole process less error-prone.