SD card problem on ESP-32
SD card problem on ESP-32
I upload this sdcard module (https://github.com/micropython/micropyt ... /sdcard.py)
to ESP-32 and import it,connect SD card to ESP-32 via SPI(1) (GPIO 6 ,GPIO 7,GPIO 8),but appear this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "sdcard.py", line 55, in __init__
File "sdcard.py", line 83, in init_card
OSError: no SD card
Micropython is not support SD card on ESP-32 current?
to ESP-32 and import it,connect SD card to ESP-32 via SPI(1) (GPIO 6 ,GPIO 7,GPIO 8),but appear this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "sdcard.py", line 55, in __init__
File "sdcard.py", line 83, in init_card
OSError: no SD card
Micropython is not support SD card on ESP-32 current?
-
- Posts: 3
- Joined: Tue Feb 06, 2018 7:27 pm
Re: SD card problem on ESP-32
hello, I am facing the same problem "OSError: no SD card", but i found you provide wrong gpio number.
Spi (1) refers to "HSPI" , using
SPI_MISO = HSPIQ(GPIO12)
SPI_MOSI = HSPID(GPIO13)
SPI_CLK = HSPICLK(GPIO14)
SPI_CS = HSPICS0(GPIO15)
I hope you can solve the problem, if solved, plz let me know, thx
Spi (1) refers to "HSPI" , using
SPI_MISO = HSPIQ(GPIO12)
SPI_MOSI = HSPID(GPIO13)
SPI_CLK = HSPICLK(GPIO14)
SPI_CS = HSPICS0(GPIO15)
I hope you can solve the problem, if solved, plz let me know, thx
Re: SD card problem on ESP-32
Actually, I tried some GPIO,
VSPI(2)
GPIO19 -- VSPIQ
GPIO23 -- VSPID
GPIO18 -- VSPICLK
GPIO5 -- VSPICS0
but appear same "no SD card" error,
refer ESP-32 (I use ESP-WROOM-32 module) offcial manual, general SPI (HSPI(1), VSPI(2)) can define on any GPIO, the GPIO number is not real reason on this error, I guess.
VSPI(2)
GPIO19 -- VSPIQ
GPIO23 -- VSPID
GPIO18 -- VSPICLK
GPIO5 -- VSPICS0
but appear same "no SD card" error,
refer ESP-32 (I use ESP-WROOM-32 module) offcial manual, general SPI (HSPI(1), VSPI(2)) can define on any GPIO, the GPIO number is not real reason on this error, I guess.
-
- Posts: 847
- Joined: Mon Nov 20, 2017 10:18 am
Re: SD card problem on ESP-32
I have been using SD card on ESP32 fine with laboris port of micripython. I have used it in both 4line and 1 line modes see his docs at https://github.com/loboris/MicroPython_ ... ilesystems
-
- Posts: 3
- Joined: Tue Feb 06, 2018 7:27 pm
Re: SD card problem on ESP-32
[quote=OutoftheBOTS_ post_id=25294 time=1517995347 user_id=3423]
I have been using SD card on ESP32 fine with laboris port of micripython. I have used it in both 4line and 1 line modes see his docs at https://github.com/loboris/MicroPython_ ... ilesystems
[/quote]
It is an unofficial version of micropython system, and the important thing is this firmware seems to use the SDIO as the interface(instead of the Spi mode in the official driver). Also, the official one does not contain the SDIO driver.
I have been using SD card on ESP32 fine with laboris port of micripython. I have used it in both 4line and 1 line modes see his docs at https://github.com/loboris/MicroPython_ ... ilesystems
[/quote]
It is an unofficial version of micropython system, and the important thing is this firmware seems to use the SDIO as the interface(instead of the Spi mode in the official driver). Also, the official one does not contain the SDIO driver.
Re: SD card problem on ESP-32
Hi, do I need to manual config the software for 4-line or 1-line mode ? or Micropython can auto detect and config 4-line or 1-line mode for each hardware connect method ?
Are you use uos.mountsd() to initialze SD card ? it look like can not select 4-line or 1-line mode via this method.
I find another method to initialze SD card on this page:
https://www.esp32.com/viewtopic.php?f=17&t=2446
>>>import sdcard,esp,uos
>>>sd = sdcard.SDCard(esp.SD_4LINE, True)
but the "sdcard", "esp" modules is not builtin modules in this Micropython port, I use "ESP32_all"(all modules included) firmware on (https://github.com/loboris/MicroPython_ ... /esp32_all)
do you know how to install an import the "sdcard", "esp" modules ?
Are you use uos.mountsd() to initialze SD card ? it look like can not select 4-line or 1-line mode via this method.
I find another method to initialze SD card on this page:
https://www.esp32.com/viewtopic.php?f=17&t=2446
>>>import sdcard,esp,uos
>>>sd = sdcard.SDCard(esp.SD_4LINE, True)
but the "sdcard", "esp" modules is not builtin modules in this Micropython port, I use "ESP32_all"(all modules included) firmware on (https://github.com/loboris/MicroPython_ ... /esp32_all)
do you know how to install an import the "sdcard", "esp" modules ?
OutoftheBOTS_ wrote: ↑Wed Feb 07, 2018 9:22 amI have been using SD card on ESP32 fine with laboris port of micripython. I have used it in both 4line and 1 line modes see his docs at https://github.com/loboris/MicroPython_ ... ilesystems
-
- Posts: 847
- Joined: Mon Nov 20, 2017 10:18 am
Re: SD card problem on ESP-32
Edit sorry I didn't read your post and I see your using laboris port.
As laboris states below it can be set by riunning BUILD.sh menuconfig and from the menu select MicroPython then select SD card config.
Yes I use uos.umountsd() to mount the CD card then
I use os.chdir() to change between /sd and /flash
As laboris states below it can be set by riunning BUILD.sh menuconfig and from the menu select MicroPython then select SD card config.
Yes I use uos.umountsd() to mount the CD card then
I use os.chdir() to change between /sd and /flash
Last edited by OutoftheBOTS_ on Sat Feb 10, 2018 2:05 am, edited 2 times in total.
Re: SD card problem on ESP-32
@water
SDCard in SD mode (1-line or 4-line) uses the dedicated pins on ESP32.
Connect it according to instructions on filesystems Wiki. ( in 1-line mode only the first 3 pins are used).
Select 1-line or 4-line mode in menuconfig: menuconfig (→ MicroPython → SD Card configuration) and build the firmware using the instructions or flash the prebuilt firmware (4-line mode is configured).
In MicroPython use uos.mountsd() to initialize and mount the SDCard.
The example from Espressif forum are from very old version of my MicroPython port, there are no longer esp and sdcard modules.
SDCard in SD mode (1-line or 4-line) uses the dedicated pins on ESP32.
Connect it according to instructions on filesystems Wiki. ( in 1-line mode only the first 3 pins are used).
Select 1-line or 4-line mode in menuconfig: menuconfig (→ MicroPython → SD Card configuration) and build the firmware using the instructions or flash the prebuilt firmware (4-line mode is configured).
In MicroPython use uos.mountsd() to initialize and mount the SDCard.
The example from Espressif forum are from very old version of my MicroPython port, there are no longer esp and sdcard modules.
Re: SD card problem on ESP-32
Using a Loboris prebuild firmware (ESP32_LoBo_v3.1.18 on 2017-02-07, psRAM and all modules) and a WeMOS Lolin32 Pro with a 16GB microSD card (Scandisk, FAT32 DOS-formatted), I cannot *write* on the microSD. The file itself is created on the microSD, but the content is not written into the file. What could cause the problem and is there a solution for it?
Errors:
E (9433635) sdmmc_cmd: sdmmc_write_sectors_dma: sdmmc_send_cmd returned 0x109
E (9433636) diskio_sdmmc: sdmmc_write_blocks failed (265)
Test code:
f = open('/sd/data.txt', 'w')
f.write('some data')
Note: Mounting and reading the microSD card works. If it is relevant: the microSD is made "MacOS-savy" meaning no MacOS meta-data files are written on the card, when used with MacOS computer.
PS. The Loboris uP firmware is fantastic. Thanks for making it.
Thanks in advance,
Peter
Errors:
E (9433635) sdmmc_cmd: sdmmc_write_sectors_dma: sdmmc_send_cmd returned 0x109
E (9433636) diskio_sdmmc: sdmmc_write_blocks failed (265)
Test code:
f = open('/sd/data.txt', 'w')
f.write('some data')
Note: Mounting and reading the microSD card works. If it is relevant: the microSD is made "MacOS-savy" meaning no MacOS meta-data files are written on the card, when used with MacOS computer.
PS. The Loboris uP firmware is fantastic. Thanks for making it.
Thanks in advance,
Peter
Re: SD card problem on ESP-32
@flexypepo
I could not reproduce this. Have you tried with other SD cards?
Tested on the same WeMOS Lolin32 Pro and the same prebuilt firmware with 8GB Sandisk Ultra & 16GB Kingmax SD Cards.
I could not reproduce this. Have you tried with other SD cards?
Tested on the same WeMOS Lolin32 Pro and the same prebuilt firmware with 8GB Sandisk Ultra & 16GB Kingmax SD Cards.
Code: Select all
MicroPython ESP32_LoBo_v3.1.18 - 2017-02-07 on ESP32 board with ESP32
Type "help()" for more information.
>>> import os
>>> os.mountsd()
D (739798) intr_alloc: Connected src 37 to int 9 (cpu 1)
---------------------
Mode: SD (4bit)
Name: SU08G
Type: SDHC/SDXC
Speed: default speed (25 MHz)
Size: 7580 MB
CSD: ver=1, sector_size=512, capacity=15523840 read_bl_len=9
SCR: sd_spec=2, bus_width=5
>>> f=open('/sd/test.txt','w')
>>> f.write("This was written to sdcard file on MicroPython-ESP32\r\n")
54
>>> f.close()
>>> f=open('/sd/test.txt','r')
>>> f.read()
'This was written to sdcard file on MicroPython-ESP32\r\n'
>>> f.close()
>>> os.listdir('/sd')
['exynos5422-odroidxu3.dtb', 'uInitrd', 'zImage', 'boot.ini', 'boot.ini.old', 'boot.ini.default', 'exynos5422-odroidxu3-lite.dtb', 'exynos54
22-odroidxu4.dtb', 'HELLO.TXT', 'FOO.TXT', 'test1.jpg', 'test2.jpg', 'test3.jpg', 'test4.jpg', 'tiger.jpg', 'tiger.bmp', 'test.txt']
>>>
>>> os.umountsd()
>>>
>>> os.mountsd()
D (20893) intr_alloc: Connected src 37 to int 9 (cpu 1)
---------------------
Mode: SD (4bit)
Name: NCard
Type: SDHC/SDXC
Speed: default speed (25 MHz)
Size: 15079 MB
CSD: ver=1, sector_size=512, capacity=30881792 read_bl_len=9
SCR: sd_spec=2, bus_width=5
...
...