SdFat error code on Due only

I have been troubleshooting this problem for a few days now, and have decided I need help.

When running the FreeRTOS_ARM frFifoDataLogger sketch, unchanged on a stock Arduino Due, I receive the following output:

   Type any character to begin
   SD problem
   SD errorCode: 0X4,0X7F

I have classified this as a SdFat issue as replacing all of the SdFat references with the standard Arduino SD library removes this problem, but decreases the performace substantially enough to not work for my time critical project. It also leads to enough errors to once again be useless.

During my troubleshooting, I have made a number of observations: The FreeRTOS_AVR frFifoDataLogger works flawlessly using the same card on a stock Arduino Uno The Arduino Uno does not have enough RAM to handle my project Using a different SD card does not solve the problem, however the error changed from 0x4 to 0xF Replacing the SdFat folder that comes packaged with the FreeRTOS download with the latest version (from Github) does not solve the problem or change the error code. As mentioned, using the standard SD program works, but is too slow and/or prone to error Formatting the SD cards with SDFormatter V4.0 instead of the standard windows formatter does not solve the issue either. Modifying a sketch that does not use the FreeRTOS package, that works with the stock SD package, to use SdFat does not work either.

I investigated the error codes and found that 0x4 is defined as: "card returned an error response for CMD17 (read block)" and 0xF (from the other SD card) is defined as: "card returned an error token instead of read data"

I appreciate any and all help. Thank you.

Your problem may be the SD module or SPI wiring. The default SPI speed for SdFat on Due is 42 MHz. This speed requires short clean wiring and a good SD module.

Try slowing SPI by specifying a slower SPI speed like this.

  sd.begin(SD_CS_PIN, SPI_HALF_SPEED))

The error code is for a basic hardware problem so formatting the SD will not fix the problem.

Edit: The SD.h library is a wrapper for an old version of SdFat. The wrapper set SPI speed to 4 MHz on Due.

Thank you for your help. I know I'm not the only one in the community who appreciates someone who not only continues to support their projects for years, but so quickly helps out new members having trouble.

I slowed the SPI speed down to half, as you recommended, and am not longer encountering any errors. In the next day or two I will also try shortening the wires from the roughly four inches that they are now, to under an inch.