ESP-IDF v6.0.2
Code: Select all
#define SPI_RECV_DMA_BUF_SIZE (8 * 1024)
esp_err_t _spi_slave_receive()
{
recv_buf = heap_caps_calloc(SPI_RECV_DMA_BUF_SIZE, 1, MALLOC_CAP_DMA);
uint8_t * rx_ptr = recv_buf;
int offset = 0;
uint32_t bit_length;
uint32_t reaminder = 11420;
uint32_t byte_length = 0;
uint32_t cnt = 0;
while (remainder > 0) {
if (remainder > SPI_RECV_DMA_BUF_SIZE) {
section_size = SPI_RECV_DMA_BUF_SIZE;
} else {
section_size = remainder;
}
bit_length = section_size * 8;
spi_slave_transaction_t t = {
.length = bit_length,
.rx_buffer = (rx_ptr + offset),
.tx_buffer = NULL,
.flags = 0,
.trans_len = 0,
.user = NULL,
};
ret = spi_slave_bus_transmit(&t, portMAX_DELAY);
if (ret != ESP_OK) {
break;
}
byte_length = (t.trans_len / 8);
remainder -= byte_length;
cnt++;
// each time, SPI receiver 420 bytes
offset += 512; // for DMA alignment
if ((cnt % 10) == 0) { offset = 0; } // prevent buffer overflow
}
free(recv_buf);
}
First invoked, it works well, but second invoked, I got the exception.
If I fixed transaction.rx_buffer = recv_buf, It has no error occurred.Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x4037e5fa PS : 0x00060f33 A0 : 0x8037e495 A1 : 0x3fcc83a0
--- 0x4037e5fa: block_set_prev_free at /home/keroro/.espressif/v6.0.2/esp-idf/components/heap/tlsf/tlsf_block_functions.h:123
--- (inlined by) block_mark_as_free at /home/keroro/.espressif/v6.0.2/esp-idf/components/heap/tlsf/tlsf_block_functions.h:177
--- (inlined by) tlsf_free at /home/keroro/.espressif/v6.0.2/esp-idf/components/heap/tlsf/tlsf.c:631
A2 : 0x3fc95e04 A3 : 0x3fcc9290 A4 : 0x8037d868 A5 : 0x3fc933e0
A6 : 0x3fc92088 A7 : 0x3fcc9290 A8 : 0xd320e6e0 A9 : 0x93545454
A10 : 0x3fcc9288 A11 : 0xfffffffc A12 : 0x00060f20 A13 : 0x3fc964f4
A14 : 0x00060023 A15 : 0x00060f23 SAR : 0x00000005 EXCCAUSE: 0x0000001c
EXCVADDR: 0xd320e6e4 LBEG : 0x40056f5c LEND : 0x40056f72 LCOUNT : 0x00000000
--- 0x40056f5c: memcpy in ROM
--- 0x40056f72: memcpy in ROM
Backtrace: 0x4037e5f7:0x3fcc83a0 0x4037e492:0x3fcc83c0 0x40375f86:0x3fcc83e0 0x4037b0bd:0x3fcc8400 0x4037728e:0x3fcc8420 0x42015433:0x3fcc8440 0x42015462:0x3fcc8480 0x42014e1e:0x3fcc84b0 0x42012117:0x3fcc84d0
--- 0x4037e5f7: offset_to_block at /home/keroro/.espressif/v6.0.2/esp-idf/components/heap/tlsf/tlsf_block_functions.h:146
--- (inlined by) block_next at /home/keroro/.espressif/v6.0.2/esp-idf/components/heap/tlsf/tlsf_block_functions.h:159
--- (inlined by) block_link_next at /home/keroro/.espressif/v6.0.2/esp-idf/components/heap/tlsf/tlsf_block_functions.h:168
--- (inlined by) block_mark_as_free at /home/keroro/.espressif/v6.0.2/esp-idf/components/heap/tlsf/tlsf_block_functions.h:176
--- (inlined by) tlsf_free at /home/keroro/.espressif/v6.0.2/esp-idf/components/heap/tlsf/tlsf.c:631
--- 0x4037e492: multi_heap_free_impl at /home/keroro/.espressif/v6.0.2/esp-idf/components/heap/multi_heap.c:240
--- (inlined by) multi_heap_free_impl at /home/keroro/.espressif/v6.0.2/esp-idf/components/heap/multi_heap.c:229
--- 0x40375f86: heap_caps_free at /home/keroro/.espressif/v6.0.2/esp-idf/components/heap/heap_caps_base.c:86
--- 0x4037b0bd: free at /home/keroro/.espressif/v6.0.2/esp-idf/components/esp_libc/src/heap.c:34
--- 0x4037728e: spi_slave_uninstall_priv_trans at /home/keroro/.espressif/v6.0.2/esp-idf/components/esp_driver_spi/src/gpspi/spi_slave.c:409
--- 0x42015433: spi_slave_get_trans_result at /home/keroro/.espressif/v6.0.2/esp-idf/components/esp_driver_spi/src/gpspi/spi_slave.c:553
--- 0x42015462: spi_slave_transmit at /home/keroro/.espressif/v6.0.2/esp-idf/components/esp_driver_spi/src/gpspi/spi_slave.c:567
--- 0x42014e1e: spi_slave_bus_transmit at /home/keroro/TempoVision/Firmware/Espressif/ESP32/esp32-s3-spi_TV001_preTest/components/spi_bus_driver/spi_bus_driver.c:358
--- 0x42012117: _spi_slave_receive at /home/keroro/TempoVision/Firmware/Espressif/ESP32/esp32-s3-spi_TV001_preTest/components/sensor_tv001_task/spi_recev_task.c:117
--- (inlined by) spi_slave_bus_seq_task at /home/keroro/TempoVision/Firmware/Espressif/ESP32/esp32-s3-spi_TV001_preTest/components/sensor_tv001_task/spi_recev_task.c:207
Code: Select all
spi_slave_transaction_t t = {
.length = bit_length,
.rx_buffer = recv_buf,
.tx_buffer = NULL,
.flags = 0,
.trans_len = 0,
.user = NULL,
};
