Commit graph

4007 commits

Author SHA1 Message Date
bunnie
476f747c78 add skeletal bio service 2025-12-26 20:16:13 +08:00
bunnie
77f55941f0 cleanup import path 2025-12-24 13:17:19 +08:00
bunnie
444d7b310e re-enable keyboard bouncer inside bao-video hosted mode 2025-12-24 13:14:48 +08:00
bunnie
a313887c26 re-organize usb server so that hosted mode can be cleanly turned on 2025-12-24 13:14:11 +08:00
bunnie
0859b01071 add susres skeleton to emulator 2025-12-24 13:13:33 +08:00
bunnie
6f0a9c4275 fix keyboard scan configuration
turns out that when the keyboard is activated, *all* the keyboard
lines take over the GPIOs - and this will fight with the the doubled-up
PF7_PA2/PF8_PA1/PF9_PA0 I/Os.

Using the keyboard controller means that *all* of the PF2-PF9 pins
are now driven by the keyboard controller, regardless of the GPIO
setting.

This is because when the core is powered off, the GPIO output mappings
are lost (they are in the core domain, not always on), and the KPC
was implemented without the ability to selectively demux unused
rows/cols.

In particular on baosec this can lead to high power consumption on
the 24MHz clock when driving the camera, because the KPC fights
with the clock.

The mitigation for the current baosec hardware is to configure
the KPC such that the internal pull-up is responsible for the
"high" level, and it's only driven when "low". This reduces the
amount of fighting with the oscillator.

A future rev of hardware will move the osc to the PA3 pin, where
there is a PWM output but no muxing with the KPC, eliminating
the conflict entirely.
2025-12-23 23:36:17 +08:00
bunnie
f98dea3097 add missing dependency 2025-12-22 16:51:22 +08:00
bunnie
192a9148dc catch the deep sleep request 2025-12-22 02:11:54 +08:00
bunnie
3427c4965e note RTC todo's 2025-12-22 02:11:29 +08:00
bunnie
0487d5a2a3 add shipmode and deepsleep mode tests
- shipmode is for long-term storage. it disconnects the battery
from the system so that the shelf life can be ~years
- deep sleep effectively shuts down the system but leaves the
real time clock running. Requires a full reboot to recover
from deep sleep.
2025-12-22 02:10:26 +08:00
bunnie
2f2a1bcd23 fix version string retrieval 2025-12-19 03:23:24 +08:00
bunnie
cd075729c4 quite down a debug statement 2025-12-18 02:21:20 +08:00
bunnie
87dc26d832 update the keystore to ignore the deprecated board type checks 2025-12-18 02:20:44 +08:00
bunnie
d874c3e5c2 commit for version bump 2025-12-16 02:02:37 +08:00
bunnie
21d508f64b add susres dependency 2025-12-16 01:16:10 +08:00
bunnie
b0b72bc28b remove wfi api - using susres manager instead 2025-12-16 01:15:30 +08:00
bunnie
257bafcc5f structural rework of the main loop to allow for deferred blocking scalars
also invoke the susres thread manager
2025-12-16 01:14:45 +08:00
bunnie
8536b4fda4 rework power management scheme to use susres API 2025-12-16 01:10:30 +08:00
bunnie
b0ec2929d7 cleanup warning in rtc 2025-12-16 01:09:12 +08:00
bunnie
5ebc40453c add suspend/resume manager to the HAL
this gives us a clean API for power savings mode entry/exit
2025-12-16 01:08:41 +08:00
bunnie
e4eeb4603f rework ticktimer to use the susres interface 2025-12-16 01:08:17 +08:00
bunnie
9b9948e8da fix hosted mode warning 2025-12-16 01:07:49 +08:00
bunnie
e1cde0328c cleanup broken alt-target builds 2025-12-16 01:07:35 +08:00
bunnie
d261090f31 convert test routine to use susres api to enter sleep 2025-12-16 01:07:16 +08:00
bunnie
a94595ca9f RTC: rework to give milliseconds time
The original RTC was set to a 1Hz tick, which isn't sufficient
for the time API

This has been reworked to give a 1/1024 second increment.
Rollover logic is implemented in the RTC. Requires the system
to be powered on at least once every 48 days to capture the
rollover, otherwise it could miss a rollover event. This is
fine because the backup battery doesn't last that long, and
scans of QR codes for password login always reset the RTC anyways.

The RTC offset randomization code is now gone because we're
not tracking long-term power-on information in the RTC.
2025-12-15 15:16:10 +08:00
bunnie
074b0429d3 add timing dither to ticktimer
add a little bit of timing dither to one of the core delay routines
this hardens the OS against glitch attacks by making the timing of
concurrent tasks less predictable
2025-12-14 16:05:12 +08:00
bunnie
5f1b769822 cleanup warnings 2025-12-11 02:27:56 +08:00
bunnie
def8da571b add a wfi api 2025-12-11 02:22:01 +08:00
bunnie
e2d15e26e6 expand test routines 2025-12-11 02:21:02 +08:00
bunnie
261ea7a880 update apis in hal-service 2025-12-11 02:18:44 +08:00
bunnie
8950a24327 move i2c in bao1x-hal-services into bao1x-hal
this makes i2c accessible without having to rely explicitly
on the server itself, making the library callable in more contexts.
necessitated avoiding a name space collision and moving the
I2C hardware drivers to a stucture named I2cDriver; the I2C
object now unambiguously refers to the userspace interface
to I2C.
2025-12-11 02:13:21 +08:00
bunnie
8269f9f759 update apis to accommodate power savings mode 2025-12-11 02:10:25 +08:00
bunnie
b6f761a9a9 move power manager to a server
this is because the power manager itself relies on the HAL
server to manipulate GPIOs and it'll block the main loop if
the calls are handled there.
2025-12-11 02:07:17 +08:00
bunnie
0ada90fec5 fix power consumption on camera
mclk wasn't stopping correctly, causing lots of leakage power.
2025-12-11 02:03:43 +08:00
bunnie
a3a566b240 add API calls for debugging kernel under baochip targets
also updated some really bit-rotted docs

we will deprecate the docs/ directory soon, they are wrong
and misleading at this point.
2025-12-09 16:19:04 +08:00
bunnie
c9d513599c fix hosted mode 2025-12-08 01:41:44 +08:00
bunnie
772c818908 reduce power from camera 2025-12-08 01:09:12 +08:00
bunnie
c3757248a8 fix hosted mode 2025-12-07 20:52:46 +08:00
bunnie
9ade5a4a0d add notes about coding capacity:
40 bytes gives 320 bits which fits nicely into a version 3 code,
which allows 4 pixels per module rendering.

if we have to move to 3 pixels per module, the next code up that optimally
uses the full screen is version 6. This would give 102 bytes of transfer
in a single scan.

The equation for capacity is:
`binary_bytes = floor((alphanumeric_capacity / 3) × 2)`

where `alphameric_capacity` is the capacity of the QR code version
per spec lookup table.
2025-12-07 19:08:06 +08:00
bunnie
c3a0a50c9e add test routine for QR code generation/scan
a 40-byte message can be encoded in a version 3 code with
medium ECC. This is pretty optimal because it allows 4 pixels
per module in the QR code, which is a nice size for viewing.

base45 is added as a dependency to the project. Base45 is weird but
apparently it's the most efficient way to code binary data into a
QR code.

40 bytes (320 bits) is enough to exchange a 256-bit key plus
64 bits of sideband data. I think this is going to be enough for
basic device-to-device handshaking.
2025-12-07 19:01:14 +08:00
bunnie
c813aa1b92 add hook on bao-video to handle the qr_render case 2025-12-07 19:01:00 +08:00
bunnie
6ecaa36d98 cleanup warning 2025-12-07 19:00:44 +08:00
bunnie
ebb7e8dfae refactor QR code notification implementation
Previous implementation sent the QR code as draw commands.
This is inefficient as it would require hundreds of draw
commands to be sent per QR code rendered.

This implementation codes the QR code as a bool and sends
it in a single memory message, and implements a QR code renderer
on the receiver side.

The QR code rendering is also cleaned up so that the QR code is
always centered and takes the full screen, to give the best
conditions for someone scanning the code from another device.
2025-12-07 18:58:33 +08:00
bunnie
b012038c1d
fix argument to hazardous-debug print
this allows us to check that things are being done correctly
in CI.
2025-12-06 00:16:36 +08:00
bunnie
78036d71dc
add code to check the flag
there's a dummy flag checked in, and this code helps check that
the flag is treated correctly during CI testing
2025-12-04 15:10:51 +08:00
bunnie
3663ea1276 revert inadvertent testing flag that was checked in
this only makes sense for testing on specific builds.
2025-12-02 02:39:28 +08:00
bunnie
9b54fdb64f fix dabao target dependencies 2025-12-02 02:27:01 +08:00
bunnie
01475137bb add code to test the random seed 2025-12-02 01:40:39 +08:00
bunnie
fcc6fc5538 add chaffing feature to the swapper
the main imagined attack vector on the swapper is recovery
of the AES key through side channel analysis.
2025-12-02 01:06:36 +08:00
bunnie
5b4d6c1932 add benchmark data on chaffing
unchaffed AES is 5.36us/block
chaffed AES is 10.27us/block

so ~2x overhead for chaffing - about what we expect for the
implementation.
2025-12-02 01:05:26 +08:00
bunnie
da44e98257 add chaffing implementation to AES 2025-12-02 01:04:17 +08:00
bunnie
9034a08b5e fix TTS target API change 2025-11-30 22:21:31 +08:00
bunnie
d9a65a51d9 fix hosted mode 2025-11-30 21:56:32 +08:00
bunnie
381dee01eb fix interfaces in GAM for stateful lists 2025-11-30 21:32:26 +08:00
bunnie
49456db837 fix typos 2025-11-30 21:32:08 +08:00
bunnie
98e9d99de8 add stateful list creation
this allows us to have "pre-checked" checklists
2025-11-30 21:31:39 +08:00
bunnie
7d7fa75e7d add debug telemetry for keyboard connect error
sometimes on boot, a process tries to send keyboard an incorrectly
formatted message. I think this might be the IOX interrupt handler
firing due to random noise. Corrective action towards debugging
includes instrumenting the keyboard call with debug info, and also
ensuring that the iox interrupt handler banks are initialized to 0.
2025-11-29 15:49:40 +08:00
bunnie
b702a68c1c test what local time returns 2025-11-29 01:01:24 +08:00
bunnie
4ec0eda2b5 migrate service name to some place public 2025-11-29 01:01:04 +08:00
bunnie
6918e275d0 map the center key to "fire"
This allows the center key to be used as a UI trigger action
without creating a carriage return on the console. this prevents
console actions from errantly triggering during complex ui navs.

probably later on we should filter out more of the UI nav items
going to the console because the console is always listening
2025-11-28 18:43:59 +08:00
bunnie
3b1784d346 make screen panic messages somewhat more useful
some panic messages are hundreds of characters long, most of them
are path hashes or paths to crates that are less useful.

truncate any panic messages to the last set of displayable
characters, so that the "most useful" portion (e.g. file name
and line number) are always visible in a panic.
2025-11-28 18:41:53 +08:00
bunnie
106f7153a1 filter key presses through the video layer
the video layer is the "traffic cop" managing when modals
get focus. This patch creates a feed from the video layer
that listers to subscribe to that filters out key presses
destined for modals.
2025-11-28 18:40:56 +08:00
bunnie
647ec0dfb4 fix dabao target - keyboard server
dabao needs to have a vestigial keyboard server which handles
forwarding USB/serial key events to listeners. otherwise, there
is no input interface.
2025-11-28 11:35:17 +08:00
bunnie
84a083017c gate off incompatible features for hosted mode 2025-11-27 22:11:13 +08:00
bunnie
80eba30099 use screen real estate a bit more efficiently on panic 2025-11-27 17:57:41 +08:00
bunnie
6df070e95e notify waiters that mount is successful 2025-11-27 17:57:24 +08:00
bunnie
fbb04d96ab make center keypress a unique key so we handle it separately 2025-11-27 16:51:15 +08:00
bunnie
1f9ab022f2 implement on-demand QR code scanning 2025-11-27 16:50:47 +08:00
bunnie
a24aaaa944 increase keyup delay slightly
this prevents some keyboard stutter in case of ui lag
2025-11-27 12:34:13 +08:00
bunnie
72144ad35d builds with no timestamp should still display a git version
version descriptions should be reproducible, by definition.
2025-11-27 12:33:43 +08:00
bunnie
434e0c7ae5 refactor organization of code to fix dabao target
kpc isn't possible on dabao due to the pins not being broken out,
so gate out the service entirely for that target.
2025-11-26 21:37:31 +08:00
bunnie
cdf4a56d76 add backup manager ref in keystore
this claims the backup memory region - eventually we'll do
something with it
2025-11-26 20:48:29 +08:00
bunnie
601d2763e8 add keyboard userland abstractions 2025-11-26 20:45:50 +08:00
bunnie
40c94b5abc add kpc_aoint abstraction layers 2025-11-26 20:45:12 +08:00
bunnie
41f750163f change timing of PDDB mount
moving it a shy later into the boot makes the mount process faster
because it's not fighting for swap memory with everything else
trying to initialize at the time.
2025-11-25 01:08:47 +08:00
bunnie
c677f6f78a add apis & services for the rtc 2025-11-24 18:56:03 +08:00
bunnie
543f455ad0 fix scalar return discipline in usb-bao1x
also add ability to read keyboard led state
2025-11-24 18:54:50 +08:00
bunnie
62b656db8a add some test routines for checking RTC functions 2025-11-24 18:28:50 +08:00
bunnie
d30d889774 add rtc hardware drivers and service 2025-11-24 18:28:00 +08:00
bunnie
49dcc7aaa2 add CI telemetry for keystore init 2025-11-19 14:00:59 +08:00
bunnie
90362b2604 fix hosted mode 2025-11-18 23:59:17 +08:00
bunnie
22f44f82b9
add debug telemetry to the keystore
this is constructed in a way such that

1. it's gated off in production builds
2. if it was accidentally gated on, there is some security impact
but not a significant loss of security

We do need the telemetry so that during CI we can confirm that things
are actually working. I think the risk of being too buttoned-up
and then accidentally doing something like accidentally never
initializing keys and leaving them all zero is greater than the
risk of accidental partial leakage of information due to a procedural
mix-up in the image signing ceremony.
2025-11-18 23:20:31 +08:00
bunnie
ad116b5af6 reduce leakage during hazardous-debug
in theory, no production images should be signed that have this
feature enabled. But, reducing the amount of leakage just in
case an accident happens and this flag is somehow slipped
into a signed production image.
2025-11-18 22:46:20 +08:00
bunnie
0723306085 update docstring 2025-11-18 22:40:36 +08:00
bunnie
fdb613cfb3 fix corner case on non-word aligned buffers 2025-11-18 22:40:09 +08:00
bunnie
69b77f3072 allow gen2 to use the seeded trng fill 2025-11-18 19:35:59 +08:00
bunnie
0942858bbc add test cases for trng 2025-11-18 19:35:48 +08:00
bunnie
4f39532471 clean up filling API
previous implementation was full of too many special cases

also add a version that allows us to fill using a seeded CSPRNG
for better performance on bulk fills
2025-11-18 19:34:57 +08:00
bunnie
52c5400fca
cleanup debug 2025-11-13 18:36:03 +08:00
bunnie
9213755a6b
move keystore init to userspace
This moves the key store initialization to the key manager
process itself.

It has been tested to work with signed images, and to also
protect the system in case of another process trying to access
the key data as well as in the case of developer keys being
used.
2025-11-13 18:32:04 +08:00
bunnie
c3c86e857b improve pddb init 2025-11-12 22:08:01 +08:00
bunnie
59325e0571 fix warnings in placeholders in bao1x-emu 2025-11-12 15:28:42 +08:00
bunnie
f4b88ce964 fix deps in other build modes 2025-11-12 15:27:00 +08:00
bunnie
315bee22dc add placeholders for ephemeral/volatile data in keystore 2025-11-12 15:26:35 +08:00
bunnie
8c421c6050
Merge branch 'main' into vault2 2025-11-11 08:47:10 +08:00
bunnie
dd42267eb9 fix mount/format on boot ordering
pddb is working again in hardware, this time with real keys
2025-11-11 08:18:57 +08:00
bunnie
c2c135bfdc fix trng service in baosec environment
fix missing initializers
2025-11-11 07:53:52 +08:00
bunnie
54f476edd3 fixup hosted mode emulation for baosec 2025-11-08 04:20:30 +08:00
bunnie
fa8325c2ed cleanup pddb for gen2 targets
gate out modals entirely from gen2 pddb

passwords in gen2 are now entirely handled outside of the
respective service crates, cleaning up the APIs

some history - on gen1 (precursor) devices, the thesis was to
reduce the amount of distance a password has to travel from
the point of a user entering it to the point of use. I think this
is academically interesting, but it pulls in a lot of code
into each service to manage the passwords, conflating services
with UI layers.

it was a nice experiment.

in gen2 (and hopefully beyond) targets, we now commit to
the idea that something else is passing in the sensitive key
materials. This means that, in fact, keying material has to
transition between process spaces, which increases the attack
surface to recover this. However, it also makes the crates
more portable and maintainable.

This is mitigated partially by the fact that in gen2 targets
the entirety of the code base runs within a piece of silicon,
so "sniffing" (passive observation of data going to memory)
attacks are a good bit harder.
2025-11-08 03:52:39 +08:00
bunnie
792de177b0 implement keystore calls needed for pddb compatibility 2025-11-08 03:52:20 +08:00
bunnie
308529bd75 cleanup warning 2025-11-08 03:51:42 +08:00
bunnie
664ef0a6c4 use serial numbers & interim pid/vid in USB stack 2025-11-06 14:07:30 +08:00
bunnie
5863296632 cleanup the feature tree; add double-lock detection printing
this cleans up the feature dependency tree a bit and also adds
some ability to print an error when the double lock condition
is discovered. it should be solved but it can only be detected
at runtime. Insntead of it being a silent failure (because
the server hung in an interrupt context and couldn't emit any characters),
it sets an atomic bool that can be checked and reported upon by
the main thread.

also cleans up debug uart acquisition.
2025-11-03 08:02:21 +08:00
bunnie
fe136ff820
Merge branch 'main' into vault2 2025-11-02 10:40:47 +08:00
bunnie
5de6581698 include chaff output into the hazardous-debug 2025-11-02 10:38:29 +08:00
bunnie
ed94245a5c enable trng server in dabao mode
this allows the rand core crates to work
2025-11-02 10:37:47 +08:00
bunnie
26078dcc7d add keystore to dabao configuration
After some contemplation, we should include the keystore in the
core service set featured by the dabao-xous configuration.

The pros are: any compatibility/sharing of resources
that require access to RRAM, one-way counters, UUIDs, etc.
will either require a wholly separate implementation that is
"insecure" or it could just reuse the baosec work. Furthermore,
as cryptographic accelerators are laid into the keystore,
the APIs become available to the dabao environment

The cons are: more space is used in a space-constrained
dabao environment (roughly 140k "deadweight" at the start, but
as cryptographic APIs get layered in this can grow substantially);
the key slots are "used up" in part by the scheme, which leaves
less key slots available for user-defined purposes.

This is mitigated by the fact that there are a couple thousand
key slots, and so even though we use a couple hundred of them
it's still not the whole range.

Also, the baosec/dabao feature flag can be used to feature-out
cryptographic APIs/accelerators that are too obscure or not
useful for the dabao environment, to "lighten up" the
firmware load.
2025-11-01 22:59:07 +08:00
bunnie
9d07d19361
Merge branch 'main' into vault2 2025-10-30 15:06:23 +08:00
bunnie
60f1b90acb fixup apis 2025-10-30 04:14:48 +08:00
bunnie
03aeafc21a release SE0 using the tristate, not by driving the pin
this reduces current draw when the prog button is depressed.
2025-10-29 03:43:45 +08:00
bunnie
9336bdab6a
Merge branch 'main' into vault2 2025-10-28 23:15:41 +08:00
bunnie
b557cd5ebc
add some trng tests to the console 2025-10-28 18:02:33 +08:00
bunnie
5f137aac96
add TRNG service for baosec target
dabao has no external TRNG, and so it can "cheat" and use the
server ID api call from the kernel to get random numbers (the
server ID is just TRNG output from the kernel's TRNG).

baosec has an external TRNG, and it needs a userspace
server to blend both kernel TRNG output and this external TRNG.
the TRNG requires the BIO block to aggregate the random data.
This commit adds that implementation.
2025-10-28 17:55:06 +08:00
bunnie
cb6bc4d2c6
add keystore master key derivation
the master key is currently derived from a number of factors:

- the key seed
- chaff keys
- nuisance keys

and then a salt of the uuid/cpid and some info based on the
developer bit is added.

The info addition ensures that the key rotates if developer
mode is entered, so in addition to the key material being
deleted, the info itself is different which should cause
the master key to rotate and "be lost" even if the key
erasure routine is flawed.

Chaff keys harden against side channel analysis of data
in flight from the RRAM array - under the theory that
the RRAM array is a big, long set of wires (on the order
of mm's) that should make a great target for EM microprobes.
The chaff keys are read out in a random order every boot,
to make it harder to accumulate enough samples to average
out what's going on.

The nuisance keys are just read straight out of the array.
They might be recoverable by side channel analysis, but
their purpose is to make it annoying for a brute-force
read-out of the key array by a microscopist. The location
and size of the nuisance keys are picked to force the attacker
to really dial in their polishing process so that they have
to hit the right layer across the entire chip (or at least
a couple mm's); and then a set of bits are packed closely
together to try and induce as much cross talk on the word
lines, running under the theory that any attack relying
on stray electrons activating the bitlines to enable read-out
are likely to non-selectively activate bitlines, so the
resulting "glow" of the word line is going to be a superposition
of several bits at once. An attacker could, of course, cap
each bit line with a FIB, read the word lines, then uncap/recap
them one by one - but this drives up the cost of the attack
and ensures that it's not just a single imaging run but
will take at least hours if not days for a skilled adversary
with the most modern equipment to extract the data. Furthermore,
the large amount of bits demands that the attacker read out
the data with better than 97% accuracy (the last 3% can be
cleaned by the ECC coded into the array), so mistakes
are costly.

The chaff/nuisance keys are read out where the chaff keys
(which are order-independent) are interleaved with the nuisance
key readout. The chaff keys are read roughly twice, using
a continuous-time algorithm to pick which version of the
chaff key is read, making it a bit harder for sidechannel
analysis to pick out which key is in flight.

It's an attempt at sidechannel hardening, we'll see how it
holds up. Pretty sure there's still some low hanging fruit
in the read-out, it'll be interesting to see what the red
team comes up with.

Hopefully this at least makes the keystore not the low hanging
fruit, and we're back at looking at bootloader/kernel exploits etc.
to do key extraction, which I'm sure there are many; but at
least those can be patched.
2025-10-28 17:29:06 +08:00
bunnie
6a548de693
Merge branch 'main' into vault2 2025-10-27 00:02:26 +08:00
bunnie
3a02dc125c add rram debug commands & duart-debug mode for the HAL in std 2025-10-26 22:22:46 +08:00
bunnie
0003921eb1 disable preemption during video capture
the camirq is a perfectly good source of preemption,
and xous will run other threads when the handler is finished.

having both natural timer preemption and camera preemption running
at the sime time seems unnecessary and hurts performance.
2025-10-26 13:37:31 +08:00
bunnie
d2254e2ce4
add HAL to keystore dependencies 2025-10-26 13:37:04 +08:00
bunnie
2a2863c11a
put keystore in charge of enabling preemption
this is done after critical setup is done. it doesn't guarantee
that it has an infinite time slice, but it makes the startup sequence
more deterministic.
2025-10-26 13:35:57 +08:00
bunnie
21c9089de2 make pre-emption controllable 2025-10-26 13:35:35 +08:00
bunnie
6dd2a1f554
update dependencies for keystore 2025-10-26 02:00:19 +08:00
bunnie
ba91aa5b58
Add audit code for the keystore
the snippet `attack_keystore()` is left in place along with hints
on how to attack the keystore. Nominally, the attack should fail,
but there are some critical pre-assumptions that can be violated.

I am interested in knowing how robust those assumptions are, so,
documentation and sample code is provided to would-be attackers.

Do me a solid and if you do find a vulnerability, open an issue
ASAP and let me know. Full well aware that some vulns may well
be unpatchable; it is what it is. Hardware is hard, but maybe
we can work together to make it better.
2025-10-26 01:57:06 +08:00
bunnie
f68cc0ba83 reorder some bao-video operation for a cleaner init sequence 2025-10-25 22:55:23 +08:00
bunnie
37ff052b34 chunk data to the USB subsystem
the chunks match the size of the application buffer, eliminating
the possibility of an overrun (of the buffer at least)

there is a possibility still i think of overrunning USB itself
but i think the CPU can't produce data fast enough to actually
do that.
2025-10-25 22:23:36 +08:00
bunnie
8a3e9ea3f5 fix crlf issue in logging crate 2025-10-25 21:36:46 +08:00
bunnie
63b848df28 fix timing interval to match the CPU clock frequency 2025-10-25 21:36:21 +08:00
bunnie
5fb7743d3b add preemption timer to the kernel
we can use the TIMER0 mechanism now that this is available in NTO!
2025-10-24 21:10:19 +08:00
bunnie
8f208cac4c
refactor debug-print in bao1x-hal
on dabao targets the duart is unavailable, so, it's convenient to
have a uart-based debug option in the HAL. this patch creates a
flag that can allow either target.
2025-10-19 01:19:30 +08:00
bunnie
c32dde7b06
Merge branch 'main' into vault2 2025-10-06 13:45:17 +08:00
bunnie
dbb0a75118 bump versions
have to absorb a version change due to xous-semver change

might as well also update the utra/svd generator dependencies
since that's been held off for a long time now.
2025-10-06 13:23:18 +08:00
bunnie
6d4f8004d3 fix breakage associated with changes to xous-semver 2025-10-06 13:17:21 +08:00
bunnie
8fcca4f873 cleanup bitrot 2025-10-06 01:34:13 +08:00
bunnie
8d067e6819 Merge branch 'main' into vault2 2025-10-06 01:23:21 +08:00
bunnie
140f1ae538 add dabao support to usb-bao1x
the minimal set of envisioned services for the dabao would
include a USB handler. Seems like too useful a thing to not
have it enabled.
2025-10-05 17:17:31 +08:00
bunnie
4069b623c4 add note about where to get dabao console from in bao-console 2025-10-05 17:17:07 +08:00
bunnie
e00606538c add SE0 release to userspace usb driver 2025-10-04 16:21:34 +08:00
bunnie
8e4d1d047f remove debug prints from usb userspace
these conflict with the kernel debug prints.
2025-10-01 23:34:53 +08:00
bunnie
d3c55b218f turn on the power supply for the camera 2025-10-01 23:34:35 +08:00
bunnie
b86664d279 move camera clock pin setup into the camera driver in Xous.
previously this was setup in the loader, which is a bit of an
abstraction bodge.
2025-10-01 15:00:40 +08:00
bunnie
d265ce3398 note deprecated pin config 2025-10-01 02:56:40 +08:00
bunnie
889262d20c remove font mapping from bao-video; fonts are now in our space by default 2025-09-25 16:12:47 +08:00
bunnie
0fe5fcdc35 this autogenerated file should not be in the tree 2025-09-24 01:09:19 +08:00
bunnie
ff6ff8841a fix missing api in precursor target from previous PR
also fixup some warnings from the new rustc.
2025-09-21 23:33:37 +08:00
bunnie
0b1f2796f7 for hwsim target make xous-log output to the duart
this removes the kernel log but you have the verilator sim trace
to debug things
2025-09-20 22:12:19 +08:00
bunnie
179e178e96 fix up formatting that changed due to the flag day 2025-09-18 21:31:54 +08:00
bunnie
1255bf12d9 FLAG DAY: fix all names to harmonize around 'bao1x'
The code base had evolved through several code names, interim
names, company names and chip names that alternatively did or did
not exist.

Baochip is the definitive name of the company, and the Baochip1x
(full part number BAO1X2S4F-WA) is the definitivey part number of
the SoC. For convenience, the part number is shortened to 'bao1x'
in most feature flags and variable references.

This commit fixes all of the odd names and removes some unmaintained
early targets.
2025-09-18 21:25:51 +08:00
bunnie
edf5206846 test code for shutdown/keep-on
at the moment not working, will resume debug once new rev of board
is back.
2025-09-18 20:19:48 +08:00
bunnie
e697b2da77 add bio pin setup handler for xous env 2025-09-14 02:14:41 +08:00
bunnie
b0d2a18122 add some debug info for spurious irqs 2025-09-13 16:18:15 +08:00
bunnie
9b515a042f add serial port library functions and handlers
this creates hooks for applications to listen to the serial port,
as well as to send and receive data. some improvements to code
ordering for readability are bundled in this as well.

very lightly tested, most of the code comes from other more tested
code in the Precursor stack.

the TRNG test stuff is not put into this stack because I think
it belongs in the baremetal environment, as it's only ever
run for characterization. We don't need to bog down the production
stack with test code.
2025-09-13 15:37:08 +08:00
bunnie
890c311102 make the logger serial path more robust to failures
the logger should not fail under any circumstances, so
any errors in the USB stack should be ignored.
2025-09-13 15:36:36 +08:00
bunnie
7f5a288090 add some commands for testing the serial console & port setup 2025-09-13 15:36:16 +08:00
bunnie
5dae83d404 improve panic screen formatting 2025-09-13 15:35:34 +08:00
bunnie
c47334704a PoC USB serial on top of the HID modes.
this now works with windows, after much testing and patching.
2025-09-13 01:12:12 +08:00
bunnie
b99da45c38 fixup dependencies to point to local fork versions
the local forks are needed to layer in high speed support,
debug, and a couple of other minor improvements.
2025-09-12 02:51:19 +08:00
bunnie
1b9c0c7143 gate off duart mapping when not debugging deep in the usb stack 2025-09-12 02:50:45 +08:00
bunnie
d20a1e4ed9 gate of unused functions without mass-storage 2025-09-12 02:50:24 +08:00
bunnie
e79f907bb7 add basic usb-serial support
some test code to echo characters back, needs to be improved
fix some reset edge cases, needs more work as stack still
does not enumerate on second plugin
2025-09-12 02:49:21 +08:00
bunnie
08aa40e557 add ctap protocol testing routines 2025-09-09 23:11:30 +08:00
bunnie
0df2cb73f7 fixup bao-video deps 2025-09-09 22:24:55 +08:00
bunnie
5ff4b6c317 turn off debug-print by default in usb 2025-09-09 22:20:02 +08:00
bunnie
1cd6a3c4d0 clean up warning 2025-09-09 18:41:25 +08:00
bunnie
16b3c43e31 get OUT packets working; in particular, HID/U2F seems good to go 2025-09-09 17:53:47 +08:00
bunnie
51adf0e76c clean up interrupt handler & remove page allocation from handler
handler works in an interrupt context, so it can't allocate
a page to return data. this cleans up that problem, and also
removes some redundant brute-forced checks that were copypasta
from previous merging of several routines.
2025-09-09 17:52:12 +08:00
bunnie
5978de6a22 cleanup warning 2025-09-09 17:51:48 +08:00
bunnie
9931daf131 fix broken links from rename 2025-09-08 17:21:49 +08:00
bunnie
6cf4757323 rename usb-cramium to usb-bao1x 2025-09-08 17:21:32 +08:00
bunnie
7fa4bb0cc5
Merge branch 'main' into vault2 2025-09-07 11:54:17 +08:00
bunnie
75a9373fea fix AES dependencies so that the correct acceleration is enabled
This relies on a trick I was not aware of previously, which is
that transitive dependencies absorb the additive set of features
enabled within a crate.

see

https://doc.rust-lang.org/cargo/reference/features.html#feature-unification

for the full description. but basically by referring to the feature
required in "aes" despite not being used in the crate but pulled
in by aes-gcm-siv, i can ensure that the transitive dependency
is in fact used.

I think this was always there but previously I just didn't understand
it correctly or didn't use it right when I tried to deploy it, but
this time I think I got it right.
2025-09-07 11:50:12 +08:00
bunnie
1c8a3a3ee9 migrate to using the latest rqrr with perfromance enhancements 2025-09-06 22:47:48 +08:00
bunnie
ac458c4b07 reduce pixel math (do mirroring in camera module)
also add some more analytics output
2025-08-20 03:07:12 +08:00
bunnie
a403f0c5f9 fix rust warinings 2025-08-20 03:06:24 +08:00
bunnie
1d950033af add base64 dumping of captured images for off-line optimization 2025-08-19 22:44:15 +08:00
bunnie
ffc226b9a8
Merge branch 'main' into nto-bringup 2025-08-19 19:51:16 +08:00
bunnie
ecbac27e76 fix rustc-1.89 warnings 2025-08-19 19:45:29 +08:00
bunnie
f2c61e44cc add aes test options to command environment 2025-08-10 22:28:32 +08:00
bunnie
55d0a6c947 add aes testing feature to console 2025-08-10 22:28:14 +08:00
bunnie
4eacde470f add commands for AES testing and for calibrating delay loop 2025-08-10 22:27:30 +08:00
bunnie
781c74ba79 make ticktimer scale with system clock setting in loader 2025-08-10 17:54:45 +08:00
bunnie
857e54c5af move the console to its final location 2025-08-10 01:56:07 +08:00
bunnie
381b7ec90e remove gpio frame-sync 2025-08-10 01:55:25 +08:00
bunnie
e3664738bc remove AES bodges due to broken AES unit in MPW 2025-08-10 01:43:03 +08:00
bunnie
508c38cfdd refer cache flush to hal version 2025-08-05 23:01:03 +08:00
bunnie
345e8868cf make bao-console work with hosted mode 2025-08-02 00:49:55 +08:00
bunnie
d91b7843cc cleanup bit-rot in I2C API in this branch 2025-08-02 00:49:38 +08:00
bunnie
0e1018797e implement HW acceleration for AES128. 2025-07-27 03:17:40 +08:00
bunnie
098d326b55 note performance improvements 2025-07-27 03:17:15 +08:00
bunnie
6fd1757a04 optimize AES routines
- change ordering of aes instructions to remove pipeline bubbles
- port the aes-256 encryption routine from assembly
2025-07-27 02:15:05 +08:00
bunnie
bd45919944 add aes test option into the mbox1 test 2025-07-25 18:59:33 +08:00
bunnie
2e8e2e0364 introduce a message passing test before mbox test 2025-07-24 00:30:04 +08:00
bunnie
1f55dd8ab1 add the messaging test into the mbox environment 2025-07-23 01:23:45 +08:00
bunnie
c0735374f0 fix hosted mode 2025-07-22 01:43:58 +08:00
bunnie
815c082153 add breadcrumb for improving the cbo.flush instruction
whenever rust stabilizes "zicbom" in RV we can remove the ugly
.word hard-coding of the flush instruction.
2025-07-21 19:12:37 +08:00
bunnie
6eaf3501bd add cbo.flush support for vexii targets
Spinor is the one location where memory changes out "from underneath
the CPU" in a cacheable region. This happens when we update a block
of FLASH.

Vex-ii has a physically tagged d-cache, but the cbo.flush instruction
needs the *virtual* address to be passed (it then goes through a page
walk or TLB lookup to resolve the tag). The virtual address only
exists and can be correctly resolved to a physical address in the
process space of the owner of the region that maps to the SPINOR
FLASH. Thus, we introduce a flush routine in the lib.rs side that
calls the cbo.flush instruction on every line that has been potentially
modified by the flash write routine.

Note that cbo.flush is not yet natively supported by Rust stable,
so it's coded as a series of hex words fixed to a given register (a0)
to avoid introducing a nightly dependency. Once the cbo.flush
assembly instructions stabilize we can make the assembly read more
nicely, but functionally it should compile to exactly the same code.
2025-07-21 19:09:05 +08:00
bunnie
75556b2321 add feature flags for vexii-test in rootkeys and shellchat 2025-07-21 19:02:21 +08:00
bunnie
a3d350b86f note aes performance on vex-ii; fix typo on aes256soft_test
aes256 soft test was running on hw before by accident.
2025-07-21 17:19:22 +08:00
bunnie
cb7f6d50b1 add vexii-test feature to pddb 2025-07-21 17:14:02 +08:00
bunnie
7dc09bbc73 updated AES library with Vex-II drivers
This will also be the version we'll use for the daric chip once
it's available; the prior software-only version hack for MPW will
be retired soon.

Note that only AES-256 is implemented in this commit, AES-128
isn't used on the system and so is provided as a software-only
fallback path.
2025-07-21 16:34:05 +08:00
bunnie
a858c09e53 add vexii-test feature to aes lib 2025-07-21 03:10:04 +08:00
Sam Chin
04bf756b8e theoretically clean version which has been tested with and without the feature 2025-06-11 15:05:59 +08:00