Hello everyone,
I am working on an app where we use I2S driver for ws2812 LED strip to signalize status of our app. When I try to signalize status while starting BLE and starts advertising I get following error:
rtt:~$ rtt:~$ [00:00:00.530,731] <inf> bt_hci_core: HCI: version 5.4 (0x0d) revision 0x118f, manufacturer 0x0059 rtt:~$ [00:00:00.530,761] <inf> bt_hci_core: LMP: version 5.4 (0x0d) subver 0x118f rtt:~$ [00:00:00.538,330] <inf> BLE_DRIVER: Configuration mode: waiting for connections... rtt:~$ rtt:~$ [00:00:03.523,956] <err> i2s_nrfx: Next buffers not supplied on time rtt:~$ [00:00:03.524,047] <err> ws2812_i2s: Failed to trigger command 2 on TX: -5 rtt:~$ [00:00:04.524,444] <err> i2s_nrfx: Cannot write in state: 4 rtt:~$ [00:00:04.524,475] <err> ws2812_i2s: Failed to write data: -5
BLE and LED runs on different threads.
I already tried few things ():
-
CONFIG_I2S_NRFX_TX_BLOCK_COUNT=256 - I don’t see any difference between 4,64 and 256.
-
After Disabling/Not initializing BLE, LED strip works fine
-
Changing LED thread priority to -1 (and also 1) while BLE thread is equal 5. Also I checked in reverse so BLE -1 and LED thread 5 - didn’t help
-
Changing extra-wait-time = <X>; in dts from 30 to even 10000 didn’t seem to change anything
-
reset-delay = <8>; changing from 6 (minimum) to 50 didn’t seem to change anything
-
changing K_MEM_SLAB_DEFINE_STATIC(ws2812_i2s_##idx##_slab, WS2812_I2S_BUFSIZE(idx), 2, 4); to K_MEM_SLAB_DEFINE_STATIC(ws2812_i2s_##idx##_slab, WS2812_I2S_BUFSIZE(idx), 4, 4); and K_MEM_SLAB_DEFINE_STATIC(ws2812_i2s_##idx##_slab, WS2812_I2S_BUFSIZE(idx), 32, 4); didn’t do anything
-
Changing config.timeout = 1000; inside ws2812_i2s driver to config.timeout = SYS_FOREVER_MS; didn’t help
In system view i noticed something strange - normal allocation and deallocation looks like this :
k_mem_slab_alloc slab=0x20000D50, mem=0x00050000, Timeout=TIMEOUT_NO_WAIT k_slab_free slab=0x20000D50, mem=0x00000000
while when error occurs:
k_slab_alloc slab=0x20000D50, mem=0x00050000, Timeout=TIMEOUT_NO_WAIT k_slab_free slab=0x20000D50, mem=0x20000D88
where 0x20000D88 is address of mutex that I used to synchronize different threads that may use LED.
I run v3.5.99-ncs1-1 with zephyr-sdk-0.16.6.