Replying to my own issue:
First I misunderstood module registration:
#include <logging/log.h>
// Must be done outside the function
LOG_MODULE_REGISTER(toto, LOG_LEVEL_DBG);
void main(void)
{
//...
LOG_INF("Hello World ! %s\n", CONFIG_BOARD);
// ...
}
Then, I used west build -t menuconfig
to enable:
[*] Logging--> // This one was not enabled
[*] Enable Serial Wire Output (SWO) backend
(0) Set SWO output frequency
After that I managed to get traces via the JLINK SWO Viewer.
However, it only works if I launch the SWO viewer AFTER my application is launched. If I trigger a reset of the target during a swoview
session, I lost traces. I have to re-launch the swo viewer to get the logs again, meaning that I cannot have traces of a reboot for example and I cannot figure out why because the file log_backend_swo_init
has the procedure described in JLINK User guide (3.8.4 Configure SWO output after device reset)