<help> Cannot program bootloader on AtMega328P on Uno R3 board via Atmel Studio

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

Problem: Stuck in debug mode?  Cannot read device signature.  Error "Failed to enter programming mode. ispEnterProgMode: Error status received: Got 0xc0, expected 0x00 (Command has failed to execute on the tool)"

 

Configuration: 

  • New blank ATmega328P purchased from Digikey
  • Elegoo Un R3 Arduino board connected via Olimex AVR-ISP-MK2 
  • Atmel studio 7 7.0.2397 on Windows 10
  • AVR-ISP-MK2 purchased from Digikey - https://www.digikey.com/en/produ...

 

When I bring up the Atmel studio and go to program the boot loader, it cannot read the signature.  I have tried this both with the R3 powered from the AVR-ISP-MK2 and the USB port on the R3 connected to computer.

 

I have watched the video on how to swap between programming mode and debug mode... but the video presume a functional debug mode, which I cannot get into without programming first.

I tried converting the blink example program and "debugging" it, but cannot program the chip to get into debugging mode in order to enable the "clear DebugWire and restart" menu option.

 

Thanks in advance,

Mike

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

legoo Un R3 Arduino board connected via Olimex AVR-ISP-MK2 

How is is connected?  Note that the 6-pin cables that come with that programmer do NOT work with the 6pin connector on the Arduino!

From the Manual:
 

Note that there is no 6-pin ISP connector provided; there is only 10-pin ISP connector available.

 

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

That would explain it.  Okay...See there is references on how to convert 10 pin to 6 pin... I'll try that.  THank you for pointing out my incorrect assumption about the 6pin connector.

 

Mike

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

Well partial success.   I built an adapter out of two 5 pin headers and a 6 pin header extenion/ socket.    I plugged it in... Same error

Went through the trouble of taking pictures of the cable on both ends to confirm the wiring.  I went to confirm the error message was exactly the same... And it worked !

Okay strangeness, but I am not going to argue with success.  Programmed the bootloader, the fuses, and used the IDE to make the LED blink via example program.

 

Disconnected the power, swapped in another blank chip and go to program a bootloader... Back to same error again.

 

 

When I click read device ID... the yellow LED goes out (green power LED stays lit) for a second.  The programmer has two LED's...   One goes out, the other goes red.

 

Then the error.

 

Any suggestions?  

 

I insulated all the connections with heat shrink and am pretty confident the cable does not have an intermittent connection or short... but anything is possible.  Is that where I should be looking next?

 

Mike

 

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

mrc3 wrote:
One goes out, the other goes red.

IIRC, that means the connector is on backwards, turn it around and try again.

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

Olimex suggest buying their adapter.   https://www.olimex.com/Products/AVR/Programmers/AVR-ICSP/

Or making your own.

 

If you make your own,  make sure that you use keyed header sockets.   Or mark pin #1 if you have naked 5x2 and 3x2 male header strip.

 

Most commercial boards follow the Atmel 3x2 convention with pin#1 identified by white dot, arrow, and a square copper pad on the pcb.

 

I strongly advise using keyed male headers and IDC ribbon cables.   Then there is no possibility of error.

Flying wires are not only unreliable but make my head hurt.

It is well worth your time and effort to make a breadboard compatible 3x2 e.g. with some header strip and a scrap of protoboard.

 

David.

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

Thank you all for your responses.   I was just roadblocked on this so while I wait for the commercial adapter to arrive, I built my own.  Double and triple check, but may have made a mistake.  Attached are the photos.  I am pretty sure I got it right.  As it did work ONCE :)

Red = VCC

Black = Ground

Blue = MOSI

Green = MISO

White = SCK

Yellow =  RST

 

 

 

Pins135 of 6Pins 6,4,2 of 6

Last Edited: Fri. Oct 30, 2020 - 02:57 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

Yes,  your wiring looks correct.  You seem to be using a 3x2 shell for the Uno end.   So that will be 100% reliable with properly crimped Dupont connectors.

 

The 5x2 end is indeterminate.   The "wires" are in the right order but it does not look like Dupont crimped males or even soldered male header strip.

Stuffing "wires" into a female IDC socket is suspect.    Especially multi-strand flexible wires.

 

Seriously,   it is worth doing this carefully.

 

If you have an intermittent connection part way through programming,  anything can happen.   e.g. fuses.

 

David.

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

I used 3x2 header socket, 

I used two 1x5 header strips for the 5x2 end.  

 

All wires are soldered and wrapped in head shrink to the headers.

 

I did try to do it carefully with what I had on hand.   the real 10->6 will arrive tomorrow, hopefully better results with it.  

I tend to agree with you... that the "worked once" implies intermittent connection... but I cannot imagine where... everything was tight.

I did also read in another thread about somebody who had to plug the Olimex in several times to get it to work right.   But tried multiple re-plugs and a reboot of computer with no joy.

 

Thanks for double checking my work.

 

Mike

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

Hint.   Write down the list of signals.   Assign the wire colour for each signal.

 

This means you can check your wiring easily.   (and so can your readers)

 

In the days before USB and USBASP punters would use "printer port" adapters.   These were very prone to glitches.     This Forum spent a lot of time commiserating.

Typically,   a glitch would program fuses with 0x00.    Which would require external clock to recover.

 

I suspect that you have had a similar mishap at some stage.     Your current soldered joints should be 100% good.   Apply an external clock to XTAL1 pin.

 

David.

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

Regarding signals and color codes...  see signal to color coding map above the pictures. (full disclosure, edited that in shortly after posting the pictures, but within a few minutes of first post)

 

I have tried it with two fresh unprogrammed chips after the first one succeeded.   And the first one that succeeded failed a few times before succeeding. 

 

If the commercial adapter does not work,   I'll look up how to clock it with an external clock and give that a shot.  Thank you for the suggestion.

 

Mike

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

mrc3 wrote:
head shrink

your wires need therapy?!

 

cheeky wink

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

So it seems :)

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

mrc3 wrote:
And the first one that succeeded failed a few times before succeeding. 

 

That should never happen nowadays.   Your Olimex should be 100% reliable.    If you have a good cable / adapter / connections then every programming job should work first time.

 

Life is simpler now.    Just buy a Uno clone.    Buy a purpose made shield.    Or hand-wire a Protoshield with your external electronics.

 

For "quick and dirty",   put external electronics on a breadboard.   Connect breadboard to Uno with (not many) flying wires.

When the prototype works ok,   solder the external electronics onto a Protoshield.

 

You never need an external programmer.   You seldom need a debugger.

If you do,   just plug the Protoshield onto an XMINI-328

 

David.

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

Yeah, It is strange  I had assumed I wired the 10->6 incorrectly... I just went back yesterday to verify the error message... and the bloody thing worked :)

I went through and uploaded the boot loader and verified that I could write a sketch to it from the IDE... and all was good.  Then I swapped a new chip onto the board and back to no working, and no successes since.

 

PRetty  much the only reason I am going through this is to add the bootloader to blank chips.

 

Mike

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

mrc3 wrote:
PRetty  much the only reason I am going through this is to add the bootloader to blank chips.

I thought that was what the burn bootloader command in the Arduino IDE was all about, no external h/w or s/w needed (other then an uno and Ardunio ide)!???

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

Had same problem until I bought and adapter and used the 10 pin into 6 pin, problem went away.

Attachment(s): 

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

Google ' Gammon bootloader', lots of help there too on how to burn those boot loaders, he has some excellent tutorials and code

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

ki0bk wrote:

mrc3 wrote:
PRetty  much the only reason I am going through this is to add the bootloader to blank chips.

I thought that was what the burn bootloader command in the Arduino IDE was all about, no external h/w or s/w needed (other then an uno and Ardunio ide)!???

 

Jim

 

One would think, but I think that requires additional hardware.   the IDE cannot talk over USB to a blank chip.

 

Mike

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

Thanks for the link... I'll see if the adapter which is due to arrive tomorrow will resolve the issue... then I'll dive in deeper if it does not.

 

Mike

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

It is a mystery why anyone would buy bare DIP-28 chips.

You can buy a ready made Nano or Uno clone that come with TQFP-32 chips for about the same price.

 

However,  you can replace the DIP-28 on your Uno with the new DIP-28.   "Burn Bootloader" and the new chip will perform on the Uno.

 

The original DIP-28 can be put on a breadboard or another pcb.    Note that this must contain a 16MHz XTAL.   And needs a Serial-USB chip or dongle before you can "use" the bootloader.

 

David.

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

david.prentice wrote:

It is a mystery why anyone would buy bare DIP-28 chips.

You can buy a ready made Nano or Uno clone that come with TQFP-32 chips for about the same price.

 

However,  you can replace the DIP-28 on your Uno with the new DIP-28.   "Burn Bootloader" and the new chip will perform on the Uno.

 

The original DIP-28 can be put on a breadboard or another pcb.    Note that this must contain a 16MHz XTAL.   And needs a Serial-USB chip or dongle before you can "use" the bootloader.

 

David.

 

Well sometimes in my ignorance, I choose the less easy way to do things.   The chips were less that $2 each at digikey, and the preprogrammed souce I knew of was about $6 (adafruit).  I thought I had burned the I2C interface on the chip by miswiring it... but it appears the burn was on the Uno R3 board as I can move a good chip to the board, and the I2C hangs same as the original chip.

 

Now that I have all the stuff, I am stubborn enough that I want to get it working :)

 

Mike

 

 

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


mrc3 wrote:
, but I think that requires additional hardware.

Only another Arduino and few jumper wires.  There are other configurations, ie. nano to uno, or pro-micro to uno, etc.

You load the programmer sketch into the Arduino to make it a programmer, then tools/burn bootloader for the target device.

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

I think that requires additional hardware.

Only another Arduino and few jumper wires. 

 

you probably also need to disable the auto-reset on the "programmer" arduino.

 

 

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

Well, using a second arduino uno R3 and gammon bootloader sketch... I was able to get the chips programmed... I'll probably program one over again using the ISP port once I get the official adapter.

 

I did not do anything in particular to disable the auto-reset... perhaps the sketch works around that?

 

Mike

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

You don't need to disable auto-reset.   The "programming" is enabled by the RESET line on the target which is controlled by the ArduinoISP sketch on the ArduinoISP Arduino.

 

The COM port is set for the ArduinoISP Arduino.

 

Since you possess the Olimex,  life is much simpler when you use the Olimex as external programmer instead of ArduinoISP sketch running on another Arduino.

 

David.

Last Edited: Sat. Oct 31, 2020 - 12:21 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gammon bootloader sketch.

If you use a specific "bootloader sketch" like gammon's or optiLoader, you won't have reset issues; it only comes into play when you're using the "Arduino as ISP" sketch and trying to talk to the programmer with AVRDude.

 

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

Closing out the thread, with the commercial built 10->6 converter, the Olimex to Arduino connection seems reliable.  Something was wrong or noisy about the one I created.  I only connected one of the ground pins on the 10 pin plug, but that was supposed to be okay as they were all tied together in the Olimex.

 

Thanks for all the help.

 

Mike