There was a thread 6 months back now closed.
I am getting lots of issues with a device with an SD Card, the device spends a good amount of time sleeping and with the power to the peripherals (including the SD card) switched off. When it wakes from sleep the power to the peripherals is immediately turned on and after a period of time (18mS) to allow the power to settle, the SD card controller is re-initialised. Occasionally this function hangs and the AWD kicks in to reset the device recording the line where the application code stopped - this is always when this SD Card initialisation function is called. SD card initialisation never fails at startup and typically fails 6 times every 24 hours given that a sleeping device will wake every 5 minutes = a 2% failure rate (have seen 6%).
So far I have tried the following:
- Changing the delay time after power turned on to SD card 0-20mS = slightly less when 0-1mS
- Reducing the SPI bus speed (normally set at 60MHz) 30MHz = no change
- Different OS, most tests done on 1.4.4 also tried 2.0.0-rc.4 = no difference
- Different quality SD card (standard Sandisk SD class 4) Sandisk Ultra SD class 10 = no change
- Different SD card = this has the most correlation to solving the problem, i.e. certain SD cards always fault and others never fault, one workaround is to ‘run-in’ a device in the factory and if it faults then swap the SD card until it stops.
I wondered if those with more knowledge of the workings of SD flash storage with Particle devices might be able to help shed any scientific reason on these findings. Also, what could be done with the SDfat library to ensure the SD Card init retries or avoids getting into a hang condition?