2020-12-01 11:38 AM
I'm using FatFs without RTOS, and quite often the f_mount() call will fail. Right now it always fails, but in a previous version of my code it failed only 20%. My current mount code (using HAL) looks like
  if (f_mount(&fatfs, "", 1))
    led_on_abort();and my initialization before in main.c looks like
  HAL_Init();
  SystemClock_Config();
  MX_GPIO_Init();
  MX_DMA_Init();
  MX_FMC_Init();
  MX_SDMMC1_SD_Init();
  MX_FATFS_Init();
  MX_RTC_Init();
  MX_NVIC_Init();I did enable interrupts and DMA for SDMMC1. That's why those init calls are before f_mount().
Could there be a timing issue causing f_mount to fail? Note that changing the immediate parameter to 0 does not prevent the failure.
When I'm debugging, everything works just fine. That's why I think there could be some timing issue -- not enough time between SDMMC/FatFs-Init and f_mount, or between f_mount and f_open (when not immediate).
Any ideas?
Solved! Go to Solution.
2020-12-03 9:26 AM
For the record, it was not a race condition. I entered a value of 100 ticks into the FatFs timeout, which was way too little. Setting the value to 10000 only makes f_mount() fail in 5%.
2020-12-03 9:26 AM
For the record, it was not a race condition. I entered a value of 100 ticks into the FatFs timeout, which was way too little. Setting the value to 10000 only makes f_mount() fail in 5%.