Commit graph

10340 commits

Author SHA1 Message Date
bunnie
e95550cb52 add oled ui for baosec board targets on boot1 2025-10-01 14:27:51 +08:00
bunnie
d80d6cbd6f
Merge pull request #690 from betrusted-io/bl0
Restore tracking for Bl0 branch
2025-10-01 03:01:47 +08:00
bunnie
2eaaa99f6e fix kernel config conflict
no signature checking is necessary in the kernel so don't
introduce the dependencies
2025-10-01 02:57:55 +08:00
bunnie
ed935c66cb loader tracking api changes; needs refinement still. 2025-10-01 02:57:32 +08:00
bunnie
f04a856037 allow .bin as uf2 conversion target 2025-10-01 02:56:53 +08:00
bunnie
d265ce3398 note deprecated pin config 2025-10-01 02:56:40 +08:00
bunnie
b85ed18cd8 boot1 improvements
- 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
2025-10-01 02:48:36 +08:00
bunnie
b0378d346c remove mass storage from baremetal
No need for it in the baremetal environment, and it frees up
a lot of RAM for use in baremetal applications.
2025-10-01 01:27:40 +08:00
bunnie
ca7afb63b6 update lockfile 2025-10-01 00:43:00 +08:00
bunnie
625e61cbe6 add alternate baremetal naming for consistent target prefixes 2025-10-01 00:42:42 +08:00
bunnie
4726056b29 cleanup baremetal flow to work with the boot1 assumptions 2025-10-01 00:42:25 +08:00
bunnie
4e2fc04d5d cleanup legacy code 2025-10-01 00:42:02 +08:00
bunnie
91232fd57b cleanup comments on boot1 code 2025-09-30 23:47:50 +08:00
bunnie
cdb60eed0f update the static table definition 2025-09-30 21:52:45 +08:00
bunnie
c1544ca5e7 fix initialization bug in statics
this unstucks the console when USB comes up.
2025-09-30 21:51:54 +08:00
bunnie
a6769c46ba track change in statics struct 2025-09-30 21:51:28 +08:00
bunnie
76f6f1fda5 pack offsets into a u16-sized pointer
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.
2025-09-30 21:50:17 +08:00
bunnie
52e9cd0630 make trailing whitespace CI happy 2025-09-30 17:35:19 +08:00
bunnie
d9ff07a32f redo the fat emulation layer
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.
2025-09-30 17:29:06 +08:00
bunnie
dec6c1944b add overflow handler to big reads (to fake big disks) 2025-09-30 17:28:42 +08:00
bunnie
9ee10257f6 update dependencies 2025-09-30 00:44:41 +08:00
bunnie
ee55ca1d8b fix formatting skip directive 2025-09-30 00:44:13 +08:00
bunnie
7ec9457854 cleanup the boot-wait code, and add autoboot toggle command 2025-09-30 00:38:19 +08:00
bunnie
cade3980cc fix double-offset error in oneway counter readback 2025-09-30 00:37:57 +08:00
bunnie
9336100965 add placeholder for debugging 2025-09-29 22:19:08 +08:00
bunnie
15562abf00 add functional code slice
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.
2025-09-29 22:17:56 +08:00
bunnie
6b8d8f09f7 cleanup functional code specifiers for boot partitions 2025-09-29 22:17:38 +08:00
bunnie
e7135d9e80 narrow down functional codes allowed for signature validation 2025-09-29 22:17:09 +08:00
bunnie
01cf1df330 u2f serial upload now working
works over both physical serial port and USB serial port.
2025-09-29 21:58:01 +08:00
bunnie
f8e124f6f9 limit writeable area to the active data area
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.
2025-09-29 18:41:29 +08:00
bunnie
a511e3c591 add uf2 over serial protocol for writing e.g. baremetal images 2025-09-29 18:40:57 +08:00
bunnie
fa875158e3 add uf2 file sender that works over the serial port 2025-09-29 18:40:33 +08:00
bunnie
0d8cf34b18 add docs to sigcheck routine and fetch public keys from the specified source
this fixes the issue where we're asking an untrusted image to
tell us what keys to check it with :P ~~~
2025-09-29 16:22:16 +08:00
bunnie
aabe88e0d5 checkpoint the baremetal routine as we integrate into the boot chain 2025-09-29 16:21:53 +08:00
bunnie
ba817cc1a9 add uf2 identifier for baochip-1x
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.
2025-09-29 16:20:43 +08:00
bunnie
54b16cdf64 fix public key origin for signature checks
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.)
2025-09-29 16:18:21 +08:00
bunnie
a3a2a1de9d add baremetal support to function codes 2025-09-29 16:18:00 +08:00
bunnie
d9347e46fb update tools to generate a uf2 image 2025-09-29 16:17:45 +08:00
bunnie
d0bd60d93c fix USB handling
- statics origin set correctly
- debug prints on USB stack go to DUART to avoid a Tx storm
when debugging e.g. Tx packets on USB
2025-09-29 14:49:06 +08:00
bunnie
59ae767741 fix statics origin in boot0 2025-09-29 14:48:48 +08:00
bunnie
7b5c4e1cd8 add a draft boot1
boot1 contains all the ideas up to and including the console.

however, the actual file transfer bits are yet to be implemented.

onward!
2025-09-29 13:52:38 +08:00
bunnie
1a0db7bb4d add boot1 to the workspace 2025-09-29 13:52:26 +08:00
bunnie
a9112a743a add mapping for loader in image signing (synonymous with baremetal) 2025-09-29 13:51:58 +08:00
bunnie
8dff74a017 don't format vendored in crates 2025-09-29 13:51:44 +08:00
bunnie
75022f0b63 track API change for location of combohash bits 2025-09-29 13:51:00 +08:00
bunnie
4375bf43d0 remove debug as a default option for ed25519 2025-09-29 13:49:39 +08:00
bunnie
8cbdb75dc8 cleanup boot0 code
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.
2025-09-29 13:46:42 +08:00
bunnie
150e46d9c0 restructure the HAL's security primitives
- 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)
2025-09-29 13:42:23 +08:00
bunnie
c6445c9a9b add an API for accessing one-way counter values
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.
2025-09-29 13:40:14 +08:00
bunnie
728072ebae add documentation of the boot0/boot1 flows 2025-09-29 13:39:37 +08:00