I mount the SD card with the following code:
Code: Select all
import machine
import uos
uos.mount(machine.SDCard(slot=2,width=1,sck=14,miso=2,mosi=15,cs=13,freq=20000000), "/sd")
Code: Select all
>>> machine.soft_reset()
MPY: soft reboot
E (877674) spi: spi_bus_initialize(462): SPI bus already initialized.
E (877674) sdspi_host: spi_bus_initialize failed with rc=0x103
Traceback (most recent call last):
File "main.py", line 5, in <module>
OSError: (-259, 'ESP_ERR_INVALID_STATE')
MicroPython v1.16 on 2021-06-23; ESP32 module with ESP32
Type "help()" for more information.
As the result, I can't access the SD card from rshell. When I connect the board and start the rshell, the SD card is not mounted.
When I enter the REPL, and issue the reset() command, I get:
Code: Select all
>>> import machine
>>> machine.reset()
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, 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:0x3fff0030,len:5640
load:0x40078000,len:12696
load:0x40080400,len:4292
entry 0x400806b0
MicroPython v1.16 on 2021-06-23; ESP32 module with ESP32
Type "help()" for more information.
>>> uos.listdir("/sd")
['test1.py', 'test2.py']
I tried to deinitialize the SPI interface before initializing and mounting the SDCard in /boot.py:
Code: Select all
import machine
import uos
spi=machine.SPI(1,sck=machine.Pin(14),miso=machine.Pin(2),mosi=machine.Pin(15))
spi.deinit()
uos.mount(machine.SDCard(slot=2,width=1,sck=14,miso=2,mosi=15,cs=13,freq=20000000), "/sd")
Code: Select all
E (468260) sdspi_host: Bus already initialized. Call `sdspi_host_init_dev` to attach an sdspi device to an initialized bus.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: (-259, 'ESP_ERR_INVALID_STATE')