ESP32Forth SD Card Initialization
From
Van Kichline@21:1/5 to
All on Sat Aug 26 15:15:16 2023
I'm having quite a bit of trouble using SD cards with Esp32Forth.
I have exactly one setup that works: An Adafruit ESP32 Feather with an AdaLogger board (which contains an SD card socket.)
Many boards don't have a setting in the Arduino IDE 2.0, such as the LilyGo T8 which includes an SD socket. I find I can modify the SD Test example program to work correctly with this board by replacing SD.begin() with:
SPI.begin(14, 2, 15, 13); //SCK, MISO, MOSI, SS
SD.begin(13);
(Both changes are required.)
However, I've been unable to introduce these changes to Esp32Forth successfully.
I've modified the Forth definition of SD.begin to call the C function SD.begin(13). I modified SD.beginDefaults to push 13 rather than SS. I added SPI.begin(14, 2, 15, 13); to the end of setup(), but when I start Esp32Forth and enter:
SD SD.begin
it always returns 0. (It returns a 1 on success.)
I have several other boards with similar issues, I just cannot get the SD to initialize, but can run the (modified) SD Test program on them successfully.
Can someone provide some guidance on how to get the SD up and running on Esp32Forth when SD.begin does not succeed?
Thanks for your time!
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)
From
Van Kichline@21:1/5 to
All on Sat Aug 26 19:45:13 2023
A little more info from trying to get the LilyGo T8's SD card working on ESP32Forth:
At the top of ESP32forth.ino, I inserted:
#define SS 13
#define MOSI 15
#define MISO 2
#define SCK 14
I changed XV(SD, "SD.begin", SD_BEGIN, PUSH SD.begin()) to XV(SD, "SD.begin", SD_BEGIN, PUSH SD.begin(SS))
I added a bit of extra code:
void print_pins() { printf("SCK=%d, MOSI=%d, MISO=%d, SS=%d\n", SCK, MOSI, MISO, SS); }
...and added a word to OPTIONAL_SD_SUPPORT:
XV(SD, "SD.Pins", SD_PINS, print_pins())
I have also added the following to setup():
SPI.begin(14, 2, 15, 13); //SCK, MISO, MOSI, SS
SD.begin still fails, simply returning zero.
SD.Pins returns: SCK=14, MOSI=15, MISO=2, SS=13 (as expected) if and only if I include the SPI.begin(14, 2, 15, 13); in setup().
Also, I found that adding the 4 #defines to the SD Test example had no effect, I could not eliminate either of the required changes for the LilyGo T8 board.
The #defines do make SD.beginDefaults return the correct SS, however.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)