May Have Bricked ATmega328p. Unable to Burn Bootloader but Continues to Run User Code

I think I've bricked my ATmega328p. I was working on a custom bootloader and was able to write it to the chip; however, I needed to change the fuse settings to ensure my bootloader would fit properly. I was also running into a problem where AVRDUDE was erasing my user code when I uploaded the bootloader.

I mistakenly copied an AVRDUDE command into my terminal to increase my bootloader size. What ended up happening was that I couldn't upload my bootloader anymore. In fact, I am unable to communicate at all with the chip.

I've hooked up the chip to another Arduino to use as "Arduino as ISP". When I turn on the programmer and the target turns on as well, the "bricked" target chip actually runs my previous user code, which was to blink the onboard LED (PB5) rapidly. As soon as I initiate a "burn bootloader," the LED instantly stops blinking, and the chip seems to halt until I disconnect and reconnect the USB cable back into the programmer.

I thought it may be a clock issue, so I jerry-rigged a crystal oscillator, but when I went to burn a bootloader, it just stopped working (I can tell because my blinking LED stopped in its last on or off state). I also used a spare STM32 to generate a ~2MHz square clock; it halts as well. To ensure it wasn't a wiring issue, I took the chip out of the (clone) Arduino socket and used a breadboard to program it. I used spare LEDs to visualize the ISP connection. It was clear that the programmer sent a MOSI, but the target was not returning a MISO.

I'm running out of ideas. However, I'm dedicated to fixing this chip is because it is still able to run my previous user code properly (blinking led rapidly). But it simply doesn't want to communicate through ISP. Anyone have any ideas on how I can go about saving this chip?

References I looked through, but to no avail:

Images of my current setup:

Crystal Oscillator (jerry-rig)

STM32 square clock

Typical AVRDUDE command output:

PS C:\Users\me> avrdude -c arduino -p m328p -P COM5 -n -b 19200 -v

avrdude: Version 7.2
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

         System wide configuration file is C:\Users\me\scoop\apps\avr-gcc\current\bin\avrdude.conf

         Using Port                    : COM5
         Using Programmer              : arduino
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : possible i/o
         RETRY pulse                   : SCK
         Serial program mode           : yes
         Parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom                 65    20     4    0 no       1024    4      0  3600  3600 0x00 0x00
           flash                  65    10   128    0 yes     32768  128    256  4500  4500 0x00 0x00
           lfuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           hfuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           efuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           lock                    0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           signature               0     0     0    0 no          3    1      0     0     0 0x00 0x00
           calibration             0     0     0    0 no          1    1      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino for bootloader using STK500 v1 protocol
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x000000 (retrying)
avrdude: device signature = 0x000000 (retrying)
avrdude: device signature = 0x000000
avrdude main() error: Yikes!  Invalid device signature.
avrdude main() error: expected signature for ATmega328P is 1E 95 0F
        Double check connections and try again, or use -F to override
        this check.


avrdude done.  Thank you.

You may have set the fuses such that it can't be programmed via ISP any more. Once you have done that, in order to change the fuses back to normal you would need to use high voltage programming. Here's an old post of mine about high voltage programming using another working Arduino, transistor, a lot of patience and wire, and a 12v battery. https://www.instructables.com/HV-Rescue-Simple/
It's been a while since I've posted here, when I was posting before there were a bunch of Instructables haters here, so sorry about that guys, I like Instructables. :slight_smile:

Unfortunately on an Atmega 328p a simple High voltage programmer won't suffice, you would need a parallel programmer. There are a lot more connections involved in that compared to a simple High-voltage programmer that can be used for AtTiny chips, which just require 12v and the SPI pins.

I thought i had a good link for it, but i can't find it now, i keep ending up with this tutorial and there is the datasheet where from page 347 onwards there is some form of explanation.

When i was busy with the ATtiny13 and it's High-voltage programmer (to use the reset pin and re-enable it thereafter) I did look into it, but considered it to complicated.

Ah found it !!

from this thread

The fuse calculator you already have i suppose

How do you do that ask another LLM?

Some are good, some are bad. Many posted projects contained errors, some projects got modified afterwards and did no longer correspond with the original post, resulting in links providing different information than the original.

Parallel programming = high voltage programming

eh well yes, but 'high voltage programming' isn't always 'Parallel programming'

Are you saying that "high voltage programming" can also be serial?

Atmel MCUs implement only one high-voltage programming method (either parallel or serial) based on the device’s architecture. This is not a selectable option; the supported method is defined in the datasheet. For instance, the ATmega328P supports high-voltage parallel programming, while the ATtiny85 supports high-voltage serial programming due to its limited number of pins. Always refer to the device’s datasheet for the exact wiring and signal requirements.

If you still have your Arduino as ISP setup, you might try AVRDudess, a Windows program by Zak Kemble, and see if it can read the existing fuse settings. It's basically a front end for AVRDude, so it may not work if you couldn't get AVRDude to work. But if it can just read the fuses, then it probably can also just change the fuses if needed.

https://blog.zakkemble.net/avrdudess-a-gui-for-avrdude/

Thank you, I looked into HV Programming earlier, but I didn't know if it was something I could do DIY at home on a breadboard. I'll try to replicate your design in the Instructable.

Getting access to a 12V power supply might be challenging. I'll see if I can connect some Duracells in series or something. I'm hoping HVP doesn't draw a huge amount of current.

Almost anything will do and if it exceeds 12v by a bit, up to 15v is still Ok. (i think the minimum is 10v ?) The current is 12v / 1000 Ohm = 12mA when using a 1K pullup as in the schematic. (fairly sure a bigger pullup will also work btw) I ended up making a circuit that uses a MT3608 step up converter, batteries will work as well (keep in mind it's inverted logic. the current will flow when the upload isn't in the process of resetting the chip) or any 12v PSU, which shares GNFD with the rest of the schematic.

That was actually the one i was looking for and found in the end, didn't see you had posted that already.

I think that has been answered already.

Nice, I ended up finding an old barrel 12V AC adapter. I have a barrel adapter with terminal leads, which seems to be outputting a solid 12V (as indicated by a multimeter). I'll have to wait until later in the week to build the HVP circuit because I needed to order the 2N3904 transistor.

I'll update here once I build it.

It's really a more or less generic NPN transistor. A BC547 will work as well as quite a few other ones.

Simply brilliant! And I didn't even break a sweat! Your instructable worked on the first try. Turns out the culprit fuse was RSTDISBL. I accidentally disabled the external reset, which explains why I couldn't upload code or get the square wave clock working. Thank you!

Some victory photos:

HV Rescue Setup:

Fixing Fuses:

Burning Bootloader: