ESP32-S3R8 crashes while mounting FATFS

simonjo
Posts: 32
Joined: Wed Sep 30, 2020 9:16 am

ESP32-S3R8 crashes while mounting FATFS

Postby simonjo » Wed Sep 17, 2025 1:52 pm

Hi,

I have ported my domotic controller (Phc2Mqtt) from ESP32-WROVER to ESP32-S3R8 with some small modifications for the IO ports and it runs fine on a Waveshare ESP32-S3 Eth board (using W5500 SPI ethernet module).

The webinterface and logging works, settings are stored and retrieved to/from NVS, MQTT client connects to broker...

I can detect domotic modules connected to the RS485 bus, send commands to them and read out status. Great.

My application also has an XMLRPC-over-HTTP management interface to provision runtime project data in ZIP file format. It extracts 1 file from the ZIP file that contains metadata to enable correct operation.

Now I noticed that this unzipping was failing because there was not enough memory available (approx 220K), huh !?

This ESP32-S3R8 is supposed to be having 8Mb in-package PSRAM... After some searching in sdkconfig I found the solution to enable SPI connected RAM... but now it crashed during boot, so switching to Octal Mode iso Quad Mode resulted in the 8Mb PSRAM being found and reported without crashing.


But now it crashed on the mounting of the FATFS partition used for storing this metadata. When I look at the startup log I see it doesn't recognise the partition as FAT but as 'unknown'.
>>>
I (49) boot: Partition Table:
I (51) boot: ## Label Usage Type ST Offset Length
I (58) boot: 0 nvs WiFi data 01 02 00009000 00004000
I (64) boot: 1 otadata OTA data 01 00 0000d000 00002000
I (71) boot: 2 phy_init RF data 01 01 0000f000 00001000
I (77) boot: 3 ota_0 OTA app 00 10 00010000 00180000
I (84) boot: 4 ota_1 OTA app 00 11 00190000 00180000
I (90) boot: 5 private Unknown data 01 81 00310000 000f0000
I (97) boot: End of partition table
<<<

This confuses me given the fact that I use below custom partition table
>>>
# ESP-IDF partition table
# Name, Type, Subtype, Offset, Size, Flags
nvs, data, nvs, 0x9000, 16K,
otadata, data, ota, 0xd000, 8K,
phy_init, data, phy, 0xf000, 4K,
ota_0, app, ota_0, 0x010000, 1536K,
ota_1, app, ota_1, 0x190000, 1536K,
private, data, fat, 0x310000, 960K,
<<<

The esp_vfs_fat_spiflash_mount_rw_wl() call uses these params
>>>
const esp_vfs_fat_mount_config_t mount_config = {
.format_if_mount_failed = TRUE,
.max_files = 5,
.allocation_unit_size = CONFIG_WL_SECTOR_SIZE, <- 4096
.disk_status_check_enable = false,
.use_one_fat = false
};

int32_t err = esp_vfs_fat_spiflash_mount_rw_wl("/spiflash", "private", &mount_config, &m_vfsWlHandle);
<<<


Here is the complete bootlog
>>>
SPIWP:0xee
mode:DIO, clock div:2
load:0x3fce2810,len:0x11f0
load:0x403c8700,len:0x4
load:0x403c8704,len:0xd04
load:0x403cb700,len:0x2e50
entry 0x403c8918
I (26) boot: ESP-IDF v5.4.1 2nd stage bootloader
I (26) boot: compile time Sep 17 2025 07:57:31
I (26) boot: Multicore bootloader
I (27) boot: chip revision: v0.2
I (29) boot: efuse block revision: v1.3
I (33) boot.esp32s3: Boot SPI Speed : 40MHz
I (37) boot.esp32s3: SPI Mode : DIO
I (40) boot.esp32s3: SPI Flash Size : 16MB
I (44) boot: Enabling RNG early entropy source...
I (49) boot: Partition Table:
I (51) boot: ## Label Usage Type ST Offset Length
I (58) boot: 0 nvs WiFi data 01 02 00009000 00004000
I (64) boot: 1 otadata OTA data 01 00 0000d000 00002000
I (71) boot: 2 phy_init RF data 01 01 0000f000 00001000
I (77) boot: 3 ota_0 OTA app 00 10 00010000 00180000
I (84) boot: 4 ota_1 OTA app 00 11 00190000 00180000
I (90) boot: 5 private Unknown data 01 81 00310000 000f0000
I (97) boot: End of partition table
I (100) esp_image: segment 0: paddr=00010020 vaddr=3c0b0020 size=1fe40h (130624) map
I (140) esp_image: segment 1: paddr=0002fe68 vaddr=3fc9c100 size=001b0h ( 432) load
I (140) esp_image: segment 2: paddr=00030020 vaddr=42000020 size=aecb8h (715960) map
I (319) esp_image: segment 3: paddr=000dece0 vaddr=3fc9c2b0 size=0856ch ( 34156) load
I (329) esp_image: segment 4: paddr=000e7254 vaddr=40374000 size=180dch ( 98524) load
I (357) esp_image: segment 5: paddr=000ff338 vaddr=600fe100 size=0001ch ( 28) load
I (368) boot: Loaded app from partition at offset 0x10000
I (368) boot: Disabling RNG early entropy source...
I (378) octal_psram: vendor id : 0x0d (AP)
I (378) octal_psram: dev id : 0x02 (generation 3)
I (378) octal_psram: density : 0x03 (64 Mbit)
I (380) octal_psram: good-die : 0x01 (Pass)
I (385) octal_psram: Latency : 0x01 (Fixed)
I (389) octal_psram: VCC : 0x01 (3V)
I (393) octal_psram: SRF : 0x01 (Fast Refresh)
I (398) octal_psram: BurstType : 0x01 (Hybrid Wrap)
I (403) octal_psram: BurstLen : 0x01 (32 Byte)
I (407) octal_psram: Readlatency : 0x02 (10 cycles@Fixed)
I (413) octal_psram: DriveStrength: 0x00 (1/1)
I (417) esp_psram: Found 8MB PSRAM device
I (420) esp_psram: Speed: 40MHz
I (423) cpu_start: Multicore app
I (1157) esp_psram: SPI SRAM memory test OK
I (1166) cpu_start: Pro cpu start user code
I (1166) cpu_start: cpu freq: 160000000 Hz
I (1167) app_init: Application information:
I (1167) app_init: Project name: e32s3P2M-4Mb-pV3
I (1171) app_init: Compile time: Sep 17 2025 07:58:50
I (1177) app_init: ELF file SHA256: e96b31681...
I (1181) app_init: ESP-IDF: v5.4.1
I (1185) efuse_init: Min chip rev: v0.0
I (1189) efuse_init: Max chip rev: v0.99
I (1193) efuse_init: Chip rev: v0.2
I (1197) heap_init: Initializing. RAM available for dynamic allocation:
I (1203) heap_init: At 3FCABEA8 len 0003D868 (246 KiB): RAM
I (1208) heap_init: At 3FCE9710 len 00005724 (21 KiB): RAM
I (1214) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (1219) heap_init: At 600FE11C len 00001ECC (7 KiB): RTCRAM
I (1225) esp_psram: Adding pool of 8192K of PSRAM memory to heap allocator
I (1232) spi_flash: detected chip: winbond
I (1235) spi_flash: flash io: dio
W (1238) i2c: This driver is an old driver, please migrate your application code to adapt `driver/i2c_master.h`
I (1249) sleep_gpio: Configure to isolate all GPIO pins in sleep state
I (1254) sleep_gpio: Enable automatic switching of GPIO sleep configuration
I (1261) main_task: Started on CPU0
I (1271) esp_psram: Reserving pool of 32K of internal memory for DMA/internal allocations
I (1271) main_task: Calling app_main()
NvsLoad(size=1024)
1970-01-01,00:01:11,D,HWMD,<rmtInit
1970-01-01,00:01:11,D,HWMD,>RmtInit,err=0
1970-01-01,00:01:11,D,HWMD,>rmtInit,err=0
I (1301) gpio: GPIO[0]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
1970-01-01,00:01:11,I,APPL,!Phc2Mqtt,v5.03.00,Sep 17 2025 by Jo Simons (c) 2020-2025
1970-01-01,00:01:11,I,APPL,!Info={"save":11,"boot":891,"evtQueOvf":0,"freeHeap":8636100},"rstReason":"0/Unknown","pcbVer":"0/4.x","nvs":{"ver":05080000,"size":1024}
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.

Core 0 register dump:
PC : 0x4037ffd9 PS : 0x00060d33 A0 : 0x80384ec0 A1 : 0x3fcb1250
--- 0x4037ffd9: spinlock_acquire at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/esp_hw_support/include/spinlock.h:105
--- (inlined by) xPortEnterCriticalTimeout at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:479

A2 : 0x10101010 A3 : 0xffffffff A4 : 0x3c0d0d58 A5 : 0x00060d23
A6 : 0x00010000 A7 : 0x0000cdcd A8 : 0x00060d20 A9 : 0x3fcb1250
A10 : 0x00060d23 A11 : 0x00000000 A12 : 0x00060d20 A13 : 0x00000008
A14 : 0x3fcb13c0 A15 : 0x3c0d0d58 SAR : 0x00000001 EXCCAUSE: 0x0000001c
EXCVADDR: 0x10101010 LBEG : 0x400570e8 LEND : 0x400570f3 LCOUNT : 0x00000000
--- 0x400570e8: memset in ROM
--- 0x400570f3: memset in ROM



Backtrace: 0x4037ffd6:0x3fcb1250 0x40384ebd:0x3fcb1280 0x40384ef2:0x3fcb12a0 0x4037611b:0x3fcb12c0 0x40376135:0x3fcb12f0 0x40375eb0:0x3fcb1310 0x4202e515:0x3fcb1360 0x4202f4ce:0x3fcb1380 0x4202bd7e:0x3fcb13b0 0x420123f7:0x3fcb1410 0x42012bba:0x3fcb15d0 0x420ae19b:0x3fcb15f0
--- 0x4037ffd6: xt_utils_get_raw_core_id at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/xtensa/include/xt_utils.h:52
--- (inlined by) spinlock_acquire at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/esp_hw_support/include/spinlock.h:89
--- (inlined by) xPortEnterCriticalTimeout at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:479
--- 0x40384ebd: xPortEnterCriticalTimeoutSafe at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h:581
--- (inlined by) vPortEnterCriticalSafe at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h:588
--- (inlined by) multi_heap_internal_lock at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/heap/multi_heap.c:164
--- 0x40384ef2: multi_heap_malloc_impl at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/heap/multi_heap.c:208
--- 0x4037611b: aligned_or_unaligned_alloc at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/heap/heap_caps_base.c:82
--- (inlined by) heap_caps_aligned_alloc_base at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/heap/heap_caps_base.c:156
--- 0x40376135: heap_caps_malloc_base at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/heap/heap_caps_base.c:176
--- 0x40375eb0: heap_caps_malloc_prefer at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/heap/heap_caps.c:180
--- 0x4202e515: ff_memalloc at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/fatfs/port/freertos/ffsystem.c:23
--- 0x4202f4ce: esp_vfs_fat_register_cfg at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/fatfs/vfs/vfs_fat.c:204
--- (inlined by) esp_vfs_fat_register_cfg at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/fatfs/vfs/vfs_fat.c:181
--- 0x4202bd7e: esp_vfs_fat_spiflash_mount_rw_wl at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/fatfs/vfs/vfs_fat_spiflash.c:160
--- 0x420123f7: CMyApp::vfsMount(int, bool) at C:/_simonjo/sources/e32s3Phc2Mqtt/main/cmyapp_vfs.hpp:33
--- (inlined by) CMyApp::OnRun() at C:/_simonjo/sources/e32s3Phc2Mqtt/main/cmyapp.cpp:136
--- 0x42012bba: app_main at C:/_simonjo/sources/e32s3Phc2Mqtt/main/cmyapp.cpp:79
--- 0x420ae19b: main_task at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/freertos/app_startup.c:208
<<<

simonjo
Posts: 32
Joined: Wed Sep 30, 2020 9:16 am

Re: ESP32-S3R8 crashes while mounting FATFS

Postby simonjo » Thu Sep 18, 2025 6:41 am

Meanwhile trying to isolate the problem...

In sdkconfig under "ESP PSRAM" you have the option "SPI RAM access method"

When I set this to "Integrate RAM into memory map" and recompile + reboot -> no crash but the PSRAM memory is not reported as available in FreeHeap space and thus a lot of memory allocations fail and unzip is not working.

When selecting "Make RAM allocatable using malloc()" AND disabling "Prefer external RAM for FAT FS buffering", rebuilding and rebooting shows VFS FAT is mounted successful, but now the module crashes on initialisation of SPI Ethernet (W5500 module).

When selecting "Make RAM allocatable using heap_caps_malloc(...)" AND disabling "Prefer external RAM for FAT FS buffering", rebuilding and rebooting shows VFS FAT being mounted and ISP Ethernet being started and working. However, malloc() fails as the PSRAM is in a separate pool and thus many allocations fail resulting in an instable module and unzip not working.

>>>
--- 0x403801bb: spinlock_acquire at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/esp_hw_support/include/spinlock.h:132
--- (inlined by) xPortEnterCriticalTimeout at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:479
--- 0x40385001: vPortEnterCriticalSafe at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h:581
--- (inlined by) multi_heap_internal_lock at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/heap/multi_heap.c:164
--- 0x40385036: multi_heap_malloc_impl at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/heap/multi_heap.c:208
--- 0x4037613f: aligned_or_unaligned_alloc at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/heap/heap_caps_base.c:82
--- (inlined by) heap_caps_aligned_alloc_base at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/heap/heap_caps_base.c:156
--- 0x40376159: heap_caps_malloc_base at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/heap/heap_caps_base.c:176
--- 0x40375e64: heap_caps_malloc_default at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/heap/heap_caps.c:120
--- 0x40386f85: malloc at C:/Users/simonjo/esp/v5.4.1/esp-idf/components/newlib/heap.c:24
--- 0x42013bbb: CRecQueue::Init(unsigned long, unsigned long) at C:/_simonjo/sources/xxlibs/crecqueue.hpp:63
--- (inlined by) COhcStmd::OnInit(unsigned long) at C:/_simonjo/sources/e32s3Phc2Mqtt/main/cohc_stmd.cpp:163
--- 0x4200ac46: CThreadWork::Exec(CThreadWorkItem*, unsigned long) at C:/_simonjo/sources/xxlibs/thread/cthread_work.hpp:241 (discriminator 2)
--- 0x4200ff10: CMyApp::OnRun() at C:/_simonjo/sources/e32s3Phc2Mqtt/main/cmyapp.cpp:166
--- 0x4201059e: app_main at C:/_simonjo/sources/e32s3Phc2Mqtt/main/cmyapp.cpp:79
<<<

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

Re: ESP32-S3R8 crashes while mounting FATFS

Postby Sprite » Thu Sep 18, 2025 10:07 am

In octal mode, the PSRAM uses a bunch of GPIOs you shouldn't otherwise connect (the usual suspects are GPIO35-37). If you do connect them (or initialize them as GPIOs, or as peripheral input/outputs), you can run into weird issues like this. Maybe that's your issue?

simonjo
Posts: 32
Joined: Wed Sep 30, 2020 9:16 am

Re: ESP32-S3R8 crashes while mounting FATFS

Postby simonjo » Thu Sep 18, 2025 1:40 pm

I have following in use:

GPIO39 = I2C SCL
GPIO40 = I2C SDA
GPIO33 = RS485 DE
GPIO43 = RS485 TX
GPIO44 = RS485 RX
GPIO0 = input button
GPIO21 = RMT led

But after consulting the ESP32-S3 datasheet I notice that GPIO33-37 (not GPIO35-37) are used by octal SPI, so GPIO33 will be the problem.

I changed the offending line to GPIO38, and behold... it works. I selected the option to make PSRAM available via malloc() and now everything works.

Thanks very much ;)
regards, Jo

Who is online

Users browsing this forum: Bing [Bot], ChatGPT-User and 1 guest