You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rCore_stu/ch1/Makefile

36 lines
987 B
Makefile

2 years ago
TARGET := riscv64gc-unknown-none-elf
KERNEL_ENTRY := 0x80200000
2 years ago
MODE := release
KERNEL_ELF := target/$(TARGET)/$(MODE)/os
KERNEL_BIN := $(KERNEL_ELF).bin
QEMU_CMD_PATH := /Users/zhangxinyu/Downloads/qemu-7.0.0/build/qemu-system-riscv64
OBJDUMP := rust-objdump --arch-name=riscv64
OBJCOPY := rust-objcopy --binary-architecture=riscv64
2 years ago
RUST_FLAGS := -Clink-arg=-Tsrc/linker.ld # 使用我们自己的链接脚本
RUST_FLAGS += -Cforce-frame-pointers=yes # 强制编译器生成帧指针
RUST_FLAGS:=$(strip ${RUST_FLAGS})
2 years ago
# 编译elf文件
2 years ago
build:
CARGO_BUILD_RUSTFLAGS="$(RUST_FLAGS)" \
cargo build --$(MODE) --target=$(TARGET)
2 years ago
# 丢弃内核可执行elf文件中的元数据得到内核镜像
$(KERNEL_BIN): build
@$(OBJCOPY) $(KERNEL_ELF) --strip-all -O binary $@
run:build $(KERNEL_BIN)
$(QEMU_CMD_PATH) \
2 years ago
-machine virt \
-nographic \
-bios ../bootloader/rustsbi-qemu.bin \
-device loader,file=$(KERNEL_ELF),addr=$(KERNEL_ENTRY) \
-s -S
2 years ago
clean:
rm -rf ./target