Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: uSD get corrupted files while reading with a teensy3.2

  1. #1
    Junior Member
    Join Date
    Apr 2020
    Posts
    3

    uSD get corrupted files while reading with a teensy3.2

    Hi all,
    We created some devices (50) using teensy 3.2, an SD card reader and a LORA radio module RFM95W.
    Basically the device will, among other things, continuously read files from the SD card while talking over the radio. Both the SD card and the radio are connected using SPI.
    The thing is that after some weeks we got back the devices and 4 of them had corrupted SD cards (files unable to read). We were using only reading and listing operations, so my first question is:
    * Is it possible to corrupt an SD card while using read only operations?
    We had some trouble with the radio over SPI (using radiohead library) conflicting with other operations (SD card reading for instance).
    * Can a busy SPI channel cause corruption on the SD card's files while reading?
    I am just looking for some directions to attack the problem.

    Thanks

    Hardware used: Teensy 3.2, usdCard reader, Adafruit RFM95W LoRa Radio
    Libraries used: SD, radiohead
    Wiring: both usdcard (CS pin 28) and rfm95 (CS pin 10) are attached to the teensy 3.2 spi
    Sorry for not posting code, I can't share it because of company policy.

  2. #2
    Hi,

    if you use an SD card and some other devices on the same SPI bus, then the first thing to do after power-on is to bring the SD card into SPI mode. By default SD cards are in SD mode after power-on, where they could/would interpret SPI commands to other devices as SD commands addressed to themselves, even if their !CS pin stays high.

    Kind regards,
    Sebastian

  3. #3
    Junior Member
    Join Date
    Apr 2020
    Posts
    3
    Thank you Sebastian,
    I will check the initialization order to verify that it is correct. What we found is that some data files of the SD are corrupted. They are impossible to read or copy to verify its content, apparently they cannot be accessed even exist and taking a normal file size.

    Kind regards.

  4. #4
    If you ask me, putting an SD card and other devices on the same SPI bus is a fragile design, as any "accidental" power cycle of the SD card returns the card into SD mode, possibly unnoticed by the host, where it would interpret SPI commands addressed to other devices on the bus as SD commands.

    Worse, the latest "Physical Layer Simplified Specification Version 7.10" even states: "The card may respond to the commands and functions [defined in SD mode after Version 2.00] even if the card is in SPI mode but hosts should not use them in SPI mode." Taken by the letter this implies that SD cards can not share the SPI bus with other devices anymore.

    Unfortunately that does not mean that this is for sure the reason of the corruptions you are seeing ...

    Kind regards,
    Sebastian

  5. #5
    Junior Member
    Join Date
    Apr 2020
    Posts
    3
    Thanks for the answer,
    Is any way on teensy 3.2 to corrupt a micro sdcard on a separated SPI bus by doing only read operations? we found that 35 of 47 devices that we made had the sdcard with a file or files unable to be accessed (corrupted).

    kind regards.

  6. #6
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    12,648
    Not sure if there are any relevant tips here for SPI bus in use :: pjrc.com/better-spi-bus-design-in-3-steps/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •