Author Topic: SanDisk 4GB MicroSd card - problems with SPI communication  (Read 2462 times)

0 Members and 1 Guest are viewing this topic.

Offline krzysiobalTopic starter

  • Newbie
  • Posts: 3
  • Country: pl
SanDisk 4GB MicroSd card - problems with SPI communication
« on: March 23, 2017, 07:12:54 pm »
I am trying to communicate with MMC/MicroSD cards, using 6502 microprocessor (and some FPGA between, which is de facto responsible for the whole communication on SPI protocol).
Firstly i developed library which allowed to communicate with MMC cards. It worked great. Then I tested it on small micro SD cards ( <= 2GB) and it worked too, without any changes. Then i wanted support SDHC cards. I am detecting card according to these diagram:
http://elm-chan.org/docs/mmc/mmc_e.html
http://elm-chan.org/docs/mmc/pic/sdinit.png

On SD/MMC, sectors were adressed like 0, 512, 10124, etc. On SDHC, they have adressees 0,1,2,3,...
It is also working without problems, I tested it on 8 GB & big 32 GB Kingston SDHC.

Few days ago I ordered a lot of random used 4 GB cards. Half of them are working, the other half (which are all branded by SanDisk) are not working at all. After sending CMD0, the card is answering 0x01, but then sending CMD8  returns odd results.

Here are my waveforms.


Do you have any idea what is the difference between Sandisk's SPI? I looked into their datasheed and for example  CMD8 is reserved..
https://web.archive.org/web/20131115122620/http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Components/General/SDSpec.pdf

When SandiskCards are inserted into computer's card reader, all of them are working of course.
SPI's !CS is permanently grounded,  MOSI/MISO/SCLK are driven by fpga's pins at 3.3 V level. SCLK freqency is 800 kHz.

 

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 6272
  • Country: ca
  • Non-expert
Re: SanDisk 4GB MicroSd card - problems with SPI communication
« Reply #1 on: March 23, 2017, 09:41:22 pm »
The computer is using 4-bit SD mode to communicate, as I'm sure you know. Probably has a ton of code to handle edge cases as well.
Have you tried the SD card decode modules for saleae and pulseview? It helped me a lot when debugging SD and will generate these diagrams you've shown. Although I'm not sure if it works with SPI mode.

If that should be R7 response, then 0xC1 doesn't make sense.
Have you tried a lower clock speed?
Not sure if this is relevant: http://stackoverflow.com/questions/2365897/initializing-sd-card-in-spi-issues
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 

Offline krzysiobalTopic starter

  • Newbie
  • Posts: 3
  • Country: pl
Re: SanDisk 4GB MicroSd card - problems with SPI communication
« Reply #2 on: March 25, 2017, 12:15:49 am »
Worked like a charm, thank you very much!
 
The following users thanked this post: thm_w


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf