|
|
@ -32,8 +32,12 @@ m_mode ?=
|
|
|
|
|
|
|
|
|
|
|
|
target := $(arch)
|
|
|
|
target := $(arch)
|
|
|
|
kernel := target/$(target)/$(mode)/rcore
|
|
|
|
kernel := target/$(target)/$(mode)/rcore
|
|
|
|
bin := target/$(target)/$(mode)/kernel.bin
|
|
|
|
boot_bin := target/$(target)/$(mode)/boot.bin
|
|
|
|
|
|
|
|
kernel_bin := target/$(target)/$(mode)/kernel.bin
|
|
|
|
|
|
|
|
kernel_img := target/$(target)/$(mode)/kernel.img
|
|
|
|
bootimage := target/$(target)/bootimage.bin
|
|
|
|
bootimage := target/$(target)/bootimage.bin
|
|
|
|
|
|
|
|
bootloader_dir = ../bootloader
|
|
|
|
|
|
|
|
bootloader := $(bootloader_dir)/target/$(target)/$(mode)/rcore-bootloader
|
|
|
|
bbl_path := $(PWD)/../riscv-pk
|
|
|
|
bbl_path := $(PWD)/../riscv-pk
|
|
|
|
user_dir := ../user
|
|
|
|
user_dir := ../user
|
|
|
|
k210_lib := ../tools/k210/libkendryte.a
|
|
|
|
k210_lib := ../tools/k210/libkendryte.a
|
|
|
@ -53,9 +57,7 @@ endif
|
|
|
|
export M_MODE = $(m_mode)
|
|
|
|
export M_MODE = $(m_mode)
|
|
|
|
|
|
|
|
|
|
|
|
ifeq ($(arch), aarch64)
|
|
|
|
ifeq ($(arch), aarch64)
|
|
|
|
graphic ?= on
|
|
|
|
graphic := on
|
|
|
|
else
|
|
|
|
|
|
|
|
graphic ?= off
|
|
|
|
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
### qemu options ###
|
|
|
|
### qemu options ###
|
|
|
@ -76,7 +78,7 @@ qemu_net_opts += \
|
|
|
|
else ifeq ($(arch), riscv32)
|
|
|
|
else ifeq ($(arch), riscv32)
|
|
|
|
qemu_opts += \
|
|
|
|
qemu_opts += \
|
|
|
|
-machine virt \
|
|
|
|
-machine virt \
|
|
|
|
-kernel $(bin) \
|
|
|
|
-kernel $(kernel_img) \
|
|
|
|
-drive file=$(SFSIMG),format=raw,id=sfs \
|
|
|
|
-drive file=$(SFSIMG),format=raw,id=sfs \
|
|
|
|
-device virtio-blk-device,drive=sfs
|
|
|
|
-device virtio-blk-device,drive=sfs
|
|
|
|
qemu_net_opts += \
|
|
|
|
qemu_net_opts += \
|
|
|
@ -89,7 +91,7 @@ endif
|
|
|
|
else ifeq ($(arch), riscv64)
|
|
|
|
else ifeq ($(arch), riscv64)
|
|
|
|
qemu_opts += \
|
|
|
|
qemu_opts += \
|
|
|
|
-machine virt \
|
|
|
|
-machine virt \
|
|
|
|
-kernel $(bin) \
|
|
|
|
-kernel $(kernel_img) \
|
|
|
|
-drive file=$(SFSIMG),format=raw,id=sfs \
|
|
|
|
-drive file=$(SFSIMG),format=raw,id=sfs \
|
|
|
|
-device virtio-blk-device,drive=sfs
|
|
|
|
-device virtio-blk-device,drive=sfs
|
|
|
|
qemu_net_opts += \
|
|
|
|
qemu_net_opts += \
|
|
|
@ -103,7 +105,7 @@ else ifeq ($(arch), aarch64)
|
|
|
|
qemu_opts += \
|
|
|
|
qemu_opts += \
|
|
|
|
-machine $(board) \
|
|
|
|
-machine $(board) \
|
|
|
|
-serial null -serial mon:stdio \
|
|
|
|
-serial null -serial mon:stdio \
|
|
|
|
-kernel $(bin)
|
|
|
|
-kernel $(kernel_img)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
ifdef d
|
|
|
|
ifdef d
|
|
|
@ -170,7 +172,7 @@ objdump := $(prefix)objdump
|
|
|
|
objcopy := $(prefix)objcopy
|
|
|
|
objcopy := $(prefix)objcopy
|
|
|
|
cc := $(prefix)gcc
|
|
|
|
cc := $(prefix)gcc
|
|
|
|
as := $(prefix)as
|
|
|
|
as := $(prefix)as
|
|
|
|
gdb := gdb
|
|
|
|
gdb := $(prefix)gdb
|
|
|
|
export CC=$(cc)
|
|
|
|
export CC=$(cc)
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: all clean run build asm doc justrun debug kernel sfsimg install runnet
|
|
|
|
.PHONY: all clean run build asm doc justrun debug kernel sfsimg install runnet
|
|
|
@ -179,6 +181,7 @@ all: kernel
|
|
|
|
|
|
|
|
|
|
|
|
clean:
|
|
|
|
clean:
|
|
|
|
@cargo clean
|
|
|
|
@cargo clean
|
|
|
|
|
|
|
|
@cd $(bootloader_dir) && make clean
|
|
|
|
@cd $(user_dir) && make clean
|
|
|
|
@cd $(user_dir) && make clean
|
|
|
|
|
|
|
|
|
|
|
|
doc:
|
|
|
|
doc:
|
|
|
@ -199,12 +202,12 @@ justrunui: build
|
|
|
|
-device virtio-gpu-device \
|
|
|
|
-device virtio-gpu-device \
|
|
|
|
-device virtio-mouse-device
|
|
|
|
-device virtio-mouse-device
|
|
|
|
|
|
|
|
|
|
|
|
debug: $(kernel) $(bin)
|
|
|
|
debug: $(kernel) $(kernel_img)
|
|
|
|
@qemu-system-$(arch) $(qemu_opts) -s -S &
|
|
|
|
@qemu-system-$(arch) $(qemu_opts) -s -S &
|
|
|
|
@sleep 1
|
|
|
|
@sleep 1
|
|
|
|
@$(gdb) $(kernel) -x ../tools/gdbinit
|
|
|
|
@$(gdb) $(kernel) -x ../tools/gdbinit
|
|
|
|
|
|
|
|
|
|
|
|
build: $(bin)
|
|
|
|
build: $(kernel_img)
|
|
|
|
|
|
|
|
|
|
|
|
asm:
|
|
|
|
asm:
|
|
|
|
@$(objdump) -dS $(kernel) | less
|
|
|
|
@$(objdump) -dS $(kernel) | less
|
|
|
@ -215,7 +218,13 @@ header:
|
|
|
|
sym:
|
|
|
|
sym:
|
|
|
|
@$(objdump) -t $(kernel) | less
|
|
|
|
@$(objdump) -t $(kernel) | less
|
|
|
|
|
|
|
|
|
|
|
|
$(bin): kernel
|
|
|
|
$(bootloader):
|
|
|
|
|
|
|
|
ifeq ($(arch), aarch64)
|
|
|
|
|
|
|
|
@echo Building $(arch) bootloader
|
|
|
|
|
|
|
|
cd $(bootloader_dir) && make arch=$(arch) mode=$(mode)
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(kernel_img): $(bootloader) kernel
|
|
|
|
ifeq ($(arch), riscv32)
|
|
|
|
ifeq ($(arch), riscv32)
|
|
|
|
@mkdir -p target/$(target)/bbl && \
|
|
|
|
@mkdir -p target/$(target)/bbl && \
|
|
|
|
cd target/$(target)/bbl && \
|
|
|
|
cd target/$(target)/bbl && \
|
|
|
@ -243,10 +252,14 @@ else
|
|
|
|
cp bbl $(abspath $@)
|
|
|
|
cp bbl $(abspath $@)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
else ifeq ($(arch), aarch64)
|
|
|
|
else ifeq ($(arch), aarch64)
|
|
|
|
@$(objcopy) $(kernel) --strip-all -O binary $@
|
|
|
|
@$(objcopy) $(bootloader) --strip-all -O binary $(boot_bin)
|
|
|
|
|
|
|
|
@$(objcopy) $(kernel) --strip-all -O binary $(kernel_bin)
|
|
|
|
|
|
|
|
dd if=$(boot_bin) of=$@ conv=notrunc
|
|
|
|
|
|
|
|
dd if=$(kernel_bin) of=$@ seek=1024 conv=notrunc
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
kernel:
|
|
|
|
kernel:
|
|
|
|
|
|
|
|
@echo Building $(arch) kernel
|
|
|
|
ifeq ($(arch), x86_64)
|
|
|
|
ifeq ($(arch), x86_64)
|
|
|
|
@bootimage build $(build_args)
|
|
|
|
@bootimage build $(build_args)
|
|
|
|
else ifeq ($(arch), riscv32)
|
|
|
|
else ifeq ($(arch), riscv32)
|
|
|
@ -287,8 +300,8 @@ endif
|
|
|
|
|
|
|
|
|
|
|
|
ifdef sd_card
|
|
|
|
ifdef sd_card
|
|
|
|
.PHONY:
|
|
|
|
.PHONY:
|
|
|
|
install: $(bin)
|
|
|
|
install: $(kernel_img)
|
|
|
|
cp $(bin) $(sd_card)/kernel8.img
|
|
|
|
cp $(kernel_img) $(sd_card)/kernel8.img
|
|
|
|
sudo umount $(sd_card)
|
|
|
|
sudo umount $(sd_card)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
@ -296,9 +309,9 @@ endif
|
|
|
|
|
|
|
|
|
|
|
|
ifeq ($(board), k210)
|
|
|
|
ifeq ($(board), k210)
|
|
|
|
.PHONY:
|
|
|
|
.PHONY:
|
|
|
|
install: $(bin)
|
|
|
|
install: $(kernel_img)
|
|
|
|
## baudrate no more than 600000
|
|
|
|
## baudrate no more than 600000
|
|
|
|
@python3 ../tools/k210/kflash.py $(bin) -b 600000
|
|
|
|
@python3 ../tools/k210/kflash.py $(kernel_img) -b 600000
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY:
|
|
|
|
.PHONY:
|
|
|
|