I set up a breadboard for programming a new ATMega328P CPU using an Arduino Uno as an ICSP programmer. I uploaded the Blink.ino sketch and ran it successfully. However, a subsequent attempt failed. I repeated this process on all of the CPUs I had on hand, ten in all. Four programmed and six failed. The failures were the result of incorrect device signatures. Investigation of the CPUS indicated that the four that programmed were labeled ATMega328P-PU and those that failed were labeled ATMega328P U. I don't know if this is significant so I repeated every attmpt to rule out a connection problem but results were the same. I am including the output of the failures. There is a line that reads: “double check connections and try again, or use -F to carry on regardless”. I don't understand the reference to -F. Is it something that relates to a command line input? I searched posts for anything that relates to this but didn't turn up anything. The solution to this problem is beyond me. Can anybody help?
Sketch uses 924 bytes (2%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
"C:\Users\ac945\AppData\Local\Arduino15\packages\arduino\tools\avrdude\8.0.0-arduino1/bin/avrdude" "-CC:\Users\ac945\AppData\Local\Arduino15\packages\arduino\tools\avrdude\8.0.0-arduino1/etc/avrdude.conf" -v -V -patmega328p -cstk500v1 -PCOM11 -b19200 "-Uflash:w:C:\Users\ac945\AppData\Local\arduino\sketches\0F766361727928869C899BE773EA08AE/Blink.ino.hex:i"
Avrdude version 8.0-arduino.1
Copyright see https://github.com/avrdudes/avrdude/blob/main/AUTHORS
System wide configuration file is C:\Users\ac945\AppData\Local\Arduino15\packages\arduino\tools\avrdude\8.0.0-arduino1\etc\avrdude.conf
Using port : COM11
Using programmer : stk500v1
Setting baud rate : 19200
AVR part : ATmega328P
Programming modes : SPM, ISP, HVPP, debugWIRE
Programmer type : STK500
Description : Atmel STK500 v1
HW Version : 2
FW Version : 1.18
Topcard : Unknown
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.0 us
XTAL frequency : 7.372800 MHz
AVR device initialized and ready to accept instructions
Device signature = 1E 95 14 (ATmega328)
Error: expected signature for ATmega328P is 1E 95 0F
- double check chip or use -F to carry on regardless
Avrdude done. Thank you.
Failed programming: uploading error: exit status 1
Which is the chip type you asked avrdude to program:
Which is a different part, the original non picoPower 328. The "PU" on the end of each of them refers to the packaging style (DIP) and environmental grading (-40C to 85C).
avrdude is telling you you're trying to program a 328 as if it was a 328P. Note the signature it read from the chip and that it differs from the signature a 328P would return. Change your chip type from 328P to 328 and I'm sure avrdude will be happy to program it for you as such. Whether it does what you wanted it to do is another question; I've honestly never used the bare 328, only 328P and 328PB. So I don't know what it's lacking other (if anything) other than consuming more current. You'd have to go through the datasheets to find out.
Since my original post I've done further research but no solution yet. I can't find any way in the IDE for changing the chip type to avoid the invalid signature. Any ideas?
You could try using MCUdude's MiniCore, that has an option for the 328/328A version of the ATmega328. The other option would be to edit the boards.txt file.
I didn't know about MiniCore until it was suggested to me in the previous post. I installed it and ran again with the following results. I am appending a photo of the two chips below.
Sketch uses 880 bytes (2%) of program storage space. Maximum is 32384 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
"C:\Users\ac945\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\8.0-arduino.1/bin/avrdude" "-CC:\Users\ac945\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\8.0-arduino.1/etc/avrdude.conf" -v -V -patmega328 -curclock -PCOM7 -b115200 -D -xnometadata "-Ueeprom:w:C:\Users\ac945\AppData\Local\arduino\sketches\6180E284356653BD9DC6AAE361567F04/Blink_IO9.ino.eep:i" "-Uflash:w:C:\Users\ac945\AppData\Local\arduino\sketches\6180E284356653BD9DC6AAE361567F04/Blink_IO9.ino.hex:i"
Avrdude version 8.0-arduino.1
Copyright see https://github.com/avrdudes/avrdude/blob/main/AUTHORS
System wide configuration file is C:\Users\ac945\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\8.0-arduino.1\etc\avrdude.conf
Using port : COM7
Using programmer : urclock
Setting baud rate : 115200
AVR part : ATmega328
Programming modes : SPM, ISP, HVPP, debugWIRE
Programmer type : Urclock
Description : Urboot bootloaders using urprotocol
Protocol : STK500v1 skeleton
AVR device initialized and ready to accept instructions
Error: connected part ATmega328P signature does not match -p ATmega328's (override with -F or use -p ATmega328P)
Error: unable to read signature data for part ATmega328 (rc = -1)
Error: unable to read signature data (rc = -1)
use -F to override this check
Avrdude done. Thank you.
Failed uploading: uploading error: exit status 1
Yes it does and applicable only when running avrdude manually from the command line.
It is best left alone unless you are 100% sure that it is actually needed. It means "Force" as in override the signature and go ahead anyway.
In this case, looking at the first post, the signatures appear to be exactly what they should be:
ATMega328 U = 1E 95 14
ATMega328P-PU = 1E 95 0F
The 'U' and the '-PU' suffixes can be ignored, however, the 'P' immediately after the 328 where it appears is significant.
It is just a question of matching the MCU specified in the IDE to the chip being programmed. Looking at the error output it looks like the 'atmega328' MCU was selected in the IDE as expected:
But the connected part appears to have been an ATMega328P:
Error: connected part ATmega328P signature does not match -p ATmega328's
I am assuming that you did use the 'Tools -> Upload using programmer' option? In which case swap the chip on the breadboard for one marked 'ATMega328 U'. Otherwise, if the general 'Tools -> Upload' option was used, or the arrow icon clicked, then the process might have detected the 328P chip on the UNO R3 board being used as the programmer.
Sketch uses 878 bytes (2%) of program storage space. Maximum is 32384 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
"C:\Users\ac945\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\8.0-arduino.1/bin/avrdude" "-CC:\Users\ac945\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\8.0-arduino.1/etc/avrdude.conf" -v -V -patmega328 -cstk500v1 -PCOM7 -b19200 "-Ueeprom:w:C:\Users\ac945\AppData\Local\arduino\sketches\6180E284356653BD9DC6AAE361567F04/Blink_IO9.ino.eep:i" "-Uflash:w:C:\Users\ac945\AppData\Local\arduino\sketches\6180E284356653BD9DC6AAE361567F04/Blink_IO9.ino.hex:i"
Avrdude version 8.0-arduino.1
Copyright see https://github.com/avrdudes/avrdude/blob/main/AUTHORS
System wide configuration file is C:\Users\ac945\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\8.0-arduino.1\etc\avrdude.conf
Using port : COM7
Using programmer : stk500v1
Setting baud rate : 19200
AVR part : ATmega328
Programming modes : SPM, ISP, HVPP, debugWIRE
Programmer type : STK500
Description : Atmel STK500 v1
HW Version : 2
FW Version : 1.18
Topcard : Unknown
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.0 us
XTAL frequency : 7.372800 MHz
AVR device initialized and ready to accept instructions
Device signature = 1E 95 14 (ATmega328)
Auto-erasing chip as flash memory needs programming (-U flash:w:...)
specify the -D option to disable this feature
Erased chip
Processing -U eeprom:w:C:\Users\ac945\AppData\Local\arduino\sketches\6180E284356653BD9DC6AAE361567F04/Blink_IO9.ino.eep:i
Warning: no eeprom data found in Intel Hex file C:\Users\ac945\AppData\Local\arduino\sketches\6180E284356653BD9DC6AAE361567F04/Blink_IO9.ino.eep
Reading 0 bytes for eeprom from input file Blink_IO9.ino.eep
in 0 sections of [0, -1]: 0 pages and 0 pad bytes
Writing 0 bytes to eeprom
Writing | ################################################## | 100% 0.00s
0 bytes of eeprom written
Processing -U flash:w:C:\Users\ac945\AppData\Local\arduino\sketches\6180E284356653BD9DC6AAE361567F04/Blink_IO9.ino.hex:i
Reading 878 bytes for flash from input file Blink_IO9.ino.hex
in 1 section [0, 0x36d]: 7 pages and 18 pad bytes
Writing 878 bytes to flash
Writing | ################################################## | 100% 1.05s
878 bytes of flash written
Avrdude done. Thank you.
This was similar to the result when I successfully programmed an ATMega328P. However, the ATMega328 was not programmed correctly. The Blink.ino sketch which lights an LED for one second and then off for one second was lighting for 7 seconds and off for 7 seconds. ????
I do appreciate all the help I've received from members and feel I'm close to a solution but not quite there yet. Just as an aside, what version of the IDE does every one use?
This is something new to me after 8 years on this forum. As far as I know, the OP is trying to program a standalone 28-pin ATmega328/328P with an UNO R3 as the programmer, which is usually done via standard Arduino IDE 1.x or 2.x.
I concur that the internal clock being set to 1MHz is most likely the explanation. How to proceed depends whether running with a 1MHz or 8MHz clock speed is desired.
To match the current clock setting and run at 1MHZ it should be just a matter of going to Tools -> Clock: and selecting the Internal 1MHz option and then uploading the sketch again. The LED blink timing should then be correct.
To make use of the full 8MHz speed of the internal clock and remove the CKDIV8 throttle, select Tools -> Clock: and select Internal 8MHz. Then burn the booloader as suggested by @david_2018 with the Tools -> Bootloader: No bootloader option first to set the fuse. Once that is done, upload the sketch.
FYI, it is also possible also to set the relevant fuse using avrdude from the command line:
I sure have learned a lot about Arduino over the past week! I hadn't used the command line in decades so a little review was in order. I also took the time to study the data sheet to confirm the lfuse definitions. After installing AvrDude I read the ATMega328 fuse values.
The new chips lfuses were 0x62, Calibrated internal RC Oscillator; CLKDIV8 enabled; Startup at max.
I changed this to 0xA7, CLKDIV8 disabled; CKOUT enabled, Full Swing Crystal Oscillator.
avrdude> sig
Device signature = 0x1e9514
C:\AvrDude>avrdude -c arduino_as_isp -p m328 -PCOM7 -U lfuse:w:0xA7:m
Reading 1 byte for lfuse from input file 0xA7
Writing 1 byte (0xA7) to lfuse, 1 byte written, 1 verified
With the CKOUT enabled I could monitor the clock on pin 14 with a frequency counter.
I now have four of the six ATMega328 chips working; the remaining two chips won't respond to anything. I suspect that these may be defective. Unless anyone has any suggestions as to what else I could try, I'll write them off.