Imagination_BXM-4-64

On-Board Testing Oracle — SpacemiT K3 Pico ITX (36.56.104.183)

This document defines how to accept a reconstructed firmware image on real hardware. It serves as the objective criterion for milestones M1–M6: each stage specifies commands, expected values, and what to do on failure.

Reference environment:

Item Value
Board SpacemiT K3 Pico ITX (BXM-4-64, 36.56.104.183, XE_TPU2, PBE2_IN_XE)
OS Bianbu / Fedora riscv64, kernel 6.18.3+
Driver vendor pvrsrvkm (DDK 24.2 @ 6603887), device cac00000.imggpu
GPU PowerVR B-Series BXM-4-64, 6 ISP pipes, 128 KiB SLC (1 bank), MULTICORE_SYSTEM = 1
Console Serial UART (/dev/ttyUSB*), 115200 8N1
ADB adb -s <ADB_SERIAL> (when more than one device is connected)

Scope notice. The board runs the vendor driver and loads the v2 container (/lib/firmware/rgx.fw.36.56.104.183). The v3 container with device_info (/lib/firmware/powervr/rogue_36.56.104.183_v1.fw) belongs to the mainline driver, which is not loaded in this snapshot. Both formats are validated during pre-flight (§1); stages A–F exercise whichever path is active.


1. .fw Container Pre-flight

The pre-flight check is static (does not require the board) and runs in seconds. It rejects an invalid firmware before anything is written to the device.

1.1 Format and Sections

Inspect the pvr_fw_info_header header and the 6 pvr_fw_layout_entry entries in the .fw footer (per memory-model.md §7).

Acceptance:

Field v2 (vendor, DDK 24.2) v3 (mainline, ABI 1.1)
entry 0xbfc00001, micromips, mips32r2 same
Layout sections 6 6
bvnc 36.56.104.183 36.56.104.183
MIPS_CODE.base 0xc0000000 0xc0000000
MIPS_CODE.alloc_size 0x01a000 (must not grow) 0x017000 (must not grow)
MIPS_EXCEPTIONS_CODE.base 0x9fc02000 (max 8 KiB section; 64 KiB remap window) same
MIPS_BOOT_CODE.base 0xbfc00000 (max 4 KiB section; 64 KiB remap window) same
MIPS_BOOT_DATA.base 0xbfc01000 same
MIPS_STACK.base 0xcf600000 (0x1000) same
MIPS_PRIVATE_DATA.base below MIPS_CODE.base + alloc_size same — varies with layout

Rules:

  1. MIPS_CODE.alloc_size is invariant. Increasing it shifts the FWIF allocations placed immediately after base + alloc_size and breaks the boot handshake (firmware_started never rises). The compiled code (MIPS_CODE) must fit entirely within the fixed alloc_size budget.
  2. Exactly 6 sections, with no extra section: the mainline driver validates layout_entry_num == 6 and pvr_fw_mips.c uses sections 2/3/5 for REMAP*.
  3. Embedded BVNC == silicon BVNC: 0x00240038006800B7.

1.2 BVNC Against Hardware

# register read (debug_dump or bus)
cat /sys/kernel/debug/pvr/gpu00/debug_dump | grep -i bvnc

Expected: 36.56.104.183 — the same 0x00240038006800B7 as in the .fw. A .fw for another BVNC is rejected in pre-flight, not on the board.

1.3 device_info (v3 only)

Validate the device_info block of the v3 .fw against the table expected by pvr_device_info.c in the mainline kernel:

Acceptance: 29 u64 parameters (sizeof(header) + 29*8 bytes), with the K3 silicon values (num_isp_ipp_pipes = 6, tile_size_x/y = 16, phys_bus_width = 36, virtual_address_space_bits = 40, num_osids = 8, xe_architecture = 1, simple_parameter_format_version = 2, cdm_control_stream_format = 1). The full list is in memory-model.md §7.


2. Safe Load and Reload on the Board

2.1 Mandatory Backup

adb -s <ADB_SERIAL> shell 'cp /lib/firmware/rgx.fw.36.56.104.183 /root/rgx.fw.orig \
    && sha256sum /lib/firmware/rgx.fw.36.56.104.183 /root/rgx.fw.orig'

Verify that both hashes match before writing any candidate.

2.2 Fast Reload (Healthy GPU)

adb -s <ADB_SERIAL> push <candidate.fw> /tmp/cand.fw
adb -s <ADB_SERIAL> shell 'su -c "cp /tmp/cand.fw /lib/firmware/rgx.fw.36.56.104.183"'
# reload the driver (≈ 0.2 s when healthy)
adb -s <ADB_SERIAL> shell 'su -c "echo cac00000.imggpu > /sys/bus/platform/drivers/pvrsrvkm/unbind"'
adb -s <ADB_SERIAL> shell 'su -c "echo cac00000.imggpu > /sys/bus/platform/drivers/pvrsrvkm/bind"'
adb -s <ADB_SERIAL> shell 'dmesg | tail -40'

Criterion: dmesg shows the new FW load and no Oops/WARNING.

Known risk. unbind/bind can corrupt the power domain in some scenarios (with a possible Oops on the subsequent debug_dump). Use it only when the GPU is healthy and the candidate is a valid firmware. If any GPU timeout occurs, skip to §2.3.

2.3 Reload After Hang (Mandatory)

  1. adb -s <ADB_SERIAL> shell 'echo 1 > /proc/sys/kernel/sysrq'.
  2. Over serial: break, s (sync), b (reboot). SysRq bypasses driver shutdown and USB re-enumerates cleanly.
  3. If the board comes back without console and without ADB (symptom of reboot with pvrsrvkm loaded): physical power-cycle (unplug power). There is no software recovery from this state.
  4. If the console returns at the login prompt, log in before running new commands.

2.4 Restore

adb -s <ADB_SERIAL> shell 'su -c "cp -f /root/rgx.fw.orig /lib/firmware/rgx.fw.36.56.104.183"'
adb -s <ADB_SERIAL> shell 'sha256sum /lib/firmware/rgx.fw.36.56.104.183'

3. Acceptance Stages (A–F)

Each stage is cumulative: only proceed once the previous stage passes. For all stages, enable tracing before the first client connects:

# GPU without firmware loaded (after bind): arm log groups and log type
su -c 'echo main,mts,cleanup,csw,bif,pm,rtd,spm,pow,hwr,hwp,rpm,dma,misc,vz,safety,debug \
        > /sys/kernel/debug/pvr/gpu00/apphint/EnableLogGroup'
su -c 'echo trace > /sys/kernel/debug/pvr/gpu00/apphint/FirmwareLogType'

EnableLogGroup is read only on the first client connection (inside RGXSetupFirmware). Writing to it while the GPU is in POW_OFF leaves a LOGTYPE_UPDATE pending and the next eglInitialize may fail with 0x3001.

Stage A — Cold Boot

Check Command / Source Acceptance
Firmware started cat /sys/kernel/debug/pvr/status Firmware Status: RUNNING
Fast handshake FW trace (vz/main) firmware_started = 1 in ~1–2 ms
BVNC debug_dump 36.56.104.183
SLC_IDLE debug_dump (0x3898) 0xFF (all 8 subunits idle)
CORE_ID/REVISION debug_dump 0x00240038006800B7 / 0x00010000
First KCCB trace (mts) APM sends POW (0xC8) right after boot, matching vendor
Errors /sys/kernel/debug/pvr/gpu00/debug_dump Server Errors: 0

Stage B — Functional Sanity per DM

Path Client Acceptance
CDM (DM4) sudo rgx_compute_test RC=0 and 83 OK (0 FAIL), Firmware OK
GEOM + FRAG (DM2→DM3) gpu_probe 3 (EGL/GLES) GL_RENDERER = PowerVR B-Series BXM-4-64, artifact-free frames
TQ_3D (DM3) rgx_blit_test RC=0, no FAIL
NULL / FENCE / UPDATE rgx_kicksync_test RC=0; UFOs signaled
FENCE_PR rgx_triangle_test RC=0 (does not hang on PR)

A minimal surfaceless EGL/GLES client can be compiled directly on the board by linking against -L/lib64/lp64d -l:libEGL.so.1 -l:libGLESv2.so.2 and running with EGL_PLATFORM=surfaceless.

Stage C — Full Vulkan Suite

sudo /usr/local/bin/vkfwtest -k -L 30 all

Acceptance (baseline measured on K3 with the vendor firmware):

47 pass, 1 fail (rta), 0 timeout, 0 lost, 0 error, 2 skip

Stage D — Power, Runtime PM, and DVFS

Check Procedure Acceptance
APM / POW_OFF GPU idle for active_pm_latency_ms = 100 ms debug_dump shows RGX Power State: OFF, state RGXFWIF_POW_OFF
Warm resume run gpu_probe 1 after POW_OFF powers back up in < 2 ms, without recreating context and without error
Counters cat /sys/kernel/debug/pvr/gpu00/power_timing_stats coherent active/idle/off durations (no negative jumps)
DVFS sustained load (rgx_compute_test in a loop or gpu_probe 30) clk_rgx ramps from 409.6 MHz to 1228.8 MHz and back down
OPPs dmesg \| grep -i opp 6 OPPs; no -524 from cpufreq interfering

To measure resume, capture the trace with the pow group enabled: the expected sequence is POW_OFF → POW_ON → POW_COMPLETE with warm reinit bypassing SOFT_RESET.

Stage E — Controlled HWR and Recovery

Goal: prove that the watchdog fires and that recovery returns the GPU to a working state.

  1. Enable hwr and spm in the trace.
  2. Trigger a controlled fault: a compute kernel reading outside its allocated buffer (MMU fault) or a shader exceeding the HWR deadline.
  3. Acceptance, in order:
    • EVENT_STATUS bit 9 (MMU_PAGE_FAULT) handled in IRQ, with an entry recorded in hwrinfobuf (hwr_type = 3 for BIF0FAULT);
    • HWR identifying the offending context and emitting CONTEXT_RESET_NOTIFICATION;
    • FWCCB_CMD_FREELISTS_RECONSTRUCTION if a freelist is loaded in the PM;
    • the client receives an error (no hang) and a new rgx_compute_test runs with RC=0;
    • hwr_dm_recovered_count increments and hwr_dm_locked_up_count does not stay stuck.
  4. If the GPU does not recover: reboot via SysRq; if there is no console, power-cycle (§2.3).

Stage F — Stress and Concurrency

Test Command Acceptance
Stress vkfwtest -k -L 30 stress 0 timeout/lost/error
Soak vkfwtest -k -L 30 soak same, for the full duration
Churn vkfwtest -k -L 30 churn same (context creation/destruction)
Context switch vkfwtest -k -L 30 ctx-switch same; csw trace shows store/resume
Real preemption gpu_prio_probe (2 processes, different priorities) lower-priority process waits; both finish without error
Survival rgx_compute_test after all stress tests RC=0, 83 OK

4. Failure Triage

Symptom Likely Cause Action
firmware_started never rises MIPS_CODE.alloc_size changed, layout shifted, or missing 0xBFC01800 = 1 + ehb + sync barrier before publishing sysinit Revalidate §1.1; compare firmware_mappings against baseline
Server Errors: 1 on first client EnableLogGroup/FirmwareLogType written while GPU was in POW_OFF Reboot and arm logging before the first client, with GPU FW not yet loaded
Boot OK, first kick hangs MemCtx not activated in BIF, or BCAST[0xF330]/BCAST[0xF310] has wrong core mask Check data-masters.md and kick-compute-and-3d.md
TA runs, 3D does not HWR/state 9, missing LASTKICK, or PM_3D_MEM_FREE/ZLS_FINISHED never arrives See hardware-recovery.md §4.1 and §4.4
Render has color/depth artifacts pds_bgnd vs pds_pr_bgnd swapped, or SLC flush with wrong mask See partial-render-spm.md §3.1 and data-masters.md §4.1
Hang after HWR freelist not reconstructed, or FORCE_UPDATE did not run Check FREELISTS_RECONSTRUCTION in trace; restart client
Board without console/ADB reboot with pvrsrvkm loaded Physical power-cycle
ADB “multiple devices” more than one device connected Always use adb -s <ADB_SERIAL>

5. Evidence to Preserve

For each approved candidate, archive:

  1. sha256sum of the flashed .fw and the header/layout validation (§1);
  2. dmesg | grep -iE 'pvr|rgx|imggpu' from boot;
  3. active (with client) and idle debug_dump;
  4. firmware_trace of the session (12,000-dword window);
  5. full output of stages B–F, including client return codes.

Without these five items, a “pass” is not reproducible.