Due as ISP Programmer for Leonardo/AtMega32u4

hey everyone,

i am trying to load the leonardo bootloader to an AtMega32u4 but that doesn`t work out.

Now I wanna take a step back and try to reload the bootloader onto the Leonardo board. (if that works I guess it`s pritty strait forward?!)

I gonna tell you what i found out so far and what I did.
a lot of steps i used PeterVH advice in the discussion: ArduinoISP on Arduino DUE - Microcontrollers - Arduino Forum

  1. connected the microUSB to the programming Atmega16u2 and opened the Arduino 1.5.2 Software.
  2. downloaded the new ArduinoISP data: GitHub - rsbohn/ArduinoISP: Use the Arduino to program AVR chips. and replaced the old ArduinoISP.
  3. After restarting the Software i changed the SS to 10 and set the clockdivider to 255.
  4. changed all Serial to SerialUSB and uploaded the file (tool->Board-> Due Programming board, tools->Programmer->AVRISP mkII, Serial Port->COM11 (in my case).
  5. changed the micorUSB to the native usb port
  6. changed the setting of tool->Board-> Leonardo, tools->Programmer->Arduino as ISP, Serial Port->COM12 (in my case; for native usb port).
  7. and pest the button tool->burn Bootloader

Well an error appeared: "avrdude: stk500_getsync(): not in sync: resp=0x00"

is the connection wrong?
I connected:

PIN - DUE ¦ pin -Leonardo
SPI ICSP
1 - MISO ¦ 1 - MISO
3 - SCK ¦ 3 - SCK
4 - MOSI ¦ 4 - MOSI
6 - GND ¦ 6 - GND
also
3.3V ¦ 3.3 V
GND ¦ GND
10 (SS) ¦ RESET

also an red led on pin 8

sorry about the bad mobile pix.

i would be very pleased if you could help me, thank
coolf

I connected the 3V3 of the Due (don't take the adjacent 5V by mistake) to Vdd ("5V") of the Leonardo
About the programmer: on windows you should do the "Leofix trick" see:ArduinoISP on the Leonardo | PeterVH, step 7.
Also do this SPI fix: SPI.end() causes SPI.transfer() to hang even after a new SPI.begin() - Arduino Due - Arduino Forum

It is better to first try something simpler: download the booter from the device or read out the signature bytes, so you know isp works.

PeterVH thank you for your fast replay. I would love to say: ITs working Jipppii, but i cant.

I changed the connection pin. power supply of the target (Vin = 3.3V) to the Vdd(5V) pin
fixed the spi library with the line: SPI_Enable(spi); in the begin() function

and made a new programmers.txt like the"leofix trick"
changed the setting to tool->Board-> Leonardo, tools->Programmer->Arduino as ISP (Arduino), Serial Port->COM12 (in my case; for native usb port).
and used the button tool->burn Bootloader

an error appeared:

java.lang.NullPointerException
at java.util.HashMap.putAll(HashMap.java:498)
at processing.app.debug.BasicUploader.burnBootloader(BasicUploader.java:262)
at processing.app.Editor$47.run(Editor.java:2524)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

The PC can`t connect all the way to there arduino leonardo(Atmega32u4 chip) board

I guess some settings are wrong. What do you think?

coolf

I would love to say: ITs working Jipppii, but i cant.

Don't worry we'll get there.

Let us first get the power aspect right. I want to avoid someone damages his or her Due because of reading this thread.

I changed the connection pin. power supply of the target (Vin = 3.3V) to the Vdd(5V) pin

Not sure how to interpret this, but I meant following:

Pin Due    |    Pin Leonardo
3.3V       |    5V

This is what I used. I found it an intuitive way to power the atmega32u4 at 3V3. From the schematcs of the Leonardo, I don't see a problem with this, but of coarse I might overlook something. (Any feedback about this is wellcome). Anyway I experienced no neagtive effect of it.

Very important: never plug in the Leo's usb port while this wiring is in place (Leo powered by the Due's 3V3) !

Now, about the call stack trace: I remember some issues being reported with the way 1.5.2 deals with sketchbook directories.

So there are two approaches:

  1. Leave the "leofix" in place and burn the bootloader using ide 1.0.3 or higher. The ide does not care your programmer happens to run on a Due.
  2. Remove the "leofix" (remove again the hardware directory from your sketchbook directory). Instead, directly modify arduino-1.5.2/hardware/arduino/avr/programmers.txt: change these items:
arduinoisp.protocol=stk500v1
arduinoisp.program.protocol=stk500v1

into

arduinoisp.protocol=arduino
arduinoisp.program.protocol=arduino

Also make sure the baud rate is correct (19200).
The arduinoisp.program.xxx entries are new to me, but the only goal is to use arduino as protocol because you are on windows.

Well

I followed the instruction but it didn't worke out.

I build an parallel Programmer: http://www.arduino.cc/en/Hacking/ParallelProgrammer?from=Main.ParallelProgrammer
and was willing to push the bootloader onto my Leonardo board.

But it didn`t work out. Now when I connect the Leonardo board. my computer can't see the leonardo board anymore (-> i killed the bootloader)

i got back to my original plan. using the due as an ISP programmer. But the problem appears:

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

other user had the same problem and it appears to be a driver error.

well i have no idea what do do. May anybody has an idea?
I thought ordering an Atmega AVRISP mkII in System Programmer http://store.atmel.comPartDetail.aspx?q=p:10500054#tc:description and to upload the the bootloader via the AVRISP programmer.

Would that work out? And how? does anyone has a good link??

I am totaly confused .... Thank you for your help
Coolf

Don't give up.
I have the same Due and the same Leo, if it works for me it must work for you too.

Try to work incrementally. First make isp work from the command line.
Go to the arduino-1.5.2/hardware/tool directory and enter this command:

avrdude.exe -C avrdude.conf -c arduino -P YOURDUECOMPORT  -p m32u4 -vvvv -U signature:r:test.hex:h

I assume you use the native usb port.

Post the output here.

I try compile the code on

and get this message

ArduinoISP.ino: In function 'void setup()':
ArduinoISP:74: error: 'SPI_CLOCK_DIV128' was not declared in this scope

@reinaldoaff: just specify 255 instead.
(actually I noticed it gets overwritten anyway by SPI::begin(), so we'll be spi!ing at 4MHz anyway, but this is ok, it works)

@coolf: I normally use linux, but for verification I tried the command line myself on windows 7 SP1 64bit.
As explained we can use the avrdude (and later the leo bootloader) from the 1.0.3 ide:

arduino-1.0.3\hardware\tools\avr\bin>avrdude.exe -C ..\etc\avrdude.conf -c arduino -P COM10 -p m32u4  -U signature:r:test.hex:h

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.04s

avrdude.exe: Device signature = 0x1e9587
avrdude.exe: reading signature memory:

Reading | ################################################## | 100% 0.04s

avrdude.exe: writing output file "test.hex"

avrdude.exe: safemode: Fuses OK

avrdude.exe done.  Thank you.

thx PeterVH

I worked around the problem by using an Teensy 2.0 as an ISP Programmer. With the good freeware of "myAVR ProgTool V1.39" i could upload the Leonardo (Caterina) Bootloader onto my original Arduino Leonardo.
JIPPI I am back in the game :slight_smile:

As i try to uploade the booaloader onto my new uC it didn`t work until I added a external Quarz osz.
Now I can upload the Leonardo (Caterian) Bootloader and change the fuses like the Leonardo fuses:
low fuses 0xff
high fuses 0xD8
ex. fuses 0xCB
Lockbits 0x3F

One more Problem appeared. The Leonardo Bootloader is on my new uC but my PC (device manager) just can find an "unknown Device" ander the USB controller but doesen`t open an comunication Port like the original Leonardo does.

I would be very glad if someone knows how to fix the problem.
thanks for reading,
coolf

Thanks PeterVH for your help

SOLVED: I forgot to connect the UCap pin with an Capacity to GND

Allow me to come up with a solution for what was once the subject of this thread: "Due as ISP Programmer for Leonardo/AtMega32u4": ArduinoISP on the Due | PeterVH