Skip to content

Commit 4f18ce9

Browse files
committed
Added support for nutshell.
- Switched to OpenSBI 1.5 for nutshell compatibility. - Added device tree for nutshell.
1 parent 2725836 commit 4f18ce9

6 files changed

Lines changed: 108 additions & 5 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ build/linux-workloads/$(1)/rootfs.cpio: $$(shell find $$(abspath workloads/linux
4747
bash scripts/build-workload-linux.sh workloads/linux/$(1) build/linux-workloads/$(1)
4848

4949
# Build all-in-one firmware
50-
build/linux-workloads/$(1)/fw_payload.bin: $(GCPT_BIN) dts/xiangshan.dts.in scripts/build-sbi.sh scripts/build-firmware-linux.sh build/linux-workloads/$(1)/rootfs.cpio $(LINUX_IMAGE) build/opensbi/build/platform/generic/firmware/fw_jump.bin
50+
build/linux-workloads/$(1)/fw_payload.bin: $$(shell find $$(abspath dts)) $(GCPT_BIN) dts/xiangshan.dts.in scripts/build-sbi.sh scripts/build-firmware-linux.sh build/linux-workloads/$(1)/rootfs.cpio $(LINUX_IMAGE) build/opensbi/build/platform/generic/firmware/fw_jump.bin
5151
CROSS_COMPILE="$$(abspath $(BUILDROOT_DIR)/output/host/bin)/riscv64-linux-" \
5252
DTC="$$(abspath $(BUILDROOT_DIR)/output/host/bin)/dtc" \
5353
bash scripts/build-firmware-linux.sh $(GCPT_BIN) build/opensbi dts $(LINUX_IMAGE) build/linux-workloads/$(1)

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ You can also build a single workload with:
2424
- `make linux/workload_name` for a Linux workload.
2525
- `make am/workload_name` for an AM workload.
2626

27+
## Workload Compatibility
28+
29+
Not all workloads can run on all NEMU configurations. The only workload supported by `riscv64-nutshell_defconfig` is `linux/hello`, since all other workloads require hardware floating point, which is not supported by nutshell. RVV related workloads require the vector ISA extension, and hypervisor related workloads require the hypervisor ISA extension.
30+
2731
## Build Requirements
2832

2933
Any modern Linux distributions should be okay. The build system of this project is using the toolchain provided by buildroot, so you do not have to set up the toolchains manually to build most workloads. Some workloads require additional toolchians not provided by buildroot. Please refer to the README file of each workload (`README.md` in the workload directory) for details.
@@ -51,7 +55,7 @@ For Linux workloads, the image assumes that execution begins at `0x80000000`, an
5155
| 2.0 MiB | Linux kernel |
5256
| -- | initramfs containing workload |
5357

54-
The "default" device tree built into the image is `dt/xiangshan.dtb`. All the device tree files for different devices are placed under the `dt` directory. To replace the device tree, the following command can be used:
58+
Multiple device trees are built for each workload, each corresponds to a specific NEMU configuration. The device tree files are placed under the `dt` directory in the build output directory of that workload. The "default" device tree built into the image is `dt/xiangshan.dtb`. To replace the device tree, the following command can be used:
5559

5660
```shell
5761
dd conv=notrunc bs=1024 seek=1536 if=dt/some_device.dtb of=fw_payload.bin

bootloader/opensbi

Submodule opensbi updated 307 files

bootloader/opensbi.patch

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1+
diff --git a/Makefile b/Makefile
2+
index 7df39b4e..da6edd2f 100644
3+
--- a/Makefile
4+
+++ b/Makefile
5+
@@ -346,7 +346,7 @@ GENFLAGS += $(libsbiutils-genflags-y)
6+
GENFLAGS += $(platform-genflags-y)
7+
GENFLAGS += $(firmware-genflags-y)
8+
9+
-CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing
10+
+CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing -std=gnu11
11+
ifneq ($(DEBUG),)
12+
CFLAGS += -O0
13+
else
114
diff --git a/firmware/fw_base.S b/firmware/fw_base.S
2-
index 5300ecf2..878aedfd 100644
15+
index b950c0b8..c1422319 100644
316
--- a/firmware/fw_base.S
417
+++ b/firmware/fw_base.S
5-
@@ -129,9 +129,19 @@ _bss_zero:
18+
@@ -101,9 +101,19 @@ _bss_zero:
619
call fw_save_info
720
MOV_5R a0, s0, a1, s1, a2, s2, a3, s3, a4, s4
821

dts/REDAME.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ These parameters are replaced with the corresponding values when building the wo
1313

1414
- `xiangshan.dts.in`: This device tree template is for the `riscv64-xs_defconfig` NEMU configuration.
1515
- `yanqihu.dts.in`: This device tree template is for the `riscv64-yanqihu_defconfig` NEMU configuration.
16+
- `nutshell.dts.in`: This device tree template is for the `riscv64-nutshell_defconfig` NEMU configuration.

dts/nutshell.dts.in

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/dts-v1/;
2+
3+
/ {
4+
#address-cells = <0x02>;
5+
#size-cells = <0x02>;
6+
compatible = "freechips,rocketchip-unknown-dev";
7+
model = "xiangshan,xiangshan-kunminghu";
8+
9+
soc {
10+
#address-cells = <0x02>;
11+
#size-cells = <0x02>;
12+
compatible = "freechips,rocketchip-unknown-soc", "simple-bus";
13+
ranges;
14+
15+
clint@38000000 {
16+
compatible = "riscv,clint0";
17+
interrupts-extended = <0x01 0x03 0x01 0x07>;
18+
reg = <0x00 0x38000000 0x00 0x10000>;
19+
reg-names = "control";
20+
clock-frequency-mhz = <0x1f4>;
21+
};
22+
23+
serial@40600000 {
24+
compatible = "xilinx,uartlite", "xlnx,xps-uartlite-1.00.a";
25+
current-speed = <0x1c200>;
26+
reg = <0x00 0x40600000 0x00 0x1000>;
27+
reg-names = "control";
28+
};
29+
};
30+
31+
chosen {
32+
bootargs = "console=hvc0 earlycon=sbi";
33+
linux,initrd-start = <0x0 INITRAMFS_BEGIN>;
34+
linux,initrd-end = <0x0 INITRAMFS_END>;
35+
};
36+
37+
memory@100000000 {
38+
device_type = "memory";
39+
reg = <0x00 0x80000000 0x00 0x08000000>;
40+
phandle = <0x02>;
41+
};
42+
43+
aliases {
44+
serial0 = "/soc/serial@40600000";
45+
};
46+
47+
cpus {
48+
#address-cells = <0x01>;
49+
#size-cells = <0x00>;
50+
timebase-frequency = <0xf4240>;
51+
52+
cpu@0 {
53+
clock-frequency = <0x00>;
54+
compatible = "UCAS,COOSCA1.0", "riscv";
55+
d-cache-block-size = <0x40>;
56+
d-cache-sets = <0x40>;
57+
d-cache-size = <0x4000>;
58+
d-tlb-sets = <0x01>;
59+
d-tlb-size = <0x20>;
60+
device_type = "cpu";
61+
i-cache-block-size = <0x40>;
62+
i-cache-sets = <0x40>;
63+
i-cache-size = <0x4000>;
64+
i-tlb-sets = <0x01>;
65+
i-tlb-size = <0x20>;
66+
mmu-type = "riscv,sv39";
67+
next-level-cache = <0x02>;
68+
reg = <0x00>;
69+
riscv,isa = "rv64imafdc";
70+
riscv,isa-base = "rv64i";
71+
riscv,isa-extensions = "i", "m", "a", "c", "zicntr", "zicsr", "zifencei", "zihpm";
72+
status = "okay";
73+
timebase-frequency = <0xf4240>;
74+
tlb-split;
75+
76+
interrupt-controller {
77+
#address-cells = <0x02>;
78+
#interrupt-cells = <0x01>;
79+
compatible = "riscv,cpu-intc";
80+
interrupt-controller;
81+
phandle = <0x01>;
82+
};
83+
};
84+
};
85+
};

0 commit comments

Comments
 (0)