Search code examples
arduino-unoavrdude

Can't program Arduino 328P after first time use of ICSP Sparkfun AVR Pocket Programmer


I needed to change my Brown Out Voltage to 4.3V from the Arduino default. I purchased from Sparkfun the AVR Pocket Programmer and connected as instructed. I have an Arduino 328P with CC3000 wifi shield. All worked perfectly before ICSP fuse change. My default fuse settings as read successfully using the AVRDude cmd,

avrdude -c usbtiny -p atmega328p was H=05, L=FF, E=DE.

I ran the following cmd to change on the BOD setting to 4.3,

avrdude -c usbtiny -p atmega328p -U lfuse:w:0xff:m -U hfuse:w:0x05:m -U efuse:w:0xfc:m as instructed using the Engbedded AVR Fuse Calculator. This appeared to run successfully. I was completely unable to program my board after this and could not run the avrdude -c usbtiny -p atmega328p without getting an initialization failed, rc=-1 error.

Killing me too as I was a hair away from launching my project to an organic farm for the first phase of an innovative irrigation control system.


Solution

  • Hopefully the problem is your connections. Check you connections, and if they isn't the problem, you have some work to do:

    After alooked at your fuses, I searched a few things up and saw this. The default fuse values are:

    • Low Fuse 0xFF
    • High Fuse 0xDE
    • Extended Fuse 0x05

    You mixed up your fuses above. I used AtmelStudio to check what your fuses would do:

    avrdude -c usbtiny -p atmega328p -U lfuse:w:0xff:m -U hfuse:w:0x05:m -U efuse:w:0xfc:m
    

    This would change the RSTDISBL value and enable RSTDISBL. According to the datasheet, doing this will

    Setting the reset disable fuse will cause JTAG and ISP programming to stop working. Can only be unset with high-voltage programming

    By doing this, you bricked your chip. Now, you would want to undo this. The only way you could do this for cheap without buying a fancy STK500 is to buy a new Atmega328p or to use another Arduino Uno to use high-voltage programming to completely erase your bricked one.

    In order to do this, follow this tutorial to erase your chip. This tutorial uses a perfboard, but you can do the same exact thing on the breadboard.

    Now once you erase your bricked Arduino, you have to put the correct fuses.

    The default ones are:

    • Low Fuse 0xFF
    • High Fuse 0xDE
    • Extended Fuse 0x05

    Now, you want to change the Brown-out Voltage to 4.3V right? Using AtmelStudio, once again, I have come up with the following fuses:

    • Low Fuse 0xFF
    • High Fuse 0xDE
    • Extended Fuse 0x04

    Once you program this, you should have a working Arduino!

    If you need to program the Arduino using the Arduino software by USB, not by the AVR programmer, you will have to program the bootloader. Reply if you need help with that. That said, if you will always be using the AVR programmer from now, the bootloader may not be necessary.

    This will fix your problem and make your brown-out voltage correct!

    Always triple check your fuses using something like AtmelStudio, because you could end up doing a lot of extra work like in this case.