E26 — RP CDC1 baud fix, SD first write, SD high speed
| ID | E26 |
| Date | 2026-12-03 |
| Status | done |
| Decisions | D104 (DECISIONS.md) |
| Board | #1 (rev A, Y2 = 12 MHz); RP on the PC (direct port), CH32 USBFS J2 (“USB2”) on the hub |
| Firmware + results | fw/tests/2026-12-03-3-cdc1-sdwrite (RP uf2, main CH32 bin, 2 SD write-order bins, results.txt) |
| Scripts | sdwfirst.py |
Summary: The RP fix that keeps the host’s CDC1 baud across a CH32 power-on works. It also broke the selftest whenever the
last program had opened CDC1 at another baud (the CH32 always boots at 115200), so the selftest now talks at 115200 and gives
the host baud back: 11/11 PASS with the host at 921600. The first SD write after init is clean in both register orders
(0 of 192 per order), unlike the first read before D101: sd_write keeps its order. CMD6 high speed (48 MHz) gives
+49 % reads and +52 % writes in 64-block chunks, 0 errors.
What
- E26a — RP CDC1 fix (chlink.c, built in ebffd43, flashed now): selftest, then with CDC1 last opened at 921600:
selftest,
ch ping, and the CH32 boot banner afterpwr cycleread at 921600 and at 115200. - E26b — SD first write: new CH32 command
sdwfirst <lba> <rounds> <nblk>(hex): save the blocks,sd_initwithout the throw-away read, pattern write as the first transfer, read back, compare, restore and verify. The firmware refuses any LBA outside 0x400–0x7ff (the card’s FAT32 starts at 0x800).RP417_SD_WORDER=0(ours, DMA_BEG1 before BLOCK_CFG) vs=1(WCH EVTSD_WriteBlock: BLOCK_CFG = 0, TRAN_MODE, BLOCK_CFG with the count, DMA address last); 1, 8 and 64 blocks at LBA 0x400 and 0x5a0, 32 rounds each, then sdcheck, sdwtest and a verified sdstream. - E26c — SD high speed: default build, the same benches at 24 MHz (default speed) and after
sdhs(CMD6, 48 MHz).
Results
| E26a | result |
|---|---|
| first selftest after flashing the fix | UART ping FAIL: some earlier open had left CDC1 at a baud ≠ 115200 |
| selftest, host CDC1 at 921600, after the selftest change | 11/11 PASS, “selftest uses 115200, restored after” |
ch ping after it (host still 921600) |
timeout, as it should be: the bridge runs at the host’s baud again |
boot banner after pwr cycle, CDC1 at 921600 / 115200 |
garbled / # rp417-ch32 0.1 boot: the host baud survives the CH32 power-on |
| E26b (32 rounds × 1, 8, 64 blocks × 2 LBAs) | first writes wrong | restored | sdcheck / sdwtest / sdstream |
|---|---|---|---|
| WORDER 0 (ours) | 0 of 192 | all | 0 / 0 / 0 errors, 2723 KB/s |
| WORDER 1 (WCH) | 0 of 192 | all | 0 / 0 / 0 errors, 2723 KB/s |
| E26c | 24 MHz | 48 MHz (CMD6) |
|---|---|---|
| read, 64-block chunks | 7854 KiB/s | 11677 KiB/s |
| read, 1-block chunks | 1650 KiB/s | 1673 KiB/s |
| write (sdwtest), 64-block chunks | 8395 KiB/s | 12743 KiB/s |
| sdstream (write + verify, 1 MB) | 2723 KB/s | 3057 KB/s |
| errors | 0 | 0 |
Single-block reads barely change: per-command overhead dominates. Not tested: E2 (USB2 high speed on J1); the cable was on J2.
Lesson
A “keep the host’s setting” fix changes what every other user of the same line sees: the RP’s own selftest and ch
commands share CDC1’s UART, and Linux sets a baud on every open. Code that power-cycles the CH32 knows its baud
(115200) and must use it. The first-transfer SD glitch is read-only: writes need no reordering.
Chip facts and numbers: fw/LEARNINGS.md. All experiments: index.