Is fclose() or funmount() blocking or non-blocking?

Hello,

I use component File System 6.15.3 to write to a FAT32 eMMC from the microcontroller (STM32H7).

example sequence:


...
f=fopen("test.txt","w");
fwrite("testtesttest",1,12,f);
fflush(f);
fclose(f);
funmount("M0:");
Powerdown();

Is it save to shut down the system directly after fclose (or funmount())? Or can this potentially damage the file system because some data are still not completely written?

If  fclose()  / funmount() is a non-blocking function,  how do I know that all data is really written onto the memory card?

Maybe it is required to check the status from the MCI driver?

Parents
  • Short answer, after fclose() closes all the files, the system can be powered off immediately, (as all file storage operations should complete at that time).

    To save power, the SD card is told to go into standby mode after each write. This happens after internal SD card programming is done.

    If you are writing a custom CMSIS-MCI driver, and if it implements card power handling using CardPower() function:
    www.keil.com/.../group__mci__interface__gr.html
    ...then funmount() must be also called. - calling it will actually trigger the CardPower() function call.

Reply
  • Short answer, after fclose() closes all the files, the system can be powered off immediately, (as all file storage operations should complete at that time).

    To save power, the SD card is told to go into standby mode after each write. This happens after internal SD card programming is done.

    If you are writing a custom CMSIS-MCI driver, and if it implements card power handling using CardPower() function:
    www.keil.com/.../group__mci__interface__gr.html
    ...then funmount() must be also called. - calling it will actually trigger the CardPower() function call.

Children
No data