Environment Patches
scripts/patch_openpiton.sh applies nineteen numbered fixes to an OpenPiton checkout and adds one unit-test environment. The fixes edit files in the checkout because some settings have no other hook. The boot ROM Makefile, for example, sets its compiler flags with plain = assignments, which neither the environment nor a sims flag can override.
Running the script
bash scripts/patch_openpiton.sh /path/to/openpiton
PITON_ROOT=/path/to/openpiton bash scripts/patch_openpiton.sh
Run it once per checkout, on every worker that hosts one. The GCP worker in cluster/local.yaml runs it from worker_setup_commands. The script needs bash, git, python3, and GNU grep and sed. It exits with status 2 when no root is given or the root has no piton/ directory. It exits with status 1 when the boot ROM Makefile is missing, when a text block or anchor it edits does not appear exactly once, or when fix 5 finds a half-applied guard.
The script is idempotent. Each fix checks whether its change is already present and, if so, skips it with a message such as already patched: <path>. Fixes 5 to 19 skip with a not found, skipping fix N message when their target file is absent. Fix 14 also skips when scripts/openpiton_generic/ is not beside the script.
PATCH_SKIP names fixes to leave out, as space-separated numbers, and the script prints skipped fix N (PATCH_SKIP) for each. A checkout patched with PATCH_SKIP="11" has every fix but 11, so the failure fix 11 addresses comes back; the evaluation’s reverted-fix runs prepare their checkouts this way.
Fix 9 edits the make line that fix 8 writes, so PATCH_SKIP="8" on an unpatched checkout makes fix 9 fail and the script exit 1.
PATCH_SKIP="11" bash scripts/patch_openpiton.sh /path/to/openpiton
The script’s edits change the checkout’s source fingerprint, so a model built before the script ran is rebuilt on its next build() (see OpenPitonWorkspaceNode).
Fixes
# |
File(s) touched |
What it fixes |
|---|---|---|
1 |
|
binutils 2.38 and later split |
2 |
Same |
GCC 15 and later default to C23, where |
3 |
Git-tracked symlinks across the checkout |
A Windows-mounted checkout defaults to |
4 |
Every |
A shebang line that ends in CRLF makes |
5 |
|
The Verilator C++ driver never calls the coverage-write API, so a coverage build writes no |
6 |
|
PicoRV32’s internal |
7 |
|
The |
8 |
|
The Verilator build and run paths hardcode |
9 |
|
The Verilator build runs a bare |
10 |
|
Under Verilator, |
11 |
|
The exit barrier polls |
12 |
|
CVA6’s Verilator instruction tracer always opens |
13 |
|
Under Verilator 5, CVA6’s L1.5 adapter sometimes drops cache invalidations, so an L1D keeps stale lines and a plain load misses another tile’s update; Ariane (CVA6) describes the cause. Moves the adapter’s four |
14 |
Creates |
Installs the Generic Tile files from |
15 |
|
Adds |
16 |
|
Adds an |
17 |
|
Adds |
18 |
|
|
19 |
|
Builds a C diag with the generic test environment’s runtime ( |
Fixes 3 and 4 address checkouts on a Windows-mounted path, such as /mnt/c under WSL. Fixes 14 to 17 change nothing for the other cores: every edit sits behind PITON_GENERIC, FLIST_GENERIC, RTL_GENERIC<n>, or -generic. Fix 19 changes only how rv32_as builds a C diag and where mem.image starts.
The pico_reset_ut environment
The script also adds pico_reset_ut, a unit-test environment for fix 6. It creates piton/verif/env/pico_reset_ut/ with pico_reset_ut_top.v, pico_reset_ut.flist, and an empty test_cases/. It writes piton/tools/src/sims/pico_reset_ut.config and appends #include "pico_reset_ut.config" to piton/tools/src/sims/sims.config. The testbench ties pico_int to 0 and checks that picorv32 raises mem_valid with mem_addr at PROGADDR_RESET after reset.
The environment builds under Verilator, using fix 8. Running it, or any other non-manycore testbench such as OpenPiton’s ifu_esl_lfsr, stops with Verilator’s Settle region did not converge error. The cause is three macros in the shared piton/verif/env/test_infrstrct/test_infrstrct.v harness that place delays inside always @* blocks.
Tests
chia_openpiton/test/test_patch_openpiton.py runs the script against a small synthetic tree: a git repository with the boot ROM Makefile, picorv32.v, pc_cmp.v.pyv, syscalls.c, cva6.sv, and wt_l15_adapter.sv. It checks that fixes 6, 7, 10, 11, 12, and 13 replace their exact text blocks, that a second run changes nothing and reports already patched, and that PATCH_SKIP leaves the named fixes out. A second tree with the text fixes 15 to 17 anchor on checks the generic tile’s fixes the same way, and that fix 14 installs every file and keeps a descriptor’s Flist.core. The test holds its own copy of each original and replacement block, so an edit to the script’s blocks fails the test. It cannot detect changes in upstream OpenPiton.
chia_openpiton/test/test_patch_openpiton_fix19.py checks fix 19 the same way on a copy of the whole upstream rv32_as (fixtures/rv32_as_upstream.sh). It runs the patched script with stub compiler tools, and with the installed riscv64-unknown-elf-gcc on every C program the generic ladder uses, for rv32i, rv32im, rv32ima, and rv32imc.
pytest chia_openpiton/test/test_patch_openpiton.py -q