Substituted to the original ch7 code.
This commit is contained in:
parent
4fdd55e2e8
commit
57f7debbc6
50 changed files with 2786 additions and 128 deletions
28
os/Makefile
28
os/Makefile
|
@ -4,6 +4,9 @@ MODE := release
|
|||
KERNEL_ELF := target/$(TARGET)/$(MODE)/os
|
||||
KERNEL_BIN := $(KERNEL_ELF).bin
|
||||
DISASM_TMP := target/$(TARGET)/$(MODE)/asm
|
||||
FS_IMG := ../user/target/$(TARGET)/$(MODE)/fs.img
|
||||
SDCARD := /dev/sdb
|
||||
APPS := ../user/src/bin/*
|
||||
|
||||
# BOARD
|
||||
BOARD ?= qemu
|
||||
|
@ -20,7 +23,7 @@ endif
|
|||
|
||||
# Run K210
|
||||
K210-SERIALPORT = /dev/ttyUSB0
|
||||
K210-BURNER = ../tools/kflash.py
|
||||
K210-BURNER = ../tools/kflash.py
|
||||
|
||||
# Binutils
|
||||
OBJDUMP := rust-objdump --arch-name=riscv64
|
||||
|
@ -29,7 +32,7 @@ OBJCOPY := rust-objcopy --binary-architecture=riscv64
|
|||
# Disassembly
|
||||
DISASM ?= -x
|
||||
|
||||
build: env switch-check $(KERNEL_BIN)
|
||||
build: env switch-check $(KERNEL_BIN) fs-img
|
||||
|
||||
switch-check:
|
||||
ifeq ($(BOARD), qemu)
|
||||
|
@ -44,11 +47,22 @@ env:
|
|||
rustup component add rust-src
|
||||
rustup component add llvm-tools-preview
|
||||
|
||||
sdcard: fs-img
|
||||
@echo "Are you sure write to $(SDCARD) ? [y/N] " && read ans && [ $${ans:-N} = y ]
|
||||
@sudo dd if=/dev/zero of=$(SDCARD) bs=1048576 count=32
|
||||
@sudo dd if=$(FS_IMG) of=$(SDCARD)
|
||||
|
||||
$(KERNEL_BIN): kernel
|
||||
@$(OBJCOPY) $(KERNEL_ELF) --strip-all -O binary $@
|
||||
|
||||
kernel:
|
||||
fs-img: $(APPS)
|
||||
@cd ../user && make build
|
||||
@rm -f $(FS_IMG)
|
||||
@cd ../easy-fs-fuse && cargo run --release -- -s ../user/src/bin/ -t ../user/target/riscv64gc-unknown-none-elf/release/
|
||||
|
||||
$(APPS):
|
||||
|
||||
kernel:
|
||||
@echo Platform: $(BOARD)
|
||||
@cp src/linker-$(BOARD).ld src/linker.ld
|
||||
@cargo build --release --features "board_$(BOARD)"
|
||||
|
@ -67,15 +81,15 @@ disasm-vim: kernel
|
|||
|
||||
run: run-inner
|
||||
|
||||
|
||||
|
||||
run-inner: build
|
||||
ifeq ($(BOARD),qemu)
|
||||
@qemu-system-riscv64 \
|
||||
-machine virt \
|
||||
-nographic \
|
||||
-bios $(BOOTLOADER) \
|
||||
-device loader,file=$(KERNEL_BIN),addr=$(KERNEL_ENTRY_PA)
|
||||
-device loader,file=$(KERNEL_BIN),addr=$(KERNEL_ENTRY_PA) \
|
||||
-drive file=$(FS_IMG),if=none,format=raw,id=x0 \
|
||||
-device virtio-blk-device,drive=x0,bus=virtio-mmio-bus.0
|
||||
else
|
||||
(which $(K210-BURNER)) || (cd .. && git clone https://github.com/sipeed/kflash.py.git && mv kflash.py tools)
|
||||
@cp $(BOOTLOADER) $(BOOTLOADER).copy
|
||||
|
@ -92,4 +106,4 @@ debug: build
|
|||
tmux split-window -h "riscv64-unknown-elf-gdb -ex 'file $(KERNEL_ELF)' -ex 'set arch riscv:rv64' -ex 'target remote localhost:1234'" && \
|
||||
tmux -2 attach-session -d
|
||||
|
||||
.PHONY: build env kernel clean disasm disasm-vim run-inner switch-check
|
||||
.PHONY: build env kernel clean disasm disasm-vim run-inner switch-check fs-img
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue