Commit graph

10120 commits

Author SHA1 Message Date
bunnie
c38214865f add a routine to initialize the ioconfig from the resource spec
in particular this makes sure the io config masks are extracted.
2026-02-28 23:20:04 +08:00
bunnie
f0b0c038f2 chore: fix out of date comment 2026-02-28 23:19:53 +08:00
bunnie
9841e0a199
Merge pull request #827 from betrusted-io/tweaks
add support for more keyboard input configs on baosec
2026-02-27 01:37:22 +08:00
bunnie
90c3f095ec add support for more keyboard input configs on baosec 2026-02-26 18:29:47 +08:00
bunnie
3e3879ba4d
Merge pull request #826 from betrusted-io/adc
ADC
2026-02-24 02:29:05 +08:00
bunnie
e47e65b708 add test routines for ADC 2026-02-24 01:35:16 +08:00
bunnie
4a542346c8 cleanup names and fixup the init delays 2026-02-24 01:34:54 +08:00
bunnie
e704477f79 api changes for ADC service 2026-02-24 01:34:32 +08:00
bunnie
663139b607 split ADC into its own service thread
this allows the ADC to depend on core HAL services. It's structured
so that other 'misc' services would go into the "other" module,
just to keep the overhead of threads/services down a bit. Up until
this point all the other services mapped to existing/other
server names, like the RTC, susres, etc.
2026-02-24 01:33:25 +08:00
bunnie
18e72a970c add draft ADC support to hal service 2026-02-23 18:53:37 +08:00
bunnie
302b7b65bf add std opcodes for ADC operations 2026-02-23 18:53:19 +08:00
bunnie
35168f8085 add getters/setters for adc channel specifications 2026-02-23 18:52:55 +08:00
bunnie
ac1e451aa1 add routines for setting/updating i2c clocks
in anticipation for frequency scaling support
2026-02-23 18:52:23 +08:00
bunnie
bd2a69327b add working draft of ADC driver
this is based on a reference driver in C but translated
largely by Claude and then checked & signed off by me.
2026-02-23 18:15:38 +08:00
bunnie
5a8d5a8de5 fix allocation bug for ifram 2026-02-23 18:15:14 +08:00
bunnie
a8012a6e01
Merge pull request #825 from betrusted-io/vault2-ui
Vault2 UI
2026-02-23 14:41:27 +08:00
bunnie
6730a01799 cleanup FIDO2 UI
messages now fit on the screen and are clearer for the small
format
2026-02-23 03:13:56 +08:00
bunnie
992cbb4388 move buttons and menus around for toggling modes
a little easier to use with a hot key for switching ui modes
2026-02-22 22:29:33 +08:00
bunnie
73c0946325
Merge pull request #824 from betrusted-io/bio-c
C compiler for BIO
2026-02-22 14:34:09 +08:00
bunnie
af6260fb43 add a check for div instructions without "softdiv.h"
This will hopefully save some troubles for developers who
accidentally invoke a divide without realizing it.

Prints an error with instructions on how to resolve the
situation.
2026-02-22 03:42:51 +08:00
bunnie
7e37aa50c8 clang2rustasm.py: improve handling of more cases in clang code
- handle .rodata, .data, .bss, .set labels better. This allows
for static globals
- handle call instructions. These are manually resolved by
changing the call pseudo-instruction into a jal with a rust
assembly-compliant label.
2026-02-22 03:34:42 +08:00
bunnie
db6aa1255a rename fixed point converters
Q20.12 and Q16.16 come as .h files in the BIO C library,
so converters in Rust to shove data to and from the BIO in
those formats are provided.
2026-02-22 03:33:23 +08:00
bunnie
75ce3f886d constrain the C compiler codegen
1. we can't resolve jump tables in Rust assembly. The label
grammar isn't rich enough to do this. As a result, this code
genreation method is suppressed.

2.there is no 'div' instruction on this PicoRV, so the +m is
converted to +zmmul, which correctly emits mulitplies, but
skips the divide.

A soft divide library is provided for programs that require
division.
2026-02-22 03:23:57 +08:00
bunnie
174b97a3a7 add the colorwheel feature 2026-02-22 03:23:41 +08:00
bunnie
3e2daa8746 add "wheel" test
color wheel test, where the colors are generated directly in
the BIO.
2026-02-22 03:23:05 +08:00
bunnie
02d90fe056 add a more complicated demo program
This C routine incorporates statics, arrays, globals,
switch/case, division, and a bunch of other stuff that
is designed to exercise corner cases in the assembly conversion
script.

The program itself just cycles LEDs in a rainbow vomit pattern.
2026-02-22 03:20:57 +08:00
bunnie
8ee6d86748 cleanup math test Fp refernce 2026-02-22 03:20:11 +08:00
bunnie
c80877d064 add various C libraries for BIO use.
Note that there is no LTO/trimming in the BIO flow, so
wantonly including libraries you don't use just grows
your code size for no use.
2026-02-22 03:19:04 +08:00
bunnie
19d8294369 add math test routine to dabao-console 2026-02-20 23:54:49 +08:00
bunnie
8f709216d6 add autogeneration header to math_test.rs 2026-02-20 23:54:34 +08:00
bunnie
40a275232c udpate tomls to explicitly enumerate features used 2026-02-20 23:54:07 +08:00
bunnie
905939d8f1 featurify all BIO modules
the reason we do this is that if we don't switch off library
modules, they are compiled in and just become dead code in the
OS image. with enough modules, this will eventually become
a significant drag on binary size.
2026-02-20 23:53:09 +08:00
bunnie
85a9579626 update readme with toolflow and erratum 2026-02-20 23:52:42 +08:00
bunnie
9e34da0bf7 add autogeneration header to output artifacts 2026-02-20 23:52:16 +08:00
bunnie
6176d3379d streamline zig build flow 2026-02-20 23:51:58 +08:00
bunnie
aa06be9c82 commit an initial c test program
this is a "math test" that can compute cosines in fixed point
using the BIO.
2026-02-20 21:02:54 +08:00
bunnie
cdf489d2b1 fix std-implementation for code size/offset/padding specification 2026-02-20 21:02:19 +08:00
bunnie
6cc9e2d5f7 fix constant table in cosine 2026-02-20 21:01:55 +08:00
bunnie
9d23703e45 fix API for new code specification method 2026-02-20 21:01:23 +08:00
bunnie
c1571479d6 remove out of place comment 2026-02-20 21:01:00 +08:00
bunnie
60d0126f37 implementation of code-length & padding for BIO code segments 2026-02-20 20:58:40 +08:00
bunnie
29437c1ae8 Add an aligned bio_code macro
This macro introduces page-level padding around the BIO code
regions, so that the rust assembler/linker computes relative
offsets correctly. This is necessary for code that is
autogenerated from C that uses `statics`

It's not recommended to be used *everywhere* because even
tiny BIO snippets of a few bytes would be blow up to 4k each.
2026-02-20 20:57:10 +08:00
bunnie
a97675592c Add erratum notes to README and a tool to check & repair erratum
erratum_check.py will automatically scan bio_code! segments
in a .rs file, flag patterns that could be a problem, and
can automatically patch these, if requested.
2026-02-20 20:55:34 +08:00
bunnie
a6a8341223 Fix BIO erratum in assembly translator.
Getting compiled code going has revealed a couple of frankly
embarassing erratum in the BIO. Kind of shameful to make such
a n00b mistake but I guess my sole defense is I had to put it
together in a hurry with little resources.

Here's the bugs:

BUG 1 ("phantom rs1"): For lui/auipc/jal, the 5-bit field at
instruction bits [19:15] is not gated off. If that field decodes
to register 16-19 (x16-x19) for just these instruction types,
a spurious pending read is made from the corresponding FIFO,
which affects correctnes and can block execution.

BUG 2 ("phantom rs2"): For non-R/S/B-type instructions, the 5-bit
field at instruction bits [24:20] should be gated off but isn't.
When that field equals 20 (0b10100), a spurious `quantum` signal
triggers, which can affect the instruction fetch pipeline

This script inspects the output of the Clang assembly, and in the
process of translating it to Rust assembly, transparently patches
almost all of the cases with work-arounds. The assumptions and
exceptions for the work-arounds are:

- The stack pointer is initialized and valid. This is always
true for Clang-derived scripts because it's in the _start()
routine

- No interrupts that can mutate stack: true because interrupts aren't
supported in this implementation.

There is one edge case that isn't covered: J-type instructions
aren't patchable at this stage because the label offsets haven't
been resolved into instructions. However, "naked" jal instructions
are rare in compiled code - it's always jalr, which is an I-type
instruction. This is noted as a warning when the script runs, and
is fixable by simply inserting a "nop" after the jal instruction
if the target is at the wrong address - this will shift the immediate
so that it no longer contains the 0x14 (decimal 20) pattern in
the immediate field.
2026-02-20 18:40:37 +08:00
bunnie
db78b28b37 checkpoint the c -> rust asm flow for the BIO
An abomination: a zig-based C toolchain, installed via python,
compiles to clang assembly, translated by python script, into
Rust assembly. Then compiled and linked into your app.

Really tempting fate with this one...will I come back to this
commit in a couple years and be filled with regret?

Already, I have some misgivings - the zig toolchain is
definitely not stable, and has been through some API changes,
and doesn't run on all platforms. But - I forge ahead.
2026-02-20 02:19:46 +08:00
bunnie
b932d7d755 fix a the mul demo
we don't have to do the weird mul coding anymore because
we added ".option arch, +m" to bio_code! macro
2026-02-20 02:11:09 +08:00
bunnie
b991a54b52 add debug call for bio 2026-02-20 02:09:09 +08:00
bunnie
a56ed768e8
Merge pull request #823 from betrusted-io/sram-tests
add tests to check sram glitch event triggers in baremetal
2026-02-18 21:27:55 +08:00
bunnie
2e0c7c2722 fix CI to run on dev branch as well as main 2026-02-18 21:22:47 +08:00
bunnie
7d6272fc8a fix formatting regression 2026-02-18 21:20:41 +08:00