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
Cannot write files to SD in ESP32 port #76
Comments
So it is not a case of PEBCAK that I have this problem too: #74 (comment) I saw it on boards with WROOM32 and with WROVER32(-A). Unchecked on WROVER32-B. |
the sdfat examples work fine. tried with external and internal CCP.... cant imagine what the problem is. |
The message is definitely coming from the card layer, as it is not from RunCPM. Can you show which is the code that actually works (the simplest one) on the examples? |
in the arduino examples. Initialization :
Creating a file:
Works fine ( i am writing the file to drive F so, i can see it in RunCpm) in RunCPM:
_sys_makefile (ignore the added debug lines)
Cant see any difference, but this routine fails. |
Not a write protect issue, a i can remove files with del command. :-) |
This is definitely strange. As the normal with bad card setup would be to
not be able to either read or write.
Any chance it can be a bad library?
The only way I can imagine to debug this would be to replicate it and go
deeper into the library code.
…On Mon, Mar 4, 2019, 2:43 PM Ramon Martinez ***@***.***> wrote:
Not a write protect issue, a i can remove files with del command. :-)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#76 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AP_Gi1oBZ--hHh6oMsxc9acFuCOrCfoJks5vTXdWgaJpZM4bW-jM>
.
|
I had the same effects on ESP32-Wroom and ESP32-Wrover(-A) boards. So it is not a strictly local installation or library download problem. |
But, when you say "had", did you fix it? |
I mean "had" like "a while ago". |
Just for sanity check I have upgraded my SdFat library from 1.0.7 to 1.1.0. |
Hey guys ... any luck here? Let me know. |
Closing this one as "Can't reproduce / Can't fix". |
I spent a morning on this one and I found a solution! I have 3 ESP32 modules running RunCP/M out of the box, multiple SD cards, all reformatted to Fat32 and then files/directory structure all cloned. It seems to be a write issue, and for me it comes up when Wordstar boots and it gives a "bdos error on [drive]" This sent me off on the wrong trail thinking it was CP/M but it is not. It appears it is the brand of SD card. Sandisk works. Kingston works. No Name "MicroSD" ones do not. The cards are all 1gb to 4gb. Hope this helps someone :) Cheers, James |
@moxhamj: Wow. This may be a solution! My errors were directory related. I only have few SD cards more than I need and the ones I tried with different ESP32ers (Wroom and Wrover) were Intenso (4GB Class10), Sandisk (2GB Class unknown) and Nonames (2GB Class unknown). They did work with the previously used (slower) SD lib and I use them without problems in other contexts too. So I did not really question the cards. A library being so picky, is it really intended to be that way or is the newer library overly aggressive? Hmmm... looks like I need more SD cards... But 1st I have to end my overly long Thursday. My eyes really need some hours without screens. |
I tried a quick experiment dropping the clock rate (I think in the ifdef it is the sd begin that does not have a clock rate, so not sure what the default is). Started at 50mhz, tried dropping to 4mhz but wouldn't work with any cards then. More experiments to do. I know with other emulations eg the FPGA ones, the biggest problem source of bugs was also different SD cards. |
Cool. Hopefully messing with the clock would solve the problem. I wonder if there's something I could do from inside RunCPM to help. Like drop a clock to x if writing at y fails. |
I'll keep experimenting. Yeti mentioned in another thread about a directory error message - I recall seeing that too. There are lots of "CP/M" type error messages but I suspect they are actually related to the SD code. It is very handy that I have 5 SD cards that work and 2 that do not, so can swap them back and forth and test things. Strange that the non-working ones read fine but don't write. (They write fine when in a PC with a USB adaptor). I might try shortening the wires to the SD card (I'm using ribbon cable, who knows what sort of crosstalk there could be, plus at high frequencies, a 10cm bit of wire is a resistor, a capacitor, an inductor and an antenna). I might also go back to the ESP32 SD demo code as this reads and writes some files. Quick internet search, is the default frequency 20Mhz? I saw that somewhere. If so, I reckon that would be right on the threshold for breadboard style wires to an SD card. At least we are nailing this bug down a bit :) |
I had the same problems with boards having a SD card slot and with the ones where I had 10 cm long jumper wires between board and SD card. Both setups seemed equally often to fail. |
More experiments August 2nd regarding the SD card and ESP32. Simple test for writes - start MBASIC, write a one line program and then save it. Works with sandisk and kingston, not with no-name sd cards. Tried very short leads, no change. Ok, on the arduino IDE once ESP 32 is installed, File/Examples/ESP32 examples,/SD(esp32)/SD_Test., this appears to be the official SD code for the ESP32, and indeed it works fine for every SD card I can find. So... what would it take to port this code into the RunCPM? Lots of #ifdefs I suspect. There are some syntax changes, for instance, no need to declare which pins are which as these are fixed. And there are two SD.h files that are different, so need to tell the compiler which one is being used (more ifdefs). And then there are slight differences in the way functions are called, eg in runCPM to append a file f = SD.open((char *)filename, O_WRITE | O_APPEND); and in the ESP 32 example it is File file = fs.open(path, FILE_APPEND); Quick perusal through the code, I dunno, 20 to 50 lines need changing. |
Deep inside the code thinking about how to incorporate the working ESP32 SD code. |
I am having the same issues of unable to write to cards. If I compile posix under Linux, the above command works. I am running the latest arduino (1.8.9) and have tried the sdfat + adafruit_sdfat libraries. If it is working for you, what version of arduino software are you using? |
Two solutions: 1) is to try different SD cards, some brands work, some do not. 2) is to recode the simulation so it uses the official ESP32 SD driver code. |
I'm experiencing this problem (or something very similar) as well, compiled with the current Arduino on Windows 10 on a TTGO T1, using the 60kb DR CCP. Attempts to write a file with e.g. mbasic result in a zero-byte file being created and CP/M crashing, regardless of initialization speed. Also, I don't know if it's related, but when CP/M crashes, pressing the reboot button on the T1 results in CP/M starting, then failing with "unable to initialize SD card". If I unplug and reconnect the board it then boots correctly. Edit: I seem to now have a correctly-working system, by virtue of changing some of the board settings in Arduino. Specifically, I lowered the CPU frequency to 80MHz, and the flash frequency to 40MHz. (Arduino defaulted to these being 240MHz and 80MHz, respectively.) I can now create, edit, and move files successfully, and rebooting the device via the button no longer produces "unable to initialize SD card" errors. |
After Adafruit's fork of SDFAT being mentioned in issue #106 I dedusted a Lolin32-Pro to try this lib instead of the picky SDFAT/original. And it works! I could rebuild SPL with its libs and demos ( Because the SDFAT/original doesn't work for me, I cannot make speed comparisons. IIRC with the lib in use before switching to SDFAT/original it lasted much over an hour (that's all I remember now) and with SDFAT/Adafruit 15±ε minutes. As it doesn't need fiddling in a library's header file, maybe switching to this one is a good idea for everyone? |
I have compiled the ESP32 port in a lolin D32 and all seem to be fine. All works except write files in the filesystem.
Each time i try to wite a file (saving zork, installing wordstar, editing with TE, etc i get an error.
the erase command is working, pip,rena, etc no.
Any clue?
only changed the pins in the SD definition and hat to change the sd.begin line to:
if (SD.begin(SDINIT,SD_SCK_MHZ(30))) {
(tried lower speeds, but the error is the same, with higher speeds, lots of problems accesing files)
The text was updated successfully, but these errors were encountered: