nRF9160 with Zephyr - SD card & fatfs errors

Hi,

I'm working on a project using Zephyr and ncs 1.7.1. One of its functions is to stream WAV files from a SD card. It only ever reads data.

The issue I'm having is every so often of playing a sound file on loop (after about 5 mins) Zephyr reports an error: <err> fs: file read error (-5). The errors happen randomly - it does not seem to be an issue with any particular point in the play/loop process. The SD card becomes totally unreadable and any further reads also fail.

I've tried all of the normal approaches - retrying reads, closing and re-opening the file, unmount and remount the drive, recalling the SD card init functions (via disk_access_init()), etc. No approach seems to work (there will either be a hard error or the recovery simply doesnt work) and resetting the entire system is the only reliable recovery.

Is there a method to successfully reinitialize the SD card and fatfs without resetting the whole system? I feel like the drivers and Zephyr should be able to accommodate this functionality.

The SD card is running at 8MHz (the maximum allowed frequency on the 9160)

  • jenga said:
    Catching the error on an oscilloscope won't be easy - when the error does happen, it happens randomly after many minutes.

    Would it be possible to do a logic trace from the pins instead. I agree that using an oscilloscope would be cumbersome.

    jenga said:
    A fellow engineer suggested that perhaps the CS signal causes this issue. Is there an option in Zephyr's SPI driver to hold CS low?

    You mean hold it low permanently? Don't think there is an option for this. Maybe you can modify the delay.

Related