Go Down

Topic: Burning bootloader on standalone Atmega328(internal clock 8MHz) (Read 44266 times) previous topic - next topic

johnwasser

Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

Vilimerth

John, could you please give me the setup which you are using for the same task to make me sure that I have done everything as it should be?
I will not give up on this :)
The only thing is that for the next 2 weeks I will be offshore so I have to suspend my efforts.

johnwasser

Burning a Bootloader
(Arduino 1.6.1 running on MacBook Pro w/ OS X 10.10.2)
ISP Arduino: Arduino Diecimila w/ATmega168 (didn't have a second ATmega328P available)
Target chip in breadboard: ATmega328P (has UNO bootloader and no crystal)

Connect the USB cable to the PC and ISP Arduino

Install the ArduinoISP sketch in the ISP Arduino.
File->Examples->ArduinoISP
Tools->Board->Arduino Duemilanove or Diecimila
Tools->Processor->ATmega168
Tools->Port->(serial port for ISP Arduino)
File->Upload


Go to Preferences... and check the box for "Show verbose output during: [  ] compilation [X] upload"

Install the breadboard wiring:

Target
Pin
Arduino
Pin
Target
Pin
Arduino
Pin
1Pin 1028
227
326
425
524
623
7+5V22GND
8GND21
9
20+5V
1019Pin 13
1118Pin 12
1217Pin 11
1316
1415


Attempt to burn bootloader without disabling auto-reset on ISP Ardiuino.
Tools->Board->Arduino UNO
Tools->Port->(serial port for ISP Arduino)
Tools->Programmer->Arduino as ISP
Tools->Burn Bootloader.

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

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



Note: If the ISP Arduino had an ATmega328P processor this check would have passed and an error would occur further into the process. Here is what happens if I put an ATmega168 into the breadboard and try to burn a Diecimila 168 bootloader to it:
avrdude: Device signature = 0x1e9406
avrdude: erasing chip
avrdude: reading input file "0x3F"
avrdude: writing lock (1 bytes):

Writing |  ***failed;  
################################################## | 100% 0.13s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x3F:
avrdude: load data lock data from input file 0x3F:
avrdude: input file 0x3F contains 1 bytes
avrdude: reading on-chip lock data:

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

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0x00 != 0x3f
avrdude: verification error; content mismatch



Added a 10 uF capacitor to the ISP Arduino with the positive side of the capacitor going to Reset and the negative side of the capacitor going to Ground.

Now attempt to burn a bootloader.  If the chip is not set to expect a crystal or external clock then this should be successful.  If the chip came with (or has had burned) an Arduino bootloader it will fail like this:

Tools->Burn Bootloader.

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check..



This is a symptom of the target chip's clock not running.  An ATmega that is expecting a crystal won't accept serial programming without a crystal or ceramic resonator between pins 9 and 10, or an external clock injected into pin 9.   I found a crystal between 8 MHz and 20 MHz (14.3180 MHz in my case) in my 'salvaged parts' box and plugged it into the breadboard between pins 9 and 10.

Attempt to burn bootloader again: Tools->Burn Bootloader.

avrdude: verifying ...
avrdude: 1 bytes of lock verified

avrdude done.  Thank you.



SUCCESS!
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

johshmoh

Here's what I did:
1) locate your installed boards.txt (mine was in /usr/share/arduino/hardware/arduino/avr/boards.txt)
2) add the following at the end. Restart the IDE and choose ATmega328 on a breadboard from the list

hope that works for you!
##############################################################
atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)

atmega328bb.upload.protocol=arduino
atmega328bb.upload.maximum_size=30720
atmega328bb.upload.maximum_data_size=2048
atmega328bb.upload.speed=57600

atmega328bb.bootloader.tool=arduino:avrdude
#atmega328bb.bootloader.tool=avrdude

atmega328bb.upload.tool=avrdude

atmega328bb.bootloader.low_fuses=0xE2
#atmega328bb.bootloader.low_fuses=0xFF
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05

atmega328bb.bootloader.file=atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F

atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
#atmega328bb.build.core=arduino:arduino
atmega328bb.build.core=arduino
#atmega328bb.build.variant=arduino:standard
atmega328bb.build.variant=standard
###Experimental name:
atmega328bb.build.board=AVR_BARE

Vilimerth

Guys thank you for all your help.

Final I managed to burn bootloader on the standalone Atmega328P.

To accomplish that I removed all old Arduino IDE's (all together with the all boards.txt files with which I was playing), I installed Arduino 1.6.3, afterwards I edited boards.txt with the instructions from johshmoh,  I took brand new Atmega328P and followed johnwasser instructions. Everything went smoothly. It works even without 10uF capacitor.

 I checked all my microcontrollers with Atmel Studio and Atmel ICE and I found that during my first attempts of upload bootloader I changed the fuses to use external oscilator... I don't know how it happend.

Anyway now everything works how it should.

johshmoh

update 1.6.4 broke things. here's the new boards.txt section:
##############################################################

atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)

atmega328bb.upload.tool=avrdude
atmega328bb.upload.protocol=arduino
atmega328bb.upload.maximum_size=30720
atmega328bb.upload.speed=57600

atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05
atmega328bb.bootloader.path=arduino:atmega
atmega328bb.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F

atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino
atmega328bb.build.variant=arduino:standard

LukasD

johshmoh, your update is not corect, i had to add the line "atmega328bb.bootloader.tool=arduino:avrdude" to make it work.
Please check and confirm.

GoForSmoke

Guys thank you for all your help.

Final I managed to burn bootloader on the standalone Atmega328P.

To accomplish that I removed all old Arduino IDE's (all together with the all boards.txt files with which I was playing), I installed Arduino 1.6.3, afterwards I edited boards.txt with the instructions from johshmoh,  I took brand new Atmega328P and followed johnwasser instructions. Everything went smoothly. It works even without 10uF capacitor.

 I checked all my microcontrollers with Atmel Studio and Atmel ICE and I found that during my first attempts of upload bootloader I changed the fuses to use external oscilator... I don't know how it happend.

Anyway now everything works how it should.
Some time try Nick's burner program, it's really good.
http://www.gammon.com.au/bootloader

I have yet to bootload chips without wiggling some wires to get all the contacts right. Need to solder.
With Nick's software I didn't have to edit text to get my 328P-PU chips recognized.

There is also Nick's minimal breadboard blog that covers so much so well.
http://www.gammon.com.au/breadboard
1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

prettyasadiagramm

Hey there.
I have the same problem but the instructions doesn't really helped.
I try to put biitloader in ATmega 328P with a Leonardo board as ISP.

I tried to do it on 1.6.4 IDE and took the same steps Johnwasser has adviced to Vilimerth but after taking the 2nd step I got this msg :

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

avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36
         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                    : \\.\COM7
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
avrdude: Send: 0 [30]   [20]
avrdude: ser_send(): write error: sorry no info avail

and it works the same for both internal and external CLK source, and for 1.6.4. IDE the same as for 1.0.6., I also used 2 different MCUs.

Could you pls help me with that trouble or at least say what may be wrong?

johshmoh

johshmoh, your update is not corect, i had to add the line "atmega328bb.bootloader.tool=arduino:avrdude" to make it work.
Please check and confirm.
Yes, i can confirm it's working fine as is on v1.6.5 on Arch Linux and Windows 8.1
I really don't know what i'm doing, but i managed to get it working for me. glad you were able to work it out?

Glenn81

I'm not sure if anyone is watching this anymore...

I have the same problem, a device I built for a customer, based on Atmega328 internal 8MHz clock.
I have updated the boards file as per the above post, I can't get the device to respond for programming.
The serial link is OK because the 'old' installed program communicates properly via the serial link (input and output).

Has avrdude changed anything in it's protocol?  I don't remember what version of the IDE I used originally - 1.5 something...

Please help!

[Update :] followed the (super) how-to on Nick's site, flashed a new chip with the "Lilypad internal 8MHz" profile, but still no joy.  Incidently, I took out my original chip and cheked it with Nick's 'detector' program, it responds correctly and has the correct bootloader.  *So - my problem persists....*

EEGamble

Hi,

I have the exact same problem as Glenn81. I have bootloaded several times, using both Nick Gammon's beautiful work (Arduino_Board_Programmer) and the 'official' at https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard. Both methods have bootloaded the chip fine, i have checked with Nick's verify function in Arduino_board_programmer sketch. And also checked with the Arduino_Board_Detector (Also Nick's work)..

Also as Glenn81, i have messed around with the boards.txt file but nothing is working unfortunately.

So the problem is the same as Glenn81, i cant program the chip.

i'm using Arduino IDE v.1.6.5..

Have anyone solved this yet?


CrossRoads

Are you last 2 posters using '328, or '328P? They have different signature bytes that can cause issues.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

EEGamble

It should be '328P



Atmega chip detector.
Written by Nick Gammon.
Version 1.17
Compiled on Oct 16 2015 at 20:17:01 with Arduino IDE 10605.
Attempting to enter ICSP programming mode ...
Entered programming mode OK.
Signature = 0x1E 0x95 0x0F
Processor = ATmega328P
Flash memory size = 32768 bytes.
LFuse = 0xE2
HFuse = 0xDA
EFuse = 0xFD
Lock byte = 0xEF
Clock calibration = 0xB7
Bootloader in use: Yes
EEPROM preserved through erase: No
Watchdog timer always on: No
Bootloader is 2048 bytes starting at 7800




*** EDITED OUT (bootloader) ***


MD5 sum of bootloader = 0x27 0xEB 0x87 0x14 0x5D 0x45 0xD4 0xD8 0x41 0x44 0x52 0xCE 0x0A 0x2B 0x8C 0x5F
Bootloader name: ATmegaBOOT_168_atmega328_pro_8MHz



*** EDITED OUT (Program memory) ***





johshmoh

Don't know if this helps anybody or is just wasting space, but:
I upgraded to arduino 1:1.6.5.r5-2 (Arch Linux) and that seems to have broken something. This boards.txt file (living at <arduinofolder>/hardware/breadboard/avr) works now:
##############################################################

atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)

atmega328bb.upload.tool=arduino:avrdude
atmega328bb.upload.protocol=arduino
atmega328bb.upload.maximum_size=30720
atmega328bb.upload.speed=57600

atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xDA
atmega328bb.bootloader.extended_fuses=0x05
#atmega328bb.bootloader.path=arduino:atmega
atmega328bb.bootloader.file=atmega/ATmegaBOOT_168_atmega328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F
atmega328bb.bootloader.tool=arduino:avrdude

atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino
atmega328bb.build.variant=arduino:standard


*****
Confusingly, there's a 1-6-x zip file on the Arduino Tutorial page (https://www.arduino.cc/en/uploads/Tutorial/breadboard-1-6-x.zip) that doesn't work as-is.
For those still having trouble, have you tried a complete removal of the IDE and re-install?

Go Up