2025-11-25 2:27 AM
stack:
Zephyr on stm32n6 (nucleo_n657x0_q)
When sending a buffer over sai via i2s_write data is written into the buffer.
I expected the TX buffer to be treated as read-only and remain unchanged by the driver.
It's only ever the first 2 numbers.
Why is that?
In attachment a minimal version of a project that displays this issue.
Solved! Go to Solution.
2025-11-25 4:59 AM
(declaring the buffer as const did raise warnings.)
I found what the issue is.
I2s_write expect's it's buffer to be from the memory slab that was assigned in I2s's config.
And at the end of i2s_write the memory block is freed to the memory slab.
Memory slabs store data about the linked list of all their buffers in the first 4 bytes of empty buffers.
Meaning that when i2s_write finishes the memory slab mistakenly attempts to put it back in it's linked list of buffers. Which writes data into the first 4 bytes.
2025-11-25 3:11 AM - edited 2025-11-25 3:11 AM
Hello @wouter-van-bastelaere
Try using a buffer declared as const with i2s_write to check if the compiler issues any warnings or errors.
2025-11-25 4:59 AM
(declaring the buffer as const did raise warnings.)
I found what the issue is.
I2s_write expect's it's buffer to be from the memory slab that was assigned in I2s's config.
And at the end of i2s_write the memory block is freed to the memory slab.
Memory slabs store data about the linked list of all their buffers in the first 4 bytes of empty buffers.
Meaning that when i2s_write finishes the memory slab mistakenly attempts to put it back in it's linked list of buffers. Which writes data into the first 4 bytes.