Unable to program SAM4S Xplained Pro using SWD

Go To Last Post
13 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, I am trying to use an Atmel-ICE programmer to program a SAM4S Xplained Pro board using the SWD interface, but I keep getting a "No device detected. Error 4109". I think I have connected everything up as explained in the datasheets. Below is how I have done this.

 

I have connected the "50-mil 10-pin mini squid cable" of the SAM connector on the Atmel programmer, this is connected to the SAM4S board using the test points on the back of the board, the pins I have connected are as follows,

SAM Squid Cable SAM4S Board
Pin 1 VTG VCC
Pin 2 SWDIO TMS
Pin 4 SWCLK TCK
Pin 6 SWO TDO
Pin 10 NotRST RST

Pin 3, 5, 9 GND

GND

 

I am powering the board using a USB cable plugged into the SAM4S USB port. I have tried the Microchip Studio GUI programmer and the command line programmer and I get the same error for both.

 

This is how the GUI is set up and it finds the programmer and reads the boards voltage as you can see,

 

 

Below is the error message I am seeing,

 

I have read I may need to force the MCU into SW-DP mode (as it starts up in JTAG-DP mode), but I am unsure if this is the cause of the error and if so how I go about doing this. Do I need to write some code to manually do this, or does the programmer automatically do this when I select SWD mode?

 

I have also seen there is a JTAGSEL pin on the board, my understanding is this is active high so if it is low then SWJ-DP should not be selected so I can program using the SW-DP, is this correct, or do I need to pull this high to connect using the SWD?

 

Thanks for any help, and I am happy to give any more information or clarify anything that is not clear.

This topic has a solution.
Last Edited: Mon. Jan 24, 2022 - 02:55 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mashley1 wrote:
SAM4S Xplained Pro board

that already has the on-board debugger connected to SWD - are you sure you've disconnected/disabled that ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think so, there are two USB ports available, one is labeled SAM4S USB and one is labelled DEBUG USB. I am using the SAM4S USB to power the board and I have nothing plugged into the DEBUG USB, so I thought this meant the on-board debugger is not powered or has any signals connected to it.

 

Is this the case or do I need to do something else to disable this on board debugger?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mashley1 wrote:
test points on the back of the board

Connected to the embedded debugger IC rather than the SAM4S maybe?

/Lars

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Lajon wrote:

Connected to the embedded debugger IC rather than the SAM4S maybe?

That is certainly possible but I can't seem to find the schematic for the board I am using to check. Any idea where I can find that information?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

The product page has links to documentation.
https://www.microchip.com/en-us/...
/Lars

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Lajon wrote:

The product page has links to documentation.
https://www.microchip.com/en-us/...

 

Looks like you are indeed right, it looks like the schematic says they are "Programming interface of the embedded debugger". Does this mean I am not able to use them to programme the SAM4S?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mashley1 wrote:
do I need to do something else to disable this on board debugger?

What does the User Manual say ... ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I can't find anything in the User Manual about disabling the onboard debugger, I think it is because this is not a normal operation and not an option. I think the header I am using is only meant for programming the onboard debugger during production, it is not meant for the purpose I thought it was.

 

Let me know if you think I am missing something though?

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Mashley1 wrote:
I can't find anything in the User Manual about disabling the onboard debugger, I think it is because this is not a normal operation and not an option.

Indeed.

 

On boards where this is an intended operation, it is documented in the User Guide.

 

EDIT: and on such boards, there would be a means to disconnect the built-in debugger; eg, jumpers/links/solder-bridges - I don't see any of those. Also, as noted below, there doesn't seem to be  any proper means for a user to connect an external debugger/programmer.

 

Why is it that you want to use an external debugger, rather than the built-in one?

 

 

I think the header (sic?) I am using is only meant for programming the onboard debugger during production

What header? All I can see in the documentation is a group of test points.

 

The schematic seems pretty clear that these are only connected to the EDBG, that they are for programming the EDBG, and not intended for end-users:

 

 it is not meant for the purpose I thought it was

What led you to think it was for the target processor?

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Thu. Jan 20, 2022 - 09:43 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

Why is it that you want to use an external debugger, rather than the built-in one?

 

I am writing code to facilitate the programming of the SAN4S in our custom-developed board, in this application, it will not have an onboard debugger, just the connections to the chip over the SWD. The powers that be have chosen this protocol and an Atmel-ICE to do this.

 

awneil wrote:

What header? All I can see in the documentation is a group of test points.

 

My mistake, I just used the wrong word here.

 

awneil wrote:

The schematic seems pretty clear that these are only connected to the EDBG, that they are for programming the EDBG, and not intended for end-users:

 

Yep, I can see this also now I have managed to find the schematic. I wanted to ask if it was possible though just to make sure I wasn't missing something.

Thank you for clarifying this.

I am going to look to see if I can attach the programmer to any other pins/header/test point on that board that are connected to the SAM4S. I am WFH for a while now as I just tested + for COVID, so I will attempt it when back in the office.

 

awneil wrote:

What led you to think it was for the target processor?

 

I was told that I should be able to connect to it and program through those test points when given this task, so I made the mistake of just assuming without checking myself. I think the thought was that the names of the pins look the same as the SWD header on the SAM4S so it was assumed they connect to that chip, not the onboard debugger.

 

Thanks for everyone's help, it's my first time in this community and it's been nice to get such helpful constructive advice.

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mashley1 wrote:
in our custom-developed board, in this application, it will not have an onboard debugger

Of course.

 

But why are you trying to use the external debugger on the XPlained-Pro board?

 

While you're on the Dev Board, just use the built-in debugger; you only need the external Atmel-ICE once you get to your custom target.

 

I am going to look to see if I can attach the programmer to any other pins/header/test point on that board that are connected to the SAM4S. 

The only connection seems to be the one to the on-board debugger - so you'd have to cut those tracks, and solder-on wires.

 

But, again, why bother? So long as you're on the Dev Board, just use its built-in debugger.

 

I was told that I should be able to connect to it and program through those test points when given this task

OK, I see - so you need to feed back to whoever said that.

 

Thanks for everyone's help, it's my first time in this community and it's been nice to get such helpful constructive advice.

You're welcome.

 

If the question is now resolved, please mark the solution - see Tip #5 in my signature, below:

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Thu. Jan 20, 2022 - 10:57 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

But why are you trying to use the external debugger on the XPlained-Pro board?

 

I am only developing production code to program the SAM4S during the test/programming production stage, not developing firmware. I am sure the people developing the firmware will be using the onboard debugger to upload and test this, but this is not what I am trying to achieve.

 

I am not wanting to test firmware, this is being written and performed by someone else. I am wanting to test that my code for flashing the firmware during production works with the interface to the Microchip we will have on our custom board.

 

I am only using the Xplained Pro board as this is what was handed to me.

 

awneil wrote:

If the question is now resolved, please mark the solution - see Tip #5 in my signature, below:

 

Yep will do this now.