Skip to main content
AFung.1
Associate II
Jun 20, 2022 10:53 PM UTC
Question

Got FR_INT_ERR when running f_read() in Project FatFS_uSD_Standalone

Hello,

I am using NUCLEO-H743ZI2 and running the project FatFS_uSD_Standalone with AdaFruit microSD. The TFT_ShieldDetect() is commented out because there is no LCD. The STM32.txt is successfully created and the text is successfully written into the file and read back.

I would like to read the existing text file STM32.txt. I modified the code for this purpose:

  • f_mkfs() is commented out since I don't want the contain to be erased. Then run the following code:

 if(f_mount(&SDFatFs, (TCHAR const*)SDPath, 0) == FR_OK)

 {

HAL_Delay(1);

res = f_open(&MyFile, "STM32.TXT", FA_OPEN_EXISTING | FA_READ);

   if(res == FR_OK)

   {

   res = f_read(&MyFile, rtext, sizeof(rtext), (void *)&bytesread);

   f_close(&MyFile);

  }

}

The error FR_INT_ERR  is returned from f_read(). How can I read the content of an existing file?

Thanks,

This topic has been closed for replies.

4 replies

Tesla DeLorean
Guru
Jun 21, 2022 1:06 AM UTC

Internal errors, could be memory corruption/caching. Adequate stack space for local/auto variables.

For large MicroSD cards, could be an old version of FatFs library

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
AFung.1
AFung.1Author
Associate II
Jun 21, 2022 8:26 PM UTC

The size of the microSD is 64Mb. The buffer size of rtext is 100 bytes. The file can be successfully opened but return FR_INT_ERR from f_read(). Not sure what causing it. Can you give some advice on this?

Thanks,

AFung.1
AFung.1Author
Associate II
Jun 21, 2022 1:35 AM UTC

The size of the microSD is 64Mb. The buffer size of rtext is 100 bytes.

AFung.1
AFung.1Author
Associate II
Jun 21, 2022 3:58 PM UTC

Hello Tesla,

But the original project is working with write and read. How can I read the existing file only?

Thank,

Andy