Trying to burn bootloader into atmega328, but getting this error:
Arduino: 1.6.11 (Linux), Board: "ATmega328, Yes, 328 / 328A, 2.7v, Disabled (default), 8 MHz internal"
/home/paul/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/bin/avrdude -C/home/paul/.arduino15/packages/MiniCore/hardware/avr/2.0.1/avrdude.conf -v -patmega328 -cusbasp -Pusb -e -Ulock:w:0x3f:m -Uefuse:w:0xfd:m -Uhfuse:w:0xd6:m -Ulfuse:w:0xe2:m
avrdude: Version 6.3, compiled on Jan 17 2017 at 11:00:16
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "/home/paul/.arduino15/packages/MiniCore/hardware/avr/2.0.1/avrdude.conf"
User configuration file is "/home/paul/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : usb
Using Programmer : usbasp
AVR Part : ATmega328
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 : usbasp
Description : USBasp, http://www.fischl.de/usbasp/
avrdude: auto set sck period (because given equals null)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: error: program enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.
avrdude done. Thank you.
Error while burning bootloader.
I understand this is often a wiring error, but I am using a board I made a couple of years ago for prototyping and burning bootloaders. I have used it several times to burn bootloaders and to upload sketches via ISP. So I know the wiring is correct. But it's been months since I last used it, and I have probably upgraded the IDE (currently 1.6.11) and various board packages since then.
I have tried using another atmega328. Same error. I know that atmega is OK because when I plug it back into the circuit I borrowed it from, it continues to run its old sketch perfectly.
I know the USBasp is OK, because I tested it by setting fuses and uploading the blink sketch to an attiny84. Works perfectly.
I tried building an ISP programming circuit on breadboard. Same error.
Thanks for responding. Yes, it will have those fuse bits set. I was wondering if that could be the problem. So once a bootloader is burned that sets the fuses for external clock, you have to connect up a crystal to be able to set the clock back to internal?
With the crystal there, the processor will tick over, and you can then program it. You might reconfigure it to no longer need the crystal.
Alternatively, if you have a spare board lying around, upload this sketch to it:
// For Atmega328
void setup ()
{
// set up 8 MHz timer on pin 9
pinMode (9, OUTPUT);
// set up Timer 1
TCCR1A = _BV (COM1A0); // toggle OC1A on Compare Match
TCCR1B = _BV(WGM12) | _BV(CS10); // CTC, no prescaling
OCR1A = 0; // output every cycle
}
void loop () {}
That will output an 8 MHz clock to pin 9, so you could connect pin 9 (and Gnd) from the board running the "clock" sketch to the board requiring a clock signal. Plug the clock line into the XTAL1 pin.
Switching to serial programming and attempting to upload the blink sketch:
Arduino: 1.6.11 (Linux), Board: "ATmega328, Yes (UART0), 328 / 328A, 2.7v, LTO disabled, 16 MHz external"
WARNING: Category '' in library UIPEthernet is not valid. Setting to 'Uncategorized'
Sketch uses 1,078 bytes (3%) of program storage space. Maximum is 32,256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2,039 bytes for local variables. Maximum is 2,048 bytes.
/home/paul/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/bin/avrdude -C/home/paul/.arduino15/packages/MiniCore/hardware/avr/2.0.2/avrdude.conf -v -patmega328 -carduino -P/dev/ttyUSB1 -b115200 -D -Uflash:w:/tmp/buildbe7f94c1fb4df44bfe085b21fc070d63.tmp/Blink.ino.hex:i
avrdude: Version 6.3, compiled on Jan 17 2017 at 11:00:16
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "/home/paul/.arduino15/packages/MiniCore/hardware/avr/2.0.2/avrdude.conf"
User configuration file is "/home/paul/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/ttyUSB1
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00
avrdude done. Thank you.
Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
Invalid library found in /home/paul/sketchbook/libraries/ESP-1ch-Gateway-v2.0-master: /home/paul/sketchbook/libraries/ESP-1ch-Gateway-v2.0-master
Invalid library found in /home/paul/sketchbook/libraries/Adafruit_Trellis-master: /home/paul/sketchbook/libraries/Adafruit_Trellis-master
Invalid library found in /home/paul/sketchbook/libraries/arduino-api-master: /home/paul/sketchbook/libraries/arduino-api-master
Invalid version found: 1.04
Invalid library found in /home/paul/sketchbook/libraries/arduino-onewire-slave-master: /home/paul/sketchbook/libraries/arduino-onewire-slave-master
Invalid library found in /home/paul/sketchbook/libraries/ESP-1ch-Gateway-v2.0-master: /home/paul/sketchbook/libraries/ESP-1ch-Gateway-v2.0-master
Invalid library found in /home/paul/sketchbook/libraries/Adafruit_Trellis-master: /home/paul/sketchbook/libraries/Adafruit_Trellis-master
Invalid library found in /home/paul/sketchbook/libraries/arduino-api-master: /home/paul/sketchbook/libraries/arduino-api-master
Invalid version found: 1.04
Invalid library found in /home/paul/sketchbook/libraries/arduino-onewire-slave-master: /home/paul/sketchbook/libraries/arduino-onewire-slave-master
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Sorry, my fault for confusing you by not explaining what I'm doing.
I'm still using the circuit with the 16MHz crystal, but now attempting up upload sketch via serial. I only have one 16MHz crystal, and that's soldered up on a stripboard circuit. But now, thanks to your advice, I think I can use that circuit to set fuses for 8MHz internal and burn bootloader on another atmega328, and use that in a different circuit. I had the foresight to put a socket for the atmega on the stripboard, so I can swap chips.
Anyway, I'm now trying to get a sketch uploaded over serial using a USB-serial adaptor. And I have made it work, but with difficulty.
Normally, I just connect the DTR pin on the USB-serial adaptor to the reset pin on the atmega and that works every time. (I also have 10K pull-up on the reset piin).
But for some reason, its not working. So I disconnected the atmega reset pin from DTR and connected it via a pushbutton to ground. By randomly clicking the pushbutton during the upload, I can get it to upload the sketch. But a lot of random clicking is envolved. It shouldn't be like this. On other circuits, using the DTR on my USB-serial adaptor works perfectly, no reset button required.
OK, fixed the reset problem by putting a 0.1uF cap between the atmega reset pin and the DTR pin on the USB-serial adaptor. The DTR line was pulling reset low for the entire upload process. The cap, in conjunction with the 10K pull-up, turns that constant low into a low pulse, which resets the atmega and allows sketch upload.
What I don't understand is how I got away with not having that cap in my other circuits...
I have been caught by that a couple of times. Using the Isp programmer you don't need the .1uF Cap, but then you need it for the USB-serial adapter. I have several minimum system programmers that have a .1uF capacitor tied to Gnd on the Reset lead and I have had to remove it to make the DTR pulse work.
kprims:
Using the Isp programmer you don't need the .1uF Cap
Today I learned that you must not have the 0.1uF cap in series with the reset line when using ISP programmer.
The 0.1uF I had needed to solder in the DTR-->Reset line, for serial programming, prevented me from later using the ISP programmer. To get ISP programming to work, I just needed to touch the Reset line from the programmer directly to the Reset pin on the atmega, bypassing the cap, when performing "Burn Bootloader".