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)

Parents
  • Hello,

    the max SPI frequency for the SDHC driver should be higher than 4Mhz. You should try probing the SPI pins when it breaks down to see what happens.

  • I totally agree it should work above 4MHz. However I've tested the SD card overnight (SPI CLK at 4MHz, playing a WAV file on loop) and have not encountered the -5 error again. That would indicate it's a signalling issue.

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

    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?

    The board I'm using is custom, so I guess I can't rule out being a design/routing issue. Seems unlikely though. 

Reply
  • I totally agree it should work above 4MHz. However I've tested the SD card overnight (SPI CLK at 4MHz, playing a WAV file on loop) and have not encountered the -5 error again. That would indicate it's a signalling issue.

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

    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?

    The board I'm using is custom, so I guess I can't rule out being a design/routing issue. Seems unlikely though. 

Children
No Data
Related