tulipcc icon indicating copy to clipboard operation
tulipcc copied to clipboard

SD card on T-Deck

Open coolcoder613eb opened this issue 1 year ago • 3 comments

If SD card slot on the T-Deck is supported, please tell me how to use it, if not, please add support for it.

coolcoder613eb avatar May 02 '24 11:05 coolcoder613eb

SD card support in Tulip. is not currently tested on T-Deck. It's my understanding that all the pieces are there to access the SD card, and may even be possible with pure Python (and no changes to Tulip itself.) Have you tried the instructions here: https://docs.micropython.org/en/latest/library/machine.SDCard.html ? The pins seem to be SD_CS = GPIO39, MOSI = GPIO41, CLK = GPIO40, MISO = GPIO38.

bwhitman avatar May 02 '24 21:05 bwhitman

machine.SDCard is not available in TulipCC.

coolcoder613eb avatar May 02 '24 23:05 coolcoder613eb

Ah, i see. I've gotten SDCard to appear in Tulip on T-Deck only by changing an #ifdef in the micropython setup. But the card gives an error on init. I'll take a deeper look at this later:

>>> import machine
>>> m = machine.SDCard(sck=40,miso=38,mosi=41,cs=39)
>>> uos.mount(m, '/sd')
E (187697) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107
HINT: Please reboot the board and then try again
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: 16

The diff if you want to try is:

diff --git a/tulip/esp32s3/esp32_common.cmake b/tulip/esp32s3/esp32_common.cmake
index 0689cf2c..e1d3b125 100644
--- a/tulip/esp32s3/esp32_common.cmake
+++ b/tulip/esp32s3/esp32_common.cmake
@@ -92,6 +92,7 @@ list(APPEND MICROPY_SOURCE_PORT
     gccollect.c
     fatfs_port.c
     machine_bitstream.c
+    machine_sdcard.c
     machine_timer.c
     machine_pin.c
     machine_touchpad.c
diff --git a/tulip/esp32s3/mpconfigport.h b/tulip/esp32s3/mpconfigport.h
index 8f644aa8..3e30d8bf 100644
--- a/tulip/esp32s3/mpconfigport.h
+++ b/tulip/esp32s3/mpconfigport.h
@@ -130,7 +130,11 @@
 #define MICROPY_PY_NETWORK_WLAN             (1)
 #endif
 #ifndef MICROPY_HW_ENABLE_SDCARD
-#define MICROPY_HW_ENABLE_SDCARD            (0) // TODO
+#ifdef TDECK
+#define MICROPY_HW_ENABLE_SDCARD            (1) 
+#else
+#define MICROPY_HW_ENABLE_SDCARD            (0) 
+#endif
 #endif
 #define MICROPY_HW_SOFTSPI_MIN_DELAY        (0)
 #define MICROPY_HW_SOFTSPI_MAX_BAUDRATE     (esp_rom_get_cpu_ticks_per_us() * 1000000 / 200) // roughly

bwhitman avatar May 03 '24 14:05 bwhitman