SD Card Initialisation Issue - SPI bus hangs

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:

  1. Changing the delay time after power turned on to SD card 0-20mS = slightly less when 0-1mS
  2. Reducing the SPI bus speed (normally set at 60MHz) 30MHz = no change
  3. Different OS, most tests done on 1.4.4 also tried 2.0.0-rc.4 = no difference
  4. Different quality SD card (standard Sandisk SD class 4) Sandisk Ultra SD class 10 = no change
  5. 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?