Programming a Micro with a Micro

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Barry914
 
Posts: 448
Joined: Sun Dec 08, 2013 1:26 pm

Programming a Micro with a Micro

Post by Barry914 »

I know I've seen them somewhere, but I can't find the instructions for programming an Arduino using the IDE and another Arduino as an ISP. I know I need to load the AVR-ISP sketch to the board I want to use as a programmer, and I know I need to make a change to a preferences file and then wire the ISCP headers together. I guess the only thing I don't know is what changes need to be made to the IDE environment to burn a sketch to the target board.

User avatar
adafruit_support_mike
 
Posts: 67448
Joined: Thu Feb 11, 2010 2:51 pm

Re: Programming a Micro with a Micro

Post by adafruit_support_mike »

You don't really make any changes to the IDE. You just use the "Burn Bootloader" option under the Tools menu.

This page has the information you're looking for: http://arduino.cc/en/Tutorial/ArduinoISP

User avatar
Barry914
 
Posts: 448
Joined: Sun Dec 08, 2013 1:26 pm

Re: Programming a Micro with a Micro

Post by Barry914 »

I don't want to burn the bootloader. I want to burn a sketch. I've got a Micro with a damaged USB connector, and I want to use it for a dedicated application.

User avatar
Barry914
 
Posts: 448
Joined: Sun Dec 08, 2013 1:26 pm

Re: Programming a Micro with a Micro

Post by Barry914 »

I found this via a Google search: http://arduino.cc/en/Hacking/Programmer which describes what it is I want to do, but I can't get it to work. I changed the preferences.txt file in c:\users\Barry\App Data\Roaming\Arduino line from "upload.using=bootloader" to "upload.using=arduinoisp.protocol=stk500v1" after first loading the ISP sketch onto Micro #1, then connected the ICSP headers one-for-one on Micro #1 & Micro #2. I selected AVR ISP in the tools menu and tried uploading the Blink sketch to Micro #2, but the sketch was loaded onto Micro #1, which happily began to blink its LED. Clearly there's something I'm not getting. Anticipating your question, I did make the changes to the preferences.txt file while the IDE was not running. Any ideas?

User avatar
adafruit_support_mike
 
Posts: 67448
Joined: Thu Feb 11, 2010 2:51 pm

Re: Programming a Micro with a Micro

Post by adafruit_support_mike »

Barry914 wrote:I don't want to burn the bootloader. I want to burn a sketch. I've got a Micro with a damaged USB connector, and I want to use it for a dedicated application.
Ah.. special case. The device you want to program has a bootloader, you just want the first Arduino in the chain to act as a USB-to-Serial converter.

This Instructable explains how to do that:

http://www.instructables.com/id/Arduino ... TDI-Progr/

User avatar
Barry914
 
Posts: 448
Joined: Sun Dec 08, 2013 1:26 pm

Re: Programming a Micro with a Micro

Post by Barry914 »

I thought I could use the Micro as an AVR programmer and overwrite the bootloader on the target Micro. Not so? Since I don't have a microcontoller with a removable chip I can't use this method in any case.

User avatar
adafruit_support_mike
 
Posts: 67448
Joined: Thu Feb 11, 2010 2:51 pm

Re: Programming a Micro with a Micro

Post by adafruit_support_mike »

That would be this page: http://arduino.cc/en/Hacking/Programmer

To use a second Arduino as the ISP, use the hardware connections from the first page I posted and select "Arduino as ISP" under the Tools -> Programmer menu.

User avatar
Barry914
 
Posts: 448
Joined: Sun Dec 08, 2013 1:26 pm

Re: Programming a Micro with a Micro

Post by Barry914 »

Haven't had much luck. I've got my "programmer Micro" connected to my "target Micro" as follows: gnd to gnd, +5v to +5v, MISO to MISO, MOSI to MOSI, SCK to SCK, SS to Reset. The last connection was gleaned from the ArduinoISP sketch. I've got LEDs on the heartbeat and error pins. When I load the ISP sketch onto the programmer Micro, I get the heartbeat. When I connect the target Micro and try to load the Blink sketch via File->Upload using programmer I see the activity lights blinking, but I get the following output on the IDE:

Code: Select all

Binary sketch size: 4,830 bytes (of a 28,672 byte maximum)
avrdude: stk500_getsync(): not in sync: resp=0x00
and the sketch never gets loaded onto the target. I am not sure if I should be choosing AVR ISP or Arduino as programmer but neither works. Ideas?

User avatar
adafruit_support_mike
 
Posts: 67448
Joined: Thu Feb 11, 2010 2:51 pm

Re: Programming a Micro with a Micro

Post by adafruit_support_mike »

Do you have a capacitor going to the RESET pin?

You need to pulse RESET to launch the bootloader, but holding RESET low will keep the chip in a "don't do anything" state.

User avatar
Barry914
 
Posts: 448
Joined: Sun Dec 08, 2013 1:26 pm

Re: Programming a Micro with a Micro

Post by Barry914 »

No capacitor. From the sketch it seems the target's reset pin is controlled by the programmer Micro's SS pin. And if I am trying to burn a sketch using ICSP, doesn't the target's reset have to be held low to keep the target CPU out of the picture?

User avatar
adafruit_support_mike
 
Posts: 67448
Joined: Thu Feb 11, 2010 2:51 pm

Re: Programming a Micro with a Micro

Post by adafruit_support_mike »

Sorry, I keep forgetting that you're trying to program the bare chip.

Try connecting the target Micro's RESET pin to pin 10 on the programmer Micro.

The ArduinoISP sketch is written for an ATmega328P microcontroller, but the Micro uses an ATmega32u4. The SS signal maps to different pins on the two chips, and to different pins on the two flavors of Arduino (digital 10 on the Uno, RXLED on the Micro).

I think the ArduinoISP hardcodes pin 10 as SS rather than going through the gymnastics of finding the true SS pin.

You do need some control over the RESET line to make the programming cycle work. The chip being programmed wants to see a HIGH pulse on RESET in order to synchronize with the programmer.

User avatar
Barry914
 
Posts: 448
Joined: Sun Dec 08, 2013 1:26 pm

Re: Programming a Micro with a Micro

Post by Barry914 »

So here's where I am. When I run the ISP sketch the three indicator LEDs each blink twice, as they are supposed to, and the HB LED does the heartbeat thing. When I try to burn the Blink sketch onto the target Micro, I see a few flashes of the RX/TX LEDs on the programmer and corresponding flashes on the target's pin 13 LED. Neither of the indicator LEDs show any activity, as in the programmer is not communicating with the target nor is it detecting an error. I've tried all permutations of pin 10, SS, Arduino as ISP and AVR ISP. I'm stuck.

User avatar
adafruit_support_mike
 
Posts: 67448
Joined: Thu Feb 11, 2010 2:51 pm

Re: Programming a Micro with a Micro

Post by adafruit_support_mike »

I'm afraid I've run out of ideas too.

You might need to take this over the Arduino Forums (http://forum.arduino.cc/) and see if anyone there knows what I'm missing.

User avatar
Barry914
 
Posts: 448
Joined: Sun Dec 08, 2013 1:26 pm

Re: Programming a Micro with a Micro

Post by Barry914 »

That was a great suggestion Mike. I got a response to my post in a flash, and I now have my target Micro blinking away. Here's the info:
http://forum.arduino.cc/index.php?topic ... msg1178400
Basically, I needed to add the following to programmers.txt in C:\Program Files\Adafruit Arduino 1.05\hardware\arduino:

Code: Select all

arduinoispmicro.name=Arduino as ISP on Micro
arduinoispmicro.communication=serial
arduinoispmicro.protocol=arduino
arduinoispmicro.speed=19200
and in the ISP sketch change the #define for RESET from SS to 10, and I wired the target Micro's RESET pin to the programmer's D10.

User avatar
adafruit_support_mike
 
Posts: 67448
Joined: Thu Feb 11, 2010 2:51 pm

Re: Programming a Micro with a Micro

Post by adafruit_support_mike »

I'm glad you found it because I never would have thought of that. ;-)

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”