Calling SD.begin() when no SD-card is inserted and CONFIG_DISABLE_HAL_LOCKS is not set causes LoadProhibited error #10346
Labels
Area: Arduino as ESP-IDF component
Issues about Arduino used as component in ESP-IDF
Area: Libraries
Issue is related to Library support.
Status: Solved
Board
LilyGo T-SIM7000, LilyGo T-SIM7600
Device Description
Hardware Configuration
Version
v3.0.4
IDE Name
PlatformIO
Operating System
Windows 11
Flash frequency
40MHz
PSRAM enabled
yes
Upload speed
115200
Description
Calling
SD.begin()
when no SD card is inserted andCONFIG_DISABLE_HAL_LOCKS is not set
in sdkconfig causes a LoadProhibited error and crashes the code. The expectation is thatSD.begin()
would instead returnfalse
when no SD card is inserted.Following the backtrace, the error is caused when
xSemaphoreGive(spi->lock);
is called invoid spiEndTransaction(spi_t *spi)
. I assume this fails becausespi->lock
does not point to a valid mutex. However, I can't figure out why that would be the case sincedo {} while (xSemaphoreTake(spi->lock, portMAX_DELAY) != pdPASS)
appears to be called a little bit earlier insdcard_uninit
and there it does not throw an error.I unfortunately don't have a working debugger at the moment, so I can't properly step through the code in any more detail. Setting
CONFIG_DISABLE_HAL_LOCKS=y
in sdkconfig appears to be a working remedy but has its side effects as it disables all HAL mutexes.Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: