Commit graph

186 commits

Author SHA1 Message Date
bunnie
87fb3d16fb note some decisions made in the implementation of data slots
this will hopefully help prevent future disasters
2026-06-08 23:51:41 +08:00
bunnie
542bec7541 make I2C writes retry instead of unwrap-failing 2026-05-29 00:06:55 +08:00
bunnie
318f4b30e5
Update clocks.rs
cleanup some naming
2026-05-12 21:54:29 +08:00
hanatonikkou
ead2e9dda0 Merge branch 'dev' into dali 2026-05-11 15:26:11 +02:00
bunnie
6fba742cad debug for QE mode entry/exit 2026-05-08 22:21:14 +08:00
bunnie
d30ef2f197 debug/fix frequency changes into and out of WFI
I am now confident that the FCLK frequency is correct
going into WFI.
2026-05-08 03:12:47 +08:00
bunnie
a0609ebc88 add puya device support 2026-05-06 23:35:18 +08:00
bunnie
7ca009d2b0 Revert "remove api call for reset_reason"
This reverts commit 1dd514f4be.

not sure why but this breaks stability. suspect a loader bug.
2026-05-06 03:28:52 +08:00
bunnie
1dd514f4be remove api call for reset_reason
the register doesn't seem to work.
2026-05-06 02:36:56 +08:00
bunnie
8c8ad3ab94 api level changes to allow wdt to move earlier in boot
right now the inability to move the WDT object through the
hardware manager is causing it to be initialized fairly late
in boot which makes it less useful for recovering from boot
failures
2026-05-05 23:58:17 +08:00
bunnie
47821910dd lib-side changes for i2c migration 2026-05-05 23:58:02 +08:00
bunnie
ab9a724647 cleanup debug and add reset reason ll api call 2026-05-05 23:56:36 +08:00
hanatonikkou
d69a03393b fix formatting, fix bitfield offsets 2026-04-28 20:01:34 +02:00
hanatonikkou
d26b04f043 allow changing fclk through susres server 2026-04-28 15:16:33 +02:00
bunnie
4d1dc33ef1 add a diffusive transition option to the graphics library
makes changing between bitmaps less jarring
2026-04-23 15:14:27 +08:00
bunnie
4a236cfd68 add explicit power-off command to display 2026-04-22 01:21:47 +08:00
bunnie
d94041bfeb add wdt driver
translated from C SDK with help of Claude Sonnet 4.6
2026-04-22 01:21:08 +08:00
bunnie
8521d698d7 add hooks for pre-clock transition on bio
this hook allows the application logic to warn the BIO
app that a clock transition is coming so that glitches can be
suppressed.
2026-04-21 16:27:10 +08:00
bunnie
b10b7e6309 add serdes for VbusIrq to usize 2026-04-21 01:20:42 +08:00
hanatonikkou
19df2d3cf8 read clock muxes when calculating clock frequencies 2026-04-07 17:43:33 +02:00
bunnie
1ce29e80fa add ability to flip rendering of sh1107 screen
this allows a device to be flipped upside-down and have
the screen track orientation
2026-04-07 00:36:39 +08:00
bunnie
30ca5dec71 adjust disk space usage for lite platform 2026-04-05 23:23:11 +08:00
bunnie
44a53e590a move error definition to api crate, fixes hosted ci 2026-04-04 00:08:39 +08:00
bunnie
9452422751 add some apis for owc frobbing 2026-04-03 23:43:46 +08:00
bunnie
979d00dedf attempt to debug the wfi/bio clock conundrum
the commited code works, but there's something weird going on
with the clock setting math that indicates i'm not understanding
exactly what's going on. Need to move on and solve other problems,
but this will be an outstanding issue.
2026-04-03 23:00:35 +08:00
bunnie
19b83a8650 fix offset in camera driver 2026-04-03 01:52:57 +08:00
bunnie
220124a483 fix left/right mapping swap 2026-04-02 03:49:08 +08:00
bunnie
db4d70e5ff add some more telemetry on errors 2026-03-31 00:55:08 +08:00
bunnie
3993a0dc88 'fix' for timeout issue on SPIM during display writes
occassionally the hardware block just goes unresponsive. the
'fix' is to reset it, and then re-initialize the interface.

I suspect this has to do with the UDMA silently dropping transactions
when there's too much contention on the bus.
2026-03-30 23:34:25 +08:00
bunnie
b7826c2ebc flesh out backup register interfaces
- adds API for retrieving & setting the ephemeral key. This is
a key that is erased by a power-on reset, but is preserved between
deep-sleep sleep/wake cycles. It is intended for securing a lock
PIN, and can be up to 192 bits long.

- adds API for checking the warm boot flags, which are also stored
in the backup registers.
2026-03-29 18:04:09 +08:00
bunnie
73021cb2ed add brightness setting function 2026-03-23 18:33:43 +08:00
bunnie
4f37317427 add bitmap rendering API for baosec targets 2026-03-23 14:52:00 +08:00
bunnie
2145145595 fix event setting API 2026-03-21 01:46:08 +08:00
bunnie
90c3f095ec add support for more keyboard input configs on baosec 2026-02-26 18:29:47 +08:00
bunnie
4a542346c8 cleanup names and fixup the init delays 2026-02-24 01:34:54 +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
60d0126f37 implementation of code-length & padding for BIO code segments 2026-02-20 20:58:40 +08:00
bunnie
b991a54b52 add debug call for bio 2026-02-20 02:09:09 +08:00
bunnie
4aeabd01ae
clocks has to work in std and no_std
thus the die routine doesn't work in the bollard for
the clocks routine
2026-02-15 03:43:47 +08:00
bunnie
4d86e8a82b
use die_no_std in hardening; remove excess prints
also fix some math regarding birthday paradoxes and the
random number checking.
2026-02-15 03:27:20 +08:00
bunnie
70f219ba0a
sigcheck hardening
- xor-masking of jump target moved to immediately before the jump
- mscratch csr zeroed
- anti-rollback single-update distance limited to 512: let's hope we
never even get close to having 512 security revisions in a single
generation!
- sanity check untrusted signature/add length fields - constrains
hash-checks to within the right "range", preventing abuse of the
hash reads as an oracle to leak state about other things in memory.
- check valid_key != valid_key2 invariant before returning
2026-02-15 03:22:47 +08:00
bunnie
e8380aa0e7 clarify panic intent 2026-02-15 03:20:21 +08:00
bunnie
4a776852a9
add UDC pointer check macros throughout the USB driver library 2026-02-14 19:34:49 +08:00
bunnie
272b983760
add clock skipping APIs
also fix a bug where the enable bits for reporting SRAM
parity errors was not set.
2026-02-10 22:55:21 +08:00
bunnie
c1ae6b2e5f add more dependencies to propagate key-testing flag 2026-02-04 15:57:59 +08:00
bunnie
a840beb98e
loosen check on key tag
The original check on public key tag was "if the tag doesn't match
one of four approved tags erase secrets".

With third party images, third parties can pick their own tags - so
as-writ this would constrain third parties to have to use the same tags
as baochip, which is too restrictive.

Change the check to explicitly trigger erasure if and only if
the tag is "dev ". Note there are plenty of other checks around as
well so this is not the sole check, thus I think loosening this
permission is good for keeping hygiene between third party firmwwares
and baochips own firmwares.
2026-02-03 18:33:33 +08:00
bunnie
f96c01634f
streamline acram/slot manager access
Reviewing the code, I was decomposing multi-element slots
into individual slots, but erasing them as a multi-element slot.
This results in unnecessary churn.

The barrier to doing a simple check on the full slot all at
once was a missing API for unchecked reads of the full slot:
during checking, we want to be able to retrieve the contents
even if technically the ACL access is denied (note that the
ACL is enforced in *hardware*, the software based check of
the ACL is just a "belt and suspenders" check).

So, this patch adds a routine that allows for an `unsafe`
retrieval of the slot data regardless of the ACL, where the
safety condition is that the caller has to be aware that
junk data could be passed to it if the ACL isn't correct.
2026-02-03 18:12:18 +08:00
bunnie
e349703fd5 automatically adjust BIO clock dividers on sleep
this allows the BIO to continue to function even though
the CPU core is in WFI. It isn't running at full speed, but
for some applications (such as WS2812 LED driving) the lower
speed is perfectly adequate and you save a lot of power
by turning off the CPU core.
2026-02-02 23:37:48 +08:00