Sunday, November 19th 2017, 8:47pm UTC+1

You are not logged in.

  • Login
  • Register

donturner

Beginner

Date of registration: Jul 15th 2016

Posts: 9

1

Tuesday, October 10th 2017, 9:16am

[SOLVED] Using SWO with Ozone

I have a J-Link EDU connected to an NXP MK20DX256XXX7 Cortex M4 MCU using SWO. If I run JLinkSWOViewer from the command line I am able to see the SWO output from my MCU, however, I would like to see this within Ozone, which I use for the rest of my debugging. Is this possible?

If so, is it possible to do instruction tracing, code profiling and all that other good stuff from Ozone using SWO?

SEGGER - Nino

Super Moderator

Date of registration: Jan 2nd 2017

Posts: 319

2

Tuesday, October 10th 2017, 9:43am

Hello Don,

Thank you for your inquiry.

Quoted

If I run JLinkSWOViewer from the command line I am able to see the SWO output from my MCU, however, I would like to see this within Ozone, which I use for the rest of my debugging. Is this possible?


You can activate SWO in Ozone by enabling it through Edit->Trace Settings...->Trace Source: SWO and leave Clocks on Auto.
That way you will be able to do printf SWO debugging.

Quoted

If so, is it possible to do instruction tracing, code profiling and all that other good stuff from Ozone using SWO?

Currently only basic printf SWO debugging is supported by Ozone. More advanced features are on the ToDo list.

But we have our very own IDE Embedded Studio that does support advanced SWO tracing functions. Would that be an option for you?
You can use it for free for evaluation purposes and see if it fits your needs. https://www.segger.com/products/developm…mbedded-studio/
A guide on how to enable SWO Tracing in Embedded Studio can be found here: https://wiki.segger.com/How_to_configure…udio_to_use_SWO

Best regards,
Nino

donturner

Beginner

Date of registration: Jul 15th 2016

Posts: 9

3

Tuesday, October 10th 2017, 9:57am

I tried the trace settings as per your instructions but no output appears in the terminal window, see attached. All I get is "TARGET RESET".
donturner has attached the following images:
  • Screen Shot 2017-10-10 at 08.56.15.png
  • Screen Shot 2017-10-10 at 08.55.31.png

SEGGER - Nino

Super Moderator

Date of registration: Jan 2nd 2017

Posts: 319

4

Tuesday, October 10th 2017, 11:30am

Hello Don,

With what function are you outputting the SWO messages?
Is it something CLion specific?

For reference i created an example project for you that runs out-of-the-box on any MK20DX256XXX7 target board.
Could you give it a try and see if you can see any output in the terminal with the example project?
It will be available for download for at least 24 h here.

I also included the Embedded Studio Project and Sources so you can give SWO Instruction trace and Code Profiling a try.

Best regards,
Nino

donturner

Beginner

Date of registration: Jul 15th 2016

Posts: 9

5

Tuesday, October 10th 2017, 1:30pm

Thanks very much for putting that together. I ran the elf file and saw the output "SWO-TEST" in the terminal window. It must be a problem with my code.

It's not immediately obvious to me why JLinkSWOViewer displays my output and Ozone doesn't but since I have your source to diff against I can investigate further.

I tried embedded studio with the supplied project, however, when I go to Debug->Go I get an error stating "Cannot determine SWO speed" (see attached)
donturner has attached the following image:
  • Screen Shot 2017-10-10 at 12.28.07.png

SEGGER - Nino

Super Moderator

Date of registration: Jan 2nd 2017

Posts: 319

6

Tuesday, October 10th 2017, 1:43pm

Hello Don,

Quoted

It's not immediately obvious to me why JLinkSWOViewer displays my output and Ozone doesn't but since I have your source to diff against I can investigate further.


When does the SWOViewer Output data? When debugging from Ozone or when debugging from CLion?

Quoted

I tried embedded studio with the supplied project, however, when I go to Debug->Go I get an error stating "Cannot determine SWO speed" (see attached)


This sounds strange. What J-Link are you using for the connection to the target and what Serial Number does your J-Link have?
It looks like the SWO Speed I set in the project is to high for the J-Link you are using.
You can edit that speed in the project options under: Target Trace-> SWO Baud Rate

Currently 2 MHz are set. How to find out which speeds are supported by your J-Link please follow the instructions in this Wiki article: https://wiki.segger.com/How_to_configure…udio_to_use_SWO
In section: Calculating the SWO speed

Best regards,
Nino

donturner

Beginner

Date of registration: Jul 15th 2016

Posts: 9

7

Tuesday, October 10th 2017, 2:05pm

Quoted

When does the SWOViewer Output data? When debugging from Ozone or when debugging from CLion?


Neither, SWODataViewer only works when I run it from the command line and the MCU is not being debugged by any other software.

Here's the output:

Source code

1
2
3
4
5
6
Please enter the target CPU frequency (in Hz) or press to select a device for automatic CPU frequency detection.
CPUFreq > 
Device > MK20DX256XXX7
Target CPU (MK20DX256XXX7) is running @ 21027 kHz.
Receiving SWO data @ 21493 kHz.
Showing data from stimulus port(s): 0


Quoted

What J-Link are you using for the connection to the target and what Serial Number does your J-Link have?


JLink EDU with s/n 260101749

Quoted

It looks like the SWO Speed I set in the project is to high for the J-Link you are using.
You can edit that speed in the project options under: Target Trace-> SWO Baud Rate


I set both the Trace Clock Speed and SWO Baud Rate to 21493000 Hz, then I could see the output in the Debug Terminal. Seems slightly odd that SWODataViewer can detect the CPU speed but Embedded Studio cannot but hey, it works!

This post has been edited 2 times, last edit by "donturner" (Oct 10th 2017, 2:07pm)


SEGGER - Nino

Super Moderator

Date of registration: Jan 2nd 2017

Posts: 319

8

Tuesday, October 10th 2017, 2:28pm

Hello Don,

Quoted

JLink EDU with s/n 260101749


Ok with the EDU you should see no problems running SWO trace for most targets as it supports up to 30 MHz SWO speed.

Quoted


I set both the Trace Clock Speed and SWO Baud Rate to 21493000 Hz, then I could see the output in the Debug Terminal. Seems slightly odd that SWODataViewer can detect the CPU speed but Embedded Studio cannot but hey, it works!

First, good to hear that you are up and running again. It is still weird thought that 2 MHz would not work correctly. Did you use the latest J-Link Software and Firmware?
I just tested with a J-Link Plus(same hardware as the EDU) and had no problems whatsoever running with 2 MHz SWO baud rate.
For reference i was using J-Link Software version V6.20e.

Best regards,
Nino