
@ebolisa I have used sdcard.py in the last week on ESP8266 and ESP32 and can report that it works with standard MicroPython firmware.
That said, if your hardware shares the SPI bus between the SD card and other devices there is a known issue.
Code: Select all
esptool.py --chip esp32 --port com4 write_flash -z 0x1000 esp32-idf3-20191220-v1.12.bin
Code: Select all
import machine, sdcard, gc
gc.collect()
try:
print('*** Setup ***')
# ESP32-CAM board uses the SD card to the following pins:
# SD Card | ESP32 |esp32-cam
# D2 - -
# D3 SS gpio13
# CMD MOSI gpio15
# VSS GND gnd
# VDD 3.3V 3.3v
# CLK SCK gpio14
# VSS GND gnd
# D0 MISO gpio2
# D1 - gpio4 + LED flash also :(
# FLASHLED gpio4
# red led gpio33 (mini smd led below ESP32-controler)
# SD card socket : pin 9 is SD ( = CARD DETECTION , is a card inserted ?)
spi = machine.SPI(1, baudrate=100000, phase=0, polarity=0, sck=machine.Pin(14), mosi=machine.Pin(15), miso=machine.Pin(2))
sd = sdcard.SDCard(spi, machine.Pin(13))
except AssertionError as e:
print(e)
machine.reset()
--------
MPY: soft reboot
*** Using new sdcard lib ***
*** Setup ***
Traceback (most recent call last):
File "main.py", line 24, in <module>
File "sdcard.py", line 50, in __init__
File "sdcard.py", line 78, in init_card
OSError: no SD card
MicroPython v1.12 on 2019-12-20; ESP32 module with ESP32
Code: Select all
#spi = machine.SPI(1, baudrate=100000, phase=0, polarity=0, sck=machine.Pin(14), mosi=machine.Pin(15), miso=machine.Pin(2))
sd = sdcard.SDCard(machine.SPI(1), machine.Pin(13)) #SPI(-1) and anything above 2, fails
The only change I made in main.py is to print the exception so I can see what's going on:MicroPython v1.10-128-g584bc5b2a on 2019-09-01; ESP32 module with ESP32
Type "help()" for more information.
>>>
MPY: soft reboot
network config: ('192.168.0.69', '255.255.255.0', '192.168.0.1', '192.168.0.200')
I (61600) gpio: GPIO[32]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (61680) gpio: GPIO[35]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (61680) gpio: GPIO[34]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (61690) gpio: GPIO[39]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (61700) gpio: GPIO[36]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (61710) gpio: GPIO[21]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (61720) gpio: GPIO[19]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (61720) gpio: GPIO[18]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (61730) gpio: GPIO[5]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (61740) gpio: GPIO[25]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (61750) gpio: GPIO[23]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (61760) gpio: GPIO[22]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (61770) camera: Allocating 1 frame buffers (234 KB total)
I (61810) camera: Allocating 234 KB frame buffer in OnBoard RAM
E (61840) gpio: gpio_install_isr_service(394): GPIO isr service already installed
I (62050) spi_master: Allocate TX buffer for DMA
I (62050) spi_master: Allocate TX buffer for DMA
I (62050) spi_master: Allocate TX buffer for DMA
I (62060) spi_master: Allocate TX buffer for DMA
I (62060) spi_master: Allocate TX buffer for DMA
no SD card
Restarting...
I (62070) wifi: state: run -> init (0)
I (62070) wifi: pm stop, total sleep time: 29298470 us / 58451294 us
I (62080) wifi: new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1
I (62100) wifi: flush txq
I (62100) wifi: stop sw txq
I (62100) wifi: lmac stop hw txq
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:5200
ho 0 tail 12 room 4
load:0x40078000,len:9616
load:0x40080400,len:7328
entry 0x40081758
I (485) spiram: Found 64MBit SPI RAM device
I (485) spiram: SPI RAM mode: flash 40m sram 40m
I (485) spiram: PSRAM initialized, cache is in normal (1-core) mode.
I (491) cpu_start: Pro cpu up.
I (495) cpu_start: Application information:
I (500) cpu_start: Compile time: 21:48:02
I (505) cpu_start: Compile date: Sep 1 2019
I (510) cpu_start: ESP-IDF: v3.3-beta1-268-g5c88c5996
I (517) cpu_start: Single core mode
I (1383) spiram: SPI SRAM memory test OK
I (1383) heap_init: Initializing. RAM available for dynamic allocation:
I (1384) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (1390) heap_init: At 3FFB9870 len 00026790 (153 KiB): DRAM
I (1396) heap_init: At 3FFE0440 len 0001FBC0 (126 KiB): D/IRAM
I (1403) heap_init: At 40078000 len 00008000 (32 KiB): IRAM
I (1409) heap_init: At 40097338 len 00008CC8 (35 KiB): IRAM
I (1415) cpu_start: Pro cpu start user code
I (1420) spiram: Adding pool of 4096K of external SPI memory to heap allocator
I (99) cpu_start: Starting scheduler on PRO CPU.
I (100) spiram: Reserving pool of 32K of internal memory for DMA/internal allocations
I (120) main: Allocated 2048K for micropython heap at 0x3f940020
I (180) wifi: wifi driver task: 3ffcc68c, prio:23, stack:3584, core=0
I (180) wifi: wifi firmware version: 38e2484
I (180) wifi: config NVS flash: enabled
I (180) wifi: config nano formating: disabled
I (190) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (200) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (210) wifi: Init dynamic tx buffer num: 32
I (210) wifi: Init data frame dynamic rx buffer num: 32
I (220) wifi: Init management frame dynamic rx buffer num: 32
I (220) wifi: Init static tx buffer num: 16
I (230) wifi: Init static rx buffer size: 1600
I (230) wifi: Init static rx buffer num: 10
I (230) wifi: Init dynamic rx buffer num: 32
connecting to network...
I (300) phy: phy_version: 4007, 9c6b43b, Jan 11 2019, 16:45:07, 0, 0
I (300) wifi: mode : sta (24:6f:28:16:38:08)
I (300) wifi: STA_START
I (430) wifi: new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1
I (1110) wifi: state: init -> auth (b0)
I (1120) wifi: state: auth -> assoc (0)
I (1170) wifi: state: assoc -> run (10)
I (1380) wifi: connected with PHONE_HOME, channel 1, bssid = 58:90:43:4c:65:d6
I (1390) wifi: pm start, type: 1
I (1390) network: CONNECTED
I (4280) event: sta ip: 192.168.0.69, mask: 255.255.255.0, gw: 192.168.0.1
I (4280) network: GOT_IP
Code: Select all
except Exception as e:
print(e)
print('Restarting...')
machine.reset()
Code: Select all
# sd = sdcard.SDCard(spi, machine.Pin(13))
# os.mount(sd, '/sd')
# os.listdir('/')
MPY: soft reboot
network config: ('192.168.0.69', '255.255.255.0', '192.168.0.1', '192.168.0.200')
I (104060) gpio: GPIO[32]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (104140) gpio: GPIO[35]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (104140) gpio: GPIO[34]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (104150) gpio: GPIO[39]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (104160) gpio: GPIO[36]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (104170) gpio: GPIO[21]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (104180) gpio: GPIO[19]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (104190) gpio: GPIO[18]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (104200) gpio: GPIO[5]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (104210) gpio: GPIO[25]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (104220) gpio: GPIO[23]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (104220) gpio: GPIO[22]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (104230) camera: Allocating 1 frame buffers (234 KB total)
I (104270) camera: Allocating 234 KB frame buffer in OnBoard RAM
E (104300) gpio: gpio_install_isr_service(394): GPIO isr service already installed
[Errno 110] ETIMEDOUT
Restarting...
I (105720) wifi: state: run -> init (0)
I (105720) wifi: pm stop, total sleep time: 63719911 us / 102142158 us
I (105720) wifi: new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1
I (106510) wifi: flush txq
I (106510) wifi: stop sw txq
I (106510) wifi: lmac stop hw txq
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:5200
ho 0 tail 12 room 4
load:0x40078000,len:9616
load:0x40080400,len:7328
entry 0x40081758
I (485) spiram: Found 64MBit SPI RAM device
I (485) spiram: SPI RAM mode: flash 40m sram 40m
I (485) spiram: PSRAM initialized, cache is in normal (1-core) mode.
I (491) cpu_start: Pro cpu up.
I (495) cpu_start: Application information:
I (500) cpu_start: Compile time: 21:48:02
I (505) cpu_start: Compile date: Sep 1 2019
I (510) cpu_start: ESP-IDF: v3.3-beta1-268-g5c88c5996
I (517) cpu_start: Single core mode
I (1383) spiram: SPI SRAM memory test OK
I (1383) heap_init: Initializing. RAM available for dynamic allocation:
I (1384) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (1390) heap_init: At 3FFB9870 len 00026790 (153 KiB): DRAM
I (1396) heap_init: At 3FFE0440 len 0001FBC0 (126 KiB): D/IRAM
I (1403) heap_init: At 40078000 len 00008000 (32 KiB): IRAM
I (1409) heap_init: At 40097338 len 00008CC8 (35 KiB): IRAM
I (1415) cpu_start: Pro cpu start user code
I (1420) spiram: Adding pool of 4096K of external SPI memory to heap allocator
I (99) cpu_start: Starting scheduler on PRO CPU.
I (100) spiram: Reserving pool of 32K of internal memory for DMA/internal allocations
I (110) main: Allocated 2048K for micropython heap at 0x3f940020
I (180) wifi: wifi driver task: 3ffcc710, prio:23, stack:3584, core=0
I (180) wifi: wifi firmware version: 38e2484
I (180) wifi: config NVS flash: enabled
I (180) wifi: config nano formating: disabled
I (190) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (200) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (210) wifi: Init dynamic tx buffer num: 32
I (210) wifi: Init data frame dynamic rx buffer num: 32
I (220) wifi: Init management frame dynamic rx buffer num: 32
I (220) wifi: Init static tx buffer num: 16
I (220) wifi: Init static rx buffer size: 1600
I (230) wifi: Init static rx buffer num: 10
I (230) wifi: Init dynamic rx buffer num: 32
connecting to network...
I (300) phy: phy_version: 4007, 9c6b43b, Jan 11 2019, 16:45:07, 0, 0
I (310) wifi: mode : sta (24:6f:28:16:38:08)
I (310) wifi: STA_START
I (430) wifi: new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1
I (1120) wifi: state: init -> auth (b0)
I (1120) wifi: state: auth -> assoc (0)
I (1190) wifi: state: assoc -> run (10)
I (1340) wifi: connected with PHONE_HOME, channel 1, bssid = 58:90:43:4c:65:d6
I (1340) wifi: pm start, type: 1
I (1340) network: CONNECTED
I (3320) event: sta ip: 192.168.0.69, mask: 255.255.255.0, gw: 192.168.0.1
I (3320) network: GOT_IP
network config: ('192.168.0.69', '255.255.255.0', '192.168.0.1', '192.168.0.200')
I (3610) modsocket: Initializing
I (4040) gpio: GPIO[32]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (4120) gpio: GPIO[35]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (4120) gpio: GPIO[34]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (4130) gpio: GPIO[39]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (4140) gpio: GPIO[36]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (4150) gpio: GPIO[21]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (4150) gpio: GPIO[19]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (4160) gpio: GPIO[18]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (4170) gpio: GPIO[5]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (4180) gpio: GPIO[25]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (4190) gpio: GPIO[23]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (4200) gpio: GPIO[22]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (4210) camera: Allocating 1 frame buffers (234 KB total)
I (4250) camera: Allocating 234 KB frame buffer in OnBoard RAM
E (4280) gpio: gpio_install_isr_service(394): GPIO isr service already installed
MicroPython v1.10-128-g584bc5b2a on 2019-09-01; ESP32 module with ESP32
Type "help()" for more information.
>>> FTP Server started
Code: Select all
--port COM4 erase_flash
esptool.py v3.0
Serial port COM4
Connecting....
Chip is ESP32-D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 78:21:84:80:8d:d8
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 13.1s
Hard resetting via RTS pin...
Erasing done
------------------------------------
C:\Users\Admin\AppData\Local\Programs\Thonny\python.exe -u -m esptool --chip esp32 --port COM4 write_flash --flash_mode keep --flash_size detect 0x1000 C:/Users/Admin/Downloads/micropython-camera-driver-master/micropython-camera-driver-master/firmware/micropython_cmake_9fef1c0bd_esp32_idf4.x_ble_camera.bin
esptool.py v3.0
Serial port COM4
Connecting........_____....._____....._____....._____....._____....._____....._____
A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header
Write command returned with error code 2
Code: Select all
rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371
ets Jun 8 2016 00:22:57