4.根据SD CARD、SPI NAND FLASH 、SPI NOR FLASH判断初始化那种外设。
5.根据opensbi/rtos/uboot,将其搬运到DDR中执行,然后程序运行在DDR中。
4.启动opensbi
此时程序就运行在DDR中了,对于开发RISCV的人来说,opensbi并不陌生,一方面这个是后台常驻程序,提供S-mode和M-mode的转换层,另外也起到引导下一阶段程序的目的。这个d1下个阶段指的是uboot。然后opensbi就常驻在M-mode下了。作为独立的程序,我也在裸机层面去编译下载opensbi。
https://github.com/bigmagic123/d1-nezha-baremeta/tree/main/opensbi
编译的过程可以通过
要想在d1上运行opensbi,首先需要根据下面的情况进行编译。
cd d1-nezha-baremeta/opensbi
然后导入环境变量
export CROSS_COMPILE=/home/bigmagic/work/toolchain-thead-glibc/riscv64-glibc-gcc-thead_20200702/bin/riscv64-unknown-linux-gnu- PLATFORM_RISCV_ISA=rv64gcxthead FW_JUMP_ADDR=0x40200000 FW_TEXT_START=0x40000000
最后进行编译
make PLATFORM=thead/c910
正常情况下,生成
AS platform/thead/c910/standby-normal/standby.o
CC platform/thead/c910/standby-normal/loadelf.o
CC platform/thead/c910/sunxi_platform.o
CC platform/thead/c910/opensbi_head.o
AS platform/thead/c910/sunxi_cpuidle.o
CC platform/thead/c910/sunxi_idle.o
AR platform/thead/c910/lib/libplatsbi.a
AS platform/thead/c910/firmware/fw_dynamic.o
ELF platform/thead/c910/firmware/fw_dynamic.elf
OBJCOPY platform/thead/c910/firmware/fw_dynamic.bin
AS platform/thead/c910/firmware/fw_jump.o
ELF platform/thead/c910/firmware/fw_jump.elf
OBJCOPY platform/thead/c910/firmware/fw_jump.bin
可以把build/platform/thead/c910/firmware/fw_jump.bin文件下载。