2019-03-26 07:23:29 +04:00
|
|
|
# Commands:
|
|
|
|
# make build Build
|
|
|
|
# make run Build and run in QEMU
|
|
|
|
# make justrun Run the last build
|
2019-03-26 12:03:32 +04:00
|
|
|
# make runnet Build and run in QEMU with nic
|
|
|
|
# make justrunnet Run the last build with nic
|
|
|
|
# make runui Build and run in QEMU with gui
|
|
|
|
# make justrunui Run the last build with gui
|
|
|
|
# make runtest Build and run in QEMU with specified program
|
|
|
|
# make justruntest Run the last build with specified program
|
2019-03-26 07:23:29 +04:00
|
|
|
# make doc Generate docs
|
|
|
|
# make asm Open the deassemble file of the last build
|
|
|
|
# make header Open 'objdump -h' of the last build
|
2019-01-08 15:04:34 +04:00
|
|
|
# make addr2line Use addr2line to recover line info in backtrace
|
2018-12-07 16:48:44 +04:00
|
|
|
# make clean Clean
|
2018-08-07 12:11:48 +04:00
|
|
|
#
|
|
|
|
# Options:
|
2019-03-31 18:04:22 +04:00
|
|
|
# arch = x86_64 | riscv32 | riscv64 | aarch64 | mipsel
|
2018-12-07 16:48:44 +04:00
|
|
|
# d = int | in_asm | ... QEMU debug info
|
2018-08-07 12:11:48 +04:00
|
|
|
# mode = debug | release
|
|
|
|
# LOG = off | error | warn | info | debug | trace
|
2019-04-05 19:31:02 +04:00
|
|
|
# SFSIMG = <sfsimg> SFS image path of user programs
|
|
|
|
# smp = 1 | 2 | ... SMP core number
|
|
|
|
# graphic = on | off Enable/disable qemu graphical output
|
|
|
|
# board = none Running on QEMU
|
2019-04-21 19:47:00 +04:00
|
|
|
# | pc Only available on x86_64, run on real pc
|
2019-04-05 19:31:02 +04:00
|
|
|
# | u540 Only available on riscv64, run on HiFive U540, use Sv39
|
2019-04-21 19:47:00 +04:00
|
|
|
# | k210 Only available on riscv64, run on K210, use Sv39
|
2019-04-27 19:01:44 +04:00
|
|
|
# | rocket_chip Only available on riscv64, run on Rocket Chip, use Sv39
|
2019-04-05 19:31:02 +04:00
|
|
|
# | raspi3 Only available on aarch64, run on Raspberry Pi 3 Model B/B+
|
|
|
|
# pci_passthru = 0000:00:00.1 Only available on x86_64, passthrough the specified PCI device
|
|
|
|
# init = /bin/ls Only available on riscv64, run specified program instead of user shell
|
2019-04-02 04:27:02 +04:00
|
|
|
# extra_nic = on | off Only available on x86_64, add an additional e1000 nic
|
2019-04-05 19:31:02 +04:00
|
|
|
# u_boot = /path/to/u-boot.bin Only available on aarch64, use u-boot to boot rcore
|
2019-04-30 17:32:32 +04:00
|
|
|
# . extra_features = profile | ... Add additional features
|
2018-05-21 20:31:50 +04:00
|
|
|
|
2019-03-18 14:20:27 +04:00
|
|
|
arch ?= riscv64
|
2018-12-07 16:48:44 +04:00
|
|
|
board ?= none
|
2019-04-18 20:37:30 +04:00
|
|
|
mode ?= release
|
|
|
|
LOG ?=
|
2019-01-23 18:11:41 +04:00
|
|
|
graphic ?= off
|
2018-10-19 13:11:08 +04:00
|
|
|
smp ?= 4
|
2019-03-23 21:09:58 +04:00
|
|
|
pci_passthru ?=
|
2019-03-26 12:03:32 +04:00
|
|
|
init ?=
|
2019-04-02 04:27:02 +04:00
|
|
|
extra_nic ?= off
|
2018-08-07 12:11:48 +04:00
|
|
|
|
2018-12-31 21:53:33 +04:00
|
|
|
target := $(arch)
|
2019-03-18 14:20:27 +04:00
|
|
|
build_path := target/$(target)/$(mode)
|
|
|
|
kernel := $(build_path)/rcore
|
|
|
|
kernel_img := $(build_path)/kernel.img
|
|
|
|
bootimage := $(build_path)/bootimage.bin
|
2019-03-04 11:22:19 +04:00
|
|
|
bootloader_dir = ../bootloader
|
|
|
|
bootloader := $(bootloader_dir)/target/$(target)/$(mode)/rcore-bootloader
|
2018-12-31 21:53:33 +04:00
|
|
|
bbl_path := $(PWD)/../riscv-pk
|
2018-11-28 20:39:44 +04:00
|
|
|
user_dir := ../user
|
|
|
|
|
2019-04-01 19:07:49 +04:00
|
|
|
|
2018-12-31 14:44:16 +04:00
|
|
|
### export environments ###
|
2019-04-06 07:20:50 +04:00
|
|
|
|
|
|
|
ifeq ($(arch), $(filter $(arch), aarch64 mipsel))
|
|
|
|
#link user img, so use original image
|
|
|
|
export SFSIMG = $(user_dir)/build/$(arch).img
|
|
|
|
else
|
2019-04-15 20:11:35 +04:00
|
|
|
# board is pc or qemu?
|
2019-04-27 19:01:44 +04:00
|
|
|
ifeq ($(board), $(filter $(board), pc u540 k210 rocket_chip))
|
2019-04-15 20:11:35 +04:00
|
|
|
#link user img, so use original image
|
|
|
|
export SFSIMG = $(user_dir)/build/$(arch).img
|
|
|
|
else
|
2019-03-23 20:49:48 +04:00
|
|
|
export SFSIMG = $(user_dir)/build/$(arch).qcow2
|
2019-04-15 20:11:35 +04:00
|
|
|
endif # pc or qemu
|
|
|
|
endif # aarch64 mipsel
|
2019-04-01 19:29:50 +04:00
|
|
|
|
|
|
|
ifeq ($(arch), aarch64)
|
|
|
|
board := raspi3
|
2019-04-09 12:16:09 +04:00
|
|
|
need_bootloader := true
|
2018-12-20 13:34:24 +04:00
|
|
|
endif
|
|
|
|
|
2019-05-08 07:02:23 +04:00
|
|
|
# currently only mipsel architecture and rocket-chip need DTB linked to the kernel
|
2019-04-03 11:52:34 +04:00
|
|
|
ifeq ($(arch), mipsel)
|
|
|
|
dtb := src/arch/$(arch)/board/$(board)/device.dtb
|
|
|
|
endif
|
2019-05-07 04:40:25 +04:00
|
|
|
ifeq ($(board), rocket_chip)
|
|
|
|
dtb := src/arch/riscv32/board/$(board)/device.dtb
|
|
|
|
endif
|
2019-04-03 11:52:34 +04:00
|
|
|
|
2019-04-06 17:59:16 +04:00
|
|
|
# mipssim does not support SMP
|
|
|
|
ifeq ($(board), mipssim)
|
|
|
|
smp := 1
|
|
|
|
endif
|
|
|
|
|
2019-04-03 11:52:34 +04:00
|
|
|
export ARCH = $(arch)
|
|
|
|
export BOARD = $(board)
|
|
|
|
export SMP = $(smp)
|
|
|
|
export DTB = $(dtb)
|
2019-04-01 19:29:50 +04:00
|
|
|
|
|
|
|
|
2018-10-26 07:20:03 +04:00
|
|
|
### qemu options ###
|
2018-09-18 14:05:37 +04:00
|
|
|
qemu_opts := \
|
2019-03-26 12:50:21 +04:00
|
|
|
-smp cores=$(smp)
|
2019-04-04 21:16:26 +04:00
|
|
|
qemu_net_opts :=
|
2018-11-29 17:39:43 +04:00
|
|
|
|
|
|
|
ifeq ($(arch), x86_64)
|
|
|
|
qemu_opts += \
|
2019-04-16 20:45:44 +04:00
|
|
|
-drive format=raw,file=$(bootimage) \
|
|
|
|
-serial mon:stdio \
|
|
|
|
-m 4G \
|
|
|
|
-device isa-debug-exit
|
2019-04-15 20:11:35 +04:00
|
|
|
ifeq ($(board), none)
|
|
|
|
qemu_opts += \
|
2019-03-30 06:03:08 +04:00
|
|
|
-drive format=qcow2,file=$(SFSIMG),media=disk,cache=writeback,id=sfsimg,if=none \
|
|
|
|
-device ahci,id=ahci0 \
|
2019-04-15 20:11:35 +04:00
|
|
|
-device ide-drive,drive=sfsimg,bus=ahci0.0
|
|
|
|
endif
|
2019-03-23 21:09:58 +04:00
|
|
|
ifeq ($(pci_passthru), )
|
2019-02-25 15:12:41 +04:00
|
|
|
qemu_net_opts += \
|
2019-04-04 21:16:26 +04:00
|
|
|
-netdev type=tap,id=net0,script=no,downscript=no \
|
2019-03-04 11:34:02 +04:00
|
|
|
-device e1000e,netdev=net0
|
2019-03-23 21:09:58 +04:00
|
|
|
else
|
|
|
|
qemu_opts += \
|
2019-04-03 20:16:27 +04:00
|
|
|
-machine accel=kvm
|
2019-03-23 21:09:58 +04:00
|
|
|
qemu_net_opts += \
|
|
|
|
-device vfio-pci,host=$(pci_passthru)
|
|
|
|
endif
|
2019-04-02 04:27:02 +04:00
|
|
|
ifeq ($(extra_nic), on)
|
|
|
|
qemu_net_opts += \
|
|
|
|
-netdev type=tap,id=net1,script=no,downscript=no \
|
|
|
|
-device e1000e,netdev=net1
|
|
|
|
endif
|
2018-11-29 17:39:43 +04:00
|
|
|
|
2018-10-26 07:20:03 +04:00
|
|
|
else ifeq ($(arch), riscv32)
|
2018-11-29 17:39:43 +04:00
|
|
|
qemu_opts += \
|
2018-10-21 17:35:28 +04:00
|
|
|
-machine virt \
|
2019-04-25 21:14:40 +04:00
|
|
|
-serial mon:stdio \
|
2019-04-19 20:15:22 +04:00
|
|
|
-kernel ../tools/opensbi/virt_rv32.elf \
|
|
|
|
-device loader,addr=0x80400000,file=$(kernel_img) \
|
2019-03-26 04:28:10 +04:00
|
|
|
-drive file=$(SFSIMG),format=qcow2,id=sfs \
|
2019-01-25 06:28:38 +04:00
|
|
|
-device virtio-blk-device,drive=sfs
|
2019-02-25 15:12:41 +04:00
|
|
|
qemu_net_opts += \
|
2019-04-04 21:16:26 +04:00
|
|
|
-netdev type=tap,id=net0,script=no,downscript=no \
|
2019-02-25 15:12:41 +04:00
|
|
|
-device virtio-net-device,netdev=net0
|
|
|
|
|
2018-12-28 18:20:21 +04:00
|
|
|
else ifeq ($(arch), riscv64)
|
2019-04-19 20:15:22 +04:00
|
|
|
ifeq ($(board), u540)
|
2018-12-28 18:20:21 +04:00
|
|
|
qemu_opts += \
|
|
|
|
-machine virt \
|
2019-04-25 21:14:40 +04:00
|
|
|
-serial mon:stdio \
|
2019-04-19 20:15:22 +04:00
|
|
|
-kernel ../tools/opensbi/fu540.elf \
|
|
|
|
-device loader,addr=0x80200000,file=$(kernel_img)
|
|
|
|
else
|
|
|
|
qemu_opts += \
|
|
|
|
-machine virt \
|
2019-04-25 21:14:40 +04:00
|
|
|
-serial mon:stdio \
|
2019-04-19 20:15:22 +04:00
|
|
|
-kernel ../tools/opensbi/virt_rv64.elf \
|
|
|
|
-device loader,addr=0x80200000,file=$(kernel_img) \
|
2019-03-26 04:28:10 +04:00
|
|
|
-drive file=$(SFSIMG),format=qcow2,id=sfs \
|
2019-01-25 06:28:38 +04:00
|
|
|
-device virtio-blk-device,drive=sfs
|
2019-04-19 20:15:22 +04:00
|
|
|
endif
|
2019-02-25 15:12:41 +04:00
|
|
|
qemu_net_opts += \
|
2019-04-04 21:16:26 +04:00
|
|
|
-netdev type=tap,id=net0,script=no,downscript=no \
|
2019-02-25 15:12:41 +04:00
|
|
|
-device virtio-net-device,netdev=net0
|
|
|
|
|
2018-10-26 07:20:03 +04:00
|
|
|
else ifeq ($(arch), aarch64)
|
2018-11-29 17:39:43 +04:00
|
|
|
qemu_opts += \
|
2018-10-26 07:20:03 +04:00
|
|
|
-machine $(board) \
|
2019-01-25 06:28:38 +04:00
|
|
|
-serial null -serial mon:stdio \
|
2019-03-04 11:22:19 +04:00
|
|
|
-kernel $(kernel_img)
|
2019-04-05 19:31:02 +04:00
|
|
|
ifneq ($(u_boot), )
|
|
|
|
qemu_opts += \
|
|
|
|
-sd $(bootloader)
|
|
|
|
endif
|
2018-10-26 07:20:03 +04:00
|
|
|
|
2019-04-01 19:07:49 +04:00
|
|
|
else ifeq ($(arch), mipsel)
|
2019-04-07 14:36:29 +04:00
|
|
|
ifeq ($(board), malta)
|
|
|
|
qemu_opts += \
|
2019-04-09 09:31:56 +04:00
|
|
|
-machine $(board) -device VGA \
|
2019-04-07 14:36:29 +04:00
|
|
|
-serial null -serial null -serial mon:stdio \
|
|
|
|
-kernel $(kernel_img)
|
|
|
|
endif
|
|
|
|
ifeq ($(board), mipssim)
|
2019-04-01 19:07:49 +04:00
|
|
|
qemu_opts += \
|
|
|
|
-machine $(board) \
|
2019-04-05 21:57:23 +04:00
|
|
|
-serial mon:stdio \
|
2019-04-01 19:07:49 +04:00
|
|
|
-kernel $(kernel_img)
|
|
|
|
endif
|
2019-04-03 09:53:34 +04:00
|
|
|
endif
|
2019-04-01 19:07:49 +04:00
|
|
|
|
2018-10-26 07:20:03 +04:00
|
|
|
ifdef d
|
2018-11-29 17:39:43 +04:00
|
|
|
qemu_opts += -d $(d)
|
2018-07-04 12:23:11 +04:00
|
|
|
endif
|
2018-04-09 17:20:47 +04:00
|
|
|
|
2019-01-23 18:11:41 +04:00
|
|
|
ifeq ($(graphic), off)
|
|
|
|
qemu_opts += -nographic
|
|
|
|
endif
|
|
|
|
|
2018-10-26 07:20:03 +04:00
|
|
|
### build args ###
|
2018-12-20 13:34:24 +04:00
|
|
|
ifneq ($(graphic), on)
|
|
|
|
features += nographic
|
|
|
|
endif
|
|
|
|
|
2019-03-26 12:03:32 +04:00
|
|
|
ifneq ($(init), )
|
|
|
|
features += run_cmdline
|
|
|
|
endif
|
|
|
|
|
2018-12-11 12:52:50 +04:00
|
|
|
ifeq ($(board), raspi3)
|
|
|
|
# qemu only has generic timer
|
|
|
|
# TODO: configure system/generic timer automatically
|
|
|
|
raspi3_timer ?= generic
|
|
|
|
ifeq ($(raspi3_timer), generic)
|
|
|
|
features += raspi3_use_generic_timer
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2018-12-07 16:48:44 +04:00
|
|
|
ifneq ($(board), none)
|
2018-11-29 17:39:43 +04:00
|
|
|
features += board_$(board)
|
2018-12-07 16:48:44 +04:00
|
|
|
endif
|
2019-04-15 20:11:35 +04:00
|
|
|
|
2019-04-30 17:32:32 +04:00
|
|
|
features += $(extra_features)
|
|
|
|
|
2018-12-31 21:53:33 +04:00
|
|
|
build_args := --target targets/$(target).json --features "$(features)"
|
2018-05-21 20:31:50 +04:00
|
|
|
|
|
|
|
ifeq ($(mode), release)
|
2018-11-29 17:39:43 +04:00
|
|
|
build_args += --release
|
2018-05-21 20:31:50 +04:00
|
|
|
endif
|
|
|
|
|
2018-10-26 07:20:03 +04:00
|
|
|
### prefix ###
|
2018-11-19 21:08:39 +04:00
|
|
|
ifeq ($(arch), x86_64)
|
|
|
|
ifeq ($(uname), Darwin)
|
|
|
|
prefix := x86_64-elf-
|
|
|
|
endif
|
|
|
|
else ifeq ($(arch), riscv32)
|
|
|
|
prefix := riscv64-unknown-elf-
|
2018-12-28 18:20:21 +04:00
|
|
|
else ifeq ($(arch), riscv64)
|
|
|
|
prefix := riscv64-unknown-elf-
|
2019-03-31 18:04:22 +04:00
|
|
|
else ifeq ($(arch), mipsel)
|
2019-04-07 21:00:26 +04:00
|
|
|
prefix ?= mipsel-linux-musln32-
|
2018-11-19 21:08:39 +04:00
|
|
|
else ifeq ($(arch), aarch64)
|
|
|
|
prefix ?= aarch64-none-elf-
|
2019-01-08 09:27:53 +04:00
|
|
|
ifeq (,$(shell which $(prefix)ld))
|
|
|
|
prefix := aarch64-elf-
|
|
|
|
endif
|
2018-11-19 21:08:39 +04:00
|
|
|
endif
|
|
|
|
|
2019-03-04 11:22:19 +04:00
|
|
|
gdb := $(prefix)gdb
|
2019-04-11 20:23:34 +04:00
|
|
|
objdump := cargo objdump -- -arch-name=$(subst _,-,$(arch))
|
|
|
|
objcopy := cargo objcopy -- --binary-architecture=$(subst _,-,$(arch))
|
|
|
|
strip := cargo strip --
|
2019-04-01 19:07:49 +04:00
|
|
|
dtc := dtc
|
2019-04-09 13:06:33 +04:00
|
|
|
hostcc := gcc
|
|
|
|
|
2019-04-01 19:07:49 +04:00
|
|
|
.PHONY: all clean build asm doc debug kernel sfsimg install run justrun runnet justrunnet runui justrunui runtest justruntest
|
2017-04-11 11:02:09 +04:00
|
|
|
|
2018-10-26 07:20:03 +04:00
|
|
|
all: kernel
|
2017-04-11 11:02:09 +04:00
|
|
|
|
|
|
|
clean:
|
2018-09-18 14:05:37 +04:00
|
|
|
@cargo clean
|
2019-03-04 11:22:19 +04:00
|
|
|
@cd $(bootloader_dir) && make clean
|
2018-12-02 15:56:29 +04:00
|
|
|
@cd $(user_dir) && make clean
|
2017-04-11 11:02:09 +04:00
|
|
|
|
2018-05-21 12:05:36 +04:00
|
|
|
doc:
|
|
|
|
@cargo rustdoc -- --document-private-items
|
|
|
|
|
2018-12-28 18:20:21 +04:00
|
|
|
run: build justrun
|
2019-01-23 18:11:41 +04:00
|
|
|
runnet: build justrunnet
|
|
|
|
runui: build justrunui
|
2019-03-26 12:03:32 +04:00
|
|
|
runtest: build justruntest
|
2018-07-04 12:23:11 +04:00
|
|
|
|
2018-12-02 15:51:52 +04:00
|
|
|
justrun:
|
2018-12-28 18:20:21 +04:00
|
|
|
@qemu-system-$(arch) $(qemu_opts)
|
2017-04-11 11:02:09 +04:00
|
|
|
|
2019-01-23 18:11:41 +04:00
|
|
|
justrunnet: build
|
2019-02-25 15:12:41 +04:00
|
|
|
@sudo qemu-system-$(arch) $(qemu_opts) $(qemu_net_opts)
|
2019-01-23 18:11:41 +04:00
|
|
|
|
|
|
|
justrunui: build
|
|
|
|
@qemu-system-$(arch) $(qemu_opts) \
|
|
|
|
-device virtio-gpu-device \
|
2019-01-25 06:28:38 +04:00
|
|
|
-device virtio-mouse-device
|
2019-01-23 18:11:41 +04:00
|
|
|
|
2019-03-26 12:03:32 +04:00
|
|
|
justruntest: build
|
2019-05-03 11:17:06 +04:00
|
|
|
@qemu-system-$(arch) $(filter-out -serial mon:stdio, $(qemu_opts)) --append $(init) -serial file:../tests/stdout -monitor null
|
2019-03-26 12:03:32 +04:00
|
|
|
|
2019-03-04 11:22:19 +04:00
|
|
|
debug: $(kernel) $(kernel_img)
|
2018-05-18 07:49:27 +04:00
|
|
|
@qemu-system-$(arch) $(qemu_opts) -s -S &
|
2018-10-26 18:02:24 +04:00
|
|
|
@sleep 1
|
|
|
|
@$(gdb) $(kernel) -x ../tools/gdbinit
|
2018-05-18 07:49:27 +04:00
|
|
|
|
2019-03-04 11:22:19 +04:00
|
|
|
build: $(kernel_img)
|
2018-04-09 17:20:47 +04:00
|
|
|
|
2018-05-21 20:31:50 +04:00
|
|
|
asm:
|
2019-03-16 11:44:57 +04:00
|
|
|
@$(objdump) -d $(kernel) | less
|
2018-04-12 19:44:25 +04:00
|
|
|
|
2018-10-19 13:11:08 +04:00
|
|
|
header:
|
2018-07-13 21:11:47 +04:00
|
|
|
@$(objdump) -h $(kernel)
|
|
|
|
|
2018-10-19 13:11:08 +04:00
|
|
|
sym:
|
|
|
|
@$(objdump) -t $(kernel) | less
|
|
|
|
|
2019-04-01 19:07:49 +04:00
|
|
|
### device tree process ###
|
|
|
|
|
|
|
|
%.dtb: %.dts
|
2019-04-07 14:04:28 +04:00
|
|
|
@echo Generating device tree file $@
|
|
|
|
@$(dtc) -I dts -O dtb -o $@ $<
|
|
|
|
@rm -rf src/arch/${arch}/boot/dtb.gen.s
|
2019-04-01 19:07:49 +04:00
|
|
|
|
|
|
|
### bootloader and kernel image ###
|
|
|
|
|
2019-03-05 20:46:01 +04:00
|
|
|
$(bootloader): $(kernel)
|
2019-04-01 19:07:49 +04:00
|
|
|
ifeq ($(need_bootloader), true)
|
2019-03-04 11:22:19 +04:00
|
|
|
@echo Building $(arch) bootloader
|
2019-03-05 20:46:01 +04:00
|
|
|
@$(strip) $(kernel) -o $(kernel)_stripped
|
|
|
|
@cd $(bootloader_dir) && make arch=$(arch) mode=$(mode) payload=../kernel/$(kernel)_stripped
|
|
|
|
@rm $(kernel)_stripped
|
2019-03-04 11:22:19 +04:00
|
|
|
endif
|
|
|
|
|
2019-03-05 20:46:01 +04:00
|
|
|
$(kernel_img): kernel $(bootloader)
|
2019-04-19 20:15:22 +04:00
|
|
|
ifeq ($(arch), $(filter $(arch), riscv32 riscv64))
|
|
|
|
@$(objcopy) $(kernel) --strip-all -O binary $@
|
2018-10-26 07:20:03 +04:00
|
|
|
else ifeq ($(arch), aarch64)
|
2019-04-05 19:31:02 +04:00
|
|
|
ifneq ($(u_boot), )
|
|
|
|
@cp $(u_boot) $@
|
|
|
|
else
|
2019-03-05 20:46:01 +04:00
|
|
|
@$(objcopy) $(bootloader) --strip-all -O binary $@
|
2018-08-07 12:11:48 +04:00
|
|
|
endif
|
2019-03-31 18:04:22 +04:00
|
|
|
else ifeq ($(arch), mipsel)
|
2019-04-06 10:43:10 +04:00
|
|
|
# qemu-system-mipsel accepts ELF file only, so objcopy is not needed
|
2019-04-05 20:58:32 +04:00
|
|
|
@$(strip) $(kernel) -o $@
|
2018-08-07 12:11:48 +04:00
|
|
|
endif
|
2018-07-04 12:23:11 +04:00
|
|
|
|
2019-04-01 19:07:49 +04:00
|
|
|
kernel: $(dtb)
|
2019-03-04 11:22:19 +04:00
|
|
|
@echo Building $(arch) kernel
|
2018-12-28 18:20:21 +04:00
|
|
|
ifeq ($(arch), x86_64)
|
2018-09-18 14:05:37 +04:00
|
|
|
@bootimage build $(build_args)
|
2019-03-18 14:20:27 +04:00
|
|
|
@mv target/x86_64/bootimage.bin $(bootimage)
|
2019-04-19 20:15:22 +04:00
|
|
|
else ifeq ($(arch), $(filter $(arch), riscv32 riscv64))
|
2019-04-21 19:47:00 +04:00
|
|
|
ifeq ($(board), k210)
|
|
|
|
@cp src/arch/riscv32/board/k210/linker.ld src/arch/riscv32/boot/linker64.ld
|
2019-05-07 04:40:25 +04:00
|
|
|
else ifeq ($(board), rocket_chip)
|
|
|
|
@cp src/arch/riscv32/board/rocket_chip/linker.ld src/arch/riscv32/boot/linker64.ld
|
2019-04-21 19:47:00 +04:00
|
|
|
else
|
|
|
|
@cp src/arch/riscv32/board/u540/linker.ld src/arch/riscv32/boot/linker64.ld
|
|
|
|
endif
|
2019-02-15 10:54:42 +04:00
|
|
|
@-patch -p0 -N -b \
|
|
|
|
$(shell rustc --print sysroot)/lib/rustlib/src/rust/src/libcore/sync/atomic.rs \
|
|
|
|
src/arch/riscv32/atomic.patch
|
|
|
|
@cargo xbuild $(build_args)
|
2018-12-28 18:20:21 +04:00
|
|
|
else ifeq ($(arch), aarch64)
|
2019-01-03 15:37:04 +04:00
|
|
|
@cargo xbuild $(build_args)
|
2019-03-31 18:04:22 +04:00
|
|
|
else ifeq ($(arch), mipsel)
|
2019-04-05 20:24:01 +04:00
|
|
|
@for file in context entry trap ; do \
|
2019-04-09 13:06:33 +04:00
|
|
|
$(hostcc) -E src/arch/$(arch)/boot/$${file}.S -o src/arch/$(arch)/boot/$${file}.gen.s ; \
|
2019-04-05 20:24:01 +04:00
|
|
|
done
|
2019-03-31 18:04:22 +04:00
|
|
|
@cargo xbuild $(build_args)
|
2018-09-18 14:05:37 +04:00
|
|
|
endif
|
2018-04-02 11:28:32 +04:00
|
|
|
|
2018-11-28 20:39:44 +04:00
|
|
|
|
|
|
|
### user programs ###
|
2018-12-02 15:51:52 +04:00
|
|
|
sfsimg:
|
2018-11-28 20:39:44 +04:00
|
|
|
@cd $(user_dir) && make sfsimg
|
|
|
|
|
2018-10-29 15:14:54 +04:00
|
|
|
|
|
|
|
### install ###
|
|
|
|
ifeq ($(board), raspi3)
|
|
|
|
sd_card ?=
|
|
|
|
|
|
|
|
ifeq ($(shell uname), Darwin)
|
|
|
|
sd_card := /Volumes/boot
|
|
|
|
else ifeq ($(shell uname), Linux)
|
|
|
|
sd_card := /media/$(shell whoami)/boot
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef sd_card
|
|
|
|
.PHONY:
|
2019-03-04 11:22:19 +04:00
|
|
|
install: $(kernel_img)
|
|
|
|
cp $(kernel_img) $(sd_card)/kernel8.img
|
2018-10-29 15:14:54 +04:00
|
|
|
sudo umount $(sd_card)
|
|
|
|
endif
|
|
|
|
|
|
|
|
endif
|
2018-12-31 21:53:33 +04:00
|
|
|
|
2019-03-18 14:20:27 +04:00
|
|
|
ifeq ($(board), u540)
|
|
|
|
.PHONY:
|
|
|
|
install: $(kernel_img)
|
2019-04-20 12:41:52 +04:00
|
|
|
@$(objcopy) -S -O binary ../tools/opensbi/fu540.elf $(build_path)/bin
|
2019-04-21 19:47:00 +04:00
|
|
|
@dd if=$< of=$(build_path)/bin bs=0x20000 seek=16
|
|
|
|
@../tools/u540/mkimg.sh $(build_path)/bin $(build_path)/u540.img
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(board), k210)
|
|
|
|
.PHONY:
|
|
|
|
install: $(kernel_img)
|
|
|
|
@$(objcopy) -S -O binary ../tools/opensbi/k210.elf $(build_path)/k210.img
|
|
|
|
@dd if=$< of=$(build_path)/k210.img bs=0x10000 seek=1
|
|
|
|
@python3 ../tools/k210/kflash.py -b 600000 $(build_path)/k210.img
|
2019-03-18 14:20:27 +04:00
|
|
|
endif
|
|
|
|
|
2019-01-08 15:04:34 +04:00
|
|
|
.PHONY:
|
|
|
|
addr2line:
|
2019-04-29 06:45:04 +04:00
|
|
|
@python3.7 ../tools/addr2line.py $(prefix)addr2line $(arch) $(mode)
|