notes

radon's SD card and eMMC: the DesignWare Mobile Storage Host Controller

Milestone 53 (the board's own peripherals: network and storage on real silicon), the storage half. The driver is crates/designware_mobile_storage. The kernel's part is kernel/src/designware_mobile_storage.rs (a register window and a clock), kernel/src/user/designware_mobile_storage_service.rs (the EL0 server's wiring) and kernel/src/storage_bench.rs (the bench boot). The EL0 block server, which answers file_system_contract::blk like the virtio and NVMe servers, is components/src/designware_mobile_storage.rs. Names provisional.

What the part is, and how we know

The JH7110 has two SD/MMC controllers: 0x1601_0000 wired to the VisionFive 2's eMMC socket (8-bit), and 0x1602_0000 wired to its microSD slot (4-bit), the card radon boots from. Both are a Synopsys DesignWare Mobile Storage Host Controller (DW_mshc, Linux's dw_mmc). Three sources agree, read 2026-10-06 (UTC):

It is not the newer DesignWare Cores Mobile Storage Host (DWC_mshc, sdhci-of-dwcmshc), which is SDHCI-compatible and has a different register map. Which release this one is (VERID) and how wide its FIFO is (HCON) are the first two things the bench step reads. On radon both slots read VERID 0x5342290a (release 2.90a) and HCON 0x00c43cc1: a 32-bit FIFO, 32 words deep, the kind this driver moves (Results, below). designware-mobile-storage/driver.md (nifeos/nife:notes/designware-mobile-storage/driver.md) carries the node-by-node evidence.

What was reused, and what was not

Reuse: adapted from OpenBSD's sys/dev/fdt/dwmmc.c (revision 1.33, 2026-03-11, ISC), which matches both compatibles above and so already drives this part on this board. Its register map, reset, clock and bus-width sequences, command flags and polled FIFO transfer are the crate's registers, command and host_controller modules, and the crate root carries its ISC notice. Card identification takes only the order of its addressing commands from OpenBSD's sdmmc_mem.c, and adapts none of its code.

The crates.io candidate, starfive-jh7110-dwmmc 0.1.8 (Apache-2.0, from rcore-os/tgoskits), was read and not taken. It is 333 lines of JH7110 policy over dwmmc-host 0.4.2 (5,253 lines), which pulls in sdmmc-host, sdmmc-protocol, dma-api, mmio-api, volatile, bitfield-struct and embedded-hal. Four reasons, in order of weight:

  1. Its data path is IDMAC only ("there is no FIFO fallback"), so its first read on radon would test DMA coherence and the card protocol at once. See the next section for why this lane wanted them apart.
  2. Its volatile accesses live inside the driver core. This tree's split puts every register access behind one trait the kernel implements, which is what lets the whole driver run against a simulation on a host and under Kani.
  3. Five crates from one young tree, with sixteen dwmmc-host releases since August 2026. A dependency that size is an architect's ruling (§46 (thin primitives or whole subsystems; we write everything in between)). Taking it would not have removed the need for a simulation to test against.
  4. Effort was not the reason. Had both been the same work, the split and the PIO-first bring-up would still have decided it.

What it did give: its JH7110 constants (a 50 MHz reference clock, a 32-word, 32-bit FIFO) match both device trees, a third independent agreement. Linux's dw_mmc.c and dw_mmc-starfive.c, U-Boot's driver and both device trees are GPL and were read only for facts about the hardware.

Two data paths: the FIFO and the IDMAC

HostController<R> moves every word through the FIFO by MMIO, so radon's first silicon read could fail only in the controller or the card protocol, not in DMA as well. HostController::with_internal_direct_memory_access hands each data phase to the controller's own DMA engine, the IDMAC; crates/designware_mobile_storage/src/internal_direct_memory_access.rs holds its sequence. It waited on two things, both met: radon's DMA is coherent with its caches (designware_ethernet::coherence read Coherent on 2026-10-20 (UTC), notes/designware-ethernet.md), so a fence each way is all the ordering it needs, and the polled read works (Results, below).

simulator walks the chain through memory it shares with the tests, and a Kani harness proves a chain describes exactly its bytes inside the region.

Never break the card radon boots from

radon's microSD card holds the FAT32 partition U-Boot loads the boot script, kernel and archive from (notes/visionfive2.md). Three rules keep this driver from costing that card:

The gap before the first partition belongs to no filesystem, and U-Boot reads nothing there when the board boots from QSPI flash, which is how radon is set up (DIP switches both low).

calef's bench step on radon

About fifteen minutes, three boots, and the card is never removed. radon's card was written once with --tftp (milestone 257 (boot radon over the network)), so each boot is a build and a power cycle. Do these on the Mac radon's UART goes into, in this branch's worktree.

Before you start. radon's DIP switches on QSPI (both low), the UART on that Mac, the Ethernet cable in the port U-Boot netboots over. radon's card asks for a stale server address and an old archive name; notes/designware-ethernet.md's bench step says what to type at U-Boot and what to serve until the card is rewritten. In a second terminal, leave the TFTP server running:

script/board-netboot

Power is radon's own outlet. Never switch any other outlet, and never unplug a USB hub. Which outlet is which is kept off-tree by the maintainers.

Step 1: read-only

git log -1 --format=%h
script/board-image --tftp --extra-features storage_bench
mkdir -p bench/radon-$(date -u +%F)
script/board-console --for 3m --until none --log bench/radon-$(date -u +%F)/storage-bench-read.log

Power-cycle radon with plug 2 while board-console is watching. The banner line says Read-only build: nothing on any card is written. If it says anything else, stop.

What to look for, all lines prefixed storage-bench::

line what it settles
clocks before ... already up true whether U-Boot handed the controller over running
VERID ... HCON ... (FIFO at 0x200, Some(4) bytes wide, 32 words deep ...) the release, and that the FIFO is the 32-bit kind this driver moves
card clock: ... -> ..., 49500000 Hz from a 396000000 Hz parent (the tree asks 50000000 Hz) the card clock's divider was set from the tree's rate, and the rate the driver divides
card SdHighCapacity, ... blocks (... MiB), block-addressed, 4-bit at 24750000 Hz identification worked
partition 1: type 0x0b, sectors N.. and boot sector: signature 55aa, type field "FAT32 " reads return the card's real bytes
scratch range a write test would use: Some((N-8, 8)) where step 2 would write, before it does
timed read: 16384 blocks in ... us, ... KiB/s (128 blocks per command, polled FIFO) the polled read rate
IDMAC region at 0x..., 69632 bytes where the IDMAC's region is
timed read: ... KiB/s (128 blocks per command, IDMAC); the first 64 KiB match the polled read the IDMAC rate over the same 8 MiB, and that it read the same bytes
EL0 block server: Served the same card through the EL0 server, as the FS server would call it: block 0 of partition 1 is the boot sector, a write is refused EROFS, a block past the window EINVAL
slot 0 (eMMC socket): ... whether an eMMC module is fitted (NO-CARD if not)
verdict READ-OK ... KiB/s, IDMAC READ-OK ... KiB/s, EL0 block server served the step passed: the polled rate, then the IDMAC's
IDMAC read failed: ...; IDSTS ... DSCADDR ... BUFADDR ... after a failed IDMAC read only: the engine's status and position
at the failure: STATUS ... TCBCNT n TBBCNT m printed only after a failed read: STATUS's FIFO count, and TCBCNT, the bytes the card sent. TBBCNT does not restart at each command on radon (a clean 1024-byte read leaves it near 5000), so m against n says nothing

NO-CARD on slot 1 or any FAILED verdict: stop, keep the log, and send it. Nothing was written. A verdict that opens FAILED: polled READ-OK passed polled and failed through the IDMAC, which writes only into its own region.

Step 2: the scratch write test

Only if step 1 said READ-OK and printed a scratch range. The range is the up to eight sectors just before partition 1's first sector; on a card made by diskutil eraseDisk FAT32 NIFE MBR that is inside the alignment gap no filesystem uses.

NIFE_STORAGE_BENCH_WRITE=scratch script/board-image --tftp --extra-features storage_bench
script/board-console --for 3m --until none --log bench/radon-$(date -u +%F)/storage-bench-write.log

Power-cycle with plug 2. The banner now says WRITE TEST BUILT IN: the microSD card's pre-partition gap only. Look for:

verdict meaning
READ-OK ..., WRITE-VERIFIED sectors A..B (were zero), restored, IDMAC READ-OK ... KiB/s, IDMAC WRITE-VERIFIED, EL0 block server served writes work polled, through the IDMAC (the same test again) and through the EL0 server (one block, the same range), and the range is back as it was
READ-OK ..., WRITE-REFUSED: no gap before the first partition nothing was written; the card's layout leaves no room
FAILED: write test PatternMismatch(..) or Failed(..) the original was still written back; send the log
FAILED: write test RestoreMismatch(n) sector n, inside the gap, did not take its original back. Partition 1 was never touched

Step 3: put the ordinary image back

script/board-image --tftp

One more power cycle, and radon boots what everyone else's bench work expects. Then commit the two logs under bench/radon-<date>/ and say which commit they came from.

Results

date (UTC) commit step slot 1 (microSD) slot 0 (eMMC) verdict
2026-10-20 290d3ba8b 1, read-only identified; the first block read failed, Host(Data(17, 2060)) NoCard(NoResponse(1)) FAILED: read of block 0
2026-10-21 54c8e773b 1, read-only identified; blocks 0 and 2048 read by CMD17; the CMD18 read from 2048 failed, Host(Data(18, 164)), TCBCNT 1100 TBBCNT 4580 NoCard(NoResponse(1)) FAILED: read of block 2048
2026-10-21 f7ae6ee29 1 and the read matrix as above; the matrix (below) fails every read at the nominal 25 MHz and passes every one at 12.5 and 6.25 NoCard(NoResponse(1)) FAILED: read of block 2048
2026-10-21 ffac21104 1 and the read matrix card clock set to 49.5 MHz; the 8 MiB read, 16,384 blocks in 0.75 s; every matrix row passes NoCard(NoResponse(1)) READ-OK 10959 KiB/s, EL0 block server served
2026-10-22 03fc15894 2 and 3 polled FIFO; sectors 2040 to 2047 written, verified, restored; ordinary image to its prompt NoCard(NoResponse(1)) READ-OK 10960 KiB/s, WRITE-VERIFIED sectors 2040..2048 (were zero), restored, EL0 block server served

The card clock ran four times faster than the driver thought. The tree gives the ciu clock assigned-clock-rates = <50000000>, a rate the OS is asked to program. radon's firmware leaves SDIO1_SDCARD's divider at 2 under axi_cfg0's 396 MHz: 198 MHz. The driver's 25 MHz was 99 MHz, past SD default speed. The read matrix (storage_read_matrix) showed it: the same CMD18 at three clocks, four lengths and two FIFO depths, each row printing the FIFO's peak fill. At nominal 12.5 MHz, 64 KiB read in 3,147 µs, 20.8 MB/s, three times what a 4-bit bus at 12.5 MHz can carry. At nominal 25 MHz every read failed with a data CRC error once the FIFO first filled (bench/radon-2026-10-21/53-read-matrix.log). The storage bench now sets the divider from the tree's rate (8, 49.5 MHz) and hands HostController::new the rate computed from PLL2's and the dividers' words. Every row then passes, the FIFO never fills (peak 27 of its words at 24.75 MHz), and the 8 MiB read runs at 10,959 KiB/s (bench/radon-2026-10-21/53-card-clock.log). STATUS counted 128 words with its full flag set, so radon's FIFO holds at least 128 words, not the tree's 32.

Each row's log and how it ran are in bench/radon-<date>/: 53-storage-write.log for 2026-10-22, storage-bench-read.log for 2026-10-20. The 2026-10-20 row settled:

That boot ran its card at the same 99 MHz, so the threshold is not established as its cause.

Parity

Rule 5's scope note: these controllers are the JH7110's, on one riscv64 board, so the kernel half and the bench boot are riscv64-only (storage_bench is a compile error elsewhere). The crate is architecture-neutral; a board with this controller on another ISA (several Rockchip arm64 boards have one) would need the kernel half's twenty lines and a device-tree match.

BUGS