Go Down

Topic: Bootloading ATMEGA328P-PU with Optiloader (Read 4913 times) previous topic - next topic

NickyG

Apr 10, 2016, 07:20 am Last Edit: Apr 10, 2016, 08:58 am by NickyG
Hi Guys,

First post so excuse me if my terminology is off.

I'm new to Arduino and have been tinkering around getting ready to start a few pet projects. At the moment i'm gearing up to make some standalone arduino's.

I have purchased a few ATMEGA328P-PU  microcontrollers (See here for item details) and the seller notes that the microcontrollers are pre loaded with the optiboot bootloader. However they also note that in order to write to these microcontrollers I need to burn them.

Taking a step back and please correct me if I'm wrong but if they are preloaded with optiboot are they not already burnt?

Regardless I figured I may as well learn how to burn them myself and have researched Optiloader and loaded it onto my programmer.

I have setup my Arduino Mega as the programmer and on my breadboard I have wired up everything as per this link.

However when I run the sketch and look at the serial monitor all I get is this.

Code: [Select]
OptiLoader Bootstrap programmer.
2011 by Bill Westfield (WestfW)

Target power on! ...
Starting Program Mode


It never progresses past this and seems to do nothing. Any idea where I could have gone wrong, I have checked my wiring a few times and everything seems right, the power light is on but no life from the TX or RX LED's

westfw

Does your breadboard have the crystal and caps as well?  It needs them.

Quote
if they are preloaded with optiboot are they not already burnt?
Yes, I would think so.

NickyG

Does your breadboard have the crystal and caps as well?  It needs them.
Yes, I would think so.

Hi WestFW,

Yes the crystal and caps are in there as well.


NickyG


MalharD

The image is broken. Please post a new one.
The wiring
for a MEGA and a UNO to burn a bootloader is entirely different.
Upload ArduinoISP in the examples in Arduino IDE to your mega.
Modify the following pin connections,Leave everything else as it it.

pin name:              mega      Atmega 328P
slave reset:             53            1
 MOSI:                    51           17
 MISO:                    50           18
  SCK:                     52           19

Then go to IDE,Select the board as Arduino UNO,Programmer Arduino as ISP and then click burn bootloader.
Greetings,
-Malhar
Murphy always gets me ...

westfw

Quote
for a MEGA and a UNO to burn a bootloader is entirely different.
Ah; I didn't notice that you're using a MEGA.  I wouldn't expect that to work :-(
Malhar's ideas might work, applied to optiloader as well as arduinoISP...

NickyG

#6
Apr 10, 2016, 10:57 am Last Edit: Apr 10, 2016, 11:10 am by NickyG
Hi Guys,

Yes after reading a little more i realised the pin map was completely different.

The image is broken. Please post a new one.
The wiring
for a MEGA and a UNO to burn a bootloader is entirely different.
Upload ArduinoISP in the examples in Arduino IDE to your mega.
Modify the following pin connections,Leave everything else as it it.

pin name:              mega      Atmega 328P
slave reset:             53            1
 MOSI:                    51           17
 MISO:                    50           18
  SCK:                     52           19

Then go to IDE,Select the board as Arduino UNO,Programmer Arduino as ISP and then click burn bootloader.
Greetings,
-Malhar

Malhar,

I used the method you have suggested and get the following feedback

Code: [Select]
Arduino: 1.6.8 (Windows 7), Board: "Arduino/Genuino Uno"

C:\Program Files\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -PCOM6 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m

avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM6
         Using Programmer              : stk500v1
         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    20     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 : STK500
         Description     : Atmel STK500 Version 1.x firmware
         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

Error while burning bootloader.
Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0xff00ff
avrdude: Expected signature for ATmega328P is 1E 95 0F
         Double check chip, or use -F to override this check.

avrdude done.  Thank you.


Any idea why the signatures are wrong.

Here is the amended setup.


MalharD

As the error says, please check the connections.
Can you post a photo of the circuit ?
Is the crystal attached ?
Try removing the two caps attached to the crystal.
Murphy always gets me ...

NickyG

#8
Apr 10, 2016, 11:31 am Last Edit: Apr 10, 2016, 11:37 am by NickyG
As the error says, please check the connections.
Can you post a photo of the circuit ?
Is the crystal attached ?
Try removing the two caps attached to the crystal.
Crystal is attached, have tried removing the two caps, no real change, slightly different signature same error code


MalharD

Is +5v connected to pin 7 and Pim 8 to to GND ?
Connect pin 20 to VCC and pin 22 to GND.
Try connecting a 100u capacitor to +5v and GND.
Power the mega with external supply.
Can you post a photo ?
Murphy always gets me ...

MalharD

I don't see a GND connected to pin 8.
That may be the problem.
Murphy always gets me ...

NickyG

#11
Apr 10, 2016, 12:05 pm Last Edit: Apr 10, 2016, 12:15 pm by NickyG
Is +5v connected to pin 7 and Pim 8 to to GND ?
Connect pin 20 to VCC and pin 22 to GND.
Try connecting a 100u capacitor to +5v and GND.
Power the mega with external supply.
Can you post a photo ?
Ok everything has been connecting except the 100uf capacitor, I dont have any at the moment (awaiting to arrive). All i got is a few 10uf.

The Mega is powered through the USB serial. Correct me if im wrong.

Grd is there to pin 8 (far right white wire)



Current error
Code: [Select]
avrdude: Device signature = 0xff7fff
avrdude: Expected signature for ATmega328P is 1E 95 0F
         Double check chip, or use -F to override this check.

MalharD

#12
Apr 10, 2016, 12:17 pm Last Edit: Apr 10, 2016, 12:18 pm by MalharD
Two or three 10u wil do.
Try removing the two 22p caps.
I was unable to bootload to some of my chips with those caps connected
Try connecting external supply to the mega
Murphy always gets me ...

NickyG

#13
Apr 10, 2016, 12:36 pm Last Edit: Apr 10, 2016, 01:27 pm by NickyG
Two or three 10u wil do.
Try removing the two 22p caps.
I was unable to bootload to some of my chips with those caps connected
Try connecting external supply to the mega
Thanks for your ongoing support.



three capacitors used still no luck. Also removed the 22p caps and added external power.

I swapped out the microcontroller and the signature went to 000000, from reading WestFW's posts I figured this is due to the controller not sitting right in the breadboard. Played around with it and the signature went back to 0x7f007f.

NickyG

Given these chips are ATMEGA328P-PU's do I need to change the avrdude.config file or is that just for the ATMEGA328P

Go Up