diff --git a/docs/uboot_raspi3.md b/docs/uboot_raspi3.md new file mode 100644 index 00000000..aa792bd7 --- /dev/null +++ b/docs/uboot_raspi3.md @@ -0,0 +1,18 @@ +How to use u-boot to boot rCore in Raspberry Pi +=============== + +Tested under QEMU. + +Instructions: + +1. Build u-boot + 1. Download aarch64 toolchain and u-boot source + 2. `make rpi_3_defconfig ARCH=arm CROSS_COMPILE=aarch64-elf-` + 3. `make all ARCH=arm CROSS_COMILE=aarch64-elf-` + 4. A file named `u-boot.bin` should be generated +2. Use u-boot to run rCore + 1. `make run arch=aarch64 u_boot=/path/to/u-boot.bin` + 2. In u-boot, enter following commands: + 1. `mmc read 0x1000000 0 ${nblocks}`, where ${nblocks} can be probed if you enter a large enought number + 2. `bootelf -p 0x1000000` + 3. rCore should boot now \ No newline at end of file diff --git a/kernel/Makefile b/kernel/Makefile index c47efc13..3543c70e 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -16,18 +16,19 @@ # # Options: # arch = x86_64 | riscv32 | riscv64 | aarch64 -# d = int | in_asm | ... QEMU debug info +# d = int | in_asm | ... QEMU debug info # mode = debug | release # LOG = off | error | warn | info | debug | trace -# 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 -# | u540 Only available on riscv64, run on HiFive U540, use Sv39 -# | 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 +# 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 +# | u540 Only available on riscv64, run on HiFive U540, use Sv39 +# | 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 # extra_nic = on | off Only available on x86_64, add an additional e1000 nic +# u_boot = /path/to/u-boot.bin Only available on aarch64, use u-boot to boot rcore arch ?= riscv64 board ?= none @@ -114,6 +115,10 @@ qemu_opts += \ -machine $(board) \ -serial null -serial mon:stdio \ -kernel $(kernel_img) +ifneq ($(u_boot), ) +qemu_opts += \ + -sd $(bootloader) +endif endif ifdef d @@ -262,8 +267,12 @@ else ifeq ($(arch), riscv64) make -j && \ cp bbl $(abspath $@) else ifeq ($(arch), aarch64) +ifneq ($(u_boot), ) + @cp $(u_boot) $@ +else @$(objcopy) $(bootloader) --strip-all -O binary $@ endif +endif kernel: @echo Building $(arch) kernel