Pages: [1] 2 3   Go Down
Author Topic: Burning a Atmega 328 Bootloader with an Arduino Leonardo  (Read 15135 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys,
I am at the point where I can't figure out how to get it running smiley-cry
I bought myself an Arduino Leonardo and tried to burn a Atmega 328 on a breadboard-installation. I followed the instruction from http://arduino.cc/en/Tutorial/ArduinoToBreadboard but everytime I try to install the bootloader the commandline gives me a

Code:
avrdude: stk500_getsync(): not in sync: resp=0x00

I already measured all input voltages, changed the 16Mhz Oscillator, changed both 18pF C's to 22pF one's and rechecked all pin-connections.

What am I doing wrong? Thank you so much for your help!

Regards,
Stevil
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 203
Posts: 8722
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Perhaps you need to disable auto-reset on the Leonardo. See: http://arduino.cc/en/Tutorial/ArduinoISP

"Note for Arduino 1.0: you need to make one small change to the ArduinoISP code. Find the line in the heartbeat() function that says "delay(40);" and change it to "delay(20);".

"An Arduino board serving as an ISP to program the ATmega on another Arduino board. On the Arduino Uno, you'll need to connect a 10 uF capacitor between reset and ground (after uploading the ArduinoISP sketch). Note that you need access to the reset pin on the target board, which isn't available on NG or older boards.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi John,

thanks for your answer. You mean a 10µF between RST and GND on the Leonardo or on the breadboard?
Anyway I tried both ways - no solution. Same error smiley-sad
Logged

Canada
Offline Offline
Jr. Member
**
Karma: 1
Posts: 81
Frequently Befuddled
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It looks like that is using SPI on both the source Arduino and the target Arduino / 328 chip.

If you're using pins 10, 11, 12 and 13 on the Leonardo, you are using the wrong pins. On the Leonardo, SPI only exists on its own ICSP port, not on any of the normal Arduino headers. A further possible problem is that the internal SPI function of pin '10' on the Uno (SPI SS) is not connected to anything on the Leonardo. (Well it's the RX Led but it's not anything you can use directly.)

Edited to add: Mapping the SPI pins from the regular headers to the ICSP, Uno pin 13 (SCK) is on pin 3 of the ICSP header, Uno pin 12 (MISO) is pin 1 of the header, and Uno pin 11 (MOSI) is pin 4 of the icsp header. For pin 10, you can probably leave that one where it is on the Leonardo, it's the other three that are more critical.
« Last Edit: June 01, 2012, 08:49:49 pm by Steph » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Steph,

that are great thoughts and I already thought that that was the solution for my problem. I connected the MOSI, MISO and SCLK to the ICSP-header - but with no success smiley-cry Same error message

Could it be the missing /SS-Pin? I'm afraid of cutting the signal-line to try it.
Any other solution in mind?
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 203
Posts: 8722
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Serial Programming doesn't use the Slave Select signal.  It uses the Reset pin.  The ArduinoISP sketch uses Pin 10 to control the Reset pin of the target.

The ICSP header on any Arduino (including the Leonardo) will be connected to MOSI, MISO, SCK, Vcc, Ground, and Reset.  You want to hook MOSI, MISO, SCK, Vcc, and Ground to the same pins on the target device.  Then connect Pin 10 on the Arduino running ArduinoISP to the Reset pin on the target device.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Canada
Offline Offline
Jr. Member
**
Karma: 1
Posts: 81
Frequently Befuddled
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Looking at the ArduinoISP sketch I think I see how you can make it go - the first #define statement is "#define RESET SS" if you change that to "#define RESET 10" then use your Leonardo's pin 10 as the /SS pin that might just do it. Leave the other SPI pins connected to the ICSP on the leonardo, and everything ought to be ok.

Good luck!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi John, hi Steph,

tried everything - just won't work. Seems like I'll have to get a Arduino Uno for that kind of stuff smiley-cry Seems like no one has ever tried to flash a Atmega328 with an Arduino Leonardo smiley-sad - I spent hours on google and tried to get some information.

Maybe tomorrow at work I'll check the SPI signals with a Scope.

Thanks for your help anyway dudes
Logged

Offline Offline
Full Member
***
Karma: 9
Posts: 109
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The problem is similar to the auto-reset issues when running ArduinoISP on uno, duemilenove...
Whenever avrdude opens the serial port it toggles DTR (and RTS) signals. On these 'classic' arduino's, DTR pulls low the RESET of the programming arduino, causing it to reset. Avrdude then starts communicating with the arduino which may not yet have booted and you get these 'not in sync' errors.

The difference on the leonardo is that when avrdude toggles DTR, this just boils down to an usb control message being sent to the leonardo's usb driver.
I will try to find out what the driver does in response to this message. Anyway the behavior is very similar to what I observe (on my Sanguino) when I install the auto-reset enable jumper: the ide burns a bootloader by calling avrdude twice. The first command succeeds, but the second one fails with a 'not in sync' error.

In meantime I tested two alternative ways to burn a bootloader using a leonardo:

1. Use Nick Gammon's "Atmega_Board_Programmer" sketch. It works out of the box if your target is in the list of supported processors.
This method works because this sketch is stand alone (i.e. it does not download the images over the serial line, they are compiled in, in the sketch)

2. Use ArduinoISP via the leonardo's real uart: Serial1:
- In the ArduinoISP example change all occurrences of "Serial" into "Serial1".
- Also don't forget to change the RESET define into #define RESET 10, as reported by Steph.
- Download the sketch to the leonardo.
- Hookup an ftdi cable or similar to the leonardo's tx1, rx1 and gnd lines.
- In the ide, select the target processor as board type.
- In the ide, Select the port corresponding to the ftdi cable.
- In the ide, select "burn bootloader".
Logged

Rapa Nui
Offline Offline
Edison Member
*
Karma: 60
Posts: 2066
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

All atmega chips are set in factory to 1MHz internal clock, so a standard programming may not work. You have to set the programming speed to the lowest one possible, and reflash the fuses to the external crystal mode..
Logged

Offline Offline
Full Member
***
Karma: 9
Posts: 109
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

All atmega chips are set in factory to 1MHz internal clock, so a standard programming may not work. You have to set the programming speed to the lowest one possible, and reflash the fuses to the external crystal mode..
I think this was meant for thread: http://arduino.cc/forum/index.php/topic,110321.30.html?
Logged

South Africa
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi there I'm also having the same problem! I'm new to micro controllers so any help would be appreciated. I have done everything that the previous posts have said and still no luck.
Logged

Offline Offline
Full Member
***
Karma: 9
Posts: 109
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Jared, what microcontroller are you trying to burn a bootloader into?
Can you provide more detail about what goes wrong (output of avrdude(set verbose output for upload in the preferences panel...)). What schematic are you using?

Nick Gammon's board programmer should really work but I forgot to mention you should add
Code:
while(!Serial)
    ;
as the first line of the setup() routine, otherwise you don't see the messages in the serial console and this is confusing.

In meantime I succeeded to burn a bootloader using the leonardo an ArduinoISP, using the usb cable, not the real uart.

To do this, I increased SERIAL_BUFFER_SIZE  to 150 in CDC.cpp and provided a mechanism to disable autoreset in software (on the leonardo this is all software!). This requires more investigation, not sure the autoreset disable is needed. I will write about this later.



 

Logged

South Africa
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Peter, thanks for the reply. I'm using the atmega 328 on a breadboard. I don't have access to a crystal as yet so i was attempting to burn it without the crystal present. When using the Arduino ISP (with all the recommended changes) i got the "avrdude: stk500_getsync(): not in sync: resp=0x00" message. When using Nick Gammon's i get the following:

Atmega chip programmer.
Written by Nick Gammon.
Entered programming mode OK.
Signature = 0x1E 0x95 0x14
Unrecogized signature.
LFuse = 0x62
HFuse = 0xD9
EFuse = 0xFF
Lock byte = 0xFF
Clock calibration = 0xAA

With regards to the setup on the breadboard, Im using the icsp headers on the Leo. The reset pin I connected to pin 10 of the Leo.
Thanks so Much
Jared
Logged

South Africa
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all, think i found the problem... The chip Im using is the 328-pu, not the 328p-pu, so i think that's why the program was not recognizing it. I changed the hex code in Nick's program to the signature of the 328-pu but got this message:

Atmega chip programmer.
Written by Nick Gammon.
Entered programming mode OK.
Signature = 0x1E 0x95 0x14
Processor = ATmega324P
Flash memory size = 32768 bytes.
LFuse = 0x62
HFuse = 0xD9
EFuse = 0xFF
Lock byte = 0xFF
Clock calibration = 0xBD
No bootloader support for this device.
Type 'C' when ready to continue with another chip ...
Logged

Pages: [1] 2 3   Go Up
Jump to: