Build and toolchain

Requirements

  • The GNU toolchain for mipsel-elf: GCC and binutils. The default is GCC 16.2.0 with binutils 2.42 in /opt/rgxcross; another one is selected with make CROSS=<prefix> GCC=<gcc>. C23 needs GCC 14 or later.

  • python3 (tools/mkfw.py, tools/gen_sfids.py)

  • No libc or libgcc: the firmware is freestanding (memset, memcpy, __udivdi3 and __umoddi3 live in src/util.c).

Build commands

make -C src                                      # -> build/free_rogue_36.29.52.182_v1.1.fw
make -C src FWIF=1.1                             # FWIF ABI version (default 1.1): name and .fw header
make -C src BVNC=36.29.52.182                    # the same: the GPU core is selectable
make -C src -B EXP="-DEXP_NO_RENDER"             # retire geometry/fragment commands unrun
make -C src sfid SFH=<path>/pvr_rogue_fwif_sf.h  # regenerate src/include/sfid.h
make -C src clean
make -C src CROSS=/usr/bin/mipsel-elf- GCC=/usr/bin/mipsel-elf-gcc
                                                 # another GCC (14 or later)

Outputs in build/ (git-ignored):

Artifact

Description

build/obj/*.o

Compiled object files

build/fw.elf

Linked firmware ELF32 (four PT_LOAD segments)

build/fw.dis

microMIPS disassembly (mipsel-elf-objdump -d)

build/free_rogue_36.29.52.182_v1.1.fw

Packed firmware container (free_rogue_<b.v.n.c>_v<FWIF>.fw). The driver loads powervr/rogue_<b.v.n.c>_v<FWIF major>.fw, so it is installed under that name (tools/deploy.sh fw)

The build is deterministic: identical sources produce a byte-identical .fw file.

Per-GPU constants

Everything that depends on the GPU core is in one directory, src/bvnc/<b.v.n.c>/, selected with make BVNC=<b.v.n.c> (default 36.29.52.182, the BXE-2-32 of the K1; bvnc/36.29.52.182/bvnc.h — Per-GPU constants (BXE-2-32, K1)). Each GPU has the same three kinds of file there, and each cites only the docsClean of its own GPU:

  • bvnc.h, the values (bvnc/36.29.52.182/bvnc.h — Per-GPU constants (BXE-2-32, K1)): the BVNC that names the .fw (free_rogue_<b.v.n.c>_v<FWIF>.fw), the container’s device information (BVNC_FEAT_*, BVNC_QUIRKS, BVNC_ERNS, read by tools/mkfw.py --bvnc), the register tables of the unit initialisation, the tiles-in-flight cap, and the wired TLB layout of the assembly;

  • boot.S and vectors.S, the reset and exception code (boot.S and vectors.S — Assembly);

  • seq.c, the hardware sequences whose order or structure differs between GPUs (bvnc/<bvnc>/seq.c — Per-GPU sequences), behind the interface of include/bvnc_seq.h: the GPU-unit initialisation, the dust power request, the HWR soft reset, the per-job cache flush, the TQ_3D launch, the multicore compute control, the end-of-render sync and the PM steps of the first geometry kick.

How a difference between GPUs is handled:

  • a different value goes to bvnc.h;

  • a different order or structure goes to seq.c: each GPU writes its whole sequence, even when it repeats most of another GPU’s, and the shared code only calls it;

  • a hardware feature declared in the device information stays an #ifdef BVNC_FEAT_* in the shared code (for example 0x1858 = tpu_tag_cdm_ctrl with TPU_DM_GLOBAL_REGISTERS), as the mainline driver does with features.

There are no defaults. A BVNC without a directory does not build, a header that lacks a value fails to compile, and a seq.c that lacks a function does not link: another GPU never inherits this one’s constants or sequences.

The BXM-4-64 (36.56.104.183): its boot.S and vectors.S follow its execution-environment.md (Config.K0 = 3 with the I-cache and D-cache initialised by index, Status = 0x1C00, Compare = 0xFFFFFFFF, every remap entry cleared, one 4 MiB TLB entry for the register and broadcast banks, Wired = 4). The reset vector tells an NMI from a cold reset (Status.NMI): an NMI writes struct rogue_mips_state to the NMI shared area of the boot-data page (pvr_rogue_mips.h: offset 0x100) and returns; the general exception handler writes the same dump before stopping. Only KSEG0 (the exception code) is cached: the heap stays mapped uncached and the boot-data page is reached through KSEG1, so the C code needs no D-cache maintenance.

Its seq.c follows its own specification in:

  • the dust power request (power-management.md 2.3): soft-reset assert, mask, one timer tick, trigger, POWER_COMPLETE/POWER_ABORT poll, release, retry on abort; clock gating forced on when the host sets DISABLE_CLKGATING_EN;

  • the unit initialisation (MMU cache invalidation, SLC bypass from the size in 0x3970, ORed writes, core indices) and the host’s register overrides (reg_cfg, PWR_ON group);

  • the HWR reset: per core, up to 3 attempts, bus quiesce, soft reset (0xFFEFFFF8F3FFFC1D plus the extra bits), unit initialisation, post-HWR TPU reset and SLC flush; a failure asks the host for a GPU restart (FWCCB REQUEST_GPU_RESTART);

  • the per-job flush (per-core 0x0688 and SLC polls, the 3D-only 0x1470/0x1478, the wrapper barrier for every data master), the MMUCACHE order (SLC 0x10, MMU caches, 0x1348, each polled; a timeout returns POLL_FAILURE), POW_OFF (dusts down, SLC drained);

  • the kick admission test (scheduler.md 5: DISABLE_DM_OVERLAP, strict priority, PREVENT_CDM_OVERLAP, PREVENT_ALL_OVERLAP);

  • the TQ_3D launch order (0x0F00 before ISP_RENDER), the ISP_ZLS_END wait, USC_TRIGGER forwarded to the host, the multicore compute control, and no 0x0258 at the first geometry kick.

It builds; nothing of it has run on a K3 yet. Not resolved (open points at the end of its bvnc.h): the unit bits of the power request (the specification does not give the number of units: BVNC_POWER_UNITS_MASK is 0), the overalloc controls (0x4050, 0x06D8: no source for their values), and two places where its specification contradicts itself. Still single-core in the shared code (one core on the K3): the BIF catalogue index, the occlusion-query base and the compute resume are written for core 0 only.

For the BXE-2-32, moving the constants to bvnc.h left the firmware byte-identical. Moving the sequences to seq.c changes the image only by the calls between files: every object other than gpu_init.o, kick.o, hwr.o and geom.o is byte-identical, and the moved functions are the same source (the flush minus the BXM-only steps).

Note

Always pass -B when changing EXP=…, because make does not track macro changes. Verify that the build succeeded and that the .fw SHA-256 changed before deploying — a failed build leaves the previous .fw on disk (E023).

Compiler flags

-EL -march=mips32r2 -mmicromips -mabi=32 -msoft-float
-std=gnu23 -O2 -g -ffreestanding -fno-builtin -fno-pic -mno-abicalls -G0
-mlong-calls -fno-common -fno-stack-protector -fno-jump-tables
-fno-delete-null-pointer-checks -mno-check-zero-division
-Wall -Wextra -Werror -Wno-unused-parameter

Flag

Reason

-mmicromips

Target ISA of the MIPS wrapper core; Config3.ISAOnExc = 1 enters exceptions in microMIPS mode, and function pointers carry bit 0 (ISA bit).

-mlong-calls

Code spans three distant regions (0x9FC02000, 0xBFC00000, 0xC0000000), so cross-region calls must go through jalr.

-G0 -fno-pic -mno-abicalls

Disables $gp-relative small data and PIC; the image links at fixed virtual addresses.

-fno-jump-tables

Prevents switch statements from emitting absolute-address tables in .rodata.

-msoft-float

The microcontroller has no FPU.

-std=gnu23

GNU C23: ISO C23 (nullptr, constexpr, static_assert, [[attributes]], typeof, __STDC_VERSION__ == 202311L) plus the GNU extensions the code uses (statement expressions, __asm__, register variables).

-fno-delete-null-pointer-checks

Without it, GCC at -O2 assumes a null pointer is never dereferenced and turns such paths into a teq trap (-fisolate-erroneous-paths-dereference). In this firmware a trap is a fatal exception, while address 0 merely faults through the TLB.

-mno-check-zero-division

Without it, GCC follows every division with a teq trap on a zero divisor. Every division in the firmware is already guarded.

The GNU toolchain since November 2026

Until November 2026 the firmware was built with clang and ld.lld. Moving to GCC and binutils removed two LLVM workarounds:

  • LLVM’s assembler accepts microMIPS mfc0 / mtc0 only for R6, so cp0asm.h encoded them by hand as .hword pairs. GNU as accepts them, and boot.S, vectors.S and mips.h now use the real instructions (the encodings are identical).

  • ld.lld range-checked microMIPS J/JAL relocations above 0x80000000 as if they were PC-relative, so the link needed --noinhibit-exec and tools/ld-wrap.sh to filter the false errors. GNU ld links without warnings.

The code GCC 16 generates is about 25 % smaller (.text 27 KiB instead of 36 KiB).

Compile-time experiment knobs (EXP=)

Passed via make -C src -B EXP="-DNAME[=value]":

Knob

Effect

EXP_NO_EVENT_POLL

Disable timer polling of EVENT_STATUS so completions come only from MTS IRQ tasks (E018)

EXP_SLC_FLUSH_PER_KICK

Flush and invalidate SLC before every TQ_3D kick (E020)

EXP_DM_FLUSH_PER_KICK

Run the full DM 3 cache flush before every TQ_3D kick (E026)

EXP_TIF=<n>

Override the TQ tiles-in-flight register value (E022)

EXP_SLC_ONLY_FLUSH

Use SLC-only completion flush instead of per-DM flush (E023)

EXP_NO_RENDER

Retire GEOM/FRAG/FRAG_PR commands without running them and ignore PM_OUT_OF_MEMORY (the behaviour before E041; rendering is on by default since then)

EXP_DUMP_RENDER

Dump host GEOM/FRAG render structures to debug trace (E027)

EXP_SHARED_PB

Shared free lists between the PM contexts (CONTEXT_PB_BASE = 0, no reload) when PM context 1 holds the same free lists; off by default since it hung the board in E040 (it no longer does in E042, but does not fix Q29b either)

EXP_PR_FULL_INVAL

Full PM-MMU invalidation (SLC, BIF, PM TLB) in the restart after a partial render, as the spec reads; it hung the board in E043, so the default writes 0x1348 only (Q30)

The knobs of the PM bring-up (E028–E040: EXP_TA, EXP_CANARY, EXP_HS_MODE, EXP_PM_*, EXP_CLK_ON, EXP_SP32, EXP_20F8_EDGE, EXP_0388, EXP_RESUME (E042), EXP_TOP_FIRST, EXP_F320, EXP_UNIT_EXTRA, EXP_IDX_AFTER, EXP_NO_FL_LOAD, EXP_*_SP_CMD*, EXP_FLAGS_AFTER_SP, EXP_FRAG_*, EXP_MTILE_STRIDE, EXP_FRAG_DUMP) were removed in E041, when the working sequence became the code. The experiment pages describe what each one did.

Test harness

tools/deploy.sh testGpuFwVulkan builds the testGpuFwVulkan Vulkan harness (repository ../testGpuFwVulkan) on the board; see Test harness: testGpuFwVulkan.

Build-time checks

  • tools/check-trace-args.py runs before every link: each TRACE(SFID_x, …) must pass the argument count of its format string (the cr_poll32 trace bug of E037).

  • tools/fw-preflight.py checks the .fw container (board-testing-oracle section 2); tools/deploy.sh fw refuses to copy a file that fails it.

Trace ID generation

src/include/sfid.h is generated by tools/gen_sfids.py from the public Linux header pvr_rogue_fwif_sf.h. Each entry becomes #define SFID_<GROUP>_<id> 0x7nngiiii, under a documentation comment that holds its format string and parameter count, allowing mainline pvr_fw_trace.c to decode this firmware’s traces without changes.