From 7d5ca3f92656d56cf238855cc51892dbf85339fd Mon Sep 17 00:00:00 2001 From: Gabriel Somlo Date: Sat, 13 Jun 2020 21:31:12 -0400 Subject: [PATCH 1/3] bios/boot: addresses should use 'unsigned long' --- litex/soc/software/bios/boot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/litex/soc/software/bios/boot.c b/litex/soc/software/bios/boot.c index 47426b626..1582c7b83 100644 --- a/litex/soc/software/bios/boot.c +++ b/litex/soc/software/bios/boot.c @@ -415,7 +415,7 @@ static unsigned int check_image_in_flash(unsigned int base_address) } #if defined(MAIN_RAM_BASE) && defined(FLASH_BOOT_ADDRESS) -static int copy_image_from_flash_to_ram(unsigned int flash_address, unsigned int ram_address) +static int copy_image_from_flash_to_ram(unsigned int flash_address, unsigned long ram_address) { uint32_t length; uint32_t offset; @@ -474,7 +474,7 @@ void flashboot(void) #if defined(CSR_SPISDCARD_BASE) || defined(CSR_SDCORE_BASE) -static int copy_file_from_sdcard_to_ram(const char * filename, unsigned int ram_address) +static int copy_file_from_sdcard_to_ram(const char * filename, unsigned long ram_address) { FRESULT fr; FATFS fs; From c05d0f196649c4e399d2c9f7a21606fccfb5a7e4 Mon Sep 17 00:00:00 2001 From: Gabriel Somlo Date: Sat, 13 Jun 2020 21:34:11 -0400 Subject: [PATCH 2/3] liblitesdcard/spisdcard: streamline initialization (cosmetic). --- litex/soc/software/liblitesdcard/spisdcard.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/litex/soc/software/liblitesdcard/spisdcard.c b/litex/soc/software/liblitesdcard/spisdcard.c index 19cbaf7af..510c34fe7 100644 --- a/litex/soc/software/liblitesdcard/spisdcard.c +++ b/litex/soc/software/liblitesdcard/spisdcard.c @@ -276,14 +276,9 @@ DSTATUS disk_status(uint8_t drv) { } DSTATUS disk_initialize(uint8_t drv) { - uint8_t r; - - if (drv) return RES_NOTRDY; - - r = spisdcard_init(); + if (drv) return STA_NOINIT; + spisdcardstatus = spisdcard_init() ? 0 : STA_NOINIT; spisdcard_deselect(); - - spisdcardstatus = r ? 0 : STA_NOINIT; return spisdcardstatus; } From 5d9d99c0c282c2976a623651652b193b327c0f04 Mon Sep 17 00:00:00 2001 From: Gabriel Somlo Date: Mon, 15 Jun 2020 15:31:37 -0400 Subject: [PATCH 3/3] liblitesdcard/sdcard: streamline initialization (cosmetic) Also, s/spisdcardstatus/sdcardstatus/g (this is *not* the SPI version). --- litex/soc/software/liblitesdcard/sdcard.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/litex/soc/software/liblitesdcard/sdcard.c b/litex/soc/software/liblitesdcard/sdcard.c index 92edf8e6e..f3108f8ac 100644 --- a/litex/soc/software/liblitesdcard/sdcard.c +++ b/litex/soc/software/liblitesdcard/sdcard.c @@ -719,22 +719,17 @@ int sdcard_test(unsigned int blocks) /* SDCard FatFs disk functions */ /*-----------------------------------------------------------------------*/ -static DSTATUS spisdcardstatus = STA_NOINIT; +static DSTATUS sdcardstatus = STA_NOINIT; DSTATUS disk_status(uint8_t drv) { if (drv) return STA_NOINIT; - return spisdcardstatus; + return sdcardstatus; } DSTATUS disk_initialize(uint8_t drv) { - uint8_t r; - - if (drv) return RES_NOTRDY; - - r = sdcard_init(); - - spisdcardstatus = r ? 0 : STA_NOINIT; - return spisdcardstatus; + if (drv) return STA_NOINIT; + sdcardstatus = sdcard_init() ? 0 : STA_NOINIT; + return sdcardstatus; } DRESULT disk_read(uint8_t drv, uint8_t *buf, uint32_t sector, uint32_t count) {