From: rprinz08 Date: Fri, 15 May 2020 10:07:52 +0000 (+0200) Subject: Make booting from SD-Card to behave same as from SPI flash X-Git-Tag: 24jan2021_ls180~334^2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3f649077b1e5e57403d720534736d3b42e415fa0;p=litex.git Make booting from SD-Card to behave same as from SPI flash --- diff --git a/litex/soc/software/bios/boot.c b/litex/soc/software/bios/boot.c index 795b7b3a..2a757927 100644 --- a/litex/soc/software/bios/boot.c +++ b/litex/soc/software/bios/boot.c @@ -512,19 +512,34 @@ void spisdcardboot(void) return; } + unsigned int result; + #if defined(CONFIG_CPU_TYPE_VEXRISCV) && defined(CONFIG_CPU_VARIANT_LINUX) - if(spi_sdcard_readFile("IMAGE","",MAIN_RAM_BASE+KERNEL_IMAGE_RAM_OFFSET)==0) return; - if(spi_sdcard_readFile("ROOTFS~1","CPI",MAIN_RAM_BASE+ROOTFS_IMAGE_RAM_OFFSET)==0) return; - if(spi_sdcard_readFile("RV32","DTB",MAIN_RAM_BASE+DEVICE_TREE_IMAGE_RAM_OFFSET)==0) return; - if(spi_sdcard_readFile("EMULATOR","BIN",MAIN_RAM_BASE+EMULATOR_IMAGE_RAM_OFFSET)==0) return; + result = spi_sdcard_readFile("IMAGE", "", + MAIN_RAM_BASE + KERNEL_IMAGE_RAM_OFFSET); - boot(0,0,0,MAIN_RAM_BASE + EMULATOR_IMAGE_RAM_OFFSET); -#else - if(spi_sdcard_readFile("BOOT","BIN",MAIN_RAM_BASE)==0) { - printf("SD Card SPI boot failed\n"); + if(result) + result &= spi_sdcard_readFile("ROOTFS~1", "CPI", + MAIN_RAM_BASE + ROOTFS_IMAGE_RAM_OFFSET); + + if(result) + result &= spi_sdcard_readFile("RV32", "DTB", + MAIN_RAM_BASE + DEVICE_TREE_IMAGE_RAM_OFFSET); + + if(result) + result &= spi_sdcard_readFile("EMULATOR", "BIN", + MAIN_RAM_BASE + EMULATOR_IMAGE_RAM_OFFSET); + + if(result) { + boot(0, 0, 0, MAIN_RAM_BASE + EMULATOR_IMAGE_RAM_OFFSET); return; } - boot(0, 0, 0, MAIN_RAM_BASE); #endif + + result = spi_sdcard_readFile("BOOT", "BIN", MAIN_RAM_BASE); + if(result) + boot(0, 0, 0, MAIN_RAM_BASE); + else + printf("SD Card SPI boot failed\n"); } #endif