E20 — Shared SRAM split by 128 KB block
| ID | E20 |
| Date | 2026-12-02 |
| Status | done |
| Decisions | D98 (DECISIONS.md) |
| Board | #1 (rev A, 12 MHz HSE), RP PIO counter → CH32 DVP at 75 MHz |
| Firmware + results | fw/tests/2026-12-02-13-sram-split (sources incl. ch32/rp417_sram_split.ld, 4 CH32 binaries split/unsplit × 96/156 MHz, results.txt) |
| Scripts | sramsplit.py |
Summary: Putting the V3F’s RAM code, the DVP buffer, the ADC/SD buffers and the V5F mailbox in separate 128 KB SRAM blocks lets the V3F stream 75 MS/s DVP data with 32-sample chunks at 96 MHz (all bad before) and the V5F check 32-sample chunks at 156 MHz (108 k bad before).
What
E17/E19 showed the two cores contend inside one shared-SRAM block. ch32fun’s linker script puts everything in one
512 KB region, so the V3F’s RAM code (E16) shared block 0 with half of the DVP buffer that the DMA writes at 150 MB/s.
rp417_sram_split.ld cuts the region into the four blocks; SRAM_BLK(n) places the big buffers; RP417_SRAM_SPLIT=0
builds the old layout from the same source.
| block | address | contents |
|---|---|---|
| 0 | 0x20100000 | V3F RAM code (.data.ramcode), .data, .bss (5.9 KB), V3F stack (top) |
| 1 | 0x20120000 | dvp_buf (128 KB) |
| 2 | 0x20140000 | sdcheck buffer, sd_save, adc_buf, sd_buf (4 × 32 KB) |
| 3 | 0x20160000 | V5F mailbox, DVP scratch |
Results
75 MS/s DVP for 2 s (150 M samples), RP counter; “bad” = chunks (V5F off) or samples (V5F checking) out of sequence:
| ×32 (V3F 96 MHz) unsplit | ×32 split | ×26/FPRE 2 (156 MHz) unsplit | ×26 split | |
|---|---|---|---|---|
| V5F off, 64-sample chunks | 0 | 0 | 0 | 0 |
| V5F off, 32-sample chunks | 4.69 M bad chunks | 0 | 0 | 0 |
| V5F off, 16-sample chunks | CPU-bound (2.36 M bad) | CPU-bound (2.21 M) | 1.04 M | 0.78 M |
| V5F checks, 128 | 0 (71 % load) | 0 (71 %) | 0 (51 %) | 0 (51 %) |
| V5F checks, 64 | 162 bad | 0 | 0 | 0 |
| V5F checks, 32 | 1.59 M bad | 1.11 M | 108 k | 0 (71 %) |
| V3F RAM loop, V5F polling flat out | 17.751 ms | 17.751 ms | 10.925 ms | 10.925 ms |
- The moved buffers work: ADC1 DMA 3.43 / 5.57 MS/s, dual ADC 11.41 MS/s, SD double-read check 0 differences, 4 MB verified write stream with the window restored, DVP capture bit-exact.
- The V5F load is unchanged: the DMA and the V5F still share block 1. Splitting the ring over two blocks is the next step.
Lesson
Contention inside one SRAM block is real on this chip, and the default linker script puts every buffer and the RAM code in one region. Give each bus master’s hot data its own block. Measure the same source with the layout as a build switch.
Chip facts and numbers: fw/LEARNINGS.md. All experiments: index.