SPI SD card: LoadProhibited strlen in ROM

atcoding
Posts: 2
Joined: Wed Jun 25, 2025 8:26 am

SPI SD card: LoadProhibited strlen in ROM

Postby atcoding » Wed Jun 25, 2025 8:40 am

Hi I am seeking help regarding this issue.

I am working on a C++ ESP-IDF project using an SD card with SDSPI, VFS, and FATFS.
The project also includes TWAI, BLE (using bluedroid), and another SPI device however I have disabled the rest of the functionality while I bugfix this issue.
I am using ESP-IDF v5.4. and an ESP32-S3 on custom hardware (the hardware shouldn't be an issue as it was tested with the arduino SD library).

I have disabled SPI in IRAM in menuconfig however this error still persists (as suggested by this forum post viewtopic.php?t=7684&start=10).
I have read that this could be an issue with C++ compilation (from this semi-related issue from another ESP project https://github.com/bdring/FluidNC/issues/794 but I don't have enough knowledge to say for sure.
I have increased my app_main stack size to where this should not be an issue and the this error only occurs after a couple of seconds so some SD card commands occur before this.

Back trace below:

Code: Select all

V (6823) sdmmc_cmd: sending cmd slot=1006920328 op=17 arg=1e3640 flags=1c50 data=0x3fcaaa4c blklen=512 datalen=512 timeout=1000
V (6833) sdspi_host: sdspi_host_start_command: slot=1006920328, CMD17, arg=0x001e3640 flags=0x5, data=0x3fcaaa4c, data_size=512 crc=0x63
Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.

Core  0 register dump:
PC      : 0x4201e216  PS      : 0x00060e30  A0      : 0x8201e260  A1      : 0x3fcaa6e0  
--- 0x4201e216: get_acquiring_dev at /nix/store/8x6c4d26fbvwzs8q4qg23k1lgb1b4l0x-esp-idf-v5.4.1/components/esp_driver_spi/src/gpspi/spi_master.c:652

A2      : 0x00000000  A3      : 0x3fcaa750  A4      : 0x3fcaa720  A5      : 0x0000000c  
A6      : 0x3fcaa6bc  A7      : 0x3fc9b458  A8      : 0x3fc9b458  A9      : 0xb212290f  
A10     : 0x0000008d  A11     : 0x00000080  A12     : 0xfffffffd  A13     : 0x3c04d052  
A14     : 0x00000005  A15     : 0x3fcaa5a0  SAR     : 0x00000004  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x0000009c  LBEG    : 0x400556d5  LEND    : 0x400556e5  LCOUNT  : 0xfffffff9  
--- 0x400556d5: strlen in ROM
0x400556e5: strlen in ROM



Backtrace: 0x4201e213:0x3fcaa6e0 0x4201e25d:0x3fcaa710 0x4201f0d8:0x3fcaa740 0x42024e8f:0x3fcaa770 0x4202547b:0x3fcaa7d0 0x4201f4df:0x3fcaa830 0x42020230:0x3fcaa880 0x42020337:0x3fcaa910 0x42014930:0x3fcaa970 0x420167d9:0x3fcaa9a0 0x42013740:0x3fcaa9d0 0x42010303:0x3fcaaa10 0x4200ff45:0x3fcaba70 0x4203af73:0x3fcabad0 0x4037d682:0x3fcabb00
--- 0x4201e213: get_acquiring_dev at /nix/store/8x6c4d26fbvwzs8q4qg23k1lgb1b4l0x-esp-idf-v5.4.1/components/esp_driver_spi/src/gpspi/spi_master.c:651
0x4201e25d: spi_bus_device_is_polling at /nix/store/8x6c4d26fbvwzs8q4qg23k1lgb1b4l0x-esp-idf-v5.4.1/components/esp_driver_spi/src/gpspi/spi_master.c:665
0x4201f0d8: spi_device_acquire_bus at /nix/store/8x6c4d26fbvwzs8q4qg23k1lgb1b4l0x-esp-idf-v5.4.1/components/esp_driver_spi/src/gpspi/spi_master.c:1297
0x42024e8f: sdspi_host_start_command at /nix/store/8x6c4d26fbvwzs8q4qg23k1lgb1b4l0x-esp-idf-v5.4.1/components/esp_driver_sdspi/src/sdspi_host.c:475
0x4202547b: sdspi_host_do_transaction at /nix/store/8x6c4d26fbvwzs8q4qg23k1lgb1b4l0x-esp-idf-v5.4.1/components/esp_driver_sdspi/src/sdspi_transaction.c:153
0x4201f4df: sdmmc_send_cmd at /nix/store/8x6c4d26fbvwzs8q4qg23k1lgb1b4l0x-esp-idf-v5.4.1/components/sdmmc/sdmmc_cmd.c:24
0x42020230: sdmmc_read_sectors_dma at /nix/store/8x6c4d26fbvwzs8q4qg23k1lgb1b4l0x-esp-idf-v5.4.1/components/sdmmc/sdmmc_cmd.c:657
0x42020337: sdmmc_read_sectors at /nix/store/8x6c4d26fbvwzs8q4qg23k1lgb1b4l0x-esp-idf-v5.4.1/components/sdmmc/sdmmc_cmd.c:604
0x42014930: ff_sdmmc_read at /nix/store/8x6c4d26fbvwzs8q4qg23k1lgb1b4l0x-esp-idf-v5.4.1/components/fatfs/diskio/diskio_sdmmc.c:54
0x420167d9: ff_disk_read at /nix/store/8x6c4d26fbvwzs8q4qg23k1lgb1b4l0x-esp-idf-v5.4.1/components/fatfs/diskio/diskio.c:96
0x42013740: f_read at /nix/store/8x6c4d26fbvwzs8q4qg23k1lgb1b4l0x-esp-idf-v5.4.1/components/fatfs/src/ff.c:4025
0x42010303: espSpiSdReadFile(char const*, char*, unsigned int) at /home/engineering/Projects/blink_cxx/main/source/esp_sd/esp_spi_sd.cpp:169
0x4200ff45: app_main at /home/engineering/Projects/blink_cxx/main/source/main.cpp:97
0x4203af73: main_task at /nix/store/8x6c4d26fbvwzs8q4qg23k1lgb1b4l0x-esp-idf-v5.4.1/components/freertos/app_startup.c:208
0x4037d682: vPortTaskWrapper at /nix/store/8x6c4d26fbvwzs8q4qg23k1lgb1b4l0x-esp-idf-v5.4.1/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:139


Sprite
Espressif staff
Espressif staff
Posts: 10599
Joined: Thu Nov 26, 2015 4:08 am

Re: SPI SD card: LoadProhibited strlen in ROM

Postby Sprite » Thu Jun 26, 2025 1:32 am

Looks like some kind of memory corruption issue, but I can't really say more from the backtrace. The strlen indicator is a red herring: that's simply the last time when a zero-overhead loop was used and is unlikely to have anything to do with the issue at hand.

atcoding
Posts: 2
Joined: Wed Jun 25, 2025 8:26 am

Re: SPI SD card: LoadProhibited strlen in ROM

Postby atcoding » Thu Jun 26, 2025 2:39 am

Thanks the advice was super helpful.

I had declared some of the variables for initialising my SD card on the stack (I'm pretty sure the issue was with my sdmmc_card_t) as I didn't realise the SD card library stored the pointer value because I assumed it would copy the contents.

Who is online

Users browsing this forum: meta-externalagent, PerplexityBot and 6 guests