This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52840 logging crashes in FreeRTOS

Recently I have encountered a software hanging issue on one of our products. It was based on nRF52840, with FreeRTOS (Thread SDK v1.0). The issue was apparently related to NRF_LOG_* stuff - if I added lots of logs, software would hang very quickly (whole FreeRTOS seems to be hanging - not just one task). If I have moderate amount of logs, crashes were random and rare. After a bit, I managed to reproduce this problem on PCA10056 board (to rule out our hardware), and then on one of the examples provided within the SDK.

To reproduce the issue:

- download fresh Thread SDK 1.0

- replace examples/thread/freertos_coap_server/main.c with https://gist.github.com/Nopik/6efc683c0f5cfd709302261b81ccee4d

- make

- nrfjprog -f NRF52 --chiperase --program _build/nrf52840_xxaa.hex

- connect RTT viewer (I'm using JLink + JLinkRTTClient)

- run CPU (I'm using just 'r' in JLink)

- some logs should appear in large amounts on RTT, leds should be blinking

- if leds are still blinking after 10-20 seconds, reset CPU and start it again (I'm using just 'r' and 'g' in JLink)

Expected behavior: CPU never crashes, example runs indefinitely

Observed behavior: CPU halts very often. Sometimes after 7 logs, sometimes after 9500 of them. On my setup, I just started CPU 10 times, 3 times it was running for at least 20 seconds (and I did reset manually), 4 times it hung after 7 debugs, 3 times it hung after few seconds (logs number 9713, 8529, and 11639, respectively).

It seems, that the hangs still occur, even if we remove NRF_LOG_INFO() from led task. They stop occurring only if I remove log flushing task as well.

I tested it on MacOS and Linux machines, on 2 different PCA10056 boards, also on custom software running on custom board. Interestingly, we've been developing our software for quite long time, and been using logging a lot - and this is first time we've encountered instability like this.

On our software, if deferred logs are turned off, situation is much worse, usually crashes are much more frequent.

Is this known bug? Any fix recommended?

Parents Reply Children
Related