SAM4S Xplained SWO Interface

Discussion around product based on ARM Cortex M4 core.

Moderators: nferre, ncollot

Owais
Posts: 57
Joined: Wed Jul 23, 2014 3:25 pm

SAM4S Xplained SWO Interface

Thu Aug 14, 2014 3:59 pm

Hello everyone,

Recently I am working on the SWO interface of SAM4S Xplained board (Not Xplained Pro). I am running FreeRTOS on this board and trying to work with the integrated Trace tool available in Atmel Studio 6.2. However, I am unable to start the trace recorder after clock initialization because an error message pops up indicating that the connected emulator does not support SWO. I have double checked it on the web documents available for SAM4S Xplained at this link 

http://www.atmel.com/webdoc/sam4s16xpla ... jg_xf.html

It clearly indicates that the J-Link OB supports JTAG/SWD + SWO interface. Does anyone here have any experience with this. If so please let me know.

Regards,
Owais.
BillBoyd
Posts: 17
Joined: Fri Aug 15, 2014 10:24 pm

Re: SAM4S Xplained SWO Interface

Sat Aug 16, 2014 5:54 pm

Hello
I have plenty of SWV and ETM trace experience but with Keil - I think I can give you some information.

1) Serial Wire Viewer (SWV) is a data trace and comes out the Serial Wire Output (SWO) pin on the standard JTAG connector shared with TDO signal.

2) This means you must use Serial Wire Debug (SWD or SW) and not JTAG or a conflict arises. SWD is a two pin alternative to JTAG. You select SWD or JTAG in the debugger. A debugger should warn you when you try to use JTAG with SWV.

3) J-Link uses SWO in UART mode - so this means you must tell the debugger the frequency. This is usually the CPU clock and must be accurate.

4) You can scope the SWO pin and if you see signal there (while in SWD or SW mode) - measure the shortest period and invert it - this and multiplying by the prescaler rate set in the debugger will give the true CPU speed. I use 96 MHz on SAM4 devices.

5) The J-Link OB might also be known as J-Link Lite: it supports SWV. It might not have quite as fast SWO speed as a J-Link, J-Link Ultra, SAM-ICE, or Keil ULINK but works quite well.

6) Don't confuse the J-Link OB or Lite with the CMSIS-DAP debug adapter as found on other Atmel boards such as the SAMD20.

7) Cortex-M0/M0+ parts do not have SWV. They usually only have SWD - no JTAG. This is not a problem - most tools handle this.

8) An external J-Link or SAM-ICE version 6 or later supports SWV too as does a Keil ULINK2 or ULINKpro. It works quite well.

9) If you need really fast SWV - instead of sending the data out the 1 bit SWO port, you can send it out the 4 bit ETM trace port. You need a special debugger like Keil ULINKpro.

10) SWV is really cool - check this out - www.keil.com/appnotes/docs/apnt_228.asp if you can't get this working with your debugger. It uses Keil MDK - you can download it free...get MDK 5 and add the Legacy Support package. BTW - a year license for MDK for Atmel processors is only $745 and this includes tech support.

11) This appnote shows the cool things you can do with SWV and I think you should be able to get them working on your system.

I hope this helps !

Bob Boys
ARM/Keil
Owais
Posts: 57
Joined: Wed Jul 23, 2014 3:25 pm

Re: SAM4S Xplained SWO Interface

Mon Aug 18, 2014 9:39 am

Hello and thanks BillBoyd for the detailed response, I am certainly using the SWD interface while programming SAM4S Xplained. I have no idea why it keeps giving me the message that the emulator does not support SWO and no speed could be enumerated for SWO. Regarding the J-Link version I have checked on Segger website for the latest version and what I found was v4.90b there is no v6, I am also having the same problem when I use SAM-ICE with SAM4S-EK. Either I am missing something or it is not possible to use Trace with these debuggers.

Regards,
Owais.
BillBoyd
Posts: 17
Joined: Fri Aug 15, 2014 10:24 pm

Re: SAM4S Xplained SWO Interface

Mon Aug 18, 2014 5:05 pm

Hello

I meant the hardware Version 6 or later: this number is on the label on a J-Link or SAM-ICE. On your board with onboard J-Link - maybe you have to run the Segger diagnostic software.

You are referring to the software firmware version.

The J-Link does indeed work with SWV. See www.keil.com/appnotes/docs/apnt_228.asp page 20 for proof. The Keil engineers work very close with Segger to make sure this works.

Perhaps there is something wrong with your Studio 6 ?
A wrong clock setting can't be your problem as it sounds like you never get that far ? A wrong clock setting is the number 1 reason people can't get SWV working. A wrong clock setting results in either no trace frames or really weird ones that don't exist.

The only thing I can suggest is to download the eval version of Keil MDK and see if it works or contact Studio tech support. IAR ought to work also with J-Link - but I have no experience with that either for a long time.

If it doesn't work with Keil, I will get a board like yours and find out why.

Bob
California
Owais
Posts: 57
Joined: Wed Jul 23, 2014 3:25 pm

Re: SAM4S Xplained SWO Interface

Tue Aug 19, 2014 12:07 pm

Hello, Thanks again BillBoyd. I checked the version on SAM-ICE and it is unfortunately not v6 so I guess it is not possible to run Trace via SAM-ICE. However, I am still confused about SAM4S Xplained board which uses J-Link OB, according to my understanding it should be able to support Trace since it has SWO interface but it doesn't. I have checked the settings in Atmel Studio and the clock setting for SWD interface is set at 4MHz where it suggests that the maximum should not exceed target CPU speed * 10. I have also set the target frequency in Trace settings to 120MHz. But the problem is that it doesn't even start SWO and says that the interface is not supported and SWO speed could not be enumerated.

If you could take a look into this and let me know whether I am missing something or is it simply not possible. It would be very helpful.

Regards,
Owais.
BillBoyd
Posts: 17
Joined: Fri Aug 15, 2014 10:24 pm

Re: SAM4S Xplained SWO Interface

Tue Aug 19, 2014 9:49 pm

Hello

I will try and get a board and try it.

Can you try Keil MDK and see if it works as in my lab ?
It is free.

Thanks

Bob
Owais
Posts: 57
Joined: Wed Jul 23, 2014 3:25 pm

Re: SAM4S Xplained SWO Interface

Wed Aug 20, 2014 8:42 am

Hello, Thanks BillBoyd. I have downloaded Keil MDK v5, unfortunately I have no experience working with Keil IDE. I have no idea how to port FreeRTOS via Keil. Not even how to initialize the clock on SAM4S16C. Can you give me some pointers in this regard that would be very helpful. Thanks.

Regards,
Owais.
BillBoyd
Posts: 17
Joined: Fri Aug 15, 2014 10:24 pm

Re: SAM4S Xplained SWO Interface

Wed Aug 20, 2014 9:06 pm

Hello

I have requested a board like you have but it is not here yet. So - in the meantime:

1) I suggest you also go to http://www2.keil.com/mdk5/legacy and download the Legacy Support for Cortex-M devices and install this. This will make it easier to follow the lab: the lab is for the SAM4S-EK board but I am hoping it is close enough.

2) Get the lab at www.keil.com/appnotes/docs/apnt_228.asp

3) Look on page Blinky example program on page 8. We just want to see if we can get SWV working.

4) At Step 5 - you must configure the J-Link on your board - see page 4. Follow these instructions - the important item is to see the right information in the box SW Device and get the Flash selected.

5) You will not be able to get the screen working (might have to conmment out references to the LCD) and maybe even the LEDS will not work - but hopefully the program will run and you can stop and start and even set a breakpoint.

See if you can get this far.

Bob
Owais
Posts: 57
Joined: Wed Jul 23, 2014 3:25 pm

Re: SAM4S Xplained SWO Interface

Thu Aug 21, 2014 9:50 am

Hello and thank you once again BillBoyd for your support. I will go through the procedure you have mentioned.

Regards,
Owais.
Owais
Posts: 57
Joined: Wed Jul 23, 2014 3:25 pm

Re: SAM4S Xplained SWO Interface

Thu Aug 21, 2014 1:03 pm

Hello again BillBoyd,

I have followed the steps as you mentioned earlier. Unfortunately I am unable to build the project Blinky and getting a lot of errors. What I am doing is after installation of IDE and legacy support for Cortex-M, I open the IDE and there is already one project open for STM3201, so i close this project and make a new project choose a device SAM4S16C and in source group add a project Blinky. I then set the debugger to Jlink and check the SW option and it can detect my board and shows that J-Link OB is connected. But when i try to compile the Blinky example it suddenly shows all these errors 

.\Blinky.axf: Error: L6218E: Undefined symbol SystemInit (referred from startup_sam4s.o).
.\Blinky.axf: Error: L6218E: Undefined symbol ADC_Init (referred from blinky.o).
.\Blinky.axf: Error: L6218E: Undefined symbol AD_done (referred from blinky.o).
.\Blinky.axf: Error: L6218E: Undefined symbol AD_last (referred from blinky.o).
.\Blinky.axf: Error: L6218E: Undefined symbol LED_Init (referred from blinky.o).
.\Blinky.axf: Error: L6218E: Undefined symbol SER_Init (referred from blinky.o).
.\Blinky.axf: Error: L6218E: Undefined symbol SystemCoreClock (referred from blinky.o).
.\Blinky.axf: Error: L6218E: Undefined symbol SystemCoreClockUpdate (referred from blinky.o).
.\Blinky.axf: Error: L6218E: Undefined symbol clock_1s (referred from blinky.o)

I know there is something very basic that I am missing at this point, can you point me in the right direction. Thanks in advance.

Regards,
Owais.
bptech
Posts: 25
Joined: Fri Jul 18, 2014 3:08 pm

Re: SAM4S Xplained SWO Interface

Thu Aug 21, 2014 5:39 pm

I had a similar problem with the SAM4L-EK and finally came to the conclusion that the PA23 SWO pin is simply not implemented on that board.

The SAM4L-XPLAINED board does have PA23 connected but I was never able to get any events to show in the Percepio Trace window, maybe you have to register your tasks and queues etc. to generate these trace events. At least it did not throw an exception, it just gave me a blank window with no events. configUSE_TRACE_FACILITY is 1.

I have moved on to my own custom hardware now, but I do have PA23 connected to the ATMEL-ICE so it would be nice to know how to use it.
BillBoyd
Posts: 17
Joined: Fri Aug 15, 2014 10:24 pm

Re: SAM4S Xplained SWO Interface

Thu Aug 21, 2014 8:49 pm

Hello bptech:

I looked at the SAM4L-EK schematics and it looks like you are correct - PA23 which is also the JTAG signal TDO and SWO - is used for the LCD. So, SWV will never work. Also - clearly Segger J-Link OB is communicating with the SAM4 via 2 wire SWD and not JTAG and this is OK.

The Atmel-ICE is a CMSIS-DAP compliant device. This means it does not <yet> support SWV.

To use SWV - you need a SAM-ICE V6 or later or J-Link V6 or later or any Keil ULINK2/pro (only with Keil MDK).

My pre-mentioned lab shows what SWV can do and how to get it working...surely these instructions can be transferred to other tools.

The SWV is a hardware module in the ARM Cortex - all a debugger has to do is correctly configure certain registers and the SWV frames come out the SWO pin to be collected. SWV is quite easy to get running.

Bob
BillBoyd
Posts: 17
Joined: Fri Aug 15, 2014 10:24 pm

Re: SAM4S Xplained SWO Interface

Thu Aug 21, 2014 9:04 pm

Hello Owais

I was hoping you would use an existing Blinky - your errors indicate there are some missing files in the project you created. The Keil Blinky examples are carefully designed to compile "out of the box". This eliminates many startup problems.

Try the SAM4S-EK example found here: C:\Keil\ARM\Boards\Atmel\SAM4S-XPRO\Blinky
It is for the SAM4SL-Xplained Pro but maybe it will work.
It will compile for you with no errors or warnings.

Use my instructions in the lab to program the Flash and so on as i described before. If you can get this to run on your board -

1) try configuring the SWV as indicated on steps 1 to 5 on Page 12. Except Select Periodic instead. It looks like the Core Clock: should be 96 MHz.
2) Run the program and open the Trace Record window (Step 1 page 17)
3) This window should show PC Samples a shown on first graphic on page 19.
4) If you see nothing in the trace records window - or ITM values of anything other than 0 or 31 - this usually means the Core Clock is wrong.

I do not have this board yet to test myself. Sorry...

I looked - and it seems the SWO pin is connected to the J-Link OB processor.

Bob
BillBoyd
Posts: 17
Joined: Fri Aug 15, 2014 10:24 pm

Re: SAM4S Xplained SWO Interface

Fri Aug 22, 2014 7:45 pm

Hello

I have some additional information.

Keil engineering in Germany have a a SAM4S-XPLD RevB board.
It has “J-Link Technology http://www.segger.com” printed on it - but the on-board debugger Cortex-M3 processor has been programmed for CMSIS-DAP operation and not J-Link. They do not know who did this.
If this is the case generally, then SWV will not work because of the CMSIS-DAP adapter. Atmel's Atmel Embedded Debugger (EDBG) is/can be CMSIS-DAP compatible. Select CMSIS-DAP in your debugger to use EDBG.

It is easy using Keil uVision to see what protocol you are using. Perhaps Studio 6 has something similar.

1) Connect your board to your PC with a USB cable.
2) Start uVision.
3) Select any Cortex-M3 project - you do not need any code compiled or a program in the Flash.
4) Select Project/Options for Target xyz or Alt-F.
5) Select the Debug tab.
6) Select CMSIS-DAP or J-Link as shown in Jlinkselect.jpg.
7) Click on Settings icon to see if it is working.
8) Look at jlink.jpg attached file.
9) A valid SN means uVision is talking to the JLink.
10) If SW Device contains something useful as shown, the J-Link is talking to the Cortex-M CPU.
11) If you chose CMSIS-DAP in Step 6, CMSIS-DAP will be displayed but the window will be a bit different.
12) If it doesn't work, click OK to close the window and enter the other debug adapter and try again.

To recap - if you see a valid J-Link - you should be able to get SWV working. If you see valid CMSIS-DAP - SWV is not implemented <yet>.

Thanks for staying with me.

Bob
California
Attachments
jlinkselect.jpg
jlinkselect.jpg (35.4 KiB) Viewed 5042 times
jlink.jpg
jlink.jpg (99.56 KiB) Viewed 5042 times

Return to “SAM4 Cortex-M4 MCU”

Who is online

Users browsing this forum: No registered users and 1 guest