SpacemiT_K1_DDR

← Previous: Acceptance Criteria and Reference Measurements Index

Test Platform: FDL, Software Resets, BootROM Media, Probes

This file describes the hardware facts behind the experimental setup used to discover everything else: how images reach the SoC, how the board can be reset by software, where the BootROM looks for the first stage, and how the real DRAM clock can be measured. None of it is needed by ddr_init itself.

FDL: BootROM USB download

The K1 BootROM tries the boot media and, when they fail (or when the FDL button is held at reset), enters a USB download mode that offers a fastboot-style interface. A signed first-stage image is pushed and started with:

fastboot stage <signed-first-stage.bin>
fastboot continue

The image runs from SRAM exactly as if it had been loaded from a boot medium. An experiment image is the mainline SPL with a DDR image in the ddr_fw.bin slot (the u-boot-spl-ddr.bin of boot-interface.md), signed with the vendor signing tool.

Two practical notes from 2026-11-07, when the same board was used with a different host:

Observations useful for automation:

Loading without FDL: writing the boot medium

FDL is a download mode: the image runs from SRAM and the storage medium is not touched. The production boot path writes the signed first-stage image into the medium’s fsbl slot and lets the BootROM load it at reset. Two hardware traps were measured:

On the BPI-F3, the SD card’s first-stage slot is mmcblk1p1 (256 KiB fsbl partition, header magic AIHD at offset 0x100). A running Linux system can write it directly (dd if=image of=/dev/mmcblk1p1 bs=4096 conv=fsync).

Recovery when the SD card image fails to boot. If a written SD image hangs during DDR training (or if a watchdog-reset test hook is left enabled in an SD-booted image, causing an endless boot loop), the board cannot boot from SD. To recover without an external card reader: power off, remove the SD card, boot Linux from the onboard eMMC, and hot-plug the SD card once Linux is up. The SD host controller uses an active-low card-detect GPIO (GPIO 80 on the BPI-F3) and detects the insertion immediately, allowing the partition to be rewritten with dd.

Boot sequence printed by the BootROM

Reset source sys value printed Path taken
RST button 0x0 bm:3 (SD, fails) → bm:0 (eMMC; invalid bootinfo magic code:0x0 when empty) → FDL
FDL button 0x1000 bm:2 → download mode directly
PMIC P1 soft reset 0x0 (8 of 8) same as the RST button
SoC watchdog 0x0 (1 of 1) same as the RST button

sys reflects the boot flag register 0xd4282d10. The mainline SPL writes its own boot mode there (0x55a USB … 0x55e SD); after an image loaded through FDL it reads 0x0000055a. A PMIC reset clears it.

Software reset of the SoC (watchdog, MMIO only)

Works without I2C.

Block Address Role
MPMU 0xd4050000 Clocks / reset of the watchdog block
WDT 0xd4080000 Watchdog timer
Start 0xd4051020 bit 4 starts the counter

MPMU+0x200 (WDTPCR): bit 0 = APB clock of the WDT, bit 1 = timer clock (25.6 MHz / 100 → 256 Hz count), bit 2 = block reset (1 = held in reset; clear it for the MMIO to respond).

Every write to the WDT must be immediately preceded by the unlock pair:

WDT+0xB0 = 0xbaba
WDT+0xB4 = 0xeb10
WDT+off  = value
Offset Value Role
+0xC0 0 Clear status
+0xBC N Timeout in ticks of the 256 Hz clock (1 ≈ 4 ms; 0 fires at once)
+0xB8 3 Enable
+0xC8 1 Timeout causes a SoC reset

Sequence (does not return):

MPMU+0x200 |= 0x3            /* clocks */
MPMU+0x200 &= ~0x4           /* release block reset */
unlock; WDT+0xC0 = 0
unlock; WDT+0xBC = 1
unlock; WDT+0xB8 = 3
unlock; WDT+0xC8 = 1
*(0xd4051020) |= (1 << 4)    /* start */
loop forever

If the WDT registers always read 0, its clocks/reset are not set correctly. Clearing 0xd4282d10 before arming makes the next sys value reflect only the watchdog.

Board reset through the PMIC (closest to the RST button)

SpacemiT P1 on I2C bus 8, address 0x41 (BPI-F3 / k1-x_deb1). Register numbers from the public P1 map (the same P1_* names as in U-Boot):

Register Bit Role
0x44 0 WDT_CTRL: W1C status
0x44 1–2 Timeout (0 = 1 s … 3 = 16 s)
0x44 3 WDT enable
0x7C 7 PWR_CTRL0: the PMIC watchdog causes a reset
0x7E 1 PWR_CTRL2: SW_RST (mask 0x02)
0xAB 2 ALIVE: reboot flag (mask 0x04)

Immediate reset:

P1[0xAB] |= 0x04      /* reboot flag, not "charging" */
P1[0x7E] |= 0x02      /* SW_RST; does not return, ≈100 ms to the BootROM */

The rails go down and up: this matches the RST button (sys: 0x0). The FDL button (sys: 0x1000) is a strap and cannot be reproduced by software.

Measured: P1[0xAB] already reads 0xf4 (bit 2 set), P1[0x7E] reads 0. At the point where the SPL runs, I2C8 and its pin mux are often not configured yet; the SoC watchdog works without them.

Where the BootROM looks on eMMC

DRAM latency probe (frequency meter)

Because the PLL block has no frequency counter, the real DRAM clock is measured by latency:

With the data cache off the CPU runs at 307 MHz in the SPL and the cache does not filter (all sizes cost the same); with the data cache on (1599 MHz) use the random 32 MiB chain (sequential is hidden by the prefetcher, 16 KiB fits in L1). A PLL2-based point (fp1) is the control: it must not change between PLL1 recipes. Results in reference-measurements.md.

User-space probes (Linux)

Once the boot reaches Linux, two user-space workloads characterise the trained DRAM:

Neither replaces the register-level probes; they measure end-to-end stability and performance. Results are in reference-measurements.md.

Gaps


← Previous: Acceptance Criteria and Reference Measurements Index