The boot interface
The firmware fits the slot mainline U-Boot already provides for the proprietary
ddr_fw.bin: same file name, same load address (0xc082d000), same entry
point (offset 0), same calling convention (mainline board/spacemit/k1/spl.c,
src/blob/start.S, src/blob/blob.ld).
The ABI
int ddr_init(u64 ddr_base, u32 cs_num, u32 data_rate,
void (*puts)(const char *));
Standard RISC-V LP64 calling convention, entered at offset 0 of the image
(0xc082d000). In the firmware this is k1_blob_ddr_init
(Entry points and runtime glue).
register |
argument |
values / rules |
|---|---|---|
|
|
MC base, |
|
|
1 or 2 populated ranks; using 1 on a 2-rank package leaves CS1 untrained |
|
|
requested final rate in MT/s (mapping below) |
|
|
optional UART output routine; may be NULL, the firmware must not require it |
|
— |
undefined (caller garbage); the ABI does not grow |
return |
|
0 on success, negative on failure; the mainline SPL ignores it |
data_rate mapping
requested |
final fp |
notes |
|---|---|---|
2400 |
2 |
PLL1 VCO for 2400 |
2666 |
2 |
PLL1 VCO for 2666, same fp2 bank; SoC maximum |
1066 |
1 |
|
1200 |
0 |
PLL1 VCO for 2400; fp0 is 1200 MT/s |
1333 |
0 |
PLL1 VCO for 2666; fp0 is ≈1333 MT/s (same MC bank as 1200) |
2133 |
0 (LPDDR4X) |
no fp3 on LPDDR4X; the final DFC goes back to fp0 |
anything else |
0 |
treated as 1200; never rounded up to 2666 |
The firmware’s k1_ddr_final_fp() implements this mapping
(Boot sequence). k1_ddr_pll_init() writes the 2666 PLL1
pair when data_rate is 2666 or 1333.
What the ABI does not carry
The SPL reads the memory type (LPDDR4 vs LPDDR4X) and the Tx ODT from the EEPROM
but does not pass them, and no silicon selector is used by the firmware before
Device_Init ([design], src/blob/blob.c). Consequences:
one image per memory type — this image is LPDDR4X with Tx ODT 80 Ω; an LPDDR4 board would need a different build (and the firmware disables LPDDR4 anyway, Notes, limitations and open points);
a single image serving both types would require changing the SPL and the ABI upstream.
Execution environment
property |
value |
|---|---|
privilege / harts |
M-mode, single hart (the SPL’s) |
code location |
raw, position-dependent image linked at |
usable window |
|
writable data |
none in the image; all mutable state lives on the stack |
stack |
the SPL’s stack (SRAM) |
DRAM |
not usable (it is what is being initialised) |
time base |
|
Output contract
When ddr_init returns 0: the DRAM is at the final frequency point, out of
self-refresh and refreshing; every frequency point the boot may use is trained;
the address map covers the full detected capacity; MC STATUS reads 0x33 (or
0x11), never 0x77; and the PHY training status phy+0x18000 is 0. On
failure the firmware returns a negative code and does not continue past a failed
training pass — but because the mainline SPL ignores the return value, a UART
message (when puts is present) is the only report.