Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Fatfs example does not work with every sd card?

Hi, I am working on application where I need to store some bigger files. I chose to use sdcard, but I get weird behaviour. Some sd cards, this looks like totaly random ones are working and other are not with fatfs on nrf52. I was trying few cards with fatfs example from SDK and one was working while all other seems to hang up at disk_initialization:

I tried making changes as suggested here: https://devzone.nordicsemi.com/f/nordic-q-a/25951/sd-card-example-not-working-fine but it wont help. I can work with that few are not working but it looks like most of them is not working. Is there recommended sdcard size/type/manufacturer to be used with nrf52?

Regards,

Michał

Parents
  • Hi Michał,

    Could you provide some more information (size/type/manufacturer)  about the the SD cards. 
    Which one works and which one doesn't work?

    What SDK version do you use on the nRF52 DK ?

    Do you have any additional information that could be helpfull so it can be reproduced for someone else?

Reply
  • Hi Michał,

    Could you provide some more information (size/type/manufacturer)  about the the SD cards. 
    Which one works and which one doesn't work?

    What SDK version do you use on the nRF52 DK ?

    Do you have any additional information that could be helpfull so it can be reproduced for someone else?

Children
  • Hi Martin,

    I tried with Sandisk 8/16GB, Unirex 4GB, 2x Kingston 8GB - only one kingston would work although do not look the same, all cards are micro SDHC.

    At first I used non modified example from SDK 14.2, but then I was messing around with pull ups for data lines. By the way is setting pull up/ pull down for output gpio valid configuration operation? I was trying no pull/pull down/ pull up on MISO line. I tried decreasing frequency value for initilization (APP_SDCARD_FREQ_INIT). Every time the same result. Success for one of Kingston cards and fail for all the other ones. 

    I was also trying reformatting sdcard but it wont help.

    I will try testing my cards with arduino, which also uses fatfs to ensure that it is problem with nrf not fatfs or sdcard.

    Also this very important part of our project and from subscribers number of this thread I think this issure is pretty common problem. 

    Regards

  • Hi Martin,

    Is there any chance that in fatfs port there is used CMD1 from fatfs ? https://stackoverflow.com/questions/8080718/sdhc-microsd-card-and-spi-initialization - I found it might be a problem for SDHC cards when used too early.

  • Hi Michał,

    What are your test results with Arduino? Just curious.

    So far I did not have a problem with this library. If example "hangs" I gues you are ending in some wait loop in function DSTATUS disk_initialize(BYTE drv).  May you please verify that with a debugger?

  • For Arduino the same card was the only one working so possible it something with the shield that I am using, I will try to eliminate hardware problem.

    I debugged code yesterday and it looks like it went through initilization returning BUSY but for some reason it didnt print all logs (not deferred mode) leaving me with wrong impression that it hangs. From debugging I noticed that in app_sdcard I got too many retries at sending ACMD41. Shouldnt that command be preceded with CMD55 ?

  • The low-level diskio_* functions know to send the CMD55 before all ACMD* commands, so CMD55 won't show up in logs unless one monitors SPI directly.