Skip to content

Commit

Permalink
build: freeloader use dtb generated from conf/*.dts not uboot
Browse files Browse the repository at this point in the history
To do this mainly for Flash start mode, because in flash start
mode the dtb used is the one in uboot not the one in conf/.

It will cause linux with ux600fd enabled boot fail because
the dts in u-boot/arch/riscv/dts/nuclei-hbird.dts as below
riscv,isa = "rv64imac"; this is fixed to rv64imac which might
affect the normal boot controlled by linux/arch/riscv/kernel/cpufeature.c

Signed-off-by: Huaqi Fang <[email protected]>
  • Loading branch information
fanghuaqi committed Jan 21, 2021
1 parent 767a563 commit 134e84b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
linux-*.tar.xz
work/
toolchain
.vscode/
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ help:
@echo "- freeloader : generate freeloader(first stage loader) run in norflash"
@echo "- freeloader4m : generate freeloader(first stage loader) 4MB version run in norflash"
@echo "- upload_freeloader : upload freeloader into development board using openocd and gdb"
@echo "- debug_freeloader : connect to board, and debug it using openocd and gdb"
@echo "- uboot : build uboot and generate uboot binary"
@echo "- sim : run opensbi + linux payload in simulation using xl_spike"
@echo "- clean : clean this full workspace"
Expand Down Expand Up @@ -274,7 +275,7 @@ $(uboot_dtb): $(uboot_bin)
$(uboot_mkimage) $(uboot_bin): $(uboot_srcdir) $(uboot_wrkdir)/.config
make -C $(uboot_srcdir) O=$(uboot_wrkdir) CROSS_COMPILE=$(CROSS_COMPILE) all

.PHONY: freeloader prepare4m freeloader4m
.PHONY: freeloader prepare4m freeloader4m upload_freeloader debug_freeloader

prepare4m: buildroot_initramfs_sysroot
find $(buildroot_initramfs_wrkdir)/build/ -type f -wholename "*busybox*/.config" | xargs sed -i '/CONFIG_STATIC/cCONFIG_STATIC=y'
Expand All @@ -299,10 +300,12 @@ freeloader: $(freeloader_elf)
@echo "freeloader is generated in $(freeloader_elf)"
@echo "You can download this elf into development board using make upload_freeloader"
@echo "or using openocd and gdb to achieve it"
@echo "If you want to use gdb and openocd to debug it"
@echo "You can run make debug_freeloader to connect to the running target cpu"

$(freeloader_elf): $(freeloader_srcdir) $(uboot_bin) $(opensbi_jumpbin) $(boot_zip)
$(freeloader_elf): $(freeloader_srcdir) $(uboot_bin) $(opensbi_jumpbin) $(boot_zip) $(platform_dtb)
make -C $(freeloader_srcdir) ARCH=$(ISA) ABI=$(ABI) CROSS_COMPILE=$(CROSS_COMPILE) \
FW_JUMP_BIN=$(opensbi_jumpbin) UBOOT_BIN=$(uboot_bin) DTB=$(uboot_dtb)
FW_JUMP_BIN=$(opensbi_jumpbin) UBOOT_BIN=$(uboot_bin) DTB=$(platform_dtb)

upload_freeloader: $(freeloader_elf)
$(target_gdb) $< -ex "set remotetimeout 240" \
Expand All @@ -311,6 +314,13 @@ upload_freeloader: $(freeloader_elf)
-ex "monitor flash protect 0 0 last off" -ex "load" \
-ex "monitor resume" -ex "quit"

debug_freeloader: $(freeloader_elf)
$(target_gdb) $< -ex "set remotetimeout 240" \
-ex "target remote | $(openocd) --pipe -f $(platform_openocd_cfg)" \
-ex "set confirm off" -ex "add-symbol-file $(vmlinux)" \
-ex "add-symbol-file $(opensbi_jumpelf)" \
-ex "add-symbol-file $(uboot_elf)" -ex "set confirm on"

.PHONY: penglai cleanpenglai

penglai: buildroot_initramfs_sysroot
Expand Down
5 changes: 5 additions & 0 deletions conf/nuclei_ux600.dts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
ranges;
};

/* Used for Uboot SBI Console */
console {
compatible = "sbi,console";
};

hfclk: hfclk {
#clock-cells = <0>;
compatible = "fixed-clock";
Expand Down
5 changes: 5 additions & 0 deletions conf/nuclei_ux600fd.dts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
ranges;
};

/* Used for Uboot SBI Console */
console {
compatible = "sbi,console";
};

hfclk: hfclk {
#clock-cells = <0>;
compatible = "fixed-clock";
Expand Down

0 comments on commit 134e84b

Please sign in to comment.