diff --git a/litex/soc/software/bios/boot.c b/litex/soc/software/bios/boot.c index 67abc88c2..bcd72f0ba 100755 --- a/litex/soc/software/bios/boot.c +++ b/litex/soc/software/bios/boot.c @@ -580,7 +580,7 @@ void netboot(int nb_params, char **params) /* Flash Boot */ /*-----------------------------------------------------------------------*/ -#ifdef FLASH_BOOT_ADDRESS +#if defined(FLASH_BOOT_ADDRESS) || defined(MAIN_RAM_BASE) static unsigned int check_image_in_flash(unsigned int base_address) { @@ -603,9 +603,10 @@ static unsigned int check_image_in_flash(unsigned int base_address) return length; } +#endif -#if defined(MAIN_RAM_BASE) && defined(FLASH_BOOT_ADDRESS) -static int copy_image_from_flash_to_ram(unsigned int flash_address, unsigned long ram_address) +#if defined(MAIN_RAM_BASE) +int copy_image_from_flash_to_ram(unsigned int flash_address, unsigned long ram_address) { uint32_t length; uint32_t offset; @@ -632,6 +633,7 @@ static int copy_image_from_flash_to_ram(unsigned int flash_address, unsigned lon } #endif +#if defined(FLASH_BOOT_ADDRESS) void flashboot(void) { uint32_t length; diff --git a/litex/soc/software/bios/boot.h b/litex/soc/software/bios/boot.h index 338312d09..9128292b1 100644 --- a/litex/soc/software/bios/boot.h +++ b/litex/soc/software/bios/boot.h @@ -12,5 +12,8 @@ void flashboot(void); void romboot(void); void sdcardboot(void); void sataboot(void); +extern void target_init(void) __attribute__((weak)); +extern void target_boot(void) __attribute__((weak)); +extern int copy_image_from_flash_to_ram(unsigned int flash_address, unsigned long ram_address); #endif /* __BOOT_H */ diff --git a/litex/soc/software/bios/main.c b/litex/soc/software/bios/main.c index e576b6878..5e4d9abfb 100644 --- a/litex/soc/software/bios/main.c +++ b/litex/soc/software/bios/main.c @@ -57,6 +57,8 @@ static void boot_sequence(void) if (serialboot() == 0) return; #endif + if (target_boot) + target_boot(); #ifdef FLASH_BOOT_ADDRESS flashboot(); #endif @@ -297,6 +299,10 @@ __attribute__((__used__)) int main(int i, char **c) /* Execute initialization functions */ init_dispatcher(); + /* Execute any target specific initialisation (if linked) */ + if (target_init) + target_init(); + /* Execute Boot sequence */ #ifndef CONFIG_BIOS_NO_BOOT if(sdr_ok) {