SD Card wont init or do anything
-
I have a M5Stack Core Basic 2.7. I am attempting to use the SD card slot. It is a 16GB SDHC card that is formatted to FAT32. I created a simple block code in UIFlow2.0 that is:
Setup(Init Built in hardware->Init SD Card->Print(SDCard Listdir()). Init SD card is defined as:
sdcard.SDCard(slot=2, width=1, sck=18, miso=19, mosi=23, cs=4, freq=1000000)This gives the error of:
[Errno 22] EINVAL
E (3390) spi: spi_bus_initialize(758): SPI bus already initialized.
File "hardware/sdcard.py", line 21, in sdcard
OSError: (-259, 'ESP_ERR_INVALID_STATE')I tried adding a spi.deinit block but this doesn't even seem to be in the source code.
I have also tried the test_sdcard.py file in the uiflow-micropython repo and same thing happens.
What am I doing wrong? I have had this working on the same board and SD card with arduino but the micropython one doesn't seem to work at all.
Here is the code as well:import os, sys, io import M5 from M5 import * from hardware import sdcard label0 = None def setup(): global label0 M5.begin() Widgets.fillScreen(0x222222) label0 = Widgets.Label("label0", 117, 208, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18) sdcard.SDCard(slot=2, width=1, sck=18, miso=19, mosi=23, cs=4, freq=1000000) print(os.listdir('/sdcard/')) def loop(): global label0 M5.update() if __name__ == '__main__': try: setup() while True: loop() except (Exception, KeyboardInterrupt) as e: try: from utility import print_error_msg print_error_msg(e) except ImportError: print("please update to latest firmware")
-
import os, sys, io import M5 from M5 import * from hardware import sdcard label0 = None def setup(): global label0 M5.begin() Widgets.fillScreen(0x222222) label0 = Widgets.Label("label0", 21, 46, 1.0, 0xffffff, 0x222222, Widgets.FONTS.DejaVu18) sdcard.SDCard(slot=2, width=1, sck=18, miso=19, mosi=23, cs=4, freq=1000000) label0.setText(str(os.listdir('/sd/'))) def loop(): global label0 M5.update() if __name__ == '__main__': try: setup() while True: loop() except (Exception, KeyboardInterrupt) as e: try: from utility import print_error_msg print_error_msg(e) except ImportError: print("please update to latest firmware")