Go Down

Topic: Bootloader problem - Arduino Mega and Duemilanove (Read 4 times) previous topic - next topic

CrossRoads

If running the optiloader sketch, disabling reset is not needed.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Nick Gammon

Right then. Let me describe what I did to get to this point:

Code: [Select]

$ avrdude -c arduino -p m328p -v -P /dev/tty.usbmodemfd141 -b 19200


         avrdude: Version 5.8cvs, compiled on Jan 15 2010 at 17:27:01
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/usr/local/CrossPack-AVR-20100115/etc/avrdude.conf"
         User configuration file is "/Users/nick/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/tty.usbmodemfd141
         Using Programmer              : arduino
         Overriding Baud Rate          : 19200
         AVR Part                      : ATMEGA328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65     5     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e950f
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DE
avrdude: safemode: efuse reads as 5

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DE
avrdude: safemode: efuse reads as 5
avrdude: safemode: Fuses OK

avrdude done.  Thank you.


You will note that it detected the ATMEGA328P part, and read the fuses. So from here on, it is just formality I think.



First important point: Since we are using a Mega, and programming is done via SPI, we need to use the Mega SPI pins, not the Uno ones.

Code: [Select]

Mega      Duem
D53       Reset (SS)
D51       D11 (MOSI)
D50       D12 (MISO)
D52       D13 (SCK)
Gnd       Gnd
+5         +5


Next, I uploaded the "example" ArduinoISP sketch that shipped with 1.0 of the IDE onto the Mega.

Then, it appeared to work better (ie. at all) if I stuck a 10 uF capacitor between Reset and Gnd on the Mega.

It also appeared to need the Mega to be reset (ie. reset button) before trying anything. Wait a few seconds for the Tx/Rx lights to stop flashing, as the bootloader on the Mega tries to do serial comms.

Then I used avrdude on the command line, after working out which comm port the device was recognized on (in my case, /dev/tty.usbmodemfd141).

Code: [Select]
avrdude -c arduino -p m328p -v -P /dev/tty.usbmodemfd141 -b 19200

The -v just checks that it can communicate with the target device.

If you want to see more, replace -v by -vvvv and then you see stuff like this:

Code: [Select]

         Using Port                    : /dev/tty.usbmodemfd141
         Using Programmer              : arduino
         Overriding Baud Rate          : 19200
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
         AVR Part                      : ATMEGA328P


CrossRoads

So you're not running westfw's optiloader then?

See the video here
http://arduino.cc/forum/index.php/topic,68183.0.html
My understanding was that after connecting the 2 systems, pressing reset on the master started the process, and when done it just waited for another reset to start the next bootloading operation.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Nick Gammon


So you're not running westfw's optiloader then?


No, I was just using the supplied ArduinoISP sketch to turn the first Arduino (in this case the Mega) into an ISP programmer. Then you use avrdude in the usual way .

drwaseem

@CrossRoads,
I have tried this approach. Let me explain it here in detail so that if I may be guided if there is something wrong with what I am doing.
1. downloaded optiloader .pde and .hex from https://github.com/WestfW/OptiLoader
2. Copied both files in a directory named Optiloader and placed that directory in Libraries folder within Arduino folder.
3. Compiled the sketch and uploaded it to Mega.
4. Connected Duemilanove (having new Atmega328p inserted) with mega exactly as the way you described.
5. press the reset button on mega, the LED connected to D13 of both mega and duemilanove flash multiple times and then turn off.
6. Now connected the Duemilanove(with new Atmega328) with PC. Removed all cables connecting it with mega and tried to upload the sketch to Atmega328. It says, error uploading.
7. When I press reset on Duemilanove, the LED on D13 does not flash meaning, no bootloader was installed.

Currently working on the method shared by Mr. Gammon. Will post the results as soon as I am done with it.
Man, it sucks!! Any ideas?

Regards

Go Up