greiman / SdFat-beta

Beta SdFat for test of new features
MIT License
166 stars 62 forks source link

Fix flaky SD read into PSRAM on Teensy 4.1 #66

Closed jcj83429 closed 3 years ago

jcj83429 commented 3 years ago

Increase the drive strength to make the signal more robust against interference from the PSRAM access. The value of DSE is found by increasing it until the interference goes away then increasing it once more. I tested using the test case posted here: https://forum.pjrc.com/threads/65851-Problem-reading-from-SD-card-directly-into-PSRAM . The test case fails quickly with DSE at 5 or less and passes reliably with DSE at 6 or 7.

Defragster commented 3 years ago

@Paul - tested this to work on T_4.1 after initial failure - as noted in forum - using TD 1.54 b5 with code using the NEW SD.h with BillGr's integrated SdFat where it initially failed before making this change.

ALSO NOTE: While in that file code has a #if defined(ARDUINO_TEENSY41) that should read::

#if defined(ARDUINO_TEENSY41) || defined(ARDUINO_TEENSY40) 
                              IOMUXC_SW_PAD_CTL_PAD_DSE(6) |
Defragster commented 3 years ago

Opps - just noticed this is the Bill Greiman repository - not PJRC. I compiled above #ifdef for T_4.1 and it passes - but not setup for T_4.0 build test.

Defragster commented 3 years ago

Updated on PJRC forum - tested a T_4.0 to read from SD card with edited #ifdef above

greiman commented 3 years ago

I can't merge this request to SdFat. I have mods to about 40 file in the next beta.

jcj83429 commented 3 years ago

@greiman You can integrate this change into the next beta and drop this PR.

greiman commented 3 years ago

I added it to the mods for the Teensy SDIO driver. How have you tested it? What type cards? What modes, DMA, FIFO?

You probably don't have access to the signalling standard for SD cards in 3.3V "High Speed" mode, this the 3.3V 50 MHz mode, so can't check with a scope. I have it but it is watermarked with the company name that gave it to me and the SD Association wants people to pay thousands of dollars to see their specs.

I get burned so often with some major brand of card that doesn't confirm to the SD spec. I was about to release a mod in the next beta that enhanced shared SPI performance by using chip select to keep a card in write mode but raise chip select. The spec said this would be OK.

While the card is busy, resetting the CS signal will not terminate the programming process. The card will release the DataOut line (tri-state) and continue with programming. If the card is reselected before the programming is finished, the DataOut line will be forced back to low and all commands will be rejected.

Not true for some very popular Samsung cards.

jcj83429 commented 3 years ago

I tested with a 16GB Staples (store brand) class 10 SDHC with FAT32 and a 64GB ADATA class A2 SDXC (this card: https://www.adata.com/ca/feature/368) with EXFAT. I only tested FIFO SDIO.

jcj83429 commented 3 years ago

Fix was merged into 2.0.5-beta.1