-
Notifications
You must be signed in to change notification settings - Fork 7.6k
SD writes but doesn't append #4759
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
logic looks fine. the only thing that I see is that you should not try to print/close the file if it had failed to open. Apart from that, I recently introduced some fixes in the SD class and will be happy if you can give them a shot |
Thanks! Will re-formulate the logic. I've actually found the problem, but no solution: Will try the new PR (#4876) soon and let you know. |
Hmm, I've updated SD (cpp, h), sd_defines.h and sd_diskio.h but Arduino IDE compiler reports this and doesn't compile:
A problem on my side, or somewhere else? |
on your side. seems sd_diskio.cpp did not compile? |
could it be that MRFC522 is holding the MISO line in some way? Also, you should not control the SDCard's SS line yourself. That is done by the library |
Yep, thanks! It seems like sd_diskio.cpp wasn't there at all. Don't know how it went missing.
I'm suspecting about this too. How would I confirm/resolve this issue, if it is the case?
Hmm, alright. I will try |
SD.begin without parameter will use the default SS pin. this is not what I said :) just do not control it through your code. |
Alright, so you mean I shouldn't use the two functions (activate_RFID/activate_SD) and leave them on their own? |
yes :) |
As stranger as it gets! Updated the esp32 board to 1.0.5, replaced existing SD files with your PR, now here's what appears:
|
I can confirm that the above error appears only when I'm using my sketch. Using SD(esp32) example from sketches, work fine! |
Just put SD.begin() immediately after SPI.begin (it was TFT, mfrc then SD) and now the SD errors above don't appear anymore! Except for the Though MFRC522 reports Firmware version v2.0, it doesn't work. I started to suspect that the microSD module is not releasing MISO properly? |
one of the two is definitely the reason. What if you remove the resistors on MISO? SD + something else on the same bus is quite common thing |
If I remove the resistor on MISO, the MFRC prints: Tried to also switch places of MISO: SD Card - Resistor - MISO+MFRC522 also MFRC522 - Resistor - MISO+SD Card but it's the same, 0xE1. P.S.: I've also noticed that |
which slave are you initializing first? Try to switch them around and do not forget to power-off the board completely before retry |
I think I've found the problem, I mean, obviously, but: I've just updated esp32 to 1.0.5, and MFRC refuses to work, even if it reports firmware version v2.0. The TFT's MOSI is connected to another pin (19). If I try the same thing but with 1.0.4, it works fine. So, not initializing I've also disconnected the SD card module completely, just to be sure there aren't any hardware-connection faults. They work fine on their own, but not when connected together via SPI (TFT, MFRC, SD). Also, should I use mfrc |
So, with 1.0.5 I've managed to make SD card and TFT work, but not MFRC522. Edit: I started to suspect that it's a loose wire connection, being the culprit of why sometimes works with different versions (1.0.4/1.0.5) and sometimes not. This may or may not explain even why the SD card fails to append. I will update once I confirm this. |
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions. |
Hardware:
Description:
I've got a microSD module adapter from the far east, and so far so good it can create files using
writeFile
, but it does not append messages. It returnstrue
, i.e: message appended successfully on the first try, but when you read the file on the computer or when ESP32 reads on reboot, it's blank. I am using two (in fact, three) SPI devices: TFT display, MFRC522, and microSD module. When working with SD operations, I disable MFRC522 and enable SD, as seen in the code blocks below.I use
writeFile
ifreadFile
returnsfalse
, that is, when the file does not exist, it invokeswriteFile(SD, sdFileName, "")
Specifically, whenfs.open(path)
ofreadFile
returnsfalse
, I instruct to create a new file by invokingwriteFile
.This is
readFile
, by the way:Code:
This is the suspected code that it's not doing its job, as instructed:
And, I use these two functions to disable/enable SD/MFRC522:
Debug Messages:
Interestingly, on the first
appendFile
call, it returnstrue
and displays just this[W]
level:However, on the second
appendFile
call, it returnsfalse
and displays these:SD card space is 1GB, it is a generic brand, and its type is "SD". I've even also used
appendFile
but withFILE_WRITE
parameter then withfile.seek(EOF)
but still no luck. What makes me even more, puzzled, is that the default exampleSD(esp32)
works well: creating files, appending, deleting, renaming, etc. Therefore I suspect the problem is seeded hidden in my logic somewhere.The text was updated successfully, but these errors were encountered: