Open Benjoyo opened 3 years ago
It could be possible that the IDE is writing to the registers necessary to configure SWO on your behalf. The example above doesn't do that on your behalf. An example of a firmware image that does do that is here: https://github.com/square/pylink/blob/master/tests/functional/firmware/k21-swo/src/swo.c#L75
While I haven't tried it myself, I think you should be able to write to those registers on the host-side, which would enable SWO then allow you to start collecting.
@hkpeprah Thank you for your reply. I tried the linked code to enable SWO, but it didn't change anything. It seems like the configuration doesn't have any effect, e.g. if I look at ITM_LAR before and after setting it, it is always zero. I also tried CMSIS, same thing. Is there anything else one needs to do first? I am using an nrf52840 DK, which also has a Cortex M4.
Could this be of use? Namely the bit about the preprocessor defines in system_nrf52.c
to enable SWO and trace. It might require re-compiling your application with the defines set. Alternatively, converting those statements to register / memory read/writes.
https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/debugging-nrf52-series-devices-using-trace
@Benjoyo were you able to solve this?
I am also struggling to get SWO working. It works if I run the JLinkSWOViewer tool before the example, otherwise it does not work. I wonder what the tool might be doing additionally.
After some trial and error, I found the missing step. My firmware was configuring everything but the SWO clock speed, which is done using the TPIU_ACPR register. It works when I set the correct prescaler value using the memory_write32
command. This is probably done automatically by the J-Link SWO tool.
I am trying out the Serial Wire Viewer example: serial-wire-viewer
While it does work, it only seems to work when I put the device in debug mode from the SES IDE. Why is that? Can I do the same thing via pylink, so that the tool runs on its own?
Thanks