Closed jerryneedell closed 3 years ago
If there are other devices on the bus such as an SPI TFT, the SD card must always be initialized first. The main (but unofficial) reference I use for SD cards says this:
There is an important thing needs to be considered that the MMC/SDC is initially NOT the SPI device. Some bus activity to access another SPI device can cause a bus conflict due to an accidental response of the MMC/SDC. Therefore the MMC/SDC should be initialized to put it into the SPI mode prior to access any other device attached to the same SPI bus.
I don't think there's a way for adafruit_sdcard to detect when this rule has not been followed.
I'm not sure this is really an issue with the library but I wanted to capture it and this seemed like a good place to start...
This was initially reported by another user via Discord but i have reproduced and expanded it.
The initial scenario is with a TFT Feather wing and Adalogger Featherwing attached to a feather_m4_express. It was discovered that if the there are SDCards inserted into both the TFT Featherwing and the Adalogger then when an attempt is made to access the Adalogger SDCard, it fails
code listings for sdmount_lib.py and sdmountd5_lib.py at the bottom of this post
but if the SDCard is removed from the TFT Card rate (which is never accessed) then the Adalogger Card is accessible
however -- just to confuse things if you then insert and access the TFT SDCard them ADLogger card now becomes available...
both remain accessible until the next power cycle of the board. The Adaogger is still accessible through a Hard Reset but not after a power cycle
I tried reproducing this with the feather_m4_express, an Adalogger featherwing and an SDCard Breakout but I am unable to reproduce the problems. Both cards are accessible. No problems wit this configuration.
So, the issue appears to be dependent on the presence of the TFF featherwing.
For a third scenario, I used the feather_m4_express, TFT Featherwing and a SDCard breakout (replaced the Adalogger with the SDCard breakout) In this case, I cannot reproduce the initial issue - the SDCard in the breakout is accessible even if the TFT Card is in inserted BUT -- if I configure the TFT Display so it is active (echoing REPL), then I can no longer read from the breakout board -- it fails with a "No SD Card found" error UNTIL I power cycle only the Breakout board, leaving the TFT configured -- for one attempt after a power cycle of the Breakout board, I can read from it normally. Subsequent attempts fail with the "No SDCard found" error. I can still access the SDCard on the TFT. If I power cycle the whole system, I can repeatedly access both SDCards. (the TFT is inactive on power up)
My head hurts....
As noted, I am not convinced this is an issue with the Driver, but I'm not sure where to look or where else to post this. Suggestions welcome.
sdmount_lib.py -- mounts the Adalogger or SDCard Breakout
sdmountd5_lib.py - Mounts the TFT Featherwing