Firmware restart while refreshing DWC and pausing
-
I think the problem is the static variables in sd_mmc.c:
//! SD/MMC card list //DC added __nocache for SAME70 because 'csd' is read by DMA static __nocache struct sd_mmc_card sd_mmc_cards[SD_MMC_MEM_CNT]; //! Index of current slot selected static uint8_t sd_mmc_slot_sel; //! Pointer on current slot selected static struct sd_mmc_card *sd_mmc_card; //! Number of block to read or write on the current transfer static uint16_t sd_mmc_nb_block_to_tranfer = 0; //! Number of block remaining to read or write on the current transfer static uint16_t sd_mmc_nb_block_remaining = 0;
The first one should be OK because there is one entry per SD card, but the other four are not, assuming they are used for both HSMCI and SPI transfers. So I think that sd_mmc_slot_sel needs to be passed around as a parameter, then the second one replaced by indexing into sd_mmc_cards (i.e. initialise a local sd_mmc_card variable at the start of each function that uses it), then the other two can be turned into arrays indexed by slot (strictly speaking, one element per channel would be enough, but one per slot is simpler).
I will probably only implement it for 3.3, although it's looking likely that there will be a 3.2.1, so the fix may get back-ported to that if it is simple enough.
-