Rockchip DDR blob reversing. Part I

Rockchip DDR blob reversing. Part I

This is beginning of one of the hardest tasks, i ever tried to do.

rk3568_ddr_1560MHz_v1.23.bin - the proprietary 58KB AArch64 binary, that Rockchips ships in their rkbin repository to initialize DDR memory on the RK3568 SoC.

Goal: enough understanding to write an open-source replacement for mainline u-boot. The blob is the last proprietary component blocking a fully open RK3568 boot stack (BL31 was already replaced by mainline TF-A). I plan to write series of articles, that will describe all my way. And i hope, it will help to replacement other Rockchip binaries for other SoCs.

Chapter 0: What we were looking at

bin/rk35/rk3568_ddr_1560MHz_v1.23.bin from rkbin (commit 74213af1e952c4683d2e35952507133b61394862, 2025-06-13).

59,392 bytes (0xE800). No documentation. No symbols. No header (at least, no one we recognized).

The starting facts we knew:

  • The RK3568 BootROM loads it as CODE471 (link) into 64 KB of System SRAM at physical address 0xFDCC0000, then jumps to offset 0.
  • It runs bare-metal, before DDR is available, so the stack lives in SRAM and there's no heap.
  • It returns to BootROM, which then loads U-Boot SPL into the now-working DDR.
  • The architecture is AArch64, little-endian.

That's it.

And one sad moment:
0xFDCC0000 is wrong address :)
I don't remember exactly, why i choose this value. 0xFDCC0000 is begin of RK3568`s 64KB System SRAM, maybe because of it.
And this address became the default for future work. In future i will find out, that it is wrong address, and correct is 0xFDCC1000. And 0x1000 shift is invisible, because 0x1000 is one ADRP page. Every PC-relative reference (ADRP, ADR, B, BL, LDR-literal) shifts by the same amount. The disassmebly, the xrefs, and the string references all stayed consistent. And static analysis of course can't find that.
And when something didn't fit, I invented a theory. In Ch.5 the .dynamic pointers seemed to point past the end of the file. That was a clue. But i thought: "the BootROM has its own dynamic linker, that fills in BSS". But when i changed base address, pointers points on .dynstr, .dynsym, .hash,.rela.
And the most sad, that this problem will go to our TPL. Direct DDR-init call uses PC-relative branches, so it worked. The driver-model probe goes through absolute pointers, so it crashed. I treated that crash as separate problem. Only in Ch. 54 (it will be in future articles) i finally traced it to the same 0x1000 offset :(
What i could have checked on day one: check mainline u-boot. On every Rockchip SoC with an in-tree TPL, the TPL is linked slightly above the SRAM base (rk3328 0xff091000, px30 0xff0e1000).

Chapter 1: First contact

Before writing a single line of code, i ran the basic ReverseEngeneering things:

file rk3568_ddr_1560MHz_v1.23.bin
# rk3568_ddr_1560MHz_v1.23.bin: data

binwalk rk3568_ddr_1560MHz_v1.23.bin
# nothing - no magic numbers binwalk can recognize

xxd rk3568_ddr_1560MHz_v1.23.bin | head -n 4
# 00000000: 0100 0014 e013 bfa9 fd7b bfa9 6401 0058  .........{..d..X
# 00000010: 0700 0094 005c 7892 1f00 04eb 0100 0054  .....\x........T
# 00000020: fd7b c1a8 e013 c1a8 0300 0014 e003 1eaa  .{..............
# 00000030: c003 5fd6 6433 0014 0010 ccfd 0000 0000  .._.d3..........

0100 0014 little-endian is 0x14000001 - an AArch64 B +4 instruction.

What it means for us:

  • It's not encrypted or compressed. A real instruction at the entry point means the BootRom jumps straight into executable code.
  • It's AArch64. Confirmed by B opcode encoding.
  • The "header" is just code. No magic, no length field, no signature.

We ran strings next:

strings -n 8 rk3568_ddr_1560MHz_v1.23.bin

And got very interesting lines:

  • "DDR 03ea844c5d typ 24/09/03-10:42:57,fwver: v1.23" - the boot banner
    with build date and git commit hash.
  • "error: write leveling timeout", "err: rdtrn timeout",
    "err: wrtrn timeout", "error: CBT timeout" - these named the four
    major PHY training routines we'd need to find later.
  • "BW=%d Col=%d Bk=%d", "Size=%dMB" - printf format strings showing
    what the binary logs.
  • "unsupported dram type", "calculate ddrconfig error" - error paths.
  • "/lib/ld-linux-aarch64.so.1" - wait, what?????

That last string was the first big surprise. A bare-metal bin with a linux dynamic linker path? That meant, the binary was build as a PIE shared object (the ELF header gets stripped, but .dynamic , .dynstr, .dynsym are retained because BootROM has its own simple dynamic linker). Suddenly we have a structure to mine.

So, i saved every string with its file offset to output/strings.txt and moved on.

P.S. About BootROM own simple dynamic linker
The binary argues against it:
1) All 12 relocations are R_AARCH64_RELATIVE:

Where Points to What it is
0xDB80, 0xDBC0, 0xDC00, 0xDC40 0xFDCCEB10/20/30/40 (file 0xDB10…) word 12 of each DDR-type config table (DDR4/DDR3/LPDDR3/LPDDR4 at 0xDB50/DB90/DBD0/DC10, +0x30): ext_data_ptr
0xDC50, 0xDC58, 0xDC60, 0xDC68 file 0xD89F/8A5/8AB/8B1 a 4-entry string-pointer table: "min ", "mid ", "max ", "range" — used by the training debug output
0xE620, 0xE628, 0xE630, 0xE638 0xFDCCFD30, 0xFDCCFFE0, 0xFDCD0250, 0xFDCD01B8 real BSS runtime structures (0xFDCCFFE0 is g_sdram_params)

So 8 of 12 point inside the file, which is another way the load-address bug was visible: at base 0xFDCC0000 all 12 appear to point into nothing.

2) Each target already holds its final value. For example, offset 0xDB80 contains 0xFDCCEB10, which equals its addend.
3) The blob was linked at 0xFDCC1000 and runs at 0xFDCC1000, so the relocation shift is zero and there is nothing for a loader to apply.

P.S.2 It's not PIE shared object. The test showed -shared doesn't emit an interpreter path, so it's PIE executable, not a shared lib.

Chapter 2: Decoding the header

The first instruction was B +4 - a branch to itself+4, which is just the next instruction. Why? Because there was clearly more going on at the entry point (or jump table entry, or patch slot, or some other artifact, honestly i don't know). Claude AI and me wrote decode_header.py script (all scripts will be attached to article and git of this project) to:

  • Decode the first 64 instructions.
  • Detect any unconditional branches and follow them.
  • Compute branch targets relative to the load address (0xFDCC0000)
  • Detect ELF/encrypted/compressed magic.
  • Estimate where code ends and data begins by scanning for invalid opcodes.

Correction (added later): the load address is 0xFDCC1000 , see Ch. 0

Running it produces this:

off  encoding  instruction
0x00  14000001  b     0x04                  ; no-op
0x04  a9bf13e0  stp   x0, x4, [sp, #-16]!   ; save BootROM's x0 (config pointer) and x4
0x08  a9bf7bfd  stp   x29, x30, [sp, #-16]!
0x0c  58000164  ldr   x4, 0x38              ; x4 = literal at 0x38 = 0xFDCC1000
0x10  94000007  bl    0x2c                  ; call the two-instruction helper below
0x14  92785c00  and   x0, x0, #0xffffff00   ; round own address down to 256 bytes
0x18  eb04001f  cmp   x0, x4
0x1c  54000001  b.ne  0x1c                  ; wrong address -> spin here forever
0x20  a8c17bfd  ldp   x29, x30, [sp], #16
0x24  a8c113e0  ldp   x0, x4, [sp], #16     ; x0 restored, main gets it untouched
0x28  14000003  b     0x34
0x2c  aa1e03e0  mov   x0, x30               ; helper: x30 holds the return address...
0x30  d65f03c0  ret                         ; ...so x0 = the address of 0x14
0x34  14003364  b     0xcdc4                ; -> main()
0x38  fdcc1000  (literal, not an instruction)

So, the entry point pattern was:

  1. Skip 4 bytes (0x0000 - 0x0004).
  2. There is no way to read the program counter directly on arm64, so the code calls the helper that returns its own link register. That's the trick at 0x10/0x2c: BL leaves the address of 0x14 in x30, the helper copies x30 to x0 and returs. No system registers involved.
  3. It rounds its own address down to a 256-byte boundary — AND with 0xFFFFFF00 clears the low 8 bits — and compares the result against the literal 0xFDCC1000.
  4. If the PC mismatches, the binary spins forever in a infinite loop (b.ne branches to itself) - a hard lockup if the BootROM loaded it to the wrong address.
  5. If the PC matches, fall through to B 0xCDC4 and jump to main().
  6. The x0/x4 save-restore around all of this exists so the check is invisible for main(): function get pointer on BootROM's config pointer in x0 exactly as it was passed.

This was important: it told us the binary is strictly position-dependent even though it was build as PIE. The trampoline asserts the load address. I saved result of this analysis to output/header_analysis.md

That compare is the single most important instruction for first kilobytes in blob. I was wrong with statement about "expected page after the literal pool". It isn't a page boundary or a pool marker. It is the address this blob insists on running at, asserted in cod, and it disagreed with 0xFDCC0000 i had written down one chapter earlier.

The first invalid opcode appeared around offset 0xCDC0, suggesting code runs from 0x0040 to ~0xCDC0 and data begins after 0xCDC4. (Later refinement: code actually runs to 0xCEDC, then a small mixed region, then data from 0xCEE0 onward.)

Chapter 3: Sweeping the hardware register accesses

A DDR init blob`s job is, technically, write specific values to specific MMIO addresses.

So our next move was find every MMIO address the binary references.

In AArch64, an arbitrary 32-bit immediate can't fit in a single instruction. A MOV immediate carries 16 bits plus a shift, so the compiler builds bigger constants in pieces: MOVZ (move with zero) sets one half-word and clears the rest, then MOVK (move keep) fills in another half-word without disturbing what's already there.

When an address has only one non-zero half-word, one instruction is enough. Most of the peripheral bases looks like this:

fdcc0050: d2bfb8c0  mov x0, #0xfdc60000      ; PMU_GRF base, single MOVZ
fdcc0074: d2bfccc0  mov x0, #0xfe660000      ; UART2 base, single MOVZ

When it doesn't, we get a pair - and the two halves need not be adjacent:

fdcc0644: d2904080  mov  x0, #0x8204
fdcc0648: 129dff01  mov  w1, #0xffff1007  ; unrelated instruction in between
fdcc064c: f2bfba20  movk x0, #0xfdd1, lsl #16 ; x0 = 0xfdd18204  (PMUCRU register)
fdcc0650: b9000001  str  w1, [x0]

claude wrote scan_mmio.py script to:
1) Scan every 4-byte instructions in the binary.
2) Decode MOVZ instructions (top bits 0xD2800000 for 64-bit and 0x52800000 to 32-bit, with the shift in bits 22-21).
3) For each MOVZ, scan forward up to 4 instructions for MOVK writes to the same destination register at higher shifts, accumulating the full immediate.
4) Filter for results in known RK3568 MMIO ranges (0xFDC00000 - 0xFF030000).
5) Categorize by region using a hard-coded base-address table.
6) Output JSON for downstream tools.

The result was next:

Address Refs Description
0xFDC20000 4 SYS_GRF
0xFDC40000 1 DDR_GRF / VO_GRF
0xFDC60000 21 PMU_GRF
0xFDCD1E00 2 PMU_MEM + 0x1E00
0xFDD18204 2 PMUCRU (extended) + 0x8204
0xFDD20000 1 CRU (main clock/reset)
0xFE100000 1 USB3 OTG
0xFE250000 1 PCIE/SATA
0xFE650000 2 UART0
0xFE660000 3 UART2 (debug console)
0xFE670000 2 UART3 (UART4-9 likewise, 2 each)
0xFE800000 1 GPIO0
0xFE880070 1 GPIO4 + 0x70
0xFF010000 4 PMU_SGRF / FIREWALL
0xFEAD0002 1 ???
0xFFF0BDC0 1 ???

PMU_GRF was the heaviest by far - 21 references. I read that as "the SoC needs every IO pin and clock domain configured before DDR". That was wrong. 20 of those 21 sit between offsets 0x0050 and 0x0418 - one routine, the UART pin-mux switch (because blob can output to any UART0-9). 21st reference is somewhere else entirely, and it turns out to matter enormously.

Also, important note: i should have some caution about reading refs column. It counts MOVZ sites the compiler happened to emit, not how heavily a block is used. UART2's three hits aren`t TX,RX,status - registers are reached by base+offset from one loaded base. So three loads isn't three registers.

So, next i tried to find DDR controller base address. I expected to find 0xF8000000 (the base i naively assumed from older Rockchip conventions, but honestly i don't remember where i get this number :) ). No reference to a DDR PHY base address too. I sure, that binary writes to some DDR controller, but where?

But both addresses are in table above. The are the rows labelled PCIE/SATA and GPIO0, right next to the row labelled USB3 OTG which is really the memory scheduler. This table was filled in guesswork, and i searched its labels instead of its numbers. In Ch.9 i will finally look at what the disassembly had been printing.

Chapter 4: Finding DDR base

If the controller base wasn`t constructed via MOVZ+MOVK, it had to come from somewhere else. We wrote find_ddr_base.py with three strategies:

1) Raw value scan - search the binary's data section for any 32-bit or 64-bit word matching plausible DDR controller bases (0xF8000000, 0xFC000000, 0xFE000000...).
2) Pointer table scan - look for sequences of pointer-shaped values that might be a config struct.
3) ADRP+LDR chain detection - find ADRP instruction followed by LDR, compute the target address, see if it lands in a data region that might contain a controller pointer.

I targeted --target 0xF8 (high byte of our wrong assumption). It found nothing. Next --target 0xFE, nothing again.

The issue was that the actual address (0xFE250000) was stored not as a literal but as a runtime-initialized BSS field - built up by any init function from multiple constants.

We had hit a dead end with static scanning. Time for Ghidra.

Chapter 5: Mining the ELF

But before opening Ghidra, i decided to exploited the /lib/ld-linux-aarch64.so.1 discovery. If the dynamic linker path was retained, maybe .dynaimc, .dynstr and .dynsym were too.

claude wrote parse_elf_dynamic.py for me:
1. Search the binary for the dynamic linker path string (well-known marker for us).
2. Walk backward looking for the start of .dynstr ( a null byte preceded by valid string data).
3. Parse .dynamic by scanning for the canonical sequence of (tag, value) pairs (DT_HASH, DT_STRTAB, DT_SYMTAB, DT_STRSZ, DT_SYMENT, DT_RELA...).
4. Walk through the symbol table, looking up names in .dynstr.

It found the .dynamic section at the file offset 0xE518 (from decode_header.py i get value 0xE4F8 but it is wrong) and the string table giving us four exported symbol names:

  • dram_timing_g - the master DRAM timing parameter structure
  • sdram_configs_g - SDRAM configuration results structure
  • timing_config_g - timing configuration structure
  • printf_buffer - internal printf output buffer

There are the original C source variable names. They are the interface between the block and its callers (BootROM, SPL) . Our future open-source driver will need to expose equivalent symbols (or at least produce equivalent data). This was a huge structural win.

Thy .dynamic table also pointed to BSS region (0xFDCCE8D8+) that lie beyond the binary file end (0xE800). That's where the runtime symbol table, hash table, and relocation data live - populated by the BootROM's loader. Static analysis can't reach into those, which became important later. (Read Ch. 0 why it happened and what i did wrong). If we use correct address - we get everything right.

P.S.
Step 1 found the path at 0xD8B7. It sits alone, directly before the symbol table — exactly where a linker puts .interp. Linking with -pie produces exactly this, and objcopy -O binary keeps it when it flattens the ELF. Nothing in the blob ever reads it; it's a leftover of how the blob was built, not a sign that anything loads it dynamically.

Chapter 6: Building a register dictionary

The ddr controller is Synopsys Designware uMCTL2, licensed into a lot of SoCs. And it is well-documented IP.
The PHY is a bit different - the Synopsys PHY databook is under NDA, and there's no public equivalent. (Worse, as i'd find out much later: the RK3568`s PHY isn't a stock Synopsys PUB at all, as i found, its register fields are Rockchip-custom)

Our references sources:
1. Xilinx UG1087 (Zynq UltraScale+ register reference) - UMCTL2 module, complete bit-field descriptions for ~108 controller registers.
2. Allwinner H6 U-Boot Header (dram_sun50i_h6.h) - same UMCTL2 layout as a C struct, with a comment explicitly citing UG1087 as the source.
3. RK3328/RV1126 U-Boot drivers - the closest Rockchip chipts that actually use uMCTL2 (with an inno PHY, not the same phy as rk3568)
4. PX30 U-Boot header (sdram_pctl_px30.h) - best Rockchip-specific UMCTL2 offset definitions.

One note on one source, that i expected to use and couldn't. rk3399 is the obvious Rockchip reference, and it's the wrong IP entirely - Cadence/Denali, not Synopsys.

We wrote build_regmap.py to consolidate all of this into a single machine-readable database: tools/regmap.json. Final tally:

  • 108 UMCTL2 registers (offsets 0x000-0x540, names like MSTR, INIT0-7, DRAMTMG0-14, ZQCTL0-1, DFITMG0-1, ODTCFG, ODTMAP, SCHED, PCTRL_0-2, ADDRMAP0-11)
  • 243 PHY registers (PUB layout from H6 with bit-field descriptions)

This database became the input for every downstream tool that needed to turn an offset into a meaningful name.

Chapter 7: Loading into Ghidra

Now we opened the Ghidra. The setup:
1. File -> Import file : select the binary.
2. Format: Raw Binary
3. Language: AArch64:LE:64:v8A (little-endian, ARMv8-A).
4. Block name: .text.
5. Block start address: 0xFDCC0000 - critical moment. Ghidra needs this so that ADRP+ADD pairs and absolute branch targets resolve to the right address. (P.S. remember - 0xFDCC0000 is wrong)
6. Length: 0xE800.

Then Analysis -> Auto Analyze with the default analyzers. The analyzer produced ~1100 functions (most spurios, created from data the analyzer mistakenly dissambled).

Ghidra entities

Ghidra's auto-analysis is generic. To make sense of this binary, we wrote a Jython script that creates project-specific entities. Each step runs on the open program:

Step 1 - Function labels (~16 entries to start):
For each known address, we call createFunction() (if no function exists yet) and setName() to attach a meaningful name. Examples:

labels = {
    0xFDCC0000: "entry_trampoline",
    0xFDCCCDC4: "main",
    0xFDCCCAB8: "ddr_printf",
    0xFDCC04E4: "soc_detect_and_init",
    0xFDCC90CC: "ddr_init",
    0xFDCC47F8: "try_ddr_init",
    0xFDCC5FF0: "full_controller_phy_init",
    0xFDCC711C: "vref_training_search",
    0xFDCC7514: "phy_training",
    ...
}
for addr, name in labels.items():
    func = getFunctionAt(toAddr(addr)) or createFunction(toAddr(addr), name)
    func.setName(name, USER_DEFINED)

Step 2 - String data types:
Ghidra often dissambles printable strings as instructions. We walk the range 0xD280-0xD8B6 and call createAsciiString(addr) to convert each null-terminated region into a proper string Data. This both fixes the display and creates auto-references when other code does ADRP + ADD reg, #offset pointing to one.

Step 3 - Function discovery via prologue scan:
The standard AArch64 function prologue is
STP x29, x30, [sp, #-N]! (encoded 0xA9BF7BFD for 16-byte frame and in general match (insn & 0xFFC07FFF) == 0xA9807BFD). We scan every 4-aligned address looking for instructions matching this pattern that don't already belong to a function. For each hit, we call createFunction() to add it. This caught ~40 extra functions auto-analysis missed.

Step 4 - MMIO annotations:
For every MOVZ instructions whose constructed value lies in a known MMIO range (loaded from our scan_mmio output), we call setEOLComment(instr, "PMU_GRF base") etc. This makes the dissasembly self-documenting in the listing view.

Step 5 - String cross-reference annotations:
For every ADRP + ADD reg, page, #offset pair where the resulting address is a known string, set the EOL comment to show the string's content. So adrp x0, 0xfdccd2c8; add x0, x0, #0x88 gets a comment like -> "calculate ddrconfig error".

Step 6 - UART functions:
Find all functions that touch the UART2 base (0xFE660000). These are candidates for putchar, puts, printf. We label them uart_writer_* for further investigation.

Step 7 - Data section markers:
Use createData() to mark the boundary at 0xCEE0 as the start of .data, preventing the auto-analyzer from re-disassembling the tables as instructions. Also mark known table addresses (0xDB50, 0xDB90, 0xDBD0, 0xDC10) with Bookmark notes.

What Ghidra was bad at

  • Stripped binary plus PIE : many internal references go through the GOT, which lives in BSS. Ghidra can't follow them statically because the GOT is zero in the file image. (P.S. because of wrong base address, with right address it's not zero)
  • Position-dependent literal pools: AArch64 likes to use ADRP+LDR to load constants from inline literal pools. Ghidra resolves these but the decompiler often doesn't propagate the value into the using expression.
  • Function boundary detection: many small leaf functions (memset, memcpy variants or other inline things) got merged into their callers because there was no BL in-between, just a fall-through. (P.S. no, many small leaf functions (memset, memcpy and other) got merged into their callers because the call was a tail call (B instead of BL, so Ghidra sees a jump, not a call), or because they follow a call that never returns)

The fix for all of these was the same: hand-label, then re-run analysis, then iterate.

Chapter 8: Annotated disassembly

We wanted a single text file we could grep and read on a plane without opening Ghidra. So:

aarch64-linux-gnu-objdump -D -b binary -m aarch64 \
    --adjust-vma=0xFDCC0000 bin/rk3568_ddr_1560MHz_v1.23.bin \
    > output/raw_disasm.asm

Still remember, that 0xFDCC0000 is wrong ☹️

That gave us 14,614 lines of raw assembly. Then annotate_disasm.py post-processed it to add four kinds of annotation:
1. Function labels: at the start of every known function, insert a <function_name:> line.
2. MMIO annotations: for every MOVZ+MOVK pair in our database, append ; -> PMU_GRF base etc.
3. String references: for every ADRP+ADD pointing to a known string, append ; -> "the string content" .
4. BL targets: for every bl 0xfdccXXXX, append the called function's name if known.

The result: output/annotated_disasm.asm, was 14,924 lines: 56 function labels, 56 MMIO annotations, 66 string-ref annotations, 112 BL target annotations. It's the document we kept open in a side terminal whenever we wanted to trace something quickly.

Chapter 9: Mistake - assuming the wrong DDR controller base address

Here is where i did big mistake.

For long time, i assumed the DDR controller base was 0xF8000000, because that's what showed up in some older Rockchip code i've seen. I even build draft register annotations against this address.

Two clues should have warned me earlier:
1. scan_mmio.py found zero MOVZ-constructed references to anything near 0xF8000000.
2. find_ddr_base.py --target 0xF8 came back empty.

I assumed the address was hidden behind some indirection i've missed and moved on. That was the mistake - i treated absence of evidence as problem with our tool, not as evidence the assumption was wrong.

The answer was in a file I'd generated on the first day. Here is init_config_struct at 0xFDCCAD9C - a short routine that does nothing but store seven constants into one struct:

fdccad9c: d2bfd001  mov x1, #0xfe800000
fdccada0: f9000401  str x1, [x0, #8]
fdccada4: d2bfc4a1  mov x1, #0xfe250000
fdccada8: f9000001  str x1, [x0]
fdccadac: d2bfb8c1  mov x1, #0xfdc60000
fdccadb0: f9001401  str x1, [x0, #40]
...
fdccadd4: d65f03c0  ret

Every one is a single MOVZ. scan_mmio.py caught all seven. It printed 0xFE250000 as PCIE/SATA, 0xFE800000 as GPIO0, and 0xFE100000 as USB3 OTG, because those were the labels in my hand-written region table. As i wrote before it's wrong. And annotated_disasm.asm, generated after the scanner, reads:

fdccada4: d2bfc4a1  mov x1, #0xfe250000   ; <- PCIE_SATA (0xFE250000)

From Ghidra. We decompiled init_config_struct (at 0xFDCCAD9C, identified because it stores into g_ddr_config at 0xFDCCE680), and saw clean C code:

g_ddr_config[0] = 0xFE250000;  // ← UMCTL2 base, NOT 0xF8000000
g_ddr_config[1] = 0xFE800000;  // ← PHY base
g_ddr_config[2] = 0xFDD20000;  // ← CRU
g_ddr_config[3] = 0xFE100000;  // ← MSCH (memory scheduler)
g_ddr_config[4] = 0xFDC40000;  // ← DDR_GRF
g_ddr_config[5] = 0xFDC60000;  // ← PMU_GRF
g_ddr_config[8] = 0xFDC20000;  // ← SYS_GRF

One struct, filled once at startup, and every hardware access in the blob goes through it. That function is the blob entire memory map. And PMU_GRF line is last 21st reference from Ch3, the one outside the UART routine.

Both tools were telling the truth, by the way. There is no 0xF8000000 in this binary, and no literal pool holding the real base either, so find_ddr_base.py correctly found nothing. They answered the question I asked. The question was wrong: I kept asking "where is 0xF8000000?" instead of "what MMIO bases does this blob actually build?"

Lesson learned: when a tool reports nothing, the answer might be that our assumption is wrong, not that your tool is broken. Cross-check with a different technique before trusting either.

Also, hard-coded lookup table is only a hypothesis, that i can't use as data.

We rewrote everything that depended on the controller base. Updated all references in the docs.

Chapter 10: On-target validation

With correct addresses in hand, we wanted to read the live values from the running RK3568 board to validate our static analysis.

We wrote dump_ddr_regs.py a /dev/mem reader that:
1. Maps a region via mmap() from /dev/mem
2. Reads each 32-bit register at offsets in regmap.json
3. Prints name (offset) = 0xVALUE for each

The problem: any access to an unmapped or firewalled region from userspace produces SIGBUS, killing the script. So we added two safety features:

--probe mode : for each candidate region, fork a child process. The child does the read; if it dies from SIGBUS, the parent records the region as inaccessible. This lets us probe what's reachable without crashing
--safe mode: for each individual register, fork before the read. Slower (one fork per register), but survives SIGBUS at the granularity of one register, so we can dump as much as readable.

The probe results next:

Region Address Status
UMCTL2 controller 0xFE250000 SIGBUS — firewalled
DDR PHY 0xFE800000 OK (full block readable)
CRU 0xFDD20000 OK
DDR_GRF 0xFDC40000 OK
PMU_GRF 0xFDC60000 OK
SYS_GRF 0xFDC20000 OK
MSCH 0xFE100000 OK
UART2 0xFE660000 OK
PMUCRU_CLKSEL 0xFDD18200 SIGBUS

The DDR controller is firewalled. I also tried from U-Boot's bare-metal console (EL2/EL3, no Linux kernel infrastructure) and got the same result: "Synchronous Abort, esr=0x96000010" on every read of 0xFE250000.

The blob configures a hardware firewall (probably PMU_SGRF at 0xFF010000) during DDR init that blocks access from every privilege level afterward. This persists across reboots until the firewall config is changed by secure code that runs before the blob.

This was a strategic blow. The whole plan to validate our register
analysis by reading live values was dead. I needed a workaround.

The four options:
1. Extract register values from the binary's static data tables. Best
way - they're sitting right in the file.
2. Read pre-computed timing from the blob via ddrbin_tool.py -g.
3. Modify TF-A (BL31) to leave UMCTL2 unfirewalled - possible but
invasive.
4. Trust the values logged via the blob's debug printf during boot.

I pursued (1) and (2) in parallel.

P.S. My thoughts after all about it:
i test only in EL0 (linux userspace), and u-boot proper. U-boot proper runs at not-secure EL2 on rk3568 with TF-A, not in EL3. A secure-only region blocks both, and i never tested EL3
technically firewall configuration doesn't survive a reset. It set ups again on every boot. Also, blob or bl31 probably sets it. (probably - i still don't know about that)
esr=0x96000010 decodes as EC 0x25 (data abort, same EL) with DFSC 0x10 (synchronous external abort). That points to the bus rejecting the access, not MMU fault.
Anyone can reproduce it with disabling CONFIG_STRICT_DEVMEM or use iomem=relaxed for /dev/mem