ESP32 assert failed: block_next tlsf_block_functions.h:94 (!block_is_last(block))

fanmen1
Posts: 27
Joined: Thu Mar 21, 2024 1:30 pm

ESP32 assert failed: block_next tlsf_block_functions.h:94 (!block_is_last(block))

Postby fanmen1 » Wed Sep 04, 2024 2:36 pm

This project Incorporates Ethernet SPI for hosting local web page and SD card for data logging in sdspi mode. Moreover, I have enabled SPIRAM and use it for other dynamic memory allocation. I have 4 RTOS tasks running in the background, 2 for UART operations while other task is the data logging (write to SD) and host a web page for configuration and control. The functionality works well most of the time. Expect it crashes at random times during the logging function dude to shared bus config. The bus is configured to the same host (SPI2_HOST) dude to limited GPIOs.
Initially, the program crashed with looping log meesages as follows:

E (17:36:06.791) w5500.mac: emac_w5500_read_phy_reg(387): read PHY register failed
E (17:36:06.792) w5500.phy: w5500_update_link_duplex_speed(65): read PHYCFG failed
E (17:36:06.795) w5500.phy: w5500_get_link(108): update link duplex speed failed
E (17:36:08.791) w5500.mac: emac_w5500_read_phy_reg(387): read PHY register failed
E (17:36:08.791) w5500.phy: w5500_update_link_duplex_speed(65): read PHYCFG failed
E (17:36:08.795) w5500.phy: w5500_get_link(108): update link duplex speed failed

I tried applying the new patch updated in ESP-IDF 5.4v onwards, which stopped the looping errors, however, now the system is crashing at random times when the data logging task is active with the following error logs:

Code: Select all

assert failed: block_next tlsf_block_functions.h:94 (!block_is_last(block))


Backtrace: 0x40375fae:0x3fcceff0 0x4037daa1:0x3fccf010 0x40386f61:0x3fccf030 0x403835c0:0x3fccf150 0x40383448:0x3fccf170 0x40376a6e:0x3fccf190 0x40386f91:0x3fccf1b0 0x40378982:0x3fccf1d0 0x40378f0c:0x3fccf1f0 0x40378f59:0x3fccf210 0x4202ccb9:0x3fccf230 0x4202d033:0x3fccf280 0x4202d5f1:0x3fccf360 0x4202d946:0x3fccf390 0x42068577:0x3fccf3d0 0x42017d3b:0x3fccf3f0 0x42017f18:0x3fccf470 0x4201649b:0x3fccf4a0 0x4201631a:0x3fccf4c0 0x42012a12:0x3fccf4e0 0x42013469:0x3fccf500 0x420149ef:0x3fccf520 0x42014a15:0x3fccf550 0x42016a40:0x3fccf580 0x42009239:0x3fccf5a0 0x4205a6ae:0x3fccf5c0 0x420115e2:0x3fccf5e0 0x42010e74:0x3fccf600 0x4200d910:0x3fccf620 0x4200e011:0x3fccf6b0 0x403805e9:0x3fccf700
0x40375fae: panic_abort at C:/Users/lchandrashekar/esp/v5.1/esp-idf/components/esp_system/panic.c:466
0x4037daa1: esp_system_abort at C:/Users/lchandrashekar/esp/v5.1/esp-idf/components/esp_system/port/esp_system_chip.c:84
0x40386f61: __assert_func at C:/Users/lchandrashekar/esp/v5.1/esp-idf/components/newlib/assert.c:81
0x403835c0: block_next at C:/Users/lchandrashekar/esp/v5.1/esp-idf/components/heap/tlsf/tlsf_block_functions.h:94
 (inlined by) block_link_next at C:/Users/lchandrashekar/esp/v5.1/esp-idf/components/heap/tlsf/tlsf_block_functions.h:101
 (inlined by) block_mark_as_free at C:/Users/lchandrashekar/esp/v5.1/esp-idf/components/heap/tlsf/tlsf_block_functions.h:109
 (inlined by) tlsf_free at C:/Users/lchandrashekar/esp/v5.1/esp-idf/components/heap/tlsf/tlsf.c:1121
0x40383448: multi_heap_free_impl at C:/Users/lchandrashekar/esp/v5.1/esp-idf/components/heap/multi_heap.c:231
0x40376a6e: heap_caps_free at C:/Users/lchandrashekar/esp/v5.1/esp-idf/components/heap/heap_caps.c:388
0x40386f91: free at C:/Users/lchandrashekar/esp/v5.1/esp-idf/components/newlib/heap.c:39
0x40378982: uninstall_priv_desc at C:/Users/lchandrashekar/esp/v5.1/esp-idf/components/driver/spi/gpspi/spi_master.c:845
0x40378f0c: spi_device_polling_end at C:/Users/lchandrashekar/esp/v5.1/esp-idf/components/driver/spi/gpspi/spi_master.c:1107 (discriminator 15)
0x40378f59: spi_device_polling_transmit at C:/Users/lchandrashekar/esp/v5.1/esp-idf/components/driver/spi/gpspi/spi_master.c:1127
0x4202ccb9: poll_busy at C:/Users/lchandrashekar/esp/v5.1/esp-idf/components/driver/spi/sdspi/sdspi_host.c:576
0x4202d033: start_command_write_blocks at C:/Users/lchandrashekar/esp/v5.1/esp-idf/components/driver/spi/sdspi/sdspi_host.c:927
0x4202d5f1: sdspi_host_start_command at C:/Users/lchandrashekar/esp/v5.1/esp-idf/components/driver/spi/sdspi/sdspi_host.c:480
0x4202d946: sdspi_host_do_transaction at C:/Users/lchandrashekar/esp/v5.1/esp-idf/components/driver/spi/sdspi/sdspi_transaction.c:150
As said both Etherent and Sd card are intialised with same bus config as follows:
spi_bus_config_t buscfg = {
.miso_io_num = SPI_MISO_GPIO,
.mosi_io_num = SPI_MOSI_GPIO,
.sclk_io_num = SPI_SCLK_GPIO,
.quadwp_io_num = -1,
.quadhd_io_num = -1,
};
ESP_ERROR_CHECK(spi_bus_initialize(SPI2_HOST, &buscfg, SPI_DMA_CH_AUTO));

Clock speed is set to 20 MHz (tried 10 MHz), there is only one CS pin available, logging speed (write to SD) is less than 200ms,
Please suggest a solution or a workaround for this issue....

aliarifat794
Posts: 200
Joined: Sun Jun 23, 2024 6:18 pm

Re: ESP32 assert failed: block_next tlsf_block_functions.h:94 (!block_is_last(block))

Postby aliarifat794 » Wed Sep 04, 2024 2:44 pm

Utilize esp_log_level_set("*", ESP_LOG_DEBUG); to increase logging verbosity and identify specific areas where the SPI transactions fail.
You can also use the heap_caps_check_integrity_all() function periodically to catch memory corruption early.

Who is online

Users browsing this forum: pkf1111 and 73 guests