@@ -9,50 +9,107 @@ interrupt controller). Console input is not currently supported.
9932-bit OS boots require a workaround for the 64-bit HTIF interface,
1010which is currently not supported.
1111
12- OS boots use device-tree binary blobs generated by the ` dtc ` compiler,
13- installable on Ubuntu and Debian machines with
12+ ## Build your own ELF
1413
15- ```
16- sudo apt install device-tree-compiler
14+ ``` bash
15+ make -C os-boot
1716```
1817
19- ## Booting Linux with the C backend
18+ This will generate ` os-boot/build/platform/generic/firmware/fw_payload.elf ` .
2019
21- The C model needs an ELF-version of the BBL (Berkeley-Boot-Loader)
22- that contains the Linux kernel as an embedded payload. It also needs
23- a DTB (device-tree blob) file describing the platform (say in the file
24- ` spike.dtb ` ). Once those are available (see below for suggestions),
25- the model should be run as:
20+ ### Boot ELF
2621
27- ```
28- $ ./c_emulator/riscv_sim_<arch> -t console.log -b spike.dtb bbl > execution-trace.log 2>&1 &
29- $ tail -f console.log
22+ ``` bash
23+ make sail
3024```
3125
32- The ` console.log ` file contains the console boot messages. For maximum
33- performance and benchmarking a model without any execution tracing is
34- available on the optimize branch (` git checkout optimize ` ) of this
35- repository. This currently requires the latest Sail built from source.
26+ Use ` tail -f /tmp/console.log ` to see the terminal log.
3627
37- ## Caveats for OS boot
28+ ### Results
3829
39- - Some OS toolchains generate obsolete LR/SC instructions with now
40- illegal combinations of ` .aq ` and ` .rl ` flags. You can work-around
41- this by changing ` riscv_mem.sail ` to accept these flags.
30+ ``` log
31+ [ariel@archlinux sail-riscv]$ cat /tmp/console.log
4232
43- - One needs to manually ensure that the DTB used for the C model
44- accurately describes the physical memory map implemented in the C
45- platform. This will not be needed once the C model can generate its
46- own DTB.
33+ OpenSBI v1.6
34+ ____ _____ ____ _____
35+ / __ \ / ____| _ \_ _|
36+ | | | |_ __ ___ _ __ | (___ | |_) || |
37+ | | | | '_ \ / _ \ '_ \ \___ \| _ < | |
38+ | |__| | |_) | __/ | | |____) | |_) || |_
39+ \____/| .__/ \___|_| |_|_____/|____/_____|
40+ | |
41+ |_|
4742
48- ## Sample Linux image
43+ Platform Name : ucbbar,spike-bare
44+ Platform Features : medeleg
45+ Platform HART Count : 1
46+ Platform IPI Device : aclint-mswi
47+ Platform Timer Device : aclint-mtimer @ 10000000Hz
48+ Platform Console Device : htif
49+ Platform HSM Device : ---
50+ Platform PMU Device : ---
51+ Platform Reboot Device : htif
52+ Platform Shutdown Device : htif
53+ Platform Suspend Device : ---
54+ Platform CPPC Device : ---
55+ Firmware Base : 0x80000000
56+ Firmware Size : 317 KB
57+ Firmware RW Offset : 0x40000
58+ Firmware RW Size : 61 KB
59+ Firmware Heap Offset : 0x46000
60+ Firmware Heap Size : 37 KB (total), 2 KB (reserved), 11 KB (used), 23 KB (free)
61+ Firmware Scratch Size : 4096 B (total), 392 B (used), 3704 B (free)
62+ Runtime SBI Version : 2.0
63+ Standard SBI Extensions : time,rfnc,ipi,base,hsm,srst,pmu,dbcn,legacy
64+ Experimental SBI Extensions : fwft,sse
4965
50- ` rv64-linux-4.15.0-gcc-7.2.0-64mb.bbl ` contains a sample Linux RV64
51- image that can be booted as follows, after first generating the
52- device-tree blob for a 64MB RV64 machine using ` dtc ` :
66+ Domain0 Name : root
67+ Domain0 Boot HART : 0
68+ Domain0 HARTs : 0*
69+ Domain0 Region00 : 0x0000000000000000-0x0000000000000fff M: (I,R,W) S/U: (R,W)
70+ Domain0 Region01 : 0x0000000080040000-0x000000008004ffff M: (R,W) S/U: ()
71+ Domain0 Region02 : 0x0000000002080000-0x00000000020bffff M: (I,R,W) S/U: ()
72+ Domain0 Region03 : 0x0000000080000000-0x000000008003ffff M: (R,X) S/U: ()
73+ Domain0 Region04 : 0x0000000002000000-0x000000000207ffff M: (I,R,W) S/U: ()
74+ Domain0 Region05 : 0x0000000000000000-0xffffffffffffffff M: () S/U: (R,W,X)
75+ Domain0 Next Address : 0x0000000080200000
76+ Domain0 Next Arg1 : 0x0000000082200000
77+ Domain0 Next Mode : S-mode
78+ Domain0 SysReset : yes
79+ Domain0 SysSuspend : yes
5380
54- ```
55- dtc < os-boot/rv64-64mb.dts > os-boot/rv64-64mb.dtb
56- ./c_emulator/riscv_sim_RV64 -b os-boot/rv64-64mb.dtb -t /tmp/console.log os-boot/rv64-linux-4.15.0-gcc-7.2.0-64mb.bbl > >(gzip -c > execution-trace.log.gz) 2>&1
57- tail -f /tmp/console.log
81+ Boot HART ID : 0
82+ Boot HART Domain : root
83+ Boot HART Priv Version : v1.12
84+ Boot HART Base ISA : rv64imafdcbv
85+ Boot HART ISA Extensions : sscofpmf,zicntr,zihpm,smcntrpmf,sdtrig
86+ Boot HART PMP Count : 16
87+ Boot HART PMP Granularity : 2 bits
88+ Boot HART PMP Address Bits : 54
89+ Boot HART MHPM Info : 29 (0xfffffff8)
90+ Boot HART Debug Triggers : 0 triggers
91+ Boot HART MIDELEG : 0x0000000000002222
92+ Boot HART MEDELEG : 0x000000000004b109
93+ [ 0.000000] Linux version 6.14.4 (ariel@archlinux) (riscv64-unknown-linux-gnu-gcc (g04696df09) 14.2.0, GNU ld (GNU Binutils) 2.44) #1 SMP Sat Apr 26 14:42:54 CST 2025
94+ [ 0.000000] Machine model: ucbbar,spike-bare
95+ [ 0.000000] SBI specification v2.0 detected
96+ [ 0.000000] SBI implementation ID=0x1 Version=0x10006
97+ [ 0.000000] SBI TIME extension detected
98+ [ 0.000000] SBI IPI extension detected
99+ [ 0.000000] SBI RFENCE extension detected
100+ [ 0.000000] SBI SRST extension detected
101+ [ 0.000000] SBI DBCN extension detected
102+ [ 0.000000] earlycon: sbi0 at I/O port 0x0 (options '')
103+ [ 0.000000] printk: legacy bootconsole [sbi0] enabled
104+ [ 0.000000] efi: UEFI not found.
105+ [ 0.000000] OF: reserved mem: 0x0000000080000000..0x000000008003ffff (256 KiB) nomap non-reusable mmode_resv1@80000000
106+ [ 0.000000] OF: reserved mem: 0x0000000080040000..0x000000008004ffff (64 KiB) nomap non-reusable mmode_resv0@80040000
107+ [ 0.000000] Zone ranges:
108+ [ 0.000000] DMA32 [mem 0x0000000080000000-0x00000000ffffffff]
109+ [ 0.000000] Normal empty
110+ [ 0.000000] Movable zone start for each node
111+ [ 0.000000] Early memory node ranges
112+ [ 0.000000] node 0: [mem 0x0000000080000000-0x000000008004ffff]
113+ [ 0.000000] node 0: [mem 0x0000000080050000-0x00000000ffffffff]
114+ [ 0.000000] Initmem setup node 0 [mem 0x0000000080000000-0x00000000ffffffff]
58115```
0 commit comments