Skip to content

buildroot: Add initial upstreamd buildroot support (sim with hypervisor)#5

Open
inochisa wants to merge 5 commits into
SpinalHDL:mainfrom
project-inochi:upstream-1
Open

buildroot: Add initial upstreamd buildroot support (sim with hypervisor)#5
inochisa wants to merge 5 commits into
SpinalHDL:mainfrom
project-inochi:upstream-1

Conversation

@inochisa
Copy link
Copy Markdown

Initial support for upstreamd buildroot for the NaxSim

Require PR (SpinalHDL/VexiiRiscv#120). Especially for commit project-inochi/VexiiRiscv@4d563ef (Which adding new method for GETC check).

@inochisa
Copy link
Copy Markdown
Author

Hi, @Dolu1990. Can you have a simple try. Now I only bumped the opensbi version. At least I can run the OpenSBI with the TestBench.

But there is a small problem for it:
The dts should also include:

riscv,isa-extensions = "i", "m", "a", "f", "d", "c", "zicntr", "zicsr", "zifencei", "zihpm";

This should be generated along with ISA_STR. But I have no idea about how it was produced.

@inochisa inochisa force-pushed the upstream-1 branch 2 times, most recently from 7c4cd82 to 515f940 Compare April 24, 2026 02:26
@inochisa
Copy link
Copy Markdown
Author

Hi, @Dolu1990. I have two problem for updating the buildroot:

  1. I have bump the GCC version, the GCC 10 is already a legacy option.
  2. Can the linux switch to the latest released selected by the buildroot instead of you tree.

@inochisa inochisa force-pushed the upstream-1 branch 3 times, most recently from 1d2bb4d to 2204243 Compare April 24, 2026 06:39
@Dolu1990
Copy link
Copy Markdown
Member

Hi, @Dolu1990. I have two problem for updating the buildroot:

  1. I have bump the GCC version, the GCC 10 is already a legacy option.
  2. Can the linux switch to the latest released selected by the buildroot instead of you tree.

Hi @inochisa
I'm ok with both, no problem. Just one thing is that it may break some of the linux build.
In particular, things like CONFIG_NONPORTABLE=y need to be added to the linux config into :

(i'm using as reference https://github.com/litex-hub/linux-on-litex-vexriscv/blob/1535a97970830072a8ea1cbdb81e03eb2fb25d77/buildroot/board/litex_vexriscv/linux.config#L5)

@inochisa
Copy link
Copy Markdown
Author

Hi, @Dolu1990. I have two problem for updating the buildroot:

  1. I have bump the GCC version, the GCC 10 is already a legacy option.
  2. Can the linux switch to the latest released selected by the buildroot instead of you tree.

Hi @inochisa I'm ok with both, no problem.

Great.

Just one thing is that it may break some of the linux build. In particular, things like CONFIG_NONPORTABLE=y need to be added to the linux config into :

* https://github.com/SpinalHDL/NaxSoftware/blob/main/buildroot/configs/naxriscv_sim_raw_defconfig

(i'm using as reference https://github.com/litex-hub/linux-on-litex-vexriscv/blob/1535a97970830072a8ea1cbdb81e03eb2fb25d77/buildroot/board/litex_vexriscv/linux.config#L5)

Although I think the portable build could be OK, it is fine for me to add the this option. I have updated the branch and add these necessary things.

@inochisa
Copy link
Copy Markdown
Author

Emmm, I have updated the build script and replace QEMU with kvmtool. The qemu is too big to use. With Qemu, the size of rootfs is more than 300MiB. XD.

@inochisa inochisa force-pushed the upstream-1 branch 2 times, most recently from af26502 to a25a1a4 Compare April 24, 2026 13:04
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
@inochisa
Copy link
Copy Markdown
Author

inochisa commented Apr 25, 2026

@Dolu1990, At least the lasted build can boot now. (I have forgot to set CONFIG_VIRTUALIZATION=y in this build, but this is fixed in the commit.)

Edit: Add full poweroff log

Command:

mill Test[].runMain vexiiriscv.tester.TestBench \
    --with-isa=g,c,h,zihpm,zicntr --xlen=64 \
    --pmp-size=4 \
    --fetch-l1 --fetch-l1-ways=2 --fetch-l1-ways=4 --fetch-l1-mem-data-width-min=64 \
    --lsu-l1 --lsu-l1-ways=2 --with-lsu-bypass --lsu-l1-ways=4 --lsu-l1-mem-data-width-min=64 --lsu-l1-coherency \
    --relaxed-branch --allow-bypass-from=0 \
    --print-stats \
    --fetch-l1-hardware-prefetch=nl --fetch-l1-refill-count=3 \
    --lsu-l1-store-buffer-slots=4 --lsu-l1-store-buffer-ops=32 \
    --fail-symbol=_start_hang --pass-symbol=spinal_do_poweroff_pass \
    --load-elf /mnt/chroots/buildroot-nax/images/fw_payload.elf \
    --load-bin 0x81000000,/mnt/chroots/buildroot-nax/images/rootfs.cpio

Running log:

WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by scala.runtime.LazyVals$ (file:/usr/bin/mill)
WARNING: Please consider reporting this to the maintainers of class scala.runtime.LazyVals$
WARNING: sun.misc.Unsafe::objectFieldOffset will be removed in a future release
Mill version 1.1.5 is different than configured for this directory!
Configured version is 1.1.0 (/mnt/files/inochi/cache/fpga/VexiiRiscv/.mill-version)
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by mill.launcher.JLineNativeLoader$ in an unnamed module (file:/usr/bin/mill)
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
WARNING: Restricted methods will be blocked in a future release unless native access is enabled

395] Test.2_12_18.runMain
[Warning] RVLS not detected
With Vexiiriscv parm :
 - rv64imafdhcsu_d1At1_l1_disAt1_rfsDp_fl1xW4xS64Dwm64_lsul1xW4xS64xBpSb4w32dw64rc1wc1Co_bp0_ab_rbra_rsrc_pc0_d2Area
[Runtime] SpinalHDL dev    git head : 9a6541c0cd0d712f6c58d11634f4b615483582ff
[Runtime] JVM max memory : 30208.0MiB
[Runtime] Current date : 2026.04.25 06:22:09
[Progress] at 0.000 : Elaborate components
[Progress] at 2.707 : Checks and transforms
[Progress] at 3.672 : Generate Verilog to ./simWorkspace/tmp/job_1
[Warning] toplevel/LsuL1Plugin_logic_bus_toTilelink_coherent_onC_rspFifo/logic_ram : Mem[2*41 bits].readAsync can only be write first into Verilog
[Warning] toplevel/FetchL1Plugin_logic_translationStorage_logic_sl_0_ways_0 : Mem[32*48 bits].readAsync can only be write first into Verilog
[Warning] toplevel/FetchL1Plugin_logic_translationStorage_logic_sl_0_ways_1 : Mem[32*48 bits].readAsync can only be write first into Verilog
[Warning] toplevel/FetchL1Plugin_logic_translationStorage_logic_sl_1_ways_0 : Mem[32*30 bits].readAsync can only be write first into Verilog
[Warning] toplevel/LsuPlugin_logic_translationStorage_logic_sl_0_ways_0 : Mem[32*48 bits].readAsync can only be write first into Verilog
[Warning] toplevel/LsuPlugin_logic_translationStorage_logic_sl_0_ways_1 : Mem[32*48 bits].readAsync can only be write first into Verilog
[Warning] toplevel/LsuPlugin_logic_translationStorage_logic_sl_0_ways_2 : Mem[32*48 bits].readAsync can only be write first into Verilog
[Warning] toplevel/LsuPlugin_logic_translationStorage_logic_sl_1_ways_0 : Mem[32*30 bits].readAsync can only be write first into Verilog
[Warning] toplevel/FetchL1Plugin_logic_shadowTranslationStorage_logic_sl_0_ways_0 : Mem[32*46 bits].readAsync can only be write first into Verilog
[Warning] toplevel/FetchL1Plugin_logic_shadowTranslationStorage_logic_sl_0_ways_1 : Mem[32*46 bits].readAsync can only be write first into Verilog
[Warning] toplevel/FetchL1Plugin_logic_shadowTranslationStorage_logic_sl_1_ways_0 : Mem[32*28 bits].readAsync can only be write first into Verilog
[Warning] toplevel/LsuPlugin_logic_shadowTranslationStorage_logic_sl_0_ways_0 : Mem[32*46 bits].readAsync can only be write first into Verilog
[Warning] toplevel/LsuPlugin_logic_shadowTranslationStorage_logic_sl_0_ways_1 : Mem[32*46 bits].readAsync can only be write first into Verilog
[Warning] toplevel/LsuPlugin_logic_shadowTranslationStorage_logic_sl_0_ways_2 : Mem[32*46 bits].readAsync can only be write first into Verilog
[Warning] toplevel/LsuPlugin_logic_shadowTranslationStorage_logic_sl_1_ways_0 : Mem[32*28 bits].readAsync can only be write first into Verilog
[Warning] 1023 signals were pruned. You can call printPruned on the backend report to get more informations.
[Done] at 4.238
[Progress] Simulation workspace in /mnt/files/inochi/cache/fpga/VexiiRiscv/./simWorkspace/VexiiRiscv
[Progress] Verilator compilation started
[Progress] Verilator compilation done in 5719.578 ms
[Progress] Start VexiiRiscv test simulation with seed 2

OpenSBI v1.8
Build time: 2026-04-25 06:19:35 +0800
Build compiler: gcc version 15.2.0 (Buildroot 2026.02.1)
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name               : Generic
Platform Features           : medeleg
Platform HART Count         : 1
Platform HART Protection    : pmp
Platform IPI Device         : aclint-mswi
Platform Timer Device       : aclint-mtimer @ 100000000Hz
Platform Console Device     : spinal
Platform HSM Device         : ---
Platform PMU Device         : ---
Platform Reboot Device      : spinal-poweroff
Platform Shutdown Device    : spinal-poweroff
Platform Suspend Device     : ---
Platform CPPC Device        : ---
Firmware Base               : 0x80000000
Firmware Size               : 577 KB
Firmware RW Offset          : 0x80000
Firmware RW Size            : 65 KB
Firmware Heap Offset        : 0x87000
Firmware Heap Size          : 37 KB (total), 0 KB (reserved), 12 KB (used), 24 KB (free)
Firmware Scratch Size       : 4096 B (total), 408 B (used), 3688 B (free)
Runtime SBI Version         : 3.0
Standard SBI Extensions     : time,rfnc,ipi,base,hsm,srst,pmu,dbcn,fwft,legacy,sse
Experimental SBI Extensions : none

Domain0 Name                : root
Domain0 Boot HART           : 0
Domain0 HARTs               : 0*
Domain0 Region00            : 0x0000000080080000-0x000000008009ffff M: (F,R,W) S/U: ()
Domain0 Region01            : 0x0000000080000000-0x000000008007ffff M: (F,R,X) S/U: ()
Domain0 Region02            : 0x0000000010010000-0x000000001001ffff M: (I,R,W) S/U: ()
Domain0 Region03            : 0x0000000000000000-0xffffffffffffffff M: () S/U: (R,W,X)
Domain0 Next Address        : 0x0000000080200000
Domain0 Next Arg1           : 0x0000000082200000
Domain0 Next Mode           : S-mode
Domain0 SysReset            : yes
Domain0 SysSuspend          : yes

Boot HART ID                : 0
Boot HART Domain            : root
Boot HART Priv Version      : v1.12
Boot HART Base ISA          : rv64imafdch
Boot HART ISA Extensions    : smaia,zicntr,sdtrig
Boot HART PMP Count         : 4
Boot HART PMP Granularity   : 12 bits
Boot HART PMP Address Bits  : 30
Boot HART MHPM Info         : 0 (0x00000000)
Boot HART Debug Triggers    : 0 triggers
Boot HART MIDELEG           : 0x0000000000001666
Boot HART MEDELEG           : 0x0000000000f0b509
[    0.000000] Booting Linux on hartid 0
[    0.000000] Linux version 6.19.12 (inochi@inochi.infowork) (riscv64-buildroot-linux-gnu-gcc.br_real (Buildroot 2026.02.1) 15.2.0, GNU ld (GNU Binutils) 2.44) #1 SMP Sat Apr 25 06:17:37 CST 2026
[    0.000000] Machine model: spinal,vexiiriscv
[    0.000000] SBI specification v3.0 detected
[    0.000000] SBI implementation ID=0x1 Version=0x10008
[    0.000000] SBI TIME extension detected
[    0.000000] SBI IPI extension detected
[    0.000000] SBI RFENCE extension detected
[    0.000000] SBI SRST extension detected
[    0.000000] SBI DBCN extension detected
[    0.000000] SBI FWFT extension detected
[    0.000000] earlycon: sbi0 at I/O port 0x0 (options '')
[    0.000000] printk: legacy bootconsole [sbi0] enabled
[    0.000000] OF: reserved mem: 0x0000000080000000..0x000000008007ffff (512 KiB) nomap non-reusable mmode_resv1@80000000
[    0.000000] OF: reserved mem: 0x0000000080080000..0x000000008009ffff (128 KiB) nomap non-reusable mmode_resv0@80080000
[    0.000000] Zone ranges:
[    0.000000]   DMA32    [mem 0x0000000080000000-0x00000000bfffffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000080000000-0x000000008009ffff]
[    0.000000]   node   0: [mem 0x00000000800a0000-0x00000000bfffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000080000000-0x00000000bfffffff]
[    0.000000] SBI HSM extension detected
[    0.000000] riscv: base ISA extensions acdfhim
[    0.000000] riscv: ELF capabilities acdfim
[    0.000000] Ticket spinlock: enabled
[    0.000000] percpu: Embedded 14 pages/cpu s28056 r0 d29288 u57344
[    0.000000] Kernel command line: rootwait console=hvc0 earlycon=sbi root=/dev/ram0 init=/sbin/init
[    0.000000] printk: log buffer data + meta data: 131072 + 458752 = 589824 bytes
[    0.000000] Dentry cache hash table entries: 131072 (order: 8, 1048576 bytes, linear)
[    0.000000] Inode-cache hash table entries: 65536 (order: 7, 524288 bytes, linear)
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 262144
[    0.000000] mem auto-init: stack:all(zero), heap alloc:off, heap free:off
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000] rcu: 	RCU restricting CPUs from NR_CPUS=64 to nr_cpu_ids=1.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
[    0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[    0.000000] riscv-intc: 64 local interrupts mapped
[    0.000000] riscv: providing IPIs using SBI IPI extension
[    0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention.
[    0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x171024e7e0, max_idle_ns: 440795205315 ns
[    0.000008] sched_clock: 64 bits at 100MHz, resolution 10ns, wraps every 4398046511100ns
[    0.001957] Console: colour dummy device 80x25
[    0.002481] Calibrating delay loop (skipped), value calculated using timer frequency.. 200.00 BogoMIPS (lpj=400000)
[    0.003041] pid_max: default: 32768 minimum: 301
[    0.005656] Mount-cache hash table entries: 2048 (order: 2, 16384 bytes, linear)
[    0.006188] Mountpoint-cache hash table entries: 2048 (order: 2, 16384 bytes, linear)
[    0.026779] riscv: ELF compat mode unsupported
[    0.026889] ASID allocator disabled (0 bits)
[    0.028913] rcu: Hierarchical SRCU implementation.
[    0.029220] rcu: 	Max phase no-delay instances is 1000.
[    0.035698] smp: Bringing up secondary CPUs ...
[    0.036080] smp: Brought up 1 node, 1 CPU
[    0.037546] Memory: 1012020K/1048576K available (4802K kernel code, 710K rwdata, 1029K rodata, 300K init, 268K bss, 33960K reserved, 0K cma-reserved)
[    0.042278] devtmpfs: initialized
[    0.057841] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.058632] posixtimers hash table entries: 512 (order: 1, 8192 bytes, linear)
[    0.059221] futex hash table entries: 256 (16384 bytes on 1 NUMA nodes, total 16 KiB, linear).
[    0.069638] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[    0.073850] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
[    0.077045] SBI misaligned access exception delegation ok
[    0.202442] cpu0: Ratio of byte access time to unaligned word access is 0.00, unaligned accesses are slow
[    0.219677] iommu: Default domain type: Translated
[    0.219997] iommu: DMA domain TLB invalidation policy: strict mode
[    0.221491] pps_core: LinuxPPS API ver. 1 registered
[    0.221806] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.222406] PTP clock support registered
[    0.232126] clocksource: Switched to clocksource riscv_clocksource
[    0.343935] NET: Registered PF_INET protocol family
[    0.346972] IP idents hash table entries: 16384 (order: 5, 131072 bytes, linear)
[    0.377899] tcp_listen_portaddr_hash hash table entries: 512 (order: 1, 8192 bytes, linear)
[    0.378536] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.379021] TCP established hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.381647] TCP bind hash table entries: 8192 (order: 6, 262144 bytes, linear)
[    0.385440] TCP: Hash tables configured (established 8192 bind 8192)
[    0.386726] UDP hash table entries: 512 (order: 3, 32768 bytes, linear)
[    0.387702] UDP-Lite hash table entries: 512 (order: 3, 32768 bytes, linear)
[    0.399853] Unpacking initramfs...
[    0.420631] workingset: timestamp_bits=62 max_order=18 bucket_order=0
[    0.425037] io scheduler mq-deadline registered
[    0.425359] io scheduler kyber registered
[    1.141123] Initramfs unpacking failed: invalid magic at start of compressed archive
[    1.206624] Freeing initrd memory: 8192K
[    1.518182] printk: legacy console [hvc0] enabled
[    1.518182] printk: legacy console [hvc0] enabled
[    1.518848] printk: legacy bootconsole [sbi0] disabled
[    1.518848] printk: legacy bootconsole [sbi0] disabled
[    1.531996] NET: Registered PF_INET6 protocol family
[    1.544871] Segment Routing with IPv6
[    1.546023] In-situ OAM (IOAM) with IPv6
[    1.547558] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[    1.555805] NET: Registered PF_PACKET protocol family
[    1.699221] clk: Disabling unused clocks
[    1.705448] Freeing unused kernel image (initmem) memory: 296K
[    1.705992] Kernel memory protection not selected by kernel config.
[    1.706600] Run /init as init process
Saving 256 bits of non-creditable seed for next boot
Starting syslogd: OK
Starting klogd: OK
Running sysctl: OK
Starting network: OK
Starting crond: OK
crond[77]: crond (busybox 1.37.0) started, log level 8


Welcome to Buildroot
buildroot login: root
root
           _  _                     ___      _
    o O O | \| |   __ _    __ __   | _ \    (_)     ___     __     __ __
   o      | .` |  / _` |   \ \ /   |   /    | |    (_-<    / _|    \ V /
  TS__[O] |_|\_|  \__,_|   /_\_\   |_|_\   _|_|_   /__/_   \__|_   _\_/_
 {======|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|
./o--000'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'
login[78]: root login on 'console'
root@buildroot:~# poweroff
poweroff
root@buildroot:~# Stopping crond: stopped /usr/sbin/crond (pid 77)
OK
Stopping network: OK
Stopping klogd: stopped /sbin/klogd (pid 55)
OK
Stopping syslogd: no /sbin/syslogd found; none killed
FAIL
Seeding 256 bits without crediting
Saving 256 bits of non-creditable seed for next boot
umount: devtmpfs busy - remounted read-only
The system is going down NOW!
Sent SIGTERM to all processes
Sent SIGKILL to all processes
Requesting system poweroff
[    7.334183] reboot: Power down
### Stats ###
kind :  miss / times     miss  taken
J/B  : 21602643 / 38440842  56.1%  56.1%
  B  : 10522379 / 27360578  38.4%  38.4%
Dispatch  0   : 390516970 / 813880205  47.9%
Dispatch  1   : 423363234 / 813880205  52.0%
Candidate 0   : 390516970 / 813880205  47.9%
Candidate 1   : 423363234 / 813880205  52.0%
Dispatch halt : 105905225 / 813880205  13.0%
Execute  halt : 7871537 / 813880205   0.9%
IPC           : 242091109 / 813880205  29.7%

[Done] Simulation done in 22634423.765 ms
395/395, SUCCESS] mill Test[].runMain vexiiriscv.tester.TestBench --with-isa=g,c,h,zihpm,zicntr --xlen=64 --pmp-size=4 ...ildroot-nax/images/fw_payload.elf --load-bin 0x81000000,/mnt/chroots/buildroot-nax/images/rootfs.cpio 22647s

ranges;

serial0: serial@10000000 {
compatible = "spinal,vexiiriscv-uart";
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.

Why not relying on the opensbi terminal instead (hvc0) ?
I mean that, as a way to reduce dependencies on custom drivers ^^

Copy link
Copy Markdown
Author

@inochisa inochisa May 9, 2026

Choose a reason for hiding this comment

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

The kernel does rely on the HVC, this node is for OpenSBI. As OpenSBI take this node so it can go with generic platform.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

And if you check my log in detail, you can just find even the kernel is produced by buildroot, almost everything is upstream thing (except OpenSBI) ^^

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.

2 participants