Rikke
03/18/2025, 11:20 AMi2s_bus = i2s.Bus --tx=pin --sample_rate=100_000 --bits_per_sample=32 --buffer_size=(buf.size + reset.size) --use-apll=false
to
i2s_bus = i2s.Bus
--master=true
--mclk=null
--tx=pin
--sck=null
--ws=null
i2s_bus.configure
--sample_rate=100_000
--bits_per_sample=32
i2s_bus.start
But in 1 out of 20 reboots(ish) I get a panic when starting up the i2s:
Guru Meditation Error: Core 1 panic'ed (Cache disabled but cached memory region accessed).
Core 1 register dump:
PC : 0x400d5904 PS : 0x00060035 A0 : 0x80088c96 A1 : 0x3ffb2b50
A2 : 0x3ffd48e8 A3 : 0x3ffb2b70 A4 : 0x3ffd4810 A5 : 0x3ffaf960
A6 : 0x00000003 A7 : 0x00060723 A8 : 0x80080eef A9 : 0x00060923
A10 : 0x3ffd4810 A11 : 0x00000002 A12 : 0x00000000 A13 : 0x3ffb4484
A14 : 0x00000001 A15 : 0x3ffafa84 SAR : 0x00000001 EXCCAUSE: 0x00000007
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
*******************************************
Decoding by `jag`, device has version <2.0.0-alpha.175>
*******************************************
Crash in native code:
Backtrace: 0x400d5901:0x3ffb2b50 0x40088c93:0x3ffb2b70 0x40087079:0x3ffb2bb0 0x40089b39:0x3ffb2bd0 0x4008544a:0x3ffaf9b0 0x4008558b:0x3ffaf9d0
0x400d5901: toit::primitive_toit_callback_deinit(toit::Process*, toit::Object**) + 0x15
0x40088c93: i2s_dma_rx_callback + 0x8b
0x40087079: esp_random + 0x15
0x40089b39: interrupt_hlevel_restore + 0x11
0x4008544a: spi_flash_disable_cache$constprop$0 + 0x6
0x4008558b: spi_flash_guard_set + 0x3
*******************************************
I am using i2s_bus.write to write to the pin. It works fine most of the time, but am I starting up the I2S too early?floitsch
03/18/2025, 11:26 AMfloitsch
03/18/2025, 11:26 AMfloitsch
03/18/2025, 11:27 AMfloitsch
03/18/2025, 11:27 AMdeinit-callback)Rikke
03/18/2025, 11:28 AMfloitsch
03/18/2025, 11:28 AMfloitsch
03/18/2025, 11:28 AMfloitsch
03/18/2025, 11:28 AMdma_rx_callback can call the deinit.floitsch
03/18/2025, 11:29 AMRikke
03/18/2025, 11:29 AMRikke
03/18/2025, 11:29 AMfloitsch
03/18/2025, 11:30 AMRikke
03/18/2025, 11:30 AMfloitsch
03/18/2025, 11:32 AMIRAM attribute.floitsch
03/18/2025, 11:32 AMRikke
03/18/2025, 11:32 AMfloitsch
03/18/2025, 11:33 AMI2S_ISR_IRAM_SAFE.Rikke
03/18/2025, 11:34 AMI2S INIT 1
I2S INIT 2
I2S INIT 3
I2S INIT 4
debug: (1970-01-01T00:00:00Z) Watchdog: started led_control
Guru Meditation Error: Core 0 panic'ed (Cache disabled but cached memory region accessed).
Core 0 register dump:
PC : 0x400d5904 PS : 0x00060035 A0 : 0x80088c96 A1 : 0x3ffb2550
A2 : 0x3ffd4900 A3 : 0x3ffb2570 A4 : 0x3ffd4828 A5 : 0x3ffaf3d0
A6 : 0x00000003 A7 : 0x00060f23 A8 : 0x80080eef A9 : 0x00060123
A10 : 0x3ffd4828 A11 : 0x00000002 A12 : 0x00000000 A13 : 0x3ffb4484
A14 : 0x00000000 A15 : 0x3ffaf4f4 SAR : 0x0000001b EXCCAUSE: 0x00000007
EXCVADDR: 0x00000000 LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0xffffffff
******************************************************************************
Decoding by `jag`, device has version <2.0.0-alpha.175>
******************************************************************************
Crash in native code:
Backtrace: 0x400d5901:0x3ffb2550 0x40088c93:0x3ffb2570 0x40087079:0x3ffb25b0 0x40089b39:0x3ffb25d0 0x40085450:0x3ffaf420 0x4008558b:0x3ffaf440
0x400d5901: toit::primitive_toit_callback_deinit(toit::Process*, toit::Object**) + 0x15
0x40088c93: i2s_dma_rx_callback + 0x8b
0x40087079: esp_random + 0x15
0x40089b39: interrupt_hlevel_restore + 0x11
0x40085450: spi_flash_disable_cache$constprop$0 + 0xc
0x4008558b: spi_flash_guard_set + 0x3
******************************************************************************
so after init 4
print "I2S INIT 1"
i2s_bus = i2s.Bus
--master=true
--mclk=null
--tx=pin
--sck=null
--ws=null
print "I2S INIT 2"
i2s_bus.configure
--sample_rate=100_000
--bits_per_sample=32
print "I2S INIT 3"
i2s_bus.start
print "I2S INIT 4"
before i start writingfloitsch
03/18/2025, 11:35 AMfloitsch
03/18/2025, 11:35 AMRikke
03/18/2025, 11:35 AMfloitsch
03/18/2025, 11:36 AMI2S_ISR_IRAM_SAFE you tell the esp-idf that it shouldn't call the callback when it might not be in IRAM. So in theory that should work around the issue.floitsch
03/18/2025, 11:39 AMRikke
03/18/2025, 11:39 AMRikke
03/18/2025, 12:09 PMI2S INIT 1
I2S INIT 2
E (26638) i2s_common: i2s_alloc_dma_desc(431): allocate DMA buffer failed
E (26638) i2s_std: i2s_std_set_slot(106): allocate memory for dma descriptor failed
E (26638) i2s_std: i2s_channel_init_std_mode(217): initialize channel failed while setting slot
I2S INIT 3
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x401005ca PS : 0x00060030 A0 : 0x801012c2 A1 : 0x3ffc5da0
A2 : 0x3ffebe50 A3 : 0xffffffff A4 : 0x0000000a A5 : 0x00000000
A6 : 0x00000000 A7 : 0x3ffefc84 A8 : 0x3ff4f000 A9 : 0x00000000
A10 : 0x00000000 A11 : 0x00000002 A12 : 0x00060020 A13 : 0x00060023
A14 : 0x3ffaeb6c A15 : 0x3ffb01b8 SAR : 0x00000010 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000 LBEG : 0x4000c349 LEND : 0x4000c36b LCOUNT : 0xffffffffRikke
03/18/2025, 12:09 PM*************
Decoding by `jag`, device has version <2.0.0-alpha.175>
*************
Crash in native code:
Backtrace: 0x401005c7:0x3ffc5da0 0x401012bf:0x3ffc5dc0 0x400d5bfe:0x3ffc5df0 0x40081d3e:0x3ffc5e10 0x400f2771:0x3ffc5ea0 0x400f29f1:0x3ffc5ef0 0x400f2a11:0x3ffc5f20 0x400e58fa:0x3ffc5f40 0x400e5921:0x3ffc5f60
0x401005c7: nvs::Storage::writeItem(unsigned char, nvs::ItemType, char const*, void const*, unsigned int) + 0x13
0x401012bf: nvs::NVSPartitionManager::init_partition(char const*) + 0x53
0x400d5bfe: toit::primitive_set_characteristic_notify(toit::Process*, toit::Object**) + 0x4e
0x40081d3e: toit::Interpreter::run() + 0x9e6
0x400f2771: toit::primitive_region_open(toit::Process*, toit::Object**) + 0xd5
0x400f29f1: toit::primitive_partition_find(toit::Process*, toit::Object**) + 0x161
0x400f2a11: toit::primitive_region_is_erased(toit::Process*, toit::Object**) + 0xd
0x400e58fa: toit::FlashRegistry::write_chunk(void const*, int, int) + 0x1e
0x400e5921: toit::FlashRegistry::find_next(int, LinkedList<toit::Reservation, 1>::Iterator*) + 0x9
*************Rikke
03/18/2025, 12:10 PMfloitsch
03/18/2025, 1:53 PMfloitsch
03/18/2025, 1:53 PMfloitsch
03/18/2025, 1:53 PMfloitsch
03/18/2025, 1:54 PMfloitsch
03/18/2025, 1:57 PMecho Backtrace: 0x401005c7:0x3ffc5da0 0x401012bf:0x3ffc5dc0 0x400d5bfe:0x3ffc5df0 0x40081d3e:0x3ffc5e10 0x400f2771:0x3ffc5ea0 0x400f29f1:0x3ffc5ef0 0x400f2a11:0x3ffc5f20 0x400e58fa:0x3ffc5f40 0x400e5921:0x3ffc5f60 | build/host/sdk/tools/stacktrace build/esp32/toit.elfRikke
03/18/2025, 1:58 PMRikke
03/18/2025, 1:58 PMecho Backtrace: 0x401005c7:0x3ffc5da0 0x401012bf:0x3ffc5dc0 0x400d5bfe:0x3ffc5df0 0x40081d3e:0x3ffc5e10 0x400f2771:0x3ffc5ea0 0x400f29f1:0x3ffc5ef0 0x400f2a11:0x3ffc5f20 0x400e58fa:0x3ffc5f40 0x400e5921:0x3ffc5f60 | build/host/sdk/tools/stacktrace build/esp32/toit.elf
0x401005c7: i2s_tx_channel_start + 0xb3
0x401012bf: i2s_channel_enable + 0x7f
0x400d5bfe: toit::primitive_start(toit::Process*, toit::Object**) + 0x5a
0x40081d3e: toit::Interpreter::run() + 0xa42
0x400f2771: toit::Scheduler::run_process(toit::Locker&, toit::Process*, toit::SchedulerThread*) + 0x5d
0x400f29f1: toit::Scheduler::run(toit::SchedulerThread*) + 0x5d
0x400f2a11: toit::SchedulerThread::entry() + 0x9
0x400e58fa: toit::Thread::_boot() + 0x22
0x400e5921: toit::esp_thread_start(void*) + 0x5floitsch
03/18/2025, 1:59 PMRikke
03/18/2025, 1:59 PMfloitsch
03/18/2025, 1:59 PMfloitsch
03/18/2025, 1:59 PMRikke
03/18/2025, 2:00 PMecho Backtrace: 0x400d5901:0x3ffb2b50 0x40088c93:0x3ffb2b70 0x40087079:0x3ffb2bb0 0x40089b39:0x3ffb2bd0 0x4008544a:0x3ffaf9b0 0x4008558b:0x3ffaf9d0 | build/host/sdk/tools/stacktrace build/esp32/toit.elf
0x400d5901: toit::I2sResource::adjust_pending_event(int) + 0x9
0x40088c93: i2s_dma_tx_callback + 0x4f
0x40087079: shared_intr_isr + 0x35
0x40089b39: _xt_lowint1 + 0x89
0x4008544a: spi_flash_op_block_func + 0x22
0x4008558b: ipc_task + 0x53floitsch
03/18/2025, 2:00 PMfloitsch
03/18/2025, 2:00 PMfloitsch
03/18/2025, 2:08 PMRikke
03/18/2025, 2:09 PMfloitsch
03/18/2025, 2:09 PMRikke
03/18/2025, 2:10 PMfloitsch
03/18/2025, 2:10 PMfloitsch
03/18/2025, 2:10 PMRikke
03/18/2025, 2:11 PMfloitsch
03/18/2025, 2:12 PMRikke
03/18/2025, 2:13 PMRikke
03/18/2025, 2:13 PMfloitsch
03/18/2025, 2:13 PMRikke
03/18/2025, 2:14 PMfloitsch
03/18/2025, 2:16 PMfloitsch
03/18/2025, 2:16 PMfloitsch
03/18/2025, 2:16 PMfloitsch
03/18/2025, 2:17 PMRikke
03/18/2025, 2:17 PMfloitsch
03/18/2025, 2:18 PMRikke
03/18/2025, 2:19 PMfloitsch
03/18/2025, 2:19 PMfloitsch
03/19/2025, 11:40 AMkasperl
03/19/2025, 12:13 PMkasperl
03/19/2025, 12:25 PMkasperl
03/19/2025, 2:16 PMRikke
03/20/2025, 7:30 AMRikke
03/24/2025, 12:20 PMkasperl
03/24/2025, 12:22 PMfloitsch
03/24/2025, 12:23 PMRikke
03/24/2025, 12:24 PMxtensa-esp32-elf-objdump
echo Backtrace: 0x40101b83:0x3ffc3da0 0x4010294b:0x3ffc3dc0 0x400d5d32:0x3ffc3df0 0x40081d86:0x3ffc3e10 0x400f299d:0x3ffc3ea0 0x400f2c1d:0x3ffc3ef0 0x400f2c3d:0x3ffc3f20 0x400e5b3e:0x3ffc3f40 0x400e5b65:0x3ffc3f60 | build/host/sdk/tools/stacktrace build/esp32/toit.elf
EXCEPTION error.
Error trying to run 'xtensa-esp32-elf-objdump' using $PATH: No such file or directory: xtensa-esp32-elf-objdump
0: decode-stacktrace /home/vsts/staging/toit/tools/stacktrace.toit:66:5
1: build-command.<lambda> /home/vsts/staging/toit/tools/stacktrace.toit:38:16
2: Command.run.<block> <pkg:pkg-cli>/cli.toit:308:40
3: Parser_.parse <pkg:pkg-cli>/parser_.toit:212:5
4: Command.run <pkg:pkg-cli>/cli.toit:306:12
5: main /home/vsts/staging/toit/tools/stacktrace.toit:27:7Rikke
03/24/2025, 12:25 PME (3711657) i2s_common: i2s_alloc_dma_desc(432): allocate DMA buffer failed
E (3711657) i2s_std: i2s_std_set_slot(106): allocate memory for dma descriptor failed
E (3711667) i2s_std: i2s_channel_init_std_mode(217): initialize channel failed while setting slotRikke
03/24/2025, 12:31 PMecho Backtrace: 0x40101b83:0x3ffc5da0 0x4010294b:0x3ffc5dc0 0x400d5d32:0x3ffc5df0 0x40081d86:0x3ffc5e10 0x400f299d:0x3ffc5ea0 0x400f2c1d:0x3ffc5ef0 0x400f2c3d:0x3ffc5f20 0x400e5b3e:0x3ffc5f40 0x400e5b65:0x3ffc5f60 | build/host/sdk/tools/stacktrace build/esp32/toit.elf
0x40101b83: i2s_tx_channel_start + 0xb3
0x4010294b: i2s_channel_enable + 0x7b
0x400d5d32: toit::primitive_start(toit::Process*, toit::Object**) + 0x5a
0x40081d86: toit::Interpreter::run() + 0xa42
0x400f299d: toit::Scheduler::run_process(toit::Locker&, toit::Process*, toit::SchedulerThread*) + 0x5d
0x400f2c1d: toit::Scheduler::run(toit::SchedulerThread*) + 0x5d
0x400f2c3d: toit::SchedulerThread::entry() + 0x9
0x400e5b3e: toit::Thread::_boot() + 0x22
0x400e5b65: toit::esp_thread_start(void*) + 0x5
Same error as beforefloitsch
03/24/2025, 12:35 PMRikke
03/24/2025, 12:47 PMRikke
03/24/2025, 12:51 PMfloitsch
03/24/2025, 12:51 PMRikke
03/24/2025, 12:53 PMESP_LOGI(TAG, "DMA malloc info: dma_desc_num = %d", i); right before the line ESP_GOTO_ON_FALSE(handle->dma.bufs[i], ESP_ERR_NO_MEM, err, TAG, "allocate DMA buffer failed"); in the file third_party/esp-idf/components/esp_driver_i2s/i2s_common.c and rebuild, reflash and command the device to write to the LEDs with i2s over and over againfloitsch
03/24/2025, 12:54 PMRikke
03/24/2025, 12:55 PMkasperl
03/24/2025, 1:01 PMbuild/esp32/toit.elf file with me somehow? I'd like to take a look at the assembly code around 0x40101b83.Rikke
03/24/2025, 1:03 PMkasperl
03/24/2025, 1:03 PMRikke
03/24/2025, 1:04 PMRikke
03/24/2025, 1:06 PMRikke
03/24/2025, 1:07 PMfloitsch
03/24/2025, 1:07 PMRikke
03/24/2025, 1:09 PMRikke
03/24/2025, 1:12 PMkasperl
03/24/2025, 1:12 PMkasperl
03/24/2025, 1:17 PMkasperl
03/24/2025, 1:17 PMRikke
03/24/2025, 1:20 PMI (285857) i2s_common: DMA malloc info: dma_desc_num = 0
I (285857) i2s_common: DMA malloc info: dma_desc_num = 1
I (285857) i2s_common: DMA malloc info: dma_desc_num = 2
E (285857) i2s_common: i2s_alloc_dma_desc(433): allocate DMA buffer failed
E (285867) i2s_std: i2s_std_set_slot(106): allocate memory for dma descriptor failed
E (285877) i2s_std: i2s_channel_init_std_mode(217): initialize channel failed while setting slotfloitsch
03/24/2025, 1:38 PMRikke
03/24/2025, 1:38 PMfloitsch
03/24/2025, 1:39 PMfloitsch
03/24/2025, 1:39 PMfloitsch
03/24/2025, 1:39 PMfloitsch
03/24/2025, 1:40 PMfloitsch
03/24/2025, 1:40 PMfloitsch
03/24/2025, 1:40 PMfloitsch
03/24/2025, 1:41 PMkasperl
03/24/2025, 2:51 PMkasperl
03/25/2025, 6:37 AMkasperl
03/25/2025, 6:42 AM/* The DMA buffer need to re-allocate if the buffer size changed */
if (handle->dma.buf_size != buf_size) {
handle->dma.buf_size = buf_size;
ESP_RETURN_ON_ERROR(i2s_free_dma_desc(handle), TAG, "failed to free the old dma descriptor");
ESP_RETURN_ON_ERROR(i2s_alloc_dma_desc(handle, handle->dma.desc_num, buf_size),
TAG, "allocate memory for dma descriptor failed");
}kasperl
03/25/2025, 6:43 AMhandle->dma.buf_size before making sure that the allocations succeed. If we fail the allocation and retry, we will not try to re-allocate the structures.kasperl
03/25/2025, 6:52 AMkasperl
03/25/2025, 7:12 AMRikke
03/25/2025, 8:09 AMkasperl
03/25/2025, 8:10 AMi2s_std.c.kasperl
03/25/2025, 8:11 AME (285857) i2s_common: i2s_alloc_dma_desc(433): allocate DMA buffer failed), but at least now there should be a chance that it will not lead to a crash on the retry.Rikke
03/25/2025, 8:11 AMkasperl
03/25/2025, 8:12 AM/* The DMA buffer need to re-allocate if the buffer size changed */
if (handle->dma.buf_size != buf_size) {
- handle->dma.buf_size = buf_size;
ESP_RETURN_ON_ERROR(i2s_free_dma_desc(handle), TAG, "failed to free the old dma descriptor");
ESP_RETURN_ON_ERROR(i2s_alloc_dma_desc(handle, handle->dma.desc_num, buf_size),
TAG, "allocate memory for dma descriptor failed");
+ handle->dma.buf_size = buf_size;
}kasperl
03/25/2025, 8:12 AMRikke
03/25/2025, 8:36 AMRikke
03/25/2025, 8:37 AMkasperl
03/25/2025, 8:38 AMgit diff from the esp-idf directory? 🙂Rikke
03/25/2025, 8:39 AMRikke
03/25/2025, 8:42 AMdiff --git a/components/esp_driver_i2s/i2s_common.c b/components/esp_driver_i2s/i2s_common.c
index ca7332e32..695a7a30e 100644
--- a/components/esp_driver_i2s/i2s_common.c
+++ b/components/esp_driver_i2s/i2s_common.c
@@ -417,7 +417,7 @@ esp_err_t i2s_alloc_dma_desc(i2s_chan_handle_t handle, uint32_t num, uint32_t bu
handle->dma.desc = (lldesc_t **)heap_caps_calloc(num, sizeof(lldesc_t *), I2S_MEM_ALLOC_CAPS);
ESP_GOTO_ON_FALSE(handle->dma.desc, ESP_ERR_NO_MEM, err, TAG, "create I2S DMA descriptor array failed");
handle->dma.bufs = (uint8_t **)heap_caps_calloc(num, sizeof(uint8_t *), I2S_MEM_ALLOC_CAPS);
- ESP_GOTO_ON_FALSE(handle->dma.bufs, ESP_ERR_NO_MEM, err, TAG, "create I2S DMA buffers array failed");
+ ESP_GOTO_ON_FALSE(handle->dma.bufs, ESP_ERR_NO_MEM, err, TAG, "create I2S DMA buffer array failed");
for (int i = 0; i < num; i++) {
/* Allocate DMA descriptor */
handle->dma.desc[i] = (lldesc_t *) i2s_dma_calloc(handle, 1, sizeof(lldesc_t));Rikke
03/25/2025, 8:42 AM@@ -429,6 +429,7 @@ esp_err_t i2s_alloc_dma_desc(i2s_chan_handle_t handle, uint32_t num, uint32_t bu
handle->dma.desc[i]->size = bufsize;
handle->dma.desc[i]->offset = 0;
handle->dma.bufs[i] = (uint8_t *) i2s_dma_calloc(handle, 1, bufsize * sizeof(uint8_t));
+ // ESP_LOGI(TAG, "DMA malloc info: dma_desc_num = %d", i);
ESP_GOTO_ON_FALSE(handle->dma.bufs[i], ESP_ERR_NO_MEM, err, TAG, "allocate DMA buffer failed");
#if SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE
esp_cache_msync(handle->dma.bufs[i], bufsize * sizeof(uint8_t), ESP_CACHE_MSYNC_FLAG_DIR_C2M);
diff --git a/components/esp_driver_i2s/i2s_std.c b/components/esp_driver_i2s/i2s_std.c
index c3ef0c046..878b1845c 100644
--- a/components/esp_driver_i2s/i2s_std.c
+++ b/components/esp_driver_i2s/i2s_std.c
@@ -101,10 +101,10 @@ static esp_err_t i2s_std_set_slot(i2s_chan_handle_t handle, const i2s_std_slot_c
uint32_t buf_size = i2s_get_buf_size(handle, slot_cfg->data_bit_width, handle->dma.frame_num);
/* The DMA buffer need to re-allocate if the buffer size changed */
if (handle->dma.buf_size != buf_size) {
- handle->dma.buf_size = buf_size;
ESP_RETURN_ON_ERROR(i2s_free_dma_desc(handle), TAG, "failed to free the old dma descriptor");
ESP_RETURN_ON_ERROR(i2s_alloc_dma_desc(handle, handle->dma.desc_num, buf_size),
TAG, "allocate memory for dma descriptor failed");
+ handle->dma.buf_size = buf_size;
}
bool is_slave = handle->role == I2S_ROLE_SLAVE;
/* Share bck and ws signal in full-duplex mode */kasperl
03/25/2025, 8:43 AMRikke
03/25/2025, 8:43 AMkasperl
03/25/2025, 8:44 AMbuf_size too and it does it wrong.kasperl
03/25/2025, 8:51 AMesp_err_t i2s_free_dma_desc(i2s_chan_handle_t handle)
{
I2S_NULL_POINTER_CHECK(TAG, handle);
+ uint32_t desc_num = handle->dma.desc_num;
+
+ handle->dma.desc_num = 0;
+ handle->dma.buf_size = 0;
+
if (!handle->dma.desc) {
return ESP_OK;
}
- for (int i = 0; i < handle->dma.desc_num; i++) {
+ for (int i = 0; i < desc_num; i++) {
if (handle->dma.bufs[i]) {kasperl
03/25/2025, 8:52 AMbuf_size outside of i2s_alloc_dma_desc, but I don't think it matters much.Rikke
03/25/2025, 8:54 AMRikke
03/25/2025, 8:55 AME (971) i2s_common: i2s_alloc_dma_desc(423): create I2S DMA descriptor array failed
E (971) i2s_std: i2s_std_set_slot(105): allocate memory for dma descriptor failed
E (971) i2s_std: i2s_channel_init_std_mode(217): initialize channel failed while setting slot
E (981) i2s_common: i2s_alloc_dma_desc(423): create I2S DMA descriptor array failed
E (991) i2s_std: i2s_std_set_slot(105): allocate memory for dma descriptor failed
E (1001) i2s_std: i2s_channel_init_std_mode(217): initialize channel failed while setting slot
E (1011) i2s_common: i2s_alloc_dma_desc(423): create I2S DMA descriptor array failed
E (1011) i2s_std: i2s_std_set_slot(105): allocate memory for dma descriptor failed
E (1021) i2s_std: i2s_channel_init_std_mode(217): initialize channel failed while setting slotRikke
03/25/2025, 8:55 AMHeap report @ out of memory in primitive 7:2:
┌───────────┬──────────┬─────────────────────────────────────────────────────┐
│ Bytes │ Count │ Type │
├───────────┼──────────┼─────────────────────────────────────────────────────┤
│ 8 │ 1 │ external byte array │
│ 32768 │ 10 │ toit processes │
│ 16384 │ 4 │ system 0 ba2bb6f3-b6cd-d9c6-621d-7632ae3d2f0c │
│ 16384 │ 4 │ current 1 8de635b4-126e-3003-f980-e3a3ec6281c5 │
│ 20480 │ 1 │ heap metadata │
│ 4096 │ 1 │ spare new-space │
│ 5352 │ 13 │ lwip │
│ 4720 │ 326 │ heap overhead │
│ 2104 │ 33 │ event source │
│ 9424 │ 126 │ thread/other │
│ 26400 │ 21 │ thread/spawn │
│ 22696 │ 100 │ untagged │
└───────────┴──────────┴─────────────────────────────────────────────────────┘
Total: 128048 bytes in 304 allocations (43%), largest free 108k, total free 165k
E (1201) i2s_common: i2s_alloc_dma_desc(423): create I2S DMA descriptor array failed
E (1211) i2s_std: i2s_std_set_slot(105): allocate memory for dma descriptor failed
E (1221) i2s_std: i2s_channel_init_std_mode(217): initialize channel failed while setting slotRikke
03/25/2025, 8:58 AMdiff --git a/components/esp_driver_i2s/i2s_common.c b/components/esp_driver_i2s/i2s_common.c
index ca7332e32..f0fd7483f 100644
--- a/components/esp_driver_i2s/i2s_common.c
+++ b/components/esp_driver_i2s/i2s_common.c
@@ -380,10 +380,15 @@ uint32_t i2s_get_buf_size(i2s_chan_handle_t handle, uint32_t data_bit_width, uin
esp_err_t i2s_free_dma_desc(i2s_chan_handle_t handle)
{
I2S_NULL_POINTER_CHECK(TAG, handle);
+ uint32_t desc_num = handle->dma.desc_num;
+
+ handle->dma.desc_num = 0;
+ handle->dma.buf_size = 0;
+
if (!handle->dma.desc) {
return ESP_OK;
}
- for (int i = 0; i < handle->dma.desc_num; i++) {
+ for (int i = 0; i < desc_num; i++) {
if (handle->dma.bufs[i]) {
free(handle->dma.bufs[i]);
handle->dma.bufs[i] = NULL;kasperl
03/25/2025, 8:58 AMRikke
03/25/2025, 8:58 AMRikke
03/25/2025, 8:59 AM******************************************************************************
Decoding by `jag`, device has version <2.0.0-alpha.176>
******************************************************************************
MALLOC_FAILED error.
0: Bus.configure <sdk>/i2s.toit:475:5
1: LedI2S /home/vsts/--/src/i2s_led_driver.toit:96:13
2: led-task /home/vsts/--/src/led_handler.toit:91:13
3: setup-gpio /home/vsts/--/src/pinout.toit:130:5
4: main /home/vsts/--/src/gateway.toit:25:3
******************************************************************************
but reset because of [toit] WARN: entering deep sleep for 1s due to errorkasperl
03/25/2025, 9:00 AMkasperl
03/25/2025, 9:05 AMRikke
03/25/2025, 9:10 AMRikke
03/25/2025, 9:11 AMfloitsch
03/25/2025, 9:12 AMfloitsch
03/25/2025, 9:12 AMRikke
03/25/2025, 9:14 AMi2s_bus = i2s.Bus
--master=true
--mclk=null
--tx=pin
--sck=null
--ws=null
i2s_bus.configure
--sample_rate=100_000
--bits_per_sample=32
i2s_bus.start
and write written := i2s_bus.write buf.copy + reset.copykasperl
03/25/2025, 9:14 AMRikke
03/25/2025, 9:14 AMfloitsch
03/25/2025, 9:15 AMRikke
03/25/2025, 9:15 AMRikke
03/25/2025, 9:16 AMimport i2s
import bytes
import gpio
import encoding.hex
import system.storage
the imports we use for driverfloitsch
03/25/2025, 9:18 AMRikke
03/25/2025, 9:20 AMfloitsch
03/25/2025, 9:20 AMRikke
03/25/2025, 9:21 AMfloitsch
03/25/2025, 9:21 AMfloitsch
03/25/2025, 9:21 AMJAG_TOIT_REPO_PATH to the root of the SDK checkoutfloitsch
03/25/2025, 9:22 AMmake and it also builds the envelope.Rikke
03/25/2025, 9:23 AMJAG_TOIT_REPO_PATH=~/staging/toit make -C staging/jaguar JAG_BUILD_RELEASE=1floitsch
03/25/2025, 9:23 AMkasperl
03/25/2025, 9:24 AMJAG_BUILD_RELEASE=1 because that will give you a binary that only looks in ~/.cache/ if I am not mistaken.Rikke
03/25/2025, 9:24 AMfloitsch
03/25/2025, 9:49 AMfloitsch
03/25/2025, 9:49 AMimport i2s
import bytes
import gpio
import encoding.hex
import system.storage
main:
pin := gpio.Pin 32
i2s_bus := i2s.Bus
--master=true
--mclk=null
--tx=pin
--sck=null
--ws=null
i2s_bus.configure
--sample_rate=100_000
--bits_per_sample=32
i2s_bus.start
bytes := ByteArray 1024
i2s_bus.write bytesRikke
03/25/2025, 9:50 AMRikke
03/25/2025, 9:51 AMfloitsch
03/25/2025, 9:52 AMimport i2s
import bytes
import gpio
import encoding.hex
import system.storage
main:
while true:
pin := gpio.Pin 32
i2s_bus := i2s.Bus
--master=true
--mclk=null
--tx=pin
--sck=null
--ws=null
i2s_bus.configure
--sample_rate=100_000
--bits_per_sample=32
i2s_bus.start
bytes := ByteArray 1024
i2s_bus.write bytes
i2s_bus.stop
i2s_bus.close
pin.close
Still no crash.Rikke
03/25/2025, 9:54 AMRikke
03/25/2025, 9:56 AMfloitsch
03/25/2025, 9:56 AMRikke
03/25/2025, 9:57 AMError: Failed to open '' for reading (FILE_NOT_FOUND: "").
Error: exit status 1
JAG_TOIT_REPO_PATH=/home/vsts/staging/toitfloitsch
03/25/2025, 9:58 AMRikke
03/25/2025, 9:59 AMvsts@rikke:~/staging/jaguar$ build/jag flash
Enter WiFi network (SSID): WiFi_QA_3
Enter WiFi password for 'WiFi_QA_3':
Error: Failed to open '' for reading (FILE_NOT_FOUND: "").
Error: exit status 1floitsch
03/25/2025, 9:59 AMfloitsch
03/25/2025, 10:01 AMbuild/jag config wifi set --wifi-password="WiFi_QA_3" --wifi-ssid="WiFi_QA_3"Rikke
03/25/2025, 10:01 AMkasperl
03/25/2025, 10:01 AMfloitsch
03/25/2025, 10:02 AMfloitsch
03/25/2025, 10:04 AMfloitsch
03/25/2025, 10:04 AMRikke
03/25/2025, 10:04 AMRikke
03/25/2025, 10:05 AMfloitsch
03/25/2025, 10:05 AMRikke
03/25/2025, 10:06 AMfloitsch
03/25/2025, 10:06 AMsource $JAG_TOIT_REPO_PATH/third_party/esp-idf/export.sh should do it.Rikke
03/25/2025, 10:09 AMfloitsch
03/25/2025, 10:10 AMfloitsch
03/25/2025, 10:11 AMᐅ source ../opentoit/third_party/esp-idf/export.sh
Setting IDF_PATH to '/home/flo/work/opentoit/third_party/esp-idf'
...
ᐅ which esptool.py
/home/flo/.espressif/python_env/idf5.3_py3.13_env/bin/esptool.pyRikke
03/25/2025, 10:13 AMfloitsch
03/25/2025, 10:13 AMfloitsch
03/25/2025, 10:59 AM[jaguar] INFO: program cbaa7f18-0910-cf8a-ed22-16dbb4a5f3b7 started
E (9020) i2s_common: i2s_alloc_dma_desc(432): allocate DMA buffer failed
E (9020) i2s_std: i2s_std_set_slot(106): allocate memory for dma descriptor failed
E (9020) i2s_std: i2s_channel_init_std_mode(217): initialize channel failed while setting slot
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x40105292 PS : 0x00060930 A0 : 0x80106092 A1 : 0x3ffd1da0
A2 : 0x3ffef9f8 A3 : 0xffffffff A4 : 0x00000000 A5 : 0x00000000
A6 : 0x00000000 A7 : 0x3fff547c A8 : 0x3ff4f000 A9 : 0x00000000
A10 : 0x00000000 A11 : 0x00000002 A12 : 0x00060920 A13 : 0x00060923
A14 : 0x00000001 A15 : 0x3ffbdd28 SAR : 0x00000018 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000 LBEG : 0x4000c349 LEND : 0x4000c36b LCOUNT : 0xffffffff
******************************************************************************
Decoding by `jag`, device has version <2.0.0-alpha.176.4+floitsch-i2c.registers.slave.a63ae902>
******************************************************************************
Crash in native code:
Backtrace: 0x4010528f:0x3ffd1da0 0x4010608f:0x3ffd1dc0 0x400d99f6:0x3ffd1df0 0x40081e72:0x3ffd1e10 0x400f63d4:0x3ffd1ea0 0x400f665d:0x3ffd1ef0 0x400f667d:0x3ffd1f20 0x400e97c6:0x3ffd1f40 0x400e97ed:0x3ffd1f60
0x4010528f: i2s_tx_channel_start + 0xb3
0x4010608f: i2s_channel_enable + 0x7f
First step in reproducing.
This is still without Kasper's patch.kasperl
03/25/2025, 10:59 AMfloitsch
03/25/2025, 11:02 AMfloitsch
03/25/2025, 11:09 AM[jaguar] INFO: program 5243ce0f-2715-f465-ab36-1119f0d306ca started
E (54350) i2s_common: i2s_alloc_dma_desc(422): create I2S DMA descriptor array failed
E (54350) i2s_std: i2s_std_set_slot(105): allocate memory for dma descriptor failed
E (54350) i2s_std: i2s_channel_init_std_mode(216): initialize channel failed while setting slot
E (54370) i2s_common: i2s_alloc_dma_desc(422): create I2S DMA descriptor array failed
E (54370) i2s_std: i2s_std_set_slot(105): allocate memory for dma descriptor failed
E (54370) i2s_std: i2s_channel_init_std_mode(216): initialize channel failed while setting slot
E (54390) i2s_common: i2s_alloc_dma_desc(422): create I2S DMA descriptor array failed
E (54400) i2s_std: i2s_std_set_slot(105): allocate memory for dma descriptor failed
E (54400) i2s_std: i2s_channel_init_std_mode(216): initialize channel failed while setting slot
Heap report @ out of memory in primitive 7:2:
┌───────────┬──────────┬─────────────────────────────────────────────────────┐
...
└───────────┴──────────┴─────────────────────────────────────────────────────┘
Total: 198768 bytes in 475 allocations (83%), largest free 24k, total free 42k
E (54610) i2s_common: i2s_alloc_dma_desc(422): create I2S DMA descriptor array failed
E (54610) i2s_std: i2s_std_set_slot(105): allocate memory for dma descriptor failed
E (54620) i2s_std: i2s_channel_init_std_mode(216): initialize channel failed while setting slot
******************************************************************************
Decoding by `jag`, device has version <2.0.0-alpha.176.5+f1a00000>
******************************************************************************
MALLOC_FAILED error.
0: Bus.configure <sdk>/i2s.toit:473:5
1: main /home/flo/tmp/i2s-dma/main.toit:18:13
******************************************************************************
I can reproduce.Rikke
03/25/2025, 11:15 AMfloitsch
03/25/2025, 11:28 AMfloitsch
03/25/2025, 11:28 AMkasperl
03/25/2025, 11:40 AMRikke
03/25/2025, 11:40 AMRikke
03/25/2025, 11:56 AMkasperl
03/25/2025, 12:22 PMRikke
03/25/2025, 12:23 PMkasperl
03/25/2025, 12:33 PMkasperl
03/25/2025, 3:34 PMkasperl
03/25/2025, 3:34 PMkasperl
03/26/2025, 11:20 AMRikke
03/26/2025, 11:26 AMkasperl
03/26/2025, 11:27 AMkasperl
03/26/2025, 11:28 AMRikke
03/26/2025, 11:29 AMRikke
03/26/2025, 11:39 AME (13649) i2s_common: i2s_alloc_dma_desc(434): allocate DMA buffer failed
E (13649) i2s_std: i2s_std_set_slot(106): allocate memory for dma descriptor failed
E (13659) i2s_std: i2s_channel_init_std_mode(217): initialize channel failed while setting slot
E (13669) i2s_common: i2s_alloc_dma_desc(434): allocate DMA buffer failed
E (13669) i2s_std: i2s_std_set_slot(106): allocate memory for dma descriptor failed
E (13679) i2s_std: i2s_channel_init_std_mode(217): initialize channel failed while setting slot
no resetkasperl
03/26/2025, 11:40 AMRikke
03/26/2025, 11:40 AMkasperl
03/26/2025, 11:40 AMfloitsch
03/26/2025, 11:42 AMRikke
03/26/2025, 11:42 AMRikke
03/26/2025, 11:42 AMRikke
03/26/2025, 11:45 AM