Commit graph

4007 commits

Author SHA1 Message Date
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
Sam Chin
0412a401d8 no more deadcode 2025-06-10 21:51:55 +08:00
Sam Chin
2659fc0894 wip'
'
2025-06-10 21:51:55 +08:00
Sam Chin
c9116cffd9 adding line back in 2025-06-10 16:00:16 +08:00
bunnie
59db16aa99
remove debug message 2025-06-09 18:49:28 +08:00
Sam Chin
a25f20d045 making console flags happy 2025-06-09 17:47:00 +08:00
Sam Chin
90d88820dd dropped a ; 2025-06-09 17:37:12 +08:00
Sam Chin
d1b5a41e82 fixing help text 2025-06-09 17:37:12 +08:00
Sam Chin
c291b6a11f now passing the linter 2025-06-09 17:37:12 +08:00
Sam Chin
e5cdeaf2ca adding some cute command line arguments 2025-06-09 17:37:12 +08:00
Sam Chin
1b8554b8f2 removing the BMP180 code 2025-06-09 17:37:12 +08:00
Sam Chin
916c93e276 now with SI units 2025-06-09 17:37:12 +08:00
Sam Chin
b35f9cad33 working read 2025-06-09 17:37:12 +08:00
Sam Chin
b0b29f7d78 reestablishing devenv 2025-06-09 17:37:12 +08:00
bunnie
0d0267f0ea scaffolding the i2cdetect command 2025-06-09 17:37:12 +08:00
Sam Chin
526d8353fd hello world exercise 2025-06-09 17:37:12 +08:00
bunnie
ea3b032fbe add build flags to bao-console
two flags are added:

with-pddb - puts the PDDB commands into the console
battery-readout - turns on the periodic battery readout
2025-06-09 17:20:46 +08:00
bunnie
d17f9881b2 modify user mode i2c lib calls to return nacks
Note that a NACK is returned as an Ok(I2cResult::Nack) - this is
because the Err() path is still reserved for "OS failure" errors.
A Nack isn't a terminal failure, it is a recoverable fault, and
so it's handled in the Ok() path.
2025-06-07 22:56:51 +08:00
bunnie
63c1d975b4 modify result interpretation to allow i2c nacks 2025-06-07 22:56:29 +08:00
bunnie
76a45ff47d add code to the server
this is the actual handler inside the Xous service which, when
receiving the opcode, dereferences its exclusive pointer to the
IRQ bank and then returns the result to the caller.
2025-06-07 02:48:58 +08:00
bunnie
f3e7eec6cf add 'lib' side code for sending the API call to cramium_hal_service
this is the code that exists on the caller's side. It creates
a message with the correct opcode and decodes the result.
2025-06-07 02:48:10 +08:00
bunnie
cfe9b3c845 modify base API for GlobalConfig to auto-infer the API address
the switch based on target is now absorbed into the new() function.
This paves the way for us to add more CSR ranges into the global
configuration object, i.e. IRQ csrs for I2C.
2025-06-07 01:52:25 +08:00
bunnie
6741cba3bd fix hosted mode config issue 2025-05-23 13:18:04 +08:00
bunnie
eb379e22ba figured out my "mystery problem"
I had a feature override in the shell script I was using to wrap
the build. :-/ oops
2025-05-23 13:04:31 +08:00
bunnie
dbdc157ccf cleanup unrelated warning that crept in due to Rust version change 2025-05-23 10:56:43 +08:00
bunnie
d12bdf1494 fix the case of trying to retrieve shell history when none exists
fortunately rust handles this with a panic because it has strict
bounds checking, so this cleans up that panic.
2025-05-23 10:55:38 +08:00
bunnie
73fba43d04 fix emulation mode for baochip target after bringing up metal 2025-05-22 23:48:28 +08:00
bunnie
942a64ea3b fix saturation bug in index computation code 2025-05-21 18:22:30 +08:00
bunnie
f6aa07c20f add domain separator for gen2 keys 2025-05-21 18:22:12 +08:00
bunnie
4526e04abc cleanup some debug output in xous-swapper 2025-05-21 18:21:41 +08:00
bunnie
938f808a8a revert debug flag 2025-05-21 18:05:57 +08:00
bunnie
3004c4ab7f work around a weird feature flag not behaving as we expect 2025-05-21 18:04:02 +08:00
bunnie
8c7edaf107 add a "fake" implementation for the keystore
allows us to test pddb crate before final hardware arrives
2025-05-21 18:03:08 +08:00
bunnie
183916b548 first attempt at layering in a real SPI HAL into PDDB for gen2 targets 2025-05-21 10:23:51 +08:00
bunnie
fe190ea4f1 cleanup warning 2025-05-21 10:23:37 +08:00
bunnie
b63371a56f turn off autotest for now 2025-05-21 10:23:15 +08:00
bunnie
dd5e19878c update flash test routine to remove write flag request 2025-05-21 10:22:27 +08:00
bunnie
1810825744 add block erase routine 2025-05-21 10:20:23 +08:00
bunnie
6c9edc26a3 cleanup some of the HAL dependencies in PDDB
still have some...mysterious...problems around feature
flags that aren't being invoked when i think they should be.

but let's commit this checkpoint because I suspect I may need to
roll back to here several times and I try to figure out the
root cause of the issues.
2025-05-20 14:39:47 +08:00
bunnie
821c6ce47c cleanup dependency tree going down to the cramium-hal layer
remove features that we don't need so as to make the tree as
simple as possible to descend

in particular if we're just pinging the HAL layer for some simple
constants we don't have to pull in the hairball of std targets
2025-05-20 14:38:03 +08:00
bunnie
5d288ec9a8 cleanup dependencies to allow for hosted builds 2025-05-18 09:25:33 +08:00
bunnie
4251686c1f make the flash test optional based on the configuration
allow the console to be built for hosted targets
2025-05-18 09:25:01 +08:00
bunnie
9b13f46741 cleanup notes in toml file so i don't forget to toggle a loader flag 2025-05-18 04:41:21 +08:00
bunnie
de06522499 cleanup debug statement 2025-05-18 04:40:38 +08:00
bunnie
1a34847b19 implement the writepage mechanism
1 - lock the CPU
2 - go into userspace to do the write
3 - on exit from userspace, mark the page as swapped in the original
process so that if it tries to read the data it fetches a new clean
copy
4 - free the page from the RPT so the data can be grabbed later
5 - unlock the CPU
2025-05-18 04:30:52 +08:00
bunnie
24a70b0eb5 implement writepage mechanism, deprecate sync/dirty
writepage uses a *direct* memory message (no rkyv) for efficiency
this saves us an extra page spent on the sideband data shuffling
by loading those args directly into the cpu registers that
get shuttled along with a memory message (the now increasingly
misnamed "advisory" fields of length/valid).
2025-05-18 04:29:06 +08:00
bunnie
4c69961448 rework the test program
this uses the new writepage mechanism, and also tests a couple
of cases. not hard edge cases, but enough that we're not just
testing the 0 case.
2025-05-18 04:28:15 +08:00
bunnie
0bf3366911 attempted cleanup on the sync api to improve the race condition
unfortunately this doesn't get us all the way there. There
is always a chance that the call that marks a page as dirty
is not coupled closely enough to the actual update of the page
data. Without actual hardware support for this we can't use this
approach.
2025-05-17 16:28:57 +08:00
bunnie
7cad369a82 test cases for flash writing on real hardware
reading works fine

writing is still a work in progress.
2025-05-17 16:28:24 +08:00
bunnie
5db2b3449e remove unused "spinor" implementation now that access is delegated to swapper
the explicity "spinor" interface is no longer needed (or even
compatible!) because we now have the swap-mapped spinor layer

the main concern I have at this point is there is a potential race
condition between marking a page as dirty and when the data is actually
updated on the page. Some locking might be necessary to fix this,
but possibly it might be sufficient just to mark a page as dirty
immediately before it's written?

another option might be to handle the writes in an interrupt context
so that the write data + dirty mark are atomic. Need to think about
this a bit.
2025-05-16 19:16:20 +08:00
bunnie
432c2a528e implement dealloc dirty and write to flash
These routines provide for two types of behaviors:

1. deallocating dirty pages. Here, pages are unmapped from RAM
after they are committed to FLASH.

2. write dirty pages to flash. Here, pages are kept mapped in RAM
for future use, but the dirty bit is cleared. This allows the
pages to be quickly released in case of memory pressure.
2025-05-16 19:07:07 +08:00
bunnie
5e2472fa7f add dummy routines so code compiles for precursor target 2025-05-16 19:06:40 +08:00
bunnie
c68d8b1a77 prelim take at a HAL for cramium targets for flash read/write 2025-05-16 19:06:17 +08:00
bunnie
22a72125bd add precursor-hal to dependencies for xous-swapper 2025-05-16 19:05:52 +08:00
bunnie
7533e09f70 move swap abi into lib section; add syscall wrappers for dirty/sync 2025-05-16 19:05:09 +08:00
bunnie
3f96f876c7 more renode tests for flash access 2025-05-16 19:04:30 +08:00
bunnie
e47ed41726 add some prelim test routines for flash access 2025-05-16 19:04:12 +08:00
bunnie
230c577af0 update progress 2025-05-15 11:58:44 +08:00
bunnie
e34dbb4e6f implement a demonstration of successful map decoding of the spi flash request
this just puts dummy data in, next set of commits will do "live"
ROM access.
2025-05-15 11:58:03 +08:00
bunnie
148679af42 more constants location cleanup 2025-05-15 11:56:51 +08:00
bunnie
409e381c2d fix some bit-rotted constants in xous-swapper debug 2025-05-15 11:56:28 +08:00
bunnie
b962bfe26d add some test code for spi flash mapping
this is just to facilitate renode-based testing
2025-05-15 11:55:25 +08:00
bunnie
e2379821e6 republish xous-rs to fix cargo test 2025-05-11 15:36:17 +08:00
bunnie
8a4959056b bump version for xous crate update - commit so we can publish crates 2025-05-11 14:45:24 +08:00
bunnie
ed345ba4d7 cleanup dependency hacks from debbuging pddb issue 2025-05-11 14:42:26 +08:00
bunnie
f76dd23067 fix weird PDDB dependency issue
more of a work-around than anything else. the observation is
the PDDB_A* series of constants aren't used outide of the crate
for gen2-targets and so we just remove it as a dependency in
the lib.rs side of things.

This clears up the cargo error we're getting. still don't know
why the dependency tree is not working for that particular target,
but someone is pulling a pddb dependency and it's not obvious who.
2025-05-11 14:40:19 +08:00
bunnie
fbcb59c69e migrations applied to pddb
still broken, there is a weird dependency problem on
board-baosec target that is still to be debugged, but
wanted to get everything committed so i can try bigger
experiments without losing state
2025-05-11 12:59:00 +08:00
bunnie
52ee66e1a5 migrate kernel-to-board platform constants for swapper 2025-05-11 12:46:01 +08:00
bunnie
805ebd22a3 revert a couple things that were not meant to be committed 2025-05-11 12:45:29 +08:00
bunnie
4ef4b22cfc incorporate hal migration into bao-console 2025-05-11 12:41:39 +08:00
bunnie
ca04a3ea82 incorporate arch migrations into early-settings 2025-05-11 12:37:51 +08:00
bunnie
ee6fb3ef4f arch migrations make PDDB_LEN harder to reach in modals
this constant was just used to create a "realistic" test case
instead of trying to add the dependency we just hard-code the
constant into the test case, because in the end what we wanted
was that specific constant to test a specific edge case of
a progress bar.
2025-05-11 12:36:46 +08:00
bunnie
42c6417e46 incorporate rach mirgations into net 2025-05-11 12:36:33 +08:00
bunnie
6de085657a incorporate arch migrations into dns 2025-05-11 12:36:20 +08:00
bunnie
a71873cb7a incorporate migrations into root-keys 2025-05-11 12:34:17 +08:00
bunnie
b6ab55c6b8 incorporate arch migration into shellchat 2025-05-11 12:33:50 +08:00
bunnie
8a74ed6078 incorporate arch migrations into spinor 2025-05-11 12:32:29 +08:00
bunnie
ee22ff783c incorporate arch migrations to status 2025-05-11 12:32:05 +08:00
bunnie
a0c1b1e75a incorporate arch migrations to usb-device-xous 2025-05-11 12:31:46 +08:00
bunnie
ae2d137e12 incorporate arch migrations to xous-susres 2025-05-11 12:29:55 +08:00
bunnie
58f20057b4 update strategy 2025-05-10 08:22:38 +08:00
bunnie
c7225d227d migrate pddb size to board:: and fix boot init
the policy is to format the PDDB automatically on boot if
it can't be mounted.

Need to think about whether this is the right thing to do
or not for the product: if there is any sort of error, it will
just wipe the PDDB entirely, making it unrecoverable.

That being said, why would there be an error? if that happens,
something bad probably happened to the hardware. I feel like
if the SPI interface is reliable this shouldn't be a problem.
So the solution is to make sure the hardware is reliable...
on the other hand, fundamentally, SPI flash can wear out, so
this could aggravate problems at EOL for the device (i.e.
it will take small problems and "amplify them up" into a huge
problem).

The trade-off is...the auto-format makes the token "just work"
on boot. Maybe the right thing to do is to add some code that
checks to see if we're in a true blank state, and if so,
autoformat; and if it looks like something was there before,
prompt for a format?

tbd.
2025-05-08 16:06:42 +08:00
bunnie
f92839602e feature flag fixes for moving sizes to board:: 2025-05-08 16:04:36 +08:00
bunnie
fe599c2fe0 migrate lengths to board:: for gen2; fix opcode numbering bug
opcode numbering bug only affects test mode, fortunately. just
bit-rot from tests long not run...
2025-05-08 16:03:48 +08:00
bunnie
2ea777e04f fix key encoding bug; set DNA to "0" in emulation mode
this matches what's done in hosted mode, allowing the analysis
scripts to work on the images generated by this version
2025-05-08 16:02:52 +08:00
bunnie
34a1a33165 fix off-by-one arg error on Dna routine
this is a common api problem because yes, while arg1 is strictly
the second item, previously arg0 was hidden and in the argument
list arg1 took the first place not the second. so i make this
mistake a lot...
2025-05-08 16:01:46 +08:00
bunnie
0cb80c2afb remove sizes from the emu lib, so it can live in board:: 2025-05-08 16:01:11 +08:00
bunnie
5417c2bd87 add more test features to the console; absorb board:: api for sizes 2025-05-08 16:00:28 +08:00
bunnie
399742a3d4 feature-out some battery testing code in hosted mode 2025-05-07 23:10:04 +08:00
bunnie
231aff1f80
Merge pull request #641 from betrusted-io/axp-batt
Battery settings to confirm/test prior to fusing out TG28
2025-05-06 19:14:43 +08:00
bunnie
a2d9699bee fix argument change in api 2025-05-06 19:06:23 +08:00
bunnie
c5d2689e12 add periodic updates from the charger 2025-05-06 19:06:04 +08:00
bunnie
1a3b9131d1 reduce debug out put as this makes it hard to see what's going on in CI 2025-05-06 12:54:34 +08:00
bunnie
ef97e33ae4 fix pddb in doc-deps target 2025-05-06 03:15:51 +08:00
bunnie
4640213410 fix hosted mode 2025-05-06 03:06:21 +08:00
bunnie
89d6b0e81f debug checkpoint
left off at trying to debug the PDDB mount process.
2025-05-06 02:07:31 +08:00
bunnie
15dd0a7f17 cleanup warnings 2025-05-06 02:07:16 +08:00
bunnie
feeaa6341c improve bao-console interaction and add pddb mount call 2025-05-06 02:06:41 +08:00
bunnie
8e161d7e9d we're at least booting now and talking to the pddb service 2025-05-06 01:51:29 +08:00
bunnie
a4e86eead5 cleanup some gen1/gen2 differences 2025-05-06 01:49:42 +08:00
bunnie
095939ee53 allow multiple listeners in gen2 targets
this simplifies a bunch of stuff when we can trust the internal
code base
2025-05-06 01:48:37 +08:00
bunnie
30fcc3016f use bao-video to route the acquire/release of the modals focus
it has to route through here anyways, so this is the sensible
place to also forward on the keyboard release/acquire messages
2025-05-06 01:47:55 +08:00
bunnie
8a2651e9cb add no-gam coordination of keyboard hits based on focus of keys
modals has to be able to acquire/release focus without the
assistance of the GAM in a no-gam model.
2025-05-06 01:46:56 +08:00
bunnie
8d896b4dba add pddb command to bao-console 2025-05-06 01:46:34 +08:00
bunnie
b2f32b7b6f add an emulated keystore for hosted mode
this is a dummy keystore so we can test other UX operations.
the full keystore will be a lot harder to write.
2025-05-06 01:45:53 +08:00
bunnie
1ee1239494 fix hosted mode lifetime issue 2025-05-05 01:52:43 +08:00
bunnie
34e9a1f1ce gen2 apis now compiling clean
system doesn't work yet because none of the keystore is there, but
at least we don't have conflicting/missing APIs
2025-05-05 01:49:39 +08:00
bunnie
86b079f2f4 add spinor defs to cramium-emu
this is a shim that reps both boards and "chips" for hosted mode
so it's OK to mash them together as a synthetic target
2025-05-05 01:49:05 +08:00
bunnie
e3cb5e495c remove spinor defs from the swapper
should be defined in the board, not in the swapper
2025-05-05 01:48:46 +08:00
bunnie
71f444ff3d API framework for the keystore 2025-05-05 01:48:28 +08:00
bunnie
87140a2024 cleanup the api a bit more
realized it was dumb to have separate file paths for the
orthogonal implementations
2025-05-04 19:12:51 +08:00
bunnie
c8db01c563 re-org rootkeys-api into common and generation-specific libraries 2025-05-04 19:05:58 +08:00
bunnie
9d6223d0b2 pddb migrations for keystore-api 2025-05-04 18:34:33 +08:00
bunnie
2c47db081d other crates affected by api migration 2025-05-04 18:34:17 +08:00
bunnie
7c6ecf308e migrate rootkeys api to keystore-api 2025-05-04 18:34:01 +08:00
bunnie
22433fa25c reconfigure toml files for pddb target testing
OK, i think this gets us to the starting point of shaving down
the PDDB crate from the restored baseline
2025-05-04 17:03:00 +08:00
bunnie
8e52d4ca5d minor cleanup on swapper crate
still a lot of warnings but the code is all stubs so that's normal
2025-05-04 17:02:15 +08:00
bunnie
48c6ce7232 cleanup non-spinor config for xous-swapper
this allows us to build configs that aren't in the dev path
without errors
2025-05-04 17:00:08 +08:00
bunnie
f9c42f6176 rollback pddb to previous known good state
restart the refactor process now that the modals arc is finished.
2025-05-04 16:40:13 +08:00
bunnie
142d55a2b7 this was meant to be committed with the previous commit 2025-05-04 16:34:12 +08:00
bunnie
ae23121d6a checkin work state before we rollback the pddb area
i have decided that the current approach sucks, and i'm going
to abort the work in the pddb area. however, the stuff in
the rest of the branch is pretty useful, so we'll just revert
the stuff inside the pddb directory.
2025-05-04 16:33:12 +08:00
bunnie
abbffaaf20 more restructuring of pddb codebase
in particular, spinor driver stub does not belong in this crate
2025-05-04 03:34:01 +08:00
bunnie
0b4ff70798 remove modal testing as it's not needed in this branch 2025-05-04 03:33:09 +08:00
bunnie
b2098916c7 start to add a spinor driver into xous-swapper
the hardware interface for SPIM is shared between both
RAM and FLASH, therefore, the drivers need to be co-located
in the same crate.
2025-05-04 03:31:15 +08:00
bunnie
c6123f1aec add a placeholder for keystore 2025-05-04 03:29:53 +08:00
bunnie
2699146d62 integrate gc2145 into userspace
couple of notes:

- bw threshold is now dynamic, based on the average of the previous frame
- performance is a bit slower than ideal, because of the SPI back pressure
bug preventing us from reading out the video at full speed. This should
be better on NTO.
- rotation introduced so that the preview image should align up
with what we'll have in the final camera v. display orientation in
the baosec product
- tested against the TOTP test suite (edent.codeberg.page/TOTP_Test_Suite/)
and it can quickly capture all of the basic valid tests.
2025-05-01 16:41:03 +08:00
bunnie
535153e0cb switch cameras and move YUV setting into driver 2025-05-01 04:09:52 +08:00
bunnie
19e9bcb104 add emulation stub for gc2145 2025-05-01 04:08:06 +08:00
bunnie
e7a2c97ca3 some progress on compatibility 2025-04-29 22:32:59 +08:00
bunnie
86fb450ab4 improve compatibility of signatures 2025-04-29 22:28:20 +08:00
bunnie
2cca6ac13f
Merge branch 'main' into pddb-feat-down 2025-04-29 03:27:33 +08:00
bunnie
ed797e6a82 scrolling tests 2025-04-29 03:03:54 +08:00
bunnie
735a93756f add modes and flags for testing 2025-04-29 03:03:36 +08:00
bunnie
94969feb3c modify the entry validator test to work the numeric OSK selection 2025-04-29 03:03:13 +08:00
bunnie
0d2ecc1db3 add missing modals release calls 2025-04-28 19:03:06 +08:00
bunnie
74b427e1c4 shorten description string
this allows the test to run more nicely on small screen devices
2025-04-28 18:56:33 +08:00
bunnie
5021afcbda quiet down debug 2025-04-28 01:18:43 +08:00
bunnie
f204fd4c54 add breadcrumb note 2025-04-21 00:38:38 +08:00
bunnie
d1860fee56
Merge branch 'main' into pddb-feat-down 2025-03-05 20:57:35 +08:00
bunnie
5a36ebbb58 setup modals testing feature in the console runner 2025-03-05 20:50:09 +08:00
bunnie
77d18530f7 match dependencies on modals tests to platform 2025-03-05 20:47:51 +08:00
bunnie
7f860e058c add handler for object list drawing 2025-03-04 19:07:10 +08:00
bunnie
1a2d6bf772 intercept and warn on more v2 calls in v1 implementation 2025-03-04 19:02:15 +08:00
bunnie
938e8388e0 add modals acquire/release logic to the graphics layer 2025-03-04 02:05:21 +08:00
bunnie
0790a2dc16 more feature wrangling 2025-03-04 02:04:50 +08:00
bunnie
aafec72e64 add keyboard listener to modals in cramium targets 2025-03-04 02:04:22 +08:00
bunnie
a013720b6f more dependency fixup 2025-03-04 01:29:13 +08:00
bunnie
3be69cf8d1 cleanup dependencies and inter-dependent features 2025-03-04 01:28:38 +08:00
bunnie
4c16d42d45 fixup features 2025-03-04 01:27:37 +08:00
bunnie
56890c35c9
Merge branch 'main' into pddb-feat-down 2025-03-03 02:17:36 +08:00
bunnie
9297879f76 select trng based on emulation mode 2025-03-03 02:15:46 +08:00
bunnie
d1ec6e021a add feature adapters for bao-console so it can work in hosted mode 2025-03-03 02:15:16 +08:00
bunnie
531f5ee4f9 add modals testing mode 2025-03-03 02:14:58 +08:00
bunnie
3dec223d9d allow modals testing in more modes 2025-03-03 02:14:43 +08:00
bunnie
85a216ff0f add a warning if v2 api is sent into graphics-server which is v1 only 2025-03-03 02:14:05 +08:00
bunnie
558b96cfd5 add missing api for emulation 2025-03-03 02:13:52 +08:00
bunnie
af043c3a18 make usb-cramium suitable as a dependency for hosted emulation 2025-03-03 02:09:30 +08:00
bunnie
286bfb8135 fix hosted mode build 2025-02-28 17:52:20 +08:00
bunnie
26a147d1b8
Merge branch 'main' into pddb-feat-down 2025-02-28 17:45:06 +08:00
bunnie
e84daa0179 fixup more emulation issues 2025-02-28 17:42:30 +08:00
bunnie
cb0cfb3f2c cleanup dependencies 2025-02-28 17:31:14 +08:00
bunnie
5dcf0e33aa customize graphics testing routine for small screen 2025-02-28 17:30:51 +08:00
bunnie
db4d21c54c fix emulation bugs 2025-02-28 17:29:43 +08:00
bunnie
e829b4b4fb cleanup debug info in main 2025-02-28 16:37:28 +08:00
bunnie
bda9340045 cleanup pass-by ref change it blitstr api 2025-02-28 16:36:51 +08:00
bunnie
4710b416be cleanup trait implementation to match modifications
remove mutability from get_pixel
2025-02-28 16:36:24 +08:00
bunnie
ebd9b6e823 cleanup emulation layer to match hardware exactly 2025-02-28 16:36:06 +08:00
bunnie
002bc74d3f fix text rotation 2025-02-27 21:38:03 +08:00
bunnie
3e11c37400 fix missing path expansion in precursor target 2025-02-26 14:59:23 +08:00
bunnie
3ed1b2d707
Merge branch 'main' into pddb-feat-down 2025-02-26 14:58:05 +08:00
bunnie
4f067dc090 add gfx-testing option to bao-video 2025-02-26 14:46:47 +08:00
bunnie
cd34d0179e harmonize the apis in bao-video 2025-02-26 14:46:01 +08:00
bunnie
f3ff84cd05 fix off by one in bounds check for display size 2025-02-26 14:45:31 +08:00
bunnie
d0793b0aef fix dependencies on testing routine 2025-02-26 14:36:26 +08:00
bunnie
111d8f8d3d refactor graphics server to use reply_and_receive_next()
This new api allows for scalar-5 returns as well as more
efficient use of the scheduler's quantum by not simply yielding
time when a message is returned; it will fetch the next message
and process it until its time is up.
2025-02-26 14:35:33 +08:00
bunnie
f2d59e1ec6 fixup emulation to read the raw bitmaps identically to hardware 2025-02-24 02:41:57 +08:00
bunnie
a66a541488 pass the cramium-soc flag to blitstr2 when compiling for hardware 2025-02-24 02:30:07 +08:00
bunnie
275ae9b96c fix warnings 2025-02-24 00:59:20 +08:00
bunnie
8baaf201e6 fix back buffer swapping 2025-02-24 00:58:57 +08:00
bunnie
f922274070 fix configuration 2025-02-24 00:58:38 +08:00
bunnie
0eef3cd0e4 cleanup warnings 2025-02-23 18:20:29 +08:00
bunnie
1e007035cb modify bao-video to use shared handlers 2025-02-23 18:08:50 +08:00
bunnie
e0462f1603 modify graphics-server to use shared handlers 2025-02-23 18:07:16 +08:00
bunnie
172333c078 accommodate panic handler 2025-02-23 16:52:49 +08:00
bunnie
ef6ce40117 implement panic handler - first draft, untested 2025-02-23 16:52:32 +08:00
bunnie
8bd01bd65d
Merge branch 'main' into pddb-feat-down 2025-02-23 12:15:49 +08:00
bunnie
8c9abf6c5b add implemnetation for most graphics primitives
this is mostly a copy of what's in graphics-server. Perhaps
we can find a way to share the code between the two, but I
am going to leave it duplicated for now because it's unclear
if I can use this implementation as-is, or if it needs lots
of modifications.

If it turns out to basically work without mods, then, we can
wrap a bunch of the opcode dispatch into mega-function perhaps
that takes a display and opcode as parameters and wraps a lot
of the boilerplate into a re-usable routine.
2025-02-23 12:05:00 +08:00
bunnie
460b1543f0 add missing drawing primitives to hosted mode abstraction 2025-02-23 12:03:55 +08:00
bunnie
ef79ececb7 modify graphics-server to ignore unimplemented opcodes
the opcode list is shared between multiple implementations, so
an invalid opcode might not necessarily be a severe bug.
2025-02-23 12:03:09 +08:00
bunnie
e157d6e242 add placeholder panic server 2025-02-23 12:01:01 +08:00
bunnie
fabb3174c7 specify the doc-deps feature in ux-api so that cargo doc builds correctly 2025-02-22 01:07:31 +08:00
bunnie
9d76eda111 modify graphics-server to use the framebuffer trait 2025-02-21 23:43:26 +08:00
bunnie
10b7246bcc modify graphics-server backends to use the framebuffer traits 2025-02-21 23:43:05 +08:00
bunnie
d3278fccf4 add missing trait implementations
these aren't currently used, and probably won't be used in
the future? so just some stand-in code is used that isn't
too carefully thought-out.
2025-02-21 23:42:17 +08:00
bunnie
7c4a97da97 formatting fixes 2025-02-21 18:02:20 +08:00
bunnie
629d5c632d cleanup redundant files
this code has now all been migrated to ux-api
2025-02-21 17:58:29 +08:00
bunnie
69c2b84e42 bao-video: fix dependencies and minor API tweaks due to ux-api refactor 2025-02-21 17:52:41 +08:00
bunnie
2172046424 cleanup api changes related to opcode call renaming 2025-02-21 17:51:25 +08:00
bunnie
21a2592398 conten-plugin-api: use platform-neutral ux-api instead of graphics-server 2025-02-21 17:49:37 +08:00
bunnie
0f935a9a75 cram-console: use platform-neutral ux-api instead of graphics-server 2025-02-21 17:49:29 +08:00
bunnie
c8d00e890b ime-frontend: use platform-neutral ux-api instead of graphics-server 2025-02-21 17:49:13 +08:00