[SOLVED] Using jLinkSWOViewerCL with a pre-configured target

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] Using jLinkSWOViewerCL with a pre-configured target

    Hi there. I am using an NRF52832 target and have configuration code in my target image which sets up the SWO port to run at 4 MHz (CPU @ 64 MHz). I would like to use my Segger J-Link Base and the jLinkSWOViewerCL command-line application (JLink_V632a) to view the SWO output from the board: I do not want jLinkSWOViewerCL to configure my target hardware at all, I just want it to view the SWO output from the target HW as I have already configured it.

    I have tried various combinations of command line options but I cannot make jLinkSWOViewerCL simply read the output: it always wants to configure the target and figure out an SWO frequency for itself and I can't make it stop doing that.

    Is there a way?

    In case it is of interest, this is the target code that configures the SWO output (it is an mbed-os environment):

    Source Code

    1. /* SWO frequency: 4000 kHz */
    2. void itm_init(void)
    3. {
    4. /* Enable SWO trace functionality */
    5. CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
    6. NRF_CLOCK->TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Serial << CLOCK_TRACECONFIG_TRACEMUX_Pos;
    7. /* set SWO clock speed to 4 MHz */
    8. NRF_CLOCK->TRACECONFIG = (NRF_CLOCK->TRACECONFIG & ~CLOCK_TRACECONFIG_TRACEPORTSPEED_Msk) |
    9. (CLOCK_TRACECONFIG_TRACEPORTSPEED_4MHz << CLOCK_TRACECONFIG_TRACEPORTSPEED_Pos);
    10. /* set SWO pin */
    11. NRF_P0->PIN_CNF[18] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) |
    12. (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) |
    13. (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos);
    14. /* set prescaler */
    15. TPI->ACPR = 0;
    16. }
    Display All
  • FYI, this is the closest I have got. With the command-line below my prints of "Hello World.\n" every second come out as "H" (i.e. the initial letter) followed by nothing else every second, so I don't think jLinkSWOViewerCL has listened to my -cpufreq (and it also says 0 kHz in the command output).

    jLinkSWOViewerCL -cpufreq 64000000 -swofreq 4000000 -device NRF52832_XXAA

    ************************************************************
    * SEGGER Microcontroller GmbH *
    * Solutions for real time microcontroller applications *
    ************************************************************
    * *
    * (c) 2012 - 2017 SEGGER Microcontroller GmbH *
    * *
    * segger.com Support: support@segger.com *
    * *
    ************************************************************
    * *
    * SEGGER J-Link SWO Viewer Compiled Apr 30 2018 15:46:03 *
    * *
    ************************************************************

    ------------------------------------------------------------
    Usage:
    In the configuration dialog enter the target CPU frequency
    or the target device name.
    SWO Viewer can show data from stimulus ports 1 to 16.
    0 - 9 and a - f keys toggle display of stimulus port data.
    Ctrl-C and any other key closes SWO Viewer
    ------------------------------------------------------------


    Target CPU (NRF52832_XXAA) is running @ 64712 kHz.
    Receiving SWO data @ 0 kHz.
    Showing data from stimulus port(s): 0
    -----------------------------------------------
    HHHH
    HHrHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH

    The post was edited 1 time, last by RobMeades ().

  • Hello,

    Thank you for your inquiry.
    SWO on the nRF52 series is unfortunately not generic and needs special handling which J-Link does automatically: wiki.segger.com/NRF52_Series_Devices
    So you need to do no SWO init from your application whatsoever. Everything is handled by J-Link.

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Unfortunately I'm using software which always configures the ITM; Nordic's NRF52832 target in mbed-os does this at boot. I will try hacking it out and see if that helps but it's not ideal as I then can't use the master mbed-os code directly: surely I should be able to tell J-Link what I've configured as the SWO clock frequency and it will just do it? That's certainly what the -swofreq command-line option looks as though it should be for.
  • Hello,

    just retested the latest JLinkSWOViewerCL V6.32g with the example project from Wiki. Result is attached.
    As you can see if I call the Viewer with -cpufreq 64000000 -swofreq 4000000 -device nRF52832_xxAA (the xx in the device name is small letters, maybe this was the error) I get SWO output with exactly 4 MHz. Same happens if I select other frequencies. I conducted the measurements with the SEGGER measurement adapter: segger.com/products/debug-prob…easurement-patch-adapter/
    Which J-Link software version are you using?
    Could you update to the latest one and see if the issue resolves?
    How does you SWO signal look like, is it the frequency you expect?
    Does the example project from Wiki work on your hardware as well?
    Are you using custom hardware or an eval board?

    Best regards,
    Nino
    Images
    • SWOViewer_CL.png

      16.6 kB, 677×462, viewed 571 times
    • Scope_4MHz.png

      37.52 kB, 1,024×829, viewed 563 times
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • I've now removed the TRACECONFIG, PIN_CNF (for pin 18) and TPI->ACPR lines, so the entire ITM init, from the code but the result remains the same as above (just the initial letter of my printf() appears); I suppose this is to be expected as starting jLinkSWOViewerCL with the command-line:

    jLinkSWOViewerCL -device NRF52832_XXAA

    ...will likely overwrite the boot settings anyway.

    Interestingly, if I leave the ITM initialisation in my code and then use GDB to download the code and view the SWO output (through my JLink Base) then it is able to view the SWO output, though it adds three white-spaces after each character:

    H e l l o w o r l d .

    [Can't make this forum leave my formatting alone: there are THREE white-spaces between each character above, not one]

    I expect this is because the ITM register outputs 4-byte words and, of course, I'm only writing characters. Could it be that jLinkSWOViewerCL is seeing the other three NULL bytes and interpreting them as an end of string?

    The post was edited 1 time, last by RobMeades ().

  • Sorry, posted at the same time. Many thanks for checking this. I am using V632a and the target is a commercial u-blox NINA-B1 module on its evaluation board. I think there's something in the above: how does jLinkSWOViewerCL interpret the four bytes coming out of the SWO output?
  • Yes, that's definitely it, you're off the hook: writing four characters into the 4 bytes of the ITM register at a time does the trick. I've raised this with mbed-os to get their implementation changed to be friendly to this sort of client. Many thanks!
  • Hello,

    Great to hear that you are up and running again.
    We will consider this thread as solved now.

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.