Hello,
I got a new hardware revision of some boards in that have an Atmega328p on them using the internal 8Mhz oscillator. I use an Atmel ICE to upload the program to the 328, and I have had success up until today.
The first thing I have always done when I get a fresh 328 is burn the “ATmegaBOOT_168_atmega328_pro_8MHz.hex” bootloader using the Arduino IDE and the ICE programmer. You can download it here: https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard
I moved from visual micro to PlatformIO to develop for the 328, after a little bit of flailing I got the uploads working and since then everything has been great and I haven’t touched any json files. Now I am working from home on a different machine and I am having a weird problem I’ve never seen before.
I successfully burn the bootloader using the ICE and the Arduino IDE, then I successfully upload my program onto the 328 using the ICE and PlatformIO, and everything works fine, but when I try to upload the program again immediately afterwards I get this error:
avrdude: stk500v2_command(): command failed
avrdude: bad response to AVR sign-on command: 0xa0
avrdude: Target prepared for ISP, signed off.
avrdude: Now retrying without power-cycling the target.
avrdude: stk500v2_command(): command failed
avrdude: bad response to AVR sign-on command: 0xa0
avrdude: Target prepared for ISP, signed off.
avrdude: Now retrying without power-cycling the target.
avrdude: stk500v2_command(): command failed
avrdude: bad response to AVR sign-on command: 0xa0
avrdude: Target prepared for ISP, signed off.
avrdude: Now retrying without power-cycling the target.
avrdude: stk500v2_command(): command failed
avrdude: bad response to AVR sign-on command: 0xa0
avrdude: Target prepared for ISP, signed off.
avrdude: Now retrying without power-cycling the target.
avrdude: stk500v2_command(): command failed
avrdude: bad response to AVR sign-on command: 0xa0
avrdude: Failed to return from debugWIRE to ISP.
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.avrdude done. Thank you.
This is my “platformio.ini”:
[env:My_328p8m]
platform = atmelavr
board = ATMEGA328_8MHz_Supervisor
framework = arduino
upload_protocol = atmelice_isp
upload_flags = -e
My board file:
{
“build”: {
“core”: “arduino”,
“extra_flags”: “-DARDUINO_AVR_MICRODUINO_CORE”,
“f_cpu”: “8000000L”,
“mcu”: “atmega328p”,
“variant”: “standard”
},“frameworks”: [
“arduino”
],“fuses”: {
“efuse”: “0xFD”,
“hfuse”: “0xDA”,
“lfuse”: “0xE2”
},
“name”: “Supervisor_A328_8mhz”,
“upload”: {
“maximum_ram_size”: 2048,
“maximum_size”: 32256
},
“url”: “Microduino-Module Core - Microduino Wiki”,
“vendor”: “Dave”
}
When I first moved over to PlatformIO I found an 8Mhz 328p file (328p8m.json) and set the fuse values in the board file, now I see a section on custom bootloaders in the PlatformIO documentation: Atmel AVR — PlatformIO latest documentation and it says I should have the fuse values in platformio.ini.
Looks like I have some reading to do, but if someone has some time to give me a little guidance, I sure would appreciate it. Thanks!