Skip to content

Commit eb5ef8e

Browse files
committed
Bump rustsbi to 0.1.1 && make config of qemu/k210 different
1 parent 0746728 commit eb5ef8e

File tree

5 files changed

+62
-2
lines changed

5 files changed

+62
-2
lines changed

bootloader/rustsbi-k210.bin

1.3 KB
Binary file not shown.

bootloader/rustsbi-qemu.bin

36.7 KB
Binary file not shown.

os/Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ TARGET := riscv64gc-unknown-none-elf
33
MODE := release
44
KERNEL_ELF := target/$(TARGET)/$(MODE)/os
55
KERNEL_BIN := $(KERNEL_ELF).bin
6-
KERNEL_ENTRY_PA := 0x80020000
76
DISASM_TMP := target/$(TARGET)/$(MODE)/asm
87
FS_IMG := ../user/target/$(TARGET)/$(MODE)/fs.img
98
SDCARD := /dev/sdb
@@ -13,6 +12,14 @@ APPS := ../user/src/bin
1312
BOARD ?= qemu
1413
SBI ?= rustsbi
1514
BOOTLOADER := ../bootloader/$(SBI)-$(BOARD).bin
15+
K210_BOOTLOADER_SIZE := 131072
16+
17+
# KERNEL ENTRY
18+
ifeq ($(BOARD), qemu)
19+
KERNEL_ENTRY_PA := 0x80200000
20+
else ifeq ($(BOARD), k210)
21+
KERNEL_ENTRY_PA := 0x80020000
22+
endif
1623

1724
# Run K210
1825
K210-SERIALPORT = /dev/ttyUSB0
@@ -48,7 +55,10 @@ $(FS_IMG): $(APPS)
4855
$(APPS):
4956

5057
kernel:
58+
@echo Platform: $(BOARD)
59+
@cp src/linker-$(BOARD).ld src/linker.ld
5160
@cargo build --release --features "board_$(BOARD)"
61+
@rm src/linker.ld
5262

5363
clean:
5464
@cargo clean
@@ -74,7 +84,7 @@ ifeq ($(BOARD),qemu)
7484
-device virtio-blk-device,drive=x0,bus=virtio-mmio-bus.0
7585
else
7686
@cp $(BOOTLOADER) $(BOOTLOADER).copy
77-
@dd if=$(KERNEL_BIN) of=$(BOOTLOADER).copy bs=131072 seek=1
87+
@dd if=$(KERNEL_BIN) of=$(BOOTLOADER).copy bs=$(K210_BOOTLOADER_SIZE) seek=1
7888
@mv $(BOOTLOADER).copy $(KERNEL_BIN)
7989
@sudo chmod 777 $(K210-SERIALPORT)
8090
python3 $(K210-BURNER) -p $(K210-SERIALPORT) -b 1500000 $(KERNEL_BIN)
File renamed without changes.

os/src/linker-qemu.ld

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
OUTPUT_ARCH(riscv)
2+
ENTRY(_start)
3+
BASE_ADDRESS = 0x80200000;
4+
5+
SECTIONS
6+
{
7+
. = BASE_ADDRESS;
8+
skernel = .;
9+
10+
stext = .;
11+
.text : {
12+
*(.text.entry)
13+
. = ALIGN(4K);
14+
strampoline = .;
15+
*(.text.trampoline);
16+
. = ALIGN(4K);
17+
*(.text .text.*)
18+
}
19+
20+
. = ALIGN(4K);
21+
etext = .;
22+
srodata = .;
23+
.rodata : {
24+
*(.rodata .rodata.*)
25+
}
26+
27+
. = ALIGN(4K);
28+
erodata = .;
29+
sdata = .;
30+
.data : {
31+
*(.data .data.*)
32+
}
33+
34+
. = ALIGN(4K);
35+
edata = .;
36+
sbss_with_stack = .;
37+
.bss : {
38+
*(.bss.stack)
39+
sbss = .;
40+
*(.bss .bss.*)
41+
}
42+
43+
. = ALIGN(4K);
44+
ebss = .;
45+
ekernel = .;
46+
47+
/DISCARD/ : {
48+
*(.eh_frame)
49+
}
50+
}

0 commit comments

Comments
 (0)