-
Notifications
You must be signed in to change notification settings - Fork 7.6k
SD lib w/ card 'flakey'? #272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hm that is rather strange. I had gazillion of issues with SD_MMC and pullups but none with SD. I just connected the 4 data lines directly to SPI and that was it (I use SD->MicroSD with some wires soldered directly on the pads). |
static const uint8_t MOSI = 18; and cs on any pin really, but im using other than the SD card, all other SPI devices ive tested are working perfectly - TFT display, LoRa and RFM radio modules, VS1053 |
Done :) |
looks good - would you like me to re-test? |
Sure :) Confirmation is always good, but I was able to reproduce the issue and after the fix, was not able to anymore, regardless of what I did :) I wonder how it was working while I was developing the library? void mountSdCard(){
SPI.begin(5,19,18);
if(!SD.begin(33)){
Serial.println("Card Mount Failed");
return;
}
} |
hiya - ok so for one of my feather setups, with cardcs on IO 27, it now works every time. on another feather, with cs on IO 14 it still doesnt work :/
|
maybe on io14 there is another issue? I mean, if SPI is properly configured, and you use pins below 34, the lib itself does not care which pin you have selected. It calls digitalWrite to control SS |
yeah unknown. ill investigate more later... :) |
Interesting, I am having the same problem. Using the TFT feather wing (CS 14), the SD card works about 50% of the time, using the music maker featherwing, I can't get the same SD card to work at all (also CS 14). SPI works fine with graphics and music etc, it's just the SD card that is unreliable. If I wasn't having a similar problem (but not as bad) with the TFT featherwing, I'd suspect a bad reader on the music maker. When I have a chance I'll try it with an M0 or a WICED, see if they work with the music maker. |
I'm using the same pins as ladyada, coming from the adalogger featherwing, and I can't get the card to mount at all using: #include <SD.h>
#include <SPI.h>
void setup() {
Serial.begin(115200);
SPI.begin(5, 19, 18);
if (!SD.begin(33)) {
Serial.println("Card Mount Failed");
}
} SD card works in an M0 datalogger, but no luck with the ESP32 :/ |
@me-no-dev hmm do you mind if we send you some hardware that you can test with? the SD card works if we use our ported 'arduino-SD-library' but not with the SD library ya'll included. so I think its some init thing? |
@ladyada yes please! let's get this fixed :) How are we going to arrange this? |
done :) |
k email addr deleted, we'll reply |
|
Things just showed up :) will solder the boards tonight and prep everything |
That sounds exciting |
yay - we have a full kit of cousre, and can try replicating any branches/fixes |
So do we know where this issue comes from? What can I do to further test? |
can you try a few times? also try plugging the esp32 into the tft feather and drawing a BMP from SD? that's the only thing i can say we tried and had difficulty with :) |
I found with the tft feather, it works about 50% of the time.
I was using the music maker feather also, and it works 0% of the time with that (same pins).
I haven tried the data logger feather at all.
Nick Waterton P.Eng
Sent from my iPhone
On Jul 6, 2017, at 8:15 PM, ladyada <[email protected]<mailto:[email protected]>> wrote:
can you try a few times? also try plugging the esp32 into the tft feather and drawing a BMP from SD? that's the only thing i can say we tried and had difficulty with :)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#272 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ALCUZxuQ_GO000hKaWuJXnqJDjV9h4vlks5sLXiYgaJpZM4MhlJK>.
Unsubscribe from GE's commercial electronic messages: http://sc.ge.com/*casl-unsubscribe
Désabonner des messages électroniques commerciaux de GE: http://sc.ge.com/*lcap-desabonnement
|
@NickWaterton Are you referring to the SD card slot on the music maker wing? The VS1053 part works fine using the ESP32-Radio project. |
Hit a wall with the TFT Wing :) looking into it :) |
@ladyada I seem to get intermittent issues wit the touch on the TFT as well. Like it will not start every once in a while. Have you notice this? |
please try the latest commit :) |
@me-no-dev Works fine with SD card slot on Feather Adalogger (CS=33) and Music Maker (CS=14). |
I do not really understand this... Did not Lolin test the D32 Pro with both SD card and TFT before releasing it? @michaelkleinhenz but how do you use the SD_MMC library? I also tried it and it also fails. Or did you wire a new sd card port to the GPIOs for that? @G6EJD If this is an issue with one the libraries then it should be easy to fix, right? I mean both of them are open source so it should be possible to adjust the code and see if that fixes the issue? |
@merdok yes, I just haven't got the time right now to trace through the use of CS values to ensure they remain separate, as I'm still sure this is the issue. The Lolin D32 Pro schematic shows no SPI bus design or wiring issues that I can see. |
@G6EJD Any chance you could have a look at it? |
Here's what I've found so-far:
|
There are a few projects around that use both ili9341 and SD Card, now they don't work once complied with the latest release of the libraries. |
Oh, so i does not work also with the Wemos(Lolin) SD-Card Shield on the Wemos(Lolin) D1 Mini? I thought that this issue is just related to the Lolin D32 Pro with the built-in SD Card slot... Also during my tests i had always the Adafruit_ILI9341 lib included and when i disconnected the TFT Touch shield the SD card was working, i also did leave the TFT init code inside. Now comes the interesting part, when i then hot plug the Touch TFT shield and do a reset with the onboard reset button, both the TFT and SD card work. But when i unplug the power cable and plug it back in the SD does not work again. Isn't the issue that there are initially some wrong values set by either the Adafruit_ILI9341 or SD card lib when both of them are connected? I mean they both work together fine if you follow the steps which i mentioned above so this makes me think that this is just some issue with initialization. I do not have enough skills to debug that two cases, but maybe you could do that and there will be something obvious? |
I have concluded and observed the same a hot plug of the tft starts the sd card working again, this does indeed point to a device initiation issue and we have concluded the same. So yes, I have all Lolin components and they don’t work together (8266 or 32) there is nothing wrong that I can see with the hardware. Previously the two did work together now not. |
Hello guys. I noticed the thread is active again. Have you tried the solution I posted last year? In short: put a 100 ohm resistor in series with both the mosi and miso lines, I discovered this randomly but later found an explanation, it is to do with the fact that one of the devices (cannot remember which one probably sd controller chip) doesn’t have the standard tri-state I/O so even when the CS is pulled low, the data lines are low impedance. If only one device is on the bus it is not a problem but as soon as you add the second one the low impedance data lines pull the whole bus down introducing all sort of issues most noticeably problems in intialization of either salve devices on the bus even though they both work on their own on the bus. The resistor overcomes the issue in a very simple and crude way but it works. Hope it helps, happy to discuss it further. P.s.the 100 ohm resistor is only needed on one of the data lines, either mosi or miso can’t remember which one but it is not a problem to put one on each data line |
@G6EJD That is good that we came to the conclusion :) I hope this brings are more closer to a solution :) @arash-pyk I did not try that, but it seems the hardware is correctly designed so why would we need to put an additional resistor there? |
the issue I was having was to do with the internal design of the monolithic IC of the SD card controller and not the external components of the circuit. The solution is for people having problem with two slave devices on the SPI bus given that everything is properly setup, CS lines are managed correctly etc. give it a try, you only need to add the resistor to the second device on the bus. |
Maybe it's a good idea to make a setup with 2 SD cards and a setup with 2 TFT's to make sure which device causes the trouble. |
What is strange is that many projects/designs have been made that simultaneously display data from an SD card on a TFT and the hardware arrangement is identical. This does therefore point to a software issue. Today I’ll try an ILI9341 with in-built (unbuffered) SD (although not uSD) card reader to see if that still works. |
I guess the issue is the the touch capability of the Lolin 2.4 Touch TFT shield. It uses an additional CS line as far as i know. I also have the Lolin 2.13 EPD shield which does not have touch and he SD card works without any issues together with the display. |
TF_CS is GPIO-12 and no conflict with other devices according to the schematic. |
That is why this issue is so strange. Everything looks fine, so why it does not work? |
Out of interest SD Library no-longer works on ESP8266, but works on ESP32; an Issue is already pending on here. |
Was there ever a resolution to this issue? Why was this post closed? |
I still have the issue... |
I've been working on this issue for weeks and can't find a solution. |
It’s generally a hardware problem, some designs work, some don’t. It was closed because there is no software issue. Usually the addition of pull-up resistor can help but in all cases the SD card needs to be buffered from the SPI bus to ensure correct operation and few if any are. |
For reference I'm using a wemos Lolin D32 Pro v2. |
What happens is the display does not release the SPI lines and loads them, by a buffer I mean a isolation buffer frequently found on SD devices. For example take a look at separate SD cards on AliExpress you will find buffeted and unbuffered types, it is the latter required. If you purchase an ili9341 display with on-board SD card you will see a buffer device that separates the bus devices. Wemos made a mistake with these boards, you can use the SD card alone or Ili9341 alone but not together. The design is flawed. You can see the buffer device at the bottom right corner: £1.84 | Mini Data Logger Module Logging Shield for Arduino For Raspberry Pi Logging Recorder Data Logger Module Shield V1.0 SD Card |
Some interface boards for SD card have a design error. The MISO line will be at ground level if no card is inserted. Even if the CS is not active. The enable input of the buffer for MISO is connected to ground and not to CS. |
@G6EJD You say that this is a design error, but if you boot the Lolin d32 pro board without the screen connected and then connect the screen after the board has booted then magically both the screen and the sd card slot work together without issues. You can even reset the board with the on-board reset button and they will still work, but as soon as you disconnect the power completely they will not work and you have to repeat the process... |
Could you please check the level of the MISO signal in various (working and not working) test situations? MOSI should be HIGH most of the time. |
Same issue here, using TTGO V2.1 boards. But could solve it by moving to this lib: It works for SD access via SPI interface, while SD.cpp from arduino-esp32 doesn't. |
The card seems to need a bit of a nudge at boot to properly mount sometimes. Fixes: espressif/arduino-esp32#272
The card seems to need a bit of a nudge at boot to properly mount sometimes. Fixes: espressif/arduino-esp32#272
heya im using known good hardware, with pullups on the SD CS line, no level shifters, PCB traces not jumpers - but getting 'flakiness' on init/mount
oddly, it works maybe 10% of the time. once it starts working, it 'keeps' working until a full power reset. if it doesn't work, sometimes hitting software reset helps, but usually not. this is with the SPI library - tried changing SPI speed in SD.begin() without any noticable changes. still investigating ... but making a note here in case others can reproduce
fyi, grabbing the non-optimized SD library works great with no hiccups - https://github.com/adafruit/arduino-esp32/tree/d602169ebcd126c309009e87c1e455f2c892d08f (yeah sorry it got smooshed in the upstream merge so please download the zip from that point to get the library files)
The text was updated successfully, but these errors were encountered: