SDIF driver invalid error handling

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SDIF driver invalid error handling

890 Views
tomasvavra
Contributor I

I am using SDK 2.6.0 with LPCExpresso54618 and running an example lpcxpresso54618_fatfs_sdcard_fatfs.

If the write to the card timeouts or fail for any reason, then i run into an assert in SDIF_TransferHandleData

    1404: assert(handle->data);

Reason for this is interruptFlags & kSDIF_DataTransferStatus is true in SDIF_TransferHandleIRQ but handle->data was already set to NULL by SD_StopTransmission (SDIF_TransferNonBlocking).

How reliable is this driver?

My stack:

lpcxpresso54618_fatfs_sdcard_fatfs LinkServer Debug [C/C++ (NXP Semiconductors) MCU Application]    
    lpcxpresso54618_fatfs_sdcard_fatfs.axf [LPC54618J512 (cortex-m4)]    
        Thread #1 1 (Suspended : Signal : SIGQUIT:Quit)    
            __sys_appexit() at 0x6878    
            SDIF_TransferHandleData() at fsl_sdif.c:1,404 0x5e06    
            SDIF_TransferHandleIRQ() at fsl_sdif.c:1,521 0x5f96    
            SDIO_DriverIRQHandler() at fsl_sdif.c:1,566 0x600c    
            SDIO_IRQHandler() at startup_lpc54618.c:678 0x7ad6    
            <signal handler called>() at 0xfffffff9    
            SDIF_SendCommand() at fsl_sdif.c:729 0x56fe    
            SDIF_TransferNonBlocking() at fsl_sdif.c:1,303 0x5c46    
            SDMMCHOST_TransferFunction() at fsl_sdmmc_host.c:137 0x2b1c    
            SD_StopTransmission() at fsl_sd.c:374 0xa86    
            SD_Transfer() at fsl_sd.c:421 0xaf2    
            SD_Write() at fsl_sd.c:1,460 0x203e    
            SD_WriteBlocks() at fsl_sd.c:1,654 0x22b4    
            sd_disk_write() at fsl_sd_disk.c:45 0x44ca    
            disk_write() at diskio.c:223 0x7f4c    
            f_write() at ff.c:3,875 0x94d6    
            main() at fatfs_sdcard.c:275 0x688    
    arm-none-eabi-gdb (8.2.50.20181213)

Tags (3)
0 Kudos
3 Replies

729 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Tomas,

 

Sorry for my late reply. I ran several times the fatfs_sdcard on my LPCXpresso54618 board and I couldn’t get  run into the assert in SDIF_TransferHandleData.

 

Could you please provide the steps you are doing on your side to see if I can replicate the issue?

 

Best regards,

Felipe

0 Kudos

729 Views
tomasvavra
Contributor I

Hello Felipe, thank you for the reply. I can reproduce this by removing the SD card during the write to the file. This causes a timeout and SD_StopTransmission() being issued, which sets handle->data to null and following interrupt is trying to handle the data write SDIF_TransferHandleData() which expects handle->data not being null.

Those 2 stacked calls are simply in collision.

0 Kudos

729 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Tomas,

 

Sorry for my delayed reply.

 

I debugged the code on my side and this is a correct behavior. If there is an error in the transmission SD_StopTransmission will abort the current transfer. What you could do is to change the reply argument when you call SD_Transfer. This way if the transmission fails, the software can retry several times to see if the connection can be established again.

 

I hope this helps!

 

Best regards,

Felipe

0 Kudos