Hi Nordic Support,
I'm running into an issue with ncs v1.8.0 directing log and shell to RTT backend.
Objective:
Using nRF NCS / nRF52840dk - I want to dedicate 1x UART only for SMP Server interface and use RTT for logging AND shell backend.
How to replicate:
take smp_svr sample. as per instructions of the sample, to build for serial apply these 3 overlay files. I build this for nrf52840dk_nrf52840 board and this works as expected.
west build -p -b nrf52840dk_nrf52840 -- -DOVERLAY_CONFIG= 'overlay-serial.conf;overlay-fs.conf;overlay-shell-mgmt.conf'
Reading the logging backend docs, there are 2 approaches from my understanding to achieve the objective above:
1- Enable shell through RTT only, and then use Shell itself as log backend (i.e. default CONFIG_SHELL_LOG_BACKEND=y)
2- Enable shell through RTT only, disable shell as log backend (CONFIG_SHELL_LOG_BACKEND=n) and enable RTT as log backend directly -> this results in an error saying "Conflicting log RTT backend enabled on the same channel" - which gets resolved if we use a different buffer index for log (i.e. buffer 0 is shell) CONFIG_LOG_BACKEND_RTT_BUFFER=1
NOTE : All project files are attached in a zip at the end
Before we implement the changes above let's add some extra arbitrary logging statement to prove the point - adding a new LOG_INF inside while(1) and decrement the period of while loop to 100ms:
uint32_t r = 0; while (1) { r++; LOG_INF("run %u... and some extra chars to fill up bufferes fasterrrrr!",r); k_sleep(K_MSEC(100)); STATS_INC(smp_svr_stats, ticks); }
Approach 1:
Add these lines to overlay-shell-mgmt.conf and OR create another overlay file and add to the list of overlay configs:
CONFIG_SHELL_BACKENDS=y CONFIG_SHELL_BACKEND_RTT=y CONFIG_LOG_BACKEND_UART=n
If we connect via RTT viewer (i'm using v7.48b) right after west flash/reset, logs and shell are available.
BUT if we close the RTT Viewer or disconnect, connect a few seconds later:
Log Viewer download the last chunk and then logging completely stops. Firmware is still running because shell still works as can be seen below - I queried the uptime twice:
It's interesting it shows the # of messages dropped so that part is good, and it does download 1 last chunk of logs which look fresh, but then it fails to download newer ones!
Approach 2:
Looks more intuitive, if we disable shell as a log backend and then enable RTT as a log backend via another overlay, making sure it gets its own _RTT_BUFFER index:
i.e. apply this as another overlay (i.e. 4th overlay) or add to the end of overlay-shell-mgmt.conf
CONFIG_SHELL_BACKENDS=y CONFIG_SHELL_BACKEND_RTT=y CONFIG_SHELL_LOG_BACKEND=n CONFIG_LOG_BACKEND_RTT=y CONFIG_LOG_BACKEND_RTT_BUFFER=1 CONFIG_LOG_BACKEND_UART=n
If we connect via RTT viewer, only shell prompt shows up - i.e. no log output.
If I use the RTT Logger app, using default channel 1, I get to download the logs BUT some extra non-ascii bytes/ message wrapping is included in the logs
This kind of works but is annoying because:
1- extra non printable bytes, and no color formatting
2- two apps need to be open to interact with both RTT shell and download RTT logs (i.e. RTT Viewer and RTT Logger respectively)
Is there a better approach?
Any fixes I can apply to either of these approaches?
All project files attached below
Thanks very much for the support in advance :)