mirror of
https://github.com/rcore-os/rCore-Tutorial-v3.git
synced 2024-11-24 10:26:25 +04:00
Bump rustsbi to 0.1.1 && make config of qemu/k210 different
This commit is contained in:
parent
37e55e947a
commit
1ed9f75896
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,4 +2,4 @@
|
||||
os/target/*
|
||||
os/.idea/*
|
||||
os/src/link_app.S
|
||||
user/
|
||||
os/Cargo.lock
|
||||
|
Binary file not shown.
Binary file not shown.
5
os/Cargo.lock
generated
5
os/Cargo.lock
generated
@ -1,5 +0,0 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "os"
|
||||
version = "0.1.0"
|
14
os/Makefile
14
os/Makefile
@ -3,13 +3,20 @@ TARGET := riscv64gc-unknown-none-elf
|
||||
MODE := release
|
||||
KERNEL_ELF := target/$(TARGET)/$(MODE)/os
|
||||
KERNEL_BIN := $(KERNEL_ELF).bin
|
||||
KERNEL_ENTRY_PA := 0x80020000
|
||||
DISASM_TMP := target/$(TARGET)/$(MODE)/asm
|
||||
|
||||
# BOARD
|
||||
BOARD ?= qemu
|
||||
SBI ?= rustsbi
|
||||
BOOTLOADER := ../bootloader/$(SBI)-$(BOARD).bin
|
||||
K210_BOOTLOADER_SIZE := 131072
|
||||
|
||||
# KERNEL ENTRY
|
||||
ifeq ($(BOARD), qemu)
|
||||
KERNEL_ENTRY_PA := 0x80200000
|
||||
else ifeq ($(BOARD), k210)
|
||||
KERNEL_ENTRY_PA := 0x80020000
|
||||
endif
|
||||
|
||||
# Run K210
|
||||
K210-SERIALPORT = /dev/ttyUSB0
|
||||
@ -34,7 +41,10 @@ $(KERNEL_BIN): kernel
|
||||
@$(OBJCOPY) $(KERNEL_ELF) --strip-all -O binary $@
|
||||
|
||||
kernel:
|
||||
@echo Platform: $(BOARD)
|
||||
@cp src/linker-$(BOARD).ld src/linker.ld
|
||||
@cargo build --release
|
||||
@rm src/linker.ld
|
||||
|
||||
clean:
|
||||
@cargo clean
|
||||
@ -58,7 +68,7 @@ ifeq ($(BOARD),qemu)
|
||||
-device loader,file=$(KERNEL_BIN),addr=$(KERNEL_ENTRY_PA)
|
||||
else
|
||||
@cp $(BOOTLOADER) $(BOOTLOADER).copy
|
||||
@dd if=$(KERNEL_BIN) of=$(BOOTLOADER).copy bs=131072 seek=1
|
||||
@dd if=$(KERNEL_BIN) of=$(BOOTLOADER).copy bs=$(K210_BOOTLOADER_SIZE) seek=1
|
||||
@mv $(BOOTLOADER).copy $(KERNEL_BIN)
|
||||
@sudo chmod 777 $(K210-SERIALPORT)
|
||||
python3 $(K210-BURNER) -p $(K210-SERIALPORT) -b 1500000 $(KERNEL_BIN)
|
||||
|
45
os/src/linker-qemu.ld
Normal file
45
os/src/linker-qemu.ld
Normal file
@ -0,0 +1,45 @@
|
||||
OUTPUT_ARCH(riscv)
|
||||
ENTRY(_start)
|
||||
BASE_ADDRESS = 0x80200000;
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = BASE_ADDRESS;
|
||||
skernel = .;
|
||||
|
||||
stext = .;
|
||||
.text : {
|
||||
*(.text.entry)
|
||||
*(.text .text.*)
|
||||
}
|
||||
|
||||
. = ALIGN(4K);
|
||||
etext = .;
|
||||
srodata = .;
|
||||
.rodata : {
|
||||
*(.rodata .rodata.*)
|
||||
}
|
||||
|
||||
. = ALIGN(4K);
|
||||
erodata = .;
|
||||
sdata = .;
|
||||
.data : {
|
||||
*(.data .data.*)
|
||||
}
|
||||
|
||||
. = ALIGN(4K);
|
||||
edata = .;
|
||||
.bss : {
|
||||
*(.bss.stack)
|
||||
sbss = .;
|
||||
*(.bss .bss.*)
|
||||
}
|
||||
|
||||
. = ALIGN(4K);
|
||||
ebss = .;
|
||||
ekernel = .;
|
||||
|
||||
/DISCARD/ : {
|
||||
*(.eh_frame)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user