diff --git a/firmware/export/ata.h b/firmware/export/ata.h index 5be32da231..a3537812e5 100644 --- a/firmware/export/ata.h +++ b/firmware/export/ata.h @@ -37,7 +37,7 @@ void ata_sleepnow(void); */ bool ata_disk_is_active(void); int ata_soft_reset(void); -int ata_init(void); +int ata_init(void) STORAGE_INIT_ATTR; void ata_close(void); int ata_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf); int ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf); diff --git a/firmware/export/config.h b/firmware/export/config.h index a7f0a3578f..979a14d0c9 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -908,6 +908,16 @@ Lyre prototype 1 */ #define INITDATA_ATTR #endif +/* We need to call storage_init more than once only if USB storage mode is + * handled in hardware: + * Deinit storage -> let hardware handle USB mode -> storage_init() again + */ +#if defined(HAVE_USBSTACK) || defined(USB_NONE) +#define STORAGE_INIT_ATTR INIT_ATTR +#else +#define STORAGE_INIT_ATTR +#endif + #if (CONFIG_PLATFORM & PLATFORM_HOSTED) && defined(__APPLE__) #define DATA_ATTR __attribute__ ((section("__DATA, .data"))) #else diff --git a/firmware/export/mmc.h b/firmware/export/mmc.h index f2b0ad3509..7e72cb0846 100644 --- a/firmware/export/mmc.h +++ b/firmware/export/mmc.h @@ -33,7 +33,7 @@ void mmc_sleep(void); void mmc_sleepnow(void); bool mmc_disk_is_active(void); int mmc_soft_reset(void); -int mmc_init(void); +int mmc_init(void) STORAGE_INIT_ATTR; void mmc_close(void); int mmc_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf); int mmc_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf); diff --git a/firmware/export/nand.h b/firmware/export/nand.h index 60b986dc2f..13d559486c 100644 --- a/firmware/export/nand.h +++ b/firmware/export/nand.h @@ -33,7 +33,7 @@ void nand_sleep(void); void nand_sleepnow(void); bool nand_disk_is_active(void); int nand_soft_reset(void); -int nand_init(void); +int nand_init(void) STORAGE_INIT_ATTR; void nand_close(void); int nand_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf); int nand_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf); diff --git a/firmware/export/ramdisk.h b/firmware/export/ramdisk.h index 7a56e05989..5135e38301 100644 --- a/firmware/export/ramdisk.h +++ b/firmware/export/ramdisk.h @@ -32,7 +32,7 @@ void ramdisk_spindown(int seconds); void ramdisk_sleep(void); bool ramdisk_disk_is_active(void); int ramdisk_soft_reset(void); -int ramdisk_init(void); +int ramdisk_init(void) STORAGE_INIT_ATTR; void ramdisk_close(void); int ramdisk_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf); int ramdisk_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf); diff --git a/firmware/export/sd.h b/firmware/export/sd.h index 8e400bf88a..43c961efb3 100644 --- a/firmware/export/sd.h +++ b/firmware/export/sd.h @@ -39,7 +39,7 @@ void sd_sleep(void); void sd_sleepnow(void); bool sd_disk_is_active(void); int sd_soft_reset(void); -int sd_init(void); +int sd_init(void) STORAGE_INIT_ATTR; void sd_close(void); int sd_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf); int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf); diff --git a/firmware/export/storage.h b/firmware/export/storage.h index e9ac8b4cb9..58d8d32b6d 100644 --- a/firmware/export/storage.h +++ b/firmware/export/storage.h @@ -214,7 +214,7 @@ void storage_sleep(void); void storage_sleepnow(void); bool storage_disk_is_active(void); int storage_soft_reset(void); -int storage_init(void); +int storage_init(void) STORAGE_INIT_ATTR; int storage_flush(void); void storage_spin(void); void storage_spindown(int seconds);