Commit 9e462fc
committed
Fix raw PPG startup, FIFO recovery, and hub firmware flashing
Bring-up on 40.2.2 and 40.6.0 boards surfaced several driver bugs and made
the firmware flasher usable.
Application driver:
- startRaw() sent a 5-byte LED-current frame (0x40 0x03 <reg> <val> 0x00);
the hub expects exactly 4 bytes (UG6921 Table 6 1.8/1.9) and rejects the
padded form.
- startRaw() treated "enable BPT in estimation mode" as fatal. That command
is rejected on 40.2.2+ until a calibration vector, date/time and SpO2
coefficients are loaded, so a freshly booted board could never stream raw
PPG. The algorithm contributes nothing in sensor-only output mode, so the
step is now best-effort. Command order now follows UG6921 Table 6.
- enterAppMode() unconditionally wrote 0x01 0x00 0x00 and waited 20 ms. That
restarts the hub application, leaving later commands to land mid-init.
UG6921's flows only ever read the mode, so it now reads first and switches
only when needed, with a full settling delay.
- enableAfe(true) retries a 0xFF up to 3 times at 250 ms spacing and, on
final failure, traces the AFE PART_ID read that UG6921 Table 1 prescribes.
- readRaw()/readSamples() flush the FIFO when a sample read fails and report
the partial count. An overflowed output FIFO rejects every 0x12 0x01 read
until emptied, which previously wedged streaming permanently.
- Report the algorithm version as unavailable when the hub does not answer
0xFF/0x07 (status 0x02) instead of a fabricated 0.0.0.
- Added readAfePartId(), flushFifo(), algoVersionValid().
Firmware flashing:
- writePage() split the 8208-byte payload across 30-byte I2C frames; the
bootloader scores a page as one command and answered 0x02 (incorrect byte
count). It now sends the whole page in a single transaction, with the two
chunked strategies kept selectable for A/B testing.
- Page size comes from the image header (uint16 LE at 0x46 plus 16 CRC bytes)
rather than a hard-coded 8208. The bootloader's own 0x81 0x01 answer is not
a byte count: BL 8.0.0 reports 2048 words for the same 8192-byte page.
- configureForPageSize() grows the Wire buffer where the core allows it and
returns PageTooLarge otherwise, before the erase step, so an unsuitable
host leaves the hub's firmware intact. The UNO R4 cannot flash the hub --
its Renesas Wire caps a transaction at 255 bytes; use an ESP32 or RP2040.
- Driver traces are recorded even with no debug stream and served over a new
'D' command, so the host script can explain a failure.
- New flash-firmware.sh drives both stages, and extras/flash_tool/README.md
documents the tool, the host-board constraint and troubleshooting.
10.DeviceInfoAndDiagnostics now enables tracing, prints the AFE PART_ID,
sweeps sensor indices when it does not answer, and drains the FIFO fully.
All 11 examples compile for Uno R4 Minima; the flasher also builds for
ESP32, RP2040 and the AVR stub. The bootloader page write remains unverified
on hardware.1 parent 97a99ef commit 9e462fc
12 files changed
Lines changed: 1675 additions & 89 deletions
File tree
- examples
- 10.DeviceInfoAndDiagnostics
- 11.FirmwareFlash
- extras/flash_tool
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
5 | 113 | | |
6 | 114 | | |
7 | 115 | | |
| |||
0 commit comments