Skip to content

feat(dts): generate device trees at build time with nemu_board - #71

Merged
rezado merged 14 commits into
mainfrom
feat-dts-gen
Sep 15, 2026
Merged

rezado merged 14 commits into
mainfrom
feat-dts-gen

Conversation

@rezado

@rezado rezado commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR replaces the built-in checked-in DTS template set with a profile-based
generation flow for workload-builder firmware.

Main changes:

  • Add a canonical DTS generator under dts/.
  • Generate built-in workload-builder DTS templates into
    build/generated-dts during the build.
  • Consolidate FPGA noAIA, QEMU, and NEMU profile rendering.
  • Add profile data for memory size, ISA extensions, legacy ISA declarations,
    and Kunminghu V2/V3 configurations.
  • Expose DTS_ISA_CONFIG=kunminghu-v2|kunminghu-v3 for generated FPGA noAIA
    profiles.
  • Keep legacy riscv,isa and structured riscv,isa-extensions declarations
    consistent.
  • Restore explicit support for custom templates from
    dts/<name>.dts.in.
  • Track generator sources, profile data, and selected custom templates in the
    relevant Make dependencies.
  • Include the ISA selector in firmware/DTS rebuild identities to prevent stale
    firmware reuse.
  • Remove obsolete checked-in built-in DTS templates and the old multihart DTS
    transformation script.
  • Remove obsolete standalone DTS build helper scripts.
  • Update workload and DTS documentation to describe the new generation flow.

DTS profiles

The generator supports the following profile families:

  • FPGA noAIA
  • QEMU nemu
  • NEMU UARTLite

The basename continues to select board type, hart count, memory profile, and
vector mode. For generated FPGA noAIA profiles, DTS_ISA_CONFIG selects the
Kunminghu ISA declaration:

  • kunminghu-v3 is the default.
  • kunminghu-v2 selects the existing V2 declaration.

QEMU multi-hart profiles generate the required CPU, CLINT, PLIC, debug, UART,
and checkpoint-reservation nodes. The generated DTS uses the selected memory
capacity and validates the fixed firmware address contract.

Custom DTS templates

Built-in names are always regenerated from the profile generator.

For an unsupported basename, the build accepts a matching custom template:

dts/<name>.dts.in

rezado and others added 6 commits September 10, 2026 17:28
Generate the firmware device tree from nemu_board's DTS generator instead of
keeping one .dts.in per board, memory size and hart count under dts/.

scripts/generate-nemu-board-dts.py maps a DEFAULT_DTB basename to a nemu_board
profile and writes the template into build/generated-dts. Hart count, memory
size and the -novec suffix keep coming from the basename. Recognized basenames
are always regenerated, so they cannot go stale; an unsupported basename is
read from dts/<name>.dts.in, which keeps custom templates in the tracked tree
rather than in the build directory.

Firmware assembly, OpenSBI and LibCheckpointAlpha all consume that same
generated template, and the Make dependencies now track the generator, the
profile data and the selected custom template.
Single-hart images kept the device tree at 1.75 MiB while multi-hart images
placed it at 2 MiB, so the two layouts had to be described separately and
OpenSBI's FDT address differed per image type.

Move the single-hart device tree to 2 MiB so both layouts agree, and move the
single-hart kernel to the next 2 MiB-aligned address at 4 MiB so the two
cannot overlap. The OpenSBI jump and FDT addresses, the packer offsets and the
exported manifest follow the same addresses.
The generated xiangshan-fpga-noAIA profiles can describe either Kunminghu V2
or V3 hardware, but the build had no way to choose between them.

Add DTS_ISA_CONFIG, accepting kunminghu-v2 and kunminghu-v3 with kunminghu-v3
as the default, and pass it to the generator. Only the FPGA noAIA profiles
consume it; QEMU/NEMU profiles and supplied custom templates are unchanged,
and a non-default value for a profile that does not support it is rejected.

Include the selector in every firmware and DTS configuration stamp so
switching versions cannot silently reuse the previous firmware. The superseded
scripts/generate-xiangshan-multihart-dts.py and its documentation section are
removed here, since that section is replaced by the DTS_ISA_CONFIG notes.
Pick up the nemu_board commit that documents the generated rng-seed bytes
with their ASCII reading, matching the checked-in dts/*.dts.in templates.
Record the upstream source and GitHub authors in the README.
@rezado
rezado requested a review from poemonsense September 11, 2026 06:31
Comment thread dts/workload-builder-profiles.json Outdated
@@ -0,0 +1,226 @@
{
"fpga-noaia-novec": {
"source": "https://github.com/OpenXiangShan/workload-builder/blob/aaf4d8bd7d2da5351fc2640c8d61c9d849d69342/dts/xiangshan-fpga-noAIA-novec.dts.in",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this source for

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It record the source of this dts config, but it is not used for generating.

rezado and others added 4 commits September 12, 2026 20:16
Share profile rendering between the DTS entry points and keep legacy and structured ISA declarations consistent. Restore explicit custom template handling and track those templates as firmware build dependencies.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Some generated profiles have incorrect or missing hardware declarations, and SPECjbb lacks a required rebuild dependency.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Replaces checked-in DTS templates with build-time, profile-driven generation and updates firmware workflows accordingly.

Changes:

  • Adds canonical DTS generators, profile data, ISA selection, and custom-template fallback.
  • Rewires firmware builds and rebuild identities to use generated templates.
  • Removes obsolete templates/scripts and updates documentation.
File summaries
File Description
Makefile Integrates generated DTS profiles and ISA selection.
README.md Documents the generation workflow.
scripts/dts-config.sh Adds build-time template generation.
scripts/build-sbi.sh Uses generated DTS templates.
scripts/build-gcpt.sh Generates DTS before GCPT configuration.
scripts/build-firmware-linux.sh Generates the selected firmware template.
scripts/generate-xiangshan-multihart-dts.py Removes obsolete transformation script.
dts/DTSGen.py Adds the foundational DTS renderer.
dts/generate-nemu-board-dts.py Adds basename/profile-driven generation.
dts/generate-workload-builder-dts.py Adds the profile-oriented CLI.
dts/workload-builder-profiles.json Defines memory and ISA profiles.
dts/README.md Documents generator usage and profiles.
dts/xiangshan.dts.in Removes generated built-in template.
dts/yanqihu.dts.in Removes generated built-in template.
dts/yanqihu-2core.dts.in Removes generated built-in template.
dts/nutshell.dts.in Removes generated built-in template.
dts/spike.dts.in Removes generated built-in template.
dts/spike-2core.dts.in Removes generated built-in template.
dts/xiangshan-qemu-nemu-mem2g.dts.in Removes generated QEMU template.
dts/xiangshan-qemu-nemu-mem8g.dts.in Removes generated QEMU template.
dts/xiangshan-qemu-nemu-mem24g.dts.in Removes generated QEMU template.
dts/xiangshan-fpga-noAIA.dts.in Removes generated FPGA template.
dts/xiangshan-fpga-noAIA-novec.dts.in Removes generated no-vector template.
dts/xiangshan-fpga-noAIA-mem8g.dts.in Removes generated 8 GiB template.
dts/xiangshan-fpga-noAIA-mem8g-novec.dts.in Removes generated 8 GiB no-vector template.
dts/xiangshan-fpga-noAIA-mem24g.dts.in Removes generated 24 GiB template.
dts/xiangshan-fpga-noAIA-mem24g-novec.dts.in Removes generated 24 GiB no-vector template.
dts/xiangshan-fpga-noAIA-mem64g.dts.in Removes generated 64 GiB template.
dts/xiangshan-fpga-noAIA-mem64g-novec.dts.in Removes generated 64 GiB no-vector template.
dts/xiangshan-fpga-noAIA-mem16g-novec.dts.in Removes generated 16 GiB template.
dts/xiangshan-fpga-noAIA-mem128g-novec.dts.in Removes generated 128 GiB template.
dts/xiangshan-fpga-noAIA-2hart-mem8g-novec.dts.in Removes generated two-hart template.
dts/xiangshan-fpga-noAIA-2hart-mem16g-novec.dts.in Removes generated two-hart template.
dts/xiangshan-fpga-AIA-mem16g.dts.in Removes generated AIA template.
workloads/linux/specjbb2015/rules.mk Tracks generator inputs and firmware identity.
workloads/linux/spec2026/rules.mk Uses generated templates and ISA-aware stamps.
workloads/linux/spec2026/README.md Updates generated-template paths.
workloads/linux/spec2017/rules.mk Uses generated templates and ISA-aware stamps.
workloads/linux/spec2017/README.md Updates generated-template paths.
workloads/linux/spec2006/rules.mk Uses generated templates and ISA-aware identity.
workloads/linux/spec2006/README.md Documents generated profile selection.
workloads/linux/rocksdb/rules.mk Uses generated DTS inputs and stamps.
workloads/linux/gapbs/rules.mk Uses generated DTS inputs and stamps.
workloads/linux/geekbench-common.mk Generates Geekbench firmware templates.
workloads/linux/geekbench5/README.md Documents generated default profile.
workloads/linux/geekbench6/README.md Documents generated default profile.
Review details
  • Files reviewed: 47/47 changed files
  • Comments generated: 5
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread dts/generate-nemu-board-dts.py
Comment thread dts/generate-nemu-board-dts.py
Comment thread dts/generate-nemu-board-dts.py
Comment thread workloads/linux/specjbb2015/rules.mk Outdated
Comment thread dts/README.md Outdated
rezado and others added 3 commits September 15, 2026 14:39
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Removed unnecessary details about source URLs and streamlined the explanation of profile data storage.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@rezado
rezado merged commit 387b0e4 into main Sep 15, 2026
2 checks passed
@rezado
rezado deleted the feat-dts-gen branch September 15, 2026 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants