Skip to content

Commit 1c6ff4f

Browse files
committed
Start setting up buildroot
1 parent c9051a0 commit 1c6ff4f

File tree

24 files changed

+702
-5
lines changed

24 files changed

+702
-5
lines changed

.devcontainer/devcontainer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
"mounts": [
99
"type=volume,target=/workspaces/mlogv32/.venv",
10-
"type=volume,target=/commandhistory"
10+
"type=volume,target=/commandhistory",
11+
"type=volume,target=/home/vscode/buildroot"
1112
],
1213

1314
"postAttachCommand": {

.vscode/settings.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"files.associations": {
33
"*.s": "riscv",
44
"*.mlog.jinja": "mlog",
5-
"*.svd": "xml"
5+
"*.svd": "xml",
6+
"*_defconfig": "kconfig"
67
},
78
"[markdown]": {
89
"editor.formatOnSave": true,
@@ -22,5 +23,6 @@
2223
"ruff.lint.ignore": ["I"],
2324
"python.languageServer": "Pylance",
2425
"python.analysis.diagnosticMode": "workspace",
25-
"python.analysis.packageIndexDepths": [{ "name": "jinja2", "depth": 2 }]
26+
"python.analysis.packageIndexDepths": [{ "name": "jinja2", "depth": 2 }],
27+
"files.eol": "\n"
2628
}

console.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ else
88
fi
99

1010
{
11-
echo "{\"type\": \"serial\", \"device\": \"${DEVICE:=uart0}\", \"overrun\": false, \"direction\": \"${DIRECTION}\", \"disconnectOnHalt\": true}"
11+
echo "{\"type\": \"serial\", \"device\": \"${DEVICE:=uart0}\", \"overrun\": false, \"direction\": \"${DIRECTION}\", \"disconnectOnHalt\": ${DISCONNECT_ON_HALT:=true}}"
1212
cat
1313
} | netcat -v "${HOST:=localhost}" "${PORT:=5000}"
1414

linux/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
output/

linux/Makefile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
MAKEFLAGS += --no-builtin-rules
2+
.SUFFIXES:
3+
4+
THIS_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
5+
6+
BR2_EXTERNAL_SRC := $(THIS_DIR)/buildroot
7+
8+
BUILDROOT_RELEASE ?= https://buildroot.org/downloads/buildroot-2025.02.4.tar.gz
9+
10+
BUILDROOT ?= $(HOME)/buildroot
11+
BR2_EXTERNAL ?= $(HOME)/br2_external
12+
13+
MAKE_BUILDROOT = $(MAKE) -C $(BUILDROOT) BR2_EXTERNAL=$(BR2_EXTERNAL)
14+
15+
.DEFAULT_GOAL := all
16+
17+
.PHONY: setup-buildroot
18+
setup-buildroot:
19+
curl --location "$(BUILDROOT_RELEASE)" | tar xzv --directory $(BUILDROOT)
20+
21+
.PHONY: get-images
22+
get-images:
23+
rm -rf $(THIS_DIR)/output/images
24+
mkdir -p $(THIS_DIR)/output/images
25+
cp -r $(BUILDROOT)/output/images $(THIS_DIR)/output
26+
27+
# copy this directory to/from BR2_EXTERNAL to make buildroot run faster when this directory is in a Windows Docker volume
28+
%:
29+
ifeq ($(BR2_EXTERNAL_SRC),$(BR2_EXTERNAL))
30+
$(MAKE_BUILDROOT) $@
31+
else
32+
rsync --archive --delete $(BR2_EXTERNAL_SRC)/ $(BR2_EXTERNAL)
33+
-$(MAKE_BUILDROOT) $@
34+
cp -r --no-target-directory $(BR2_EXTERNAL) $(BR2_EXTERNAL_SRC)
35+
endif

linux/buildroot/Config.in

Whitespace-only changes.
1.63 KB
Binary file not shown.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/dts-v1/;
2+
3+
/ {
4+
#address-cells = <1>;
5+
#size-cells = <1>;
6+
model = "mlogv32";
7+
chassis-type = "embedded";
8+
9+
chosen {
10+
bootargs = "earlycon=sbi console=ttyS0";
11+
stdout-path = "/soc/serial@f0000010";
12+
};
13+
14+
memory@80000000 {
15+
device_type = "memory";
16+
reg = <0x80000000 (0x1000000 - 0x40000)>;
17+
};
18+
19+
cpus {
20+
#address-cells = <1>;
21+
#size-cells = <0>;
22+
timebase-frequency = <1000>;
23+
24+
cpu@0 {
25+
device_type = "cpu";
26+
compatible = "riscv";
27+
mmu-type = "riscv,sv32";
28+
reg = <0>;
29+
riscv,isa = "rv32ima";
30+
riscv,isa-base = "rv32i";
31+
riscv,isa-extensions = "i", "m", "a", "zicntr", "zicsr", "zifencei";
32+
};
33+
};
34+
35+
soc {
36+
#address-cells = <1>;
37+
#size-cells = <1>;
38+
compatible = "simple-bus";
39+
ranges;
40+
41+
uart0: serial@f0000010 {
42+
compatible = "ns16550a";
43+
reg = <0xf0000010 0x20>;
44+
clock-frequency = <10000000>;
45+
reg-shift = <2>;
46+
no-loopback-test = <1>;
47+
fifo-size = <253>;
48+
};
49+
50+
uart1: serial@f0000030 {
51+
compatible = "ns16550a";
52+
reg = <0xf0000030 0x20>;
53+
clock-frequency = <10000000>;
54+
reg-shift = <2>;
55+
no-loopback-test = <1>;
56+
fifo-size = <253>;
57+
};
58+
59+
uart2: serial@f0000050 {
60+
compatible = "ns16550a";
61+
reg = <0xf0000050 0x20>;
62+
clock-frequency = <10000000>;
63+
reg-shift = <2>;
64+
no-loopback-test = <1>;
65+
fifo-size = <253>;
66+
};
67+
68+
uart3: serial@f0000070 {
69+
compatible = "ns16550a";
70+
reg = <0xf0000070 0x20>;
71+
clock-frequency = <10000000>;
72+
reg-shift = <2>;
73+
no-loopback-test = <1>;
74+
fifo-size = <253>;
75+
};
76+
77+
syscon: syscon@fffffff0 {
78+
compatible = "syscon";
79+
reg = <0xfffffff0 0x4>;
80+
};
81+
82+
poweroff {
83+
compatible = "syscon-poweroff";
84+
regmap = <&syscon>;
85+
offset = <0x0>;
86+
value = <0x0>;
87+
};
88+
89+
reboot {
90+
compatible = "syscon-reboot";
91+
regmap = <&syscon>;
92+
offset = <0x0>;
93+
value = <0x1>;
94+
};
95+
};
96+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
CONFIG_BLK_DEV_INITRD=y
2+
CONFIG_INITRAMFS_SOURCE="${BR_BINARIES_DIR}/rootfs.cpio"
3+
CONFIG_NONPORTABLE=y
4+
CONFIG_ARCH_RV32I=y
5+
# CONFIG_RISCV_ISA_C is not set
6+
# CONFIG_RISCV_ISA_ZBA is not set
7+
# CONFIG_FPU is not set
8+
CONFIG_RISCV_EMULATED_UNALIGNED_ACCESS=y
9+
CONFIG_HZ_100=y
10+
CONFIG_XIP_KERNEL=y
11+
CONFIG_XIP_PHYS_ADDR=0x400000
12+
CONFIG_BUILTIN_DTB=y
13+
CONFIG_BUILTIN_DTB_NAME="mlogv32"
14+
# CONFIG_GCC_PLUGINS is not set
15+
CONFIG_SPARSEMEM_MANUAL=y
16+
CONFIG_DEVTMPFS=y
17+
CONFIG_DEVTMPFS_MOUNT=y
18+
# CONFIG_INPUT_MOUSE is not set
19+
CONFIG_SERIAL_8250=y
20+
CONFIG_SERIAL_8250_CONSOLE=y
21+
# CONFIG_HW_RANDOM is not set
22+
CONFIG_POWER_RESET=y
23+
CONFIG_POWER_RESET_SYSCON=y
24+
CONFIG_POWER_RESET_SYSCON_POWEROFF=y
25+
CONFIG_DUMMY_CONSOLE_COLUMNS=70
26+
CONFIG_DUMMY_CONSOLE_ROWS=38
27+
# CONFIG_HID_SUPPORT is not set
28+
# CONFIG_USB_SUPPORT is not set
29+
CONFIG_ROMFS_FS=y
30+
CONFIG_FRAME_WARN=2048
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.section .text.start
2+
.global _start
3+
_start:
4+
// initialize icache
5+
la t0, _etext
6+
.insn i CUSTOM_0, 0, zero, t0, 0
7+
8+
// copy payload to RAM
9+
la t0, _sipayload
10+
la t1, _spayload
11+
la t2, _epayload
12+
1:
13+
lw t3, 0(t0)
14+
sw t3, 0(t1)
15+
addi t0, t0, 4
16+
addi t1, t1, 4
17+
bltu t1, t2, 1b
18+
19+
// hartid
20+
li a0, 0
21+
22+
// DTB
23+
li a1, 0
24+
25+
// jump to payload
26+
call _spayload
27+
28+
// if the payload returns, halt the processor
29+
li t0, 0xfffffff0
30+
sw zero, 0(t0)
31+
32+
.section .data.payload
33+
.align 4
34+
.incbin ZSBL_PAYLOAD_PATH
35+
36+
.section .rodata.kernel
37+
.align 4
38+
.incbin ZSBL_KERNEL_PATH

0 commit comments

Comments
 (0)