Solved! Go to Solution.
Hello @olav,
I've had a similar problem some weeks ago.
Here is the call stack (bottom to top) of the problem (simplified code):
sdmmc/sd/fsl_sd.c : status_t SD_Init(sd_card_t *card)
{
if (!card->isHostReady)
SD_HostInit(card);
else
SD_HostDoReset(card);
...//Not important code
}
[our code] : DSTATUS sd_disk_initialize(BYTE pdrv)
{
if(sd is init)
SD_CardDeinit()
SD_Init()
...
}
[our code] : DSTATUS disk_initialize (BYTE pdrv)
{
sd_disk_initialize(pdrv);
}
fatfs/source/ff.c : ... f_mkfs(...)
At the first call to SD_Init, it goes to SD_HostInit(), wich call SDMMCHOST_CardDetectInit() that enable cardDetect interrupts.
If you call again this function, this go to SD_HostDoReset(), redirecting to
sdmmc/host/non_blocking/fsl_sdmmc_host.c : SDMMCHOST_Reset()
{
...
SDIF_DisableInterrupt(host->hostController.base, kSDIF_AllInterruptStatus); //This disable all host interrupts, including CardDetect interrupt
...
}
Card detect interrupt is never re-activated later...
We fixed this problem by changing the line to :
SDIF_DisableInterrupt(host->hostController.base, kSDIF_AllInterruptStatus & ~kSDIF_CardDetect); //Disable all interrupts except card detect
I hope your problem is related
Hello @olav,
I've had a similar problem some weeks ago.
Here is the call stack (bottom to top) of the problem (simplified code):
sdmmc/sd/fsl_sd.c : status_t SD_Init(sd_card_t *card)
{
if (!card->isHostReady)
SD_HostInit(card);
else
SD_HostDoReset(card);
...//Not important code
}
[our code] : DSTATUS sd_disk_initialize(BYTE pdrv)
{
if(sd is init)
SD_CardDeinit()
SD_Init()
...
}
[our code] : DSTATUS disk_initialize (BYTE pdrv)
{
sd_disk_initialize(pdrv);
}
fatfs/source/ff.c : ... f_mkfs(...)
At the first call to SD_Init, it goes to SD_HostInit(), wich call SDMMCHOST_CardDetectInit() that enable cardDetect interrupts.
If you call again this function, this go to SD_HostDoReset(), redirecting to
sdmmc/host/non_blocking/fsl_sdmmc_host.c : SDMMCHOST_Reset()
{
...
SDIF_DisableInterrupt(host->hostController.base, kSDIF_AllInterruptStatus); //This disable all host interrupts, including CardDetect interrupt
...
}
Card detect interrupt is never re-activated later...
We fixed this problem by changing the line to :
SDIF_DisableInterrupt(host->hostController.base, kSDIF_AllInterruptStatus & ~kSDIF_CardDetect); //Disable all interrupts except card detect
I hope your problem is related
Thank you @lucas3
This fixed the problem. Hope someone at NXP pics this up, because it is obviously a bug in the SDK.
Olav
Hi Alice
The f_mkfs() function formats the SDCARD, in other words all data will be lost every time I call f_mkfs() (at card insert, or power up), and that's not useful at all
BR
Olav