| ← Previous: ARC Execution Environment | Index | Next: Validation & Measurements → |
These normative requirements specify the processor, memory, peripheral, timing, and toolchain rules that any LPDDR5 PMU firmware implementation must satisfy to execute reliably on the SpacemiT K3 DDR PHY microcontroller. They apply to the ARC/PMU firmware image, not to host-side DDR controller programming.
In this document, must denotes a mandatory hardware or ABI requirement verified on the K3 platform. All addresses are in the PMU/ARC address space unless explicitly identified as a host CSR index.
0x0 must branch to the effective startup entry at 0x1fc. Hardware execution requires the 0x1fc entry layout; linking a flat entry directly at 0x0 without the 0x1fc startup sequence does not complete initialization.sp = 0x80010000. For full-training firmware, the host-provided parameter table base is 0x80000400.RF16) and does not implement general registers r16–r25. Generated machine code must never read or write r16–r25.-mrf16. When Link-Time Optimization (-flto) is used, passing -mrf16 only during compilation is insufficient because the linker (LTRANS) regenerates code using the full 32-register file unless -mrf16 is also present on the link command line.gp (r26) for its own small-data section, that pointer must be kept separate from the 0x80000400 parameter-table pointer so writes are never redirected into IMEM or invalid regions (passing -mno-sdata disables compiler .sdata/.sbss generation via gp)..bss isolation.bss must not overlap 0x80000400. That region holds the phypara and electrical configuration written by the host SPL (as well as runtime state words such as 0x8000042a, 0x8000042c, 0x80000430–0x80000437, and the delay divisor at 0x80000458/0x8000045a). Zeroing 0x80000400 during startup erases the input configuration and causes training to abort..bss and internal uninitialized globals at 0x80004000 (or higher unused DMEM below the stack and message scratch area).0x50000) and the host loader’s decompression buffer limit for its target boot mode (0x10000 bytes for full training, 0x6800 bytes for quickboot).volatile qualification, and unaligned table strides0x8000xxxx) and PMU/PHY peripheral CSR (0x90xxxxxx) access must be volatile-qualified and use the exact hardware width required by the register:
ldh/sth, volatile uint16_t). Using 32-bit accesses (ld/st, uint32_t) on 0x8000xxxx or 0x90xxxxxx reads zero, clobbers adjacent 16-bit registers, or stalls the internal peripheral bus.volatile on 0x8000xxxx or 0x90xxxxxx pointers allows compiler optimizations to hoist polling reads out of loops or eliminate intermediate register writes (such as clearing/restoring CSR[0x020011] bits [6:5] around period measurement).ldb/stb, volatile uint8_t) respecting little-endian byte order within the containing halfword.ldb, uint8_t *) and assembled explicitly in registers. A 32-bit dereference at an unaligned offset such as base + 6 faults and hangs the ARC core.r0–r7 and return results in r0, saving return addresses in blink (r31) and preserving callee-saved registers within the reduced r0–r15 set (r13–r15, fp, gp, sp).SequenceCtrl, CsPresentChA/B, EnabledDQsChA/B, X8Mode, and Quickboot). Unconditionally skipping an enabled calibration stage leaves the PHY uncalibrated even if the firmware still emits major completion code 0x07.0x90xxxxxx) from a 16-bit PHY CSR index and channel/rank/lane selector bits, combine the base index and selector bits using bitwise OR (|) and double the result:
ARC_CSR_address = 0x90000000 | (2 * (csr_index | block_or_rank_bits))
0x90000000 + 2 * idx for read-side descriptors, 0x9001e000 + 2 * idx for write-side descriptors, and 0x90082000 + 2 * idx for command sequences).0x90040040/0x90040042 and poll status at 0x90040062.0x90040146 and 0x9005e140: write 1, wait at least 0x20 timer units, and write 0.0x90040238: pulse 1 -> 0 on normal completion (0x07), or 4 -> 0 on fatal error (0x000000ff).0x90xxxxxx; invalid peripheral accesses stall the internal PHY bus.0x103–0x105)0x103 (RTC control), 0x104 (RTC count low), and 0x105 (RTC count high).0x103–0x105 exclusively with ARC lr and sr instructions (__builtin_arc_lr / __builtin_arc_sr or inline assembly). Treating these numbers as memory addresses causes timer polling loops to hang forever.0x103; if the counter is not running, initialize and enable it (sr 2, [0x103] followed by sr 1, [0x103]).lr from 0x104 and 0x105), compute the 64-bit expiration target, and poll until the 64-bit counter reaches the target while properly accounting for 32-bit low-word rollover into 0x105.< 16, perform a dummy 16-bit volatile read from 0x90040048 (CSR[0x020024]) per iteration to pace the loop on the peripheral bus.libgcc overridesarc-elf32 libgcc implementations of 64-bit multiplication (__muldi3 / __umulsi3_highpart) and 32-bit integer division (__udivsi3 / __divsi3 / __udivmodsi4) hang on the K3 PMU core.-mmpy-option=wlh5 -mdiv-rem and use the hardware mpymu (unsigned 32×32 high-part multiply), mpyu/mpy, and divu/divs instructions:
(uint64_t)a * b >> 32) must emit mpymu.divu and divs.libgcc helpers anywhere in the image, override __muldi3, __udivsi3, and __divsi3 globally using mpymu/mpyu/divu.-flto (while keeping -mrf16) so that LTO linking cannot discard or inline-bypass the overrides.libgcc __umulsi3_highpart or __udivmodsi4 bodies remain and no r16–r25 registers appear.0x8000e000–0x8000e0ff)0x8000e000–0x8000e0ff (host DPHY 0x5f000–0x5f07f) is a transient scratch area read and cleared by the host SPL during execution; firmware must not store persistent state there..bss (0x80004000) and below the stack (0x80010000), must not overlap phypara (0x80000400) or the message block (0x80000000–0x8000013f), and must be disabled in production builds.0x90180008 (CSR[0x0c0004]), low data/command 0x90180064 (CSR[0x0c0032]), doorbell/ACK 0x90180066 (CSR[0x0c0033]), and high data 0x90180068 (CSR[0x0c0034])—must use 16-bit halfword operations (ldh/sth).0x90180064 (and high 16-bit halfword to 0x90180068 when sending a 32-bit word);0 to 0x90180066 (clear doorbell);0x90180008 bit 0 until 0 (mailbox ready);1 to 0x90180066 (assert doorbell);0x90180008 bit 0 until 1 (host acknowledged).0x90180066 to 0 after step 5: 0x90180066 = 0 belongs at step 2 of the next word transfer. Clearing 0x90180066 to 0 immediately after step 5 leaves 0x90180008 bit 0 at 1 while the doorbell is 0, which can desynchronize the next transfer.0x08) requires first sending the 16-bit command 0x08 with its 5-step handshake, followed immediately by len + 1 32-bit words (word 0 = header (id << 16) | len, words 1..len = len payload words), each written as (low_16 -> 0x90180064, high_16 -> 0x90180068) with one 5-step doorbell/ACK handshake per 32-bit word. Do not send a separate 16-bit count word before the 32-bit header: the host reads j = len directly from the low 16 bits (0xd0032) of the already-loaded header before entering its j + 1 word ACK loop.Before loading or flashing a newly built PMU firmware image, verify:
arc-elf32-objdump -d shows zero references to r16–r25 and no unoverridden libgcc division/64-bit multiplication routines.0x0 branches to startup at 0x1fc..bss starts at or above 0x80004000 and does not touch 0x80000000–0x80003fff.<= 0x6800 bytes if targeting quickboot).SequenceCtrl stages, emits major 0x07, leaves CsTestFail == 0, populates all 5170 phypara halfwords and 4096 ACSM halfwords, and passes post-activation memory verification.