SoC: nrf52840
SDK: OpenConnect 2.4.4
I have been developing an ambient noise system using I2C microphone, nrf52840 and Zigbee networks for some time. The firmare reads 1 minute of ambient noise, filters for eight different frequencies and publishes RMS values using a customized Zigbee cluster.
Battery power devices, end-devices, are working fine. They stay online for weeks/months until the battery runs out. They never stop.
I also have another firmware with the same functionality, but it is a Zigbee router. This version also reads 1 minute of ambient noise, filters for eight different frequencies and publishes RMS values using the same customized Zigbee cluster.
Unfortunately, with the router version I’m struggling to solve a problem with the I2S driver. After a while, It seems like it runs out o memory as shown in the following log:
Boot:
I: I2S MCK frequency: 1391304, actual PCM rate: 28985
I: Production configuration is not present or invalid (status: -1)
I: Zigbee stack initialized
I: Unimplemented signal (signal: 54, status: 0)
I: Joined network successfully on reboot signal (Extended PAN ID: 00124b002a2e8593, PAN ID: 0x1a62)
(...)
I: Unimplemented signal (signal: 54, status: 0) <- Zigbee router signals
I: Unimplemented signal (signal: 54, status: 0)
I: Unimplemented signal (signal: 50, status: 0)
I: Unimplemented signal (signal: 54, status: 0)
I: Unimplemented signal (signal: 50, status: 0)
4531 4476 4710 3625 3903 2864 2990 5111 <- RMS values (some serial debug)
E: k_mem_slab_max_used_get: 3 <- slab usage
After hours or days:
I: Unimplemented signal (signal: 54, status: 0)
E: Failed to allocate next RX buffer: -12 <-- get_next_rx_buffer, return of k_mem_slab_alloc
E: No room in RX queue <-- k_msgq_put
E: Failed to read data: -5 590 <-- i2s_read
I: Unimplemented signal (signal: 54, status: 0)
E: Failed to _trigger i2s interface: -5
After those errors, I can’t trigger i2s interface anymore, nor reconfigure it. The application seems to be fine since the router keeps sending/receiving Zigbee messages but the audio thread can’t use I2S anymore.
BYTES_PER_SAMPLE = 4
SAMPLES_PER_BLOCK = 2800 ( SAMPLE_FREQUENCY / 10 )
#define BLOCK_SIZE (BYTES_PER_SAMPLE * SAMPLES_PER_BLOCK)
#define BLOCK_COUNT (4)
/** @endcond */ /* internals_doc */
/*! @brief Create a kernel memory slab to store I2S data. Required for I2S driver. */
K_MEM_SLAB_DEFINE_STATIC(mem_slab, BLOCK_SIZE, BLOCK_COUNT, 4);
Since I have a dedicated slab for the I2S driver, it couldn't run out o memory, right? Could you give some insight to debug and solve this problem?
