Author Topic: Bricked atmega 1284 with avrdude! Can it be saved?  (Read 2638 times)

0 Members and 1 Guest are viewing this topic.

Offline belzrebuthTopic starter

  • Frequent Contributor
  • **
  • Posts: 483
  • Country: gr
Bricked atmega 1284 with avrdude! Can it be saved?
« on: October 13, 2022, 04:39:02 pm »
Hi all,
I bricked an atmega 1284 (non p version) by running
Quote
avrdude -c usbtiny -p m1284p -F -U flash:r:merged.hex:i

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9706
avrdude: Expected signature for ATMEGA1284P is 1E 97 05
avrdude: reading flash memory:

Reading | ################################################## | 100% 131.95s



avrdude: writing output file "merged.hex"
avrdude: can't open output file merged.hex: Permission denied
avrdude: write to file 'merged.hex' failed

avrdude: safemode: lfuse changed! Was 62, and is now 0
Would you like this fuse to be changed back? [y/n] y
^C
Then I can't communicate with it.
I get -->  avrdude: Device signature = 0x000000

I know I shouldn't have pressed Ctrl+C but it seemed stuck trying to repair the fuses.
I have a TL866A so I tried reviving the chip by blank programming it to reset the fuses to their original state but it doesn't work either I still get an ID of 0x000000.
The chip is the SMD version so I can't just plug it in the 40P port of the TL866; I've used the ICSP port to try to unbrick it.
I could buy an adaptor if it's necessary for the chip to be in the 40P port to be restored.

Can this chip be saved? I've succesfully restored the fuses of many atmegas using the TL866 I don't know what I'm doing wrong this time.

 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3036
  • Country: us
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #1 on: October 13, 2022, 05:30:52 pm »
An lfuse setting of 0x62 suggests you're using the internal oscillator for the system clock:

http://eleccelerator.com/fusecalc/fusecalc.php?chip=atmega1284p&LOW=62&HIGH=99&EXTENDED=FF&LOCKBIT=FF

Is that right or are you using a crystal for the system clock?

If the lfuse really got set to 0x00 the chip would be expecting an external clock source and that would be needed to program the chip.

Does the TL866 supply that clock or can it be configured to supply that clock?

Note the ICSP programming speed must be <= 1/4 the system clock.

An easy way to provide a clock source to the chip would be to use another microcontroller.

« Last Edit: October 13, 2022, 05:41:34 pm by ledtester »
 

Offline belzrebuthTopic starter

  • Frequent Contributor
  • **
  • Posts: 483
  • Country: gr
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #2 on: October 13, 2022, 06:14:27 pm »
When the device used its internal clock it got recognised by avrdude fine without any ext clock.
It's only after I got it messed up that it stopped responding.

A low fuse set at 0x00 suggests that I should use an EXT clock as per the attachment.
I checked it with an AVR fuse calculator and took a screenshot of what the lfuse means but I don't understand what clock frequency I should use with that setting.
Of course I've tried with 20 and 16 MHz crystals I had lying around but I didn't get it to respond.I have other MCUs and I believe I also have 8MHz and 4MHz crystals as well.

I also have an Arduino I could use as a programmer.

I don't think the TL866 can supply a clock, correct me If I'm wrong.

I recently set an ATMEGA8 to use EXT clock and it stopped communicating but I was very easily able to restore it with the TL866 just be resetting the fuses.
I don't know why I'm not able to do this with the 1284? Perhaps I should use an adapter to place it in the 40P port? Or it doesn't matter?
Is there any foolproof way to just reset everything?
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3036
  • Country: us
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #3 on: October 13, 2022, 06:37:44 pm »
I would proceed on the assumption that lfuse is set to 0x00 and apply an external clock signal (I believe to XTAL1).

Then try ICSP programming with a speed < 1/32 of the applied clock. This takes into account the divide-by-8 prescaler that is set by the lfuse setting.


I recently set an ATMEGA8 to use EXT clock and it stopped communicating but I was very easily able to restore it with the TL866 just be resetting the fuses.
I don't know why I'm not able to do this with the 1284? Perhaps I should use an adapter to place it in the 40P port? Or it doesn't matter?
Is there any foolproof way to just reset everything?

When you plugged the 1284 into the TL866 did you connect the XTAL1 pin?
« Last Edit: October 13, 2022, 06:42:39 pm by ledtester »
 

Offline belzrebuthTopic starter

  • Frequent Contributor
  • **
  • Posts: 483
  • Country: gr
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #4 on: October 13, 2022, 06:49:47 pm »
Do you know what frequency should the clock signal should be?
Provided that the lfuse is 0x00?
I read that the "6CK" is 128KHz?
I don't think I have a 128KHz XTAL only 32,768Hz..
Because I've already tried 16 and 20MHz and the usbtiny can't see the chip via avrdude.
I think I first need to find a way to see the chip and then I could try reducing the programming speed to 1/8.
I also think that the TL866 does serial programming thru its ICSP port and parallel programming via the 40P socket port.
So that may be the reason that I can't just reset it, because reseting it would require a high voltage reset and parallel programming..

 

Offline belzrebuthTopic starter

  • Frequent Contributor
  • **
  • Posts: 483
  • Country: gr
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #5 on: October 13, 2022, 06:55:50 pm »

When you plugged the 1284 into the TL866 did you connect the XTAL1 pin?
I didn't plug it directly I'm only using the ICSP port of the TL866 because the chip is a TQFP-44 package and is already soldered to an otherwise empty PCB.
That PCB has a 6pin header for programming the chip.

I've tried both with a XTAL installed and without but I'm not sure about the frequency.
The PCB has a place for a 20MHz crystal and 2* 18pF capacitors. I tried both 20MHz and 16MHz.
avrdude returns when I try the board with a usbtiny.
Code: [Select]
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.
if the chip is still alive which I believe it's maybe a matter of providing the correct CLK signal for a programmer to be able to see it..
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3036
  • Country: us
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #6 on: October 13, 2022, 08:43:01 pm »

You need the programming speed of the ICSP to be less than your system clock/32.

Try using the option "-B 8" with avrdude. This sets the ICSP bit rate to 125 KHz which will be slow but should work with crystals > 4 MHz.

Quote
-B bitclock
        Specify the bit clock period for the JTAG interface or the ISP
        clock (JTAG ICE only).  The value is a floating-point number in
        microseconds.  The default value of the JTAG ICE results in about
        1 microsecond bit clock period, suitable for target MCUs running
        at 4 MHz clock and above.  Unlike certain parameters in the
        STK500, the JTAG ICE resets all its parameters to default values
        when the programming software signs off from the ICE, so for MCUs
        running at lower clock speeds, this parameter must be specified on
        the command-line.  You can use the 'default_bitclock' keyword in
        your ${HOME}/.avrduderc file to assign a default value to keep
        from having to specify this option on every invocation.
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 14210
  • Country: de
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #7 on: October 13, 2022, 09:21:52 pm »
The most common way to brick an AVR is by setting the fuses to that is expects an external excillator.  In this case one has to provide an external clock to the XTAL1 pin, not just and external resonator.
The external clock also works when the µC is set to a different clock option (e.g. external cystal or ceramic resonator) - not sure of it is OK to still have a cystal present, but probably it work if not resonant.

The exact clock speed does not mater. If slow, the programmer has to be slowed down. Worst case the div 8 fuse is "active" and the clock seen by the µC is only 1/8 of the external clock. So one may have to use a relatively slow speed setting.
 

Offline belzrebuthTopic starter

  • Frequent Contributor
  • **
  • Posts: 483
  • Country: gr
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #8 on: October 13, 2022, 11:37:54 pm »
Shouldn't avrdude see the MCU if any clock source was available?
 Or I specifically need to to slow the programmer down in order  for the programmer to see the chip?
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3036
  • Country: us
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #9 on: October 13, 2022, 11:58:13 pm »
Shouldn't avrdude see the MCU if any clock source was available?
 Or I specifically need to to slow the programmer down in order  for the programmer to see the chip?

The way the programmer "sees" the chip is by sending a message over SPI and sees if it gets a valid response.

If the SPI speed is too fast for the mcu it will not get a valid response back.

« Last Edit: October 14, 2022, 12:08:02 am by ledtester »
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #10 on: October 14, 2022, 12:16:15 am »
IMHO the biggest flaw of the AVR chips has always been the fact that the clock source is needed for programming making it easy to brick. I've done it a few times myself and sometimes it's a real pain to hook up a clock source to get it to do something. The programmer really ought to provide the clock needed at least to configure the onboard oscillator.
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3036
  • Country: us
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #11 on: October 14, 2022, 12:22:28 am »
It is also possible that the high fuse value was mangled and serial programming was disabled.

In that case you'll have to resort to high-voltage programming.

 

Offline belzrebuthTopic starter

  • Frequent Contributor
  • **
  • Posts: 483
  • Country: gr
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #12 on: October 14, 2022, 01:09:21 am »
Code: [Select]
avrdude -c usbtiny -p m1284p -F -B 8 -U flash:r:merged.hex:i

avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
avrdude: Expected signature for ATMEGA1284P is 1E 97 05

avrdude done.  Thank you.

That is with 20MHz crystal attached.
The -F is needed for the 1284 (non-P) to be "recognised".

I may indeed have to resort to high-voltage programming which I guess needs a DIP adapter for the smd chip.
I don't have such an adapter, making a PCB and ordering it will take some time.
If not many connections are required I can get away with soldering a few cables from the chip to go directly to the TL866 socket..
 
 

Offline alm

  • Super Contributor
  • ***
  • Posts: 2881
  • Country: 00
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #13 on: October 14, 2022, 01:54:16 am »
If the clock selection fuses are set to low frequency crystal, then the standard recommendation of feeding a few MHz square wave into XTAL1 may not work. Try hooking up a 32,768 kHz watch crystal per datasheet and see if that helps.

Try a very low programming speed down to the kHz.

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 3025
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #14 on: October 14, 2022, 01:56:32 am »
You were reading from it, not writing to it, it read ok then it went away, there is no reason that the fuses should have changed.

0x00 (fuses, signature) is indicative of a complete failure to communicate.

If it was me, what I would be looking at is a lot more fundamental than a fuse or clock issue.  Check your wiring, voltages, and reset.
~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 14210
  • Country: de
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #15 on: October 14, 2022, 06:27:36 am »
The error message from the start indeed indicates a problem with the communication. It is unlikely that the fuses are changed, though with unreliable communication it is possible by accident.
So it is really about checking the supply (e.g. all pins connected, decoupling caps ?, suitable voltage (e.g. same as the programmer)). Too long cables can also be an issue (especially ringing on the clock line).

Even the low speed crystl setting has a good chance to work with an external clock, especially if not too fast. The main point for the low frequency is a weak drive strength, not to overdrive and possibly damage a 32 kHz crystal.
Providing a clock signal (e.g. 1 MHz) would indeed be a good addition to a programmer.
 

Offline belzrebuthTopic starter

  • Frequent Contributor
  • **
  • Posts: 483
  • Country: gr
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #16 on: October 14, 2022, 10:19:03 am »
Cables are okay.
I buzzed the connections and they all check out.
I would normally buy another chip and make a converter board to save this one but I can't buy another at the moment they re all out of stock for months now.
What connections are required for high voltage programming?!
I could solder 30awg wire from the chip to a couple of 20pin single headers to fit the test socket on my TL866 if not all the pins are needed.
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11653
  • Country: my
  • reassessing directives...
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #17 on: October 14, 2022, 10:41:40 am »
you can also use function generator to feed as external clock, feed at low voltage swing maybe 1Vpp (0-1V square or sine) and then you can play at the ext clock frequency end if its too difficult to configure from programmer end. i think i recovered one bricked AVR this way.
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline belzrebuthTopic starter

  • Frequent Contributor
  • **
  • Posts: 483
  • Country: gr
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #18 on: October 14, 2022, 11:04:20 am »
I have a function generator so I could do that.
But I'm a bit unsure of the pins and whether I should keep the 18pF capacitors.
I guess the capacitors should be removed since there's no loading required, the signal will be accurate enough on its own

Xtal 1 should be signal and XTAL 2 should be GND?
My DG1022z is grounded by default so I think the laptop and programmer should be floating.(on battery mode)
Is that correct?
 

Offline alm

  • Super Contributor
  • ***
  • Posts: 2881
  • Country: 00
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #19 on: October 14, 2022, 11:47:56 am »
Yes, you would remove the capacitors and crystal. Connect the function generator to XTAL1, and the function generator ground to the board ground. Don't connect anything to XTAL2. See figure 9-4 from page 46 of the datasheet:


There shouldn't be a problem with both the programmer and function generator being grounded. There's a small chance of ground loops inducing noise, but I don't think that would be a problem for a 3.3-5V digital system. Just make sure both grounds are connected to the same node in the circuit ;)
« Last Edit: October 14, 2022, 11:51:50 am by alm »
 

Offline belzrebuthTopic starter

  • Frequent Contributor
  • **
  • Posts: 483
  • Country: gr
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #20 on: October 14, 2022, 01:04:49 pm »
Thank you!I will try that later when I'm home and post back.
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12864
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #21 on: October 14, 2022, 02:06:59 pm »
Remove the crystal, or desolder one pin if its through hole.   The caps can stay as the function generator should easily be able to drive a few tens of pF.
 

Offline belzrebuthTopic starter

  • Frequent Contributor
  • **
  • Posts: 483
  • Country: gr
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #22 on: October 14, 2022, 03:18:24 pm »
Okay 1Vpp 128KHz square at pin7 and GND of the fgen to GND of the IC.
Same output on the avrdude console.

Code: [Select]
avrdude -c usbtiny -p m1284p -F

avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
avrdude: Expected signature for ATMEGA1284P is 1E 97 05

avrdude done.  Thank you.

Code: [Select]
avrdude -c usbtiny -p m1284p -F -B 8

avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
avrdude: Expected signature for ATMEGA1284P is 1E 97 05

avrdude done.  Thank you.

 :-//
I also tried 32KHz and -B 4/ 8 options..
I don't know what else to do..
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11653
  • Country: my
  • reassessing directives...
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #23 on: October 14, 2022, 03:34:11 pm »
if the RESETDISABLE fuse is set, then you need high voltage programmer, this thread might give some tips... https://www.avrfreaks.net/forum/reset-disable-preventing-serial-programming with this anomaly, i'll bring up my ISP Mk2 programmer instead of avrdude. your general purpose programmer TL866A + Func Gen may give some more light if you dont have Mk2.. set ISP freq to much slower KHz while clock is in MHz range. disconnect everything from the MCU except programmer, fg (clock) and power supply. ymmv.
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3036
  • Country: us
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #24 on: October 14, 2022, 03:44:58 pm »
I also tried 32KHz and -B 4/ 8 options..
I don't know what else to do..

The -B option is the period of an SPI clock cycle in microseconds. A system clock of 32 KHz has a period of 31 microseconds. The SPI clock period needs to be 4 times that.

Try something like "-B 300". It'll be slow but has a better chance of working.
 

Offline belzrebuthTopic starter

  • Frequent Contributor
  • **
  • Posts: 483
  • Country: gr
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #25 on: October 14, 2022, 04:04:19 pm »
I didn't know about -B option, regardless I still get the same response even with -B 300..
if the RESETDISABLE fuse is set, then you need high voltage programmer, this thread might give some tips... https://www.avrfreaks.net/forum/reset-disable-preventing-serial-programming with this anomaly, i'll bring up my ISP Mk2 programmer instead of avrdude. your general purpose programmer TL866A + Func Gen may give some more light if you dont have Mk2.. set ISP freq to much slower KHz while clock is in MHz range. disconnect everything from the MCU except programmer, fg (clock) and power supply. ymmv.

I have a ISP Mk2 as well. I think it only works with atmel studio tho, I need to change the driver for it or flash it with another firmware.
I used to have the mk2 for the atmel studio (university stuff) and the usbtiny for avrdude (home stuff) and I ended up only using the usbtiny for everything.
I can find  my MK2 if needed no problem.
How do I change the ISP frequency of TL866, I don't see any option for it.
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11653
  • Country: my
  • reassessing directives...
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #26 on: October 14, 2022, 04:32:06 pm »
How do I change the ISP frequency of TL866, I don't see any option for it.
i'm not sure with your tools. but avr (now microchip) studio we can change isp frequency. i have newer TL866II, but i only used it once to read a flash's memory, nothing more. what i know is different adapter is needed to read/progam avr mcu. if all tools/aspects are tried and still failed, maybe its the RESETDISABLE fuse, beyond that, the mcu maybe fried and the fix is $8 ;D... ymmv
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline belzrebuthTopic starter

  • Frequent Contributor
  • **
  • Posts: 483
  • Country: gr
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #27 on: October 14, 2022, 05:06:49 pm »
It's not the $8; it's that they're always backordered and the delivery dates are insane..
I'll see what I can do; I believe it's only a matter of high voltage programming.

It's not my first fail with AVR devices; I've goofed up the fuses a lot of times in the past and it always a DIP package so I revived it without ever messing with all of this.
It was just a matter of plugging it into the TL866 and by hitting "program" with the check ID option unchecked; the fuses were restored and the chip was back to action.
I never tried that procedure with ICSP but apparently it doesn't work.
That's why I'm asking which pins are necessary to perform a high voltage parallel programming; maybe I could just bite the bullet and solder 40 cables in a couple of 20pin headers and be done with it.
More often than not time spent just talking about something is more than the actual time to do it..
 

Offline belzrebuthTopic starter

  • Frequent Contributor
  • **
  • Posts: 483
  • Country: gr
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #28 on: October 14, 2022, 05:47:32 pm »
An update:
I just included -B 123 without any external clock and got this:
Code: [Select]
avrdude -c usbtiny -p m1284p -F  -B 123

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.07s

avrdude: Device signature = 0x1e9706
avrdude: Expected signature for ATMEGA1284P is 1E 97 05

avrdude: safemode: Fuses OK

avrdude done.  Thank you.
:wtf:
 

Offline belzrebuthTopic starter

  • Frequent Contributor
  • **
  • Posts: 483
  • Country: gr
Re: Bricked atmega 1284 with avrdude! Can it be saved?
« Reply #29 on: October 14, 2022, 08:04:29 pm »
The chip now works even with a 20MHz I don't know what was causing this.

I consistenly get this error though :
avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x10000
         0xff != 0xb2
avrdude: verification error; content mismatch

The error stays the same even with a different firmware so I hope it's not a hardware problem...
edit: I tried burning a MightyCore bootloader and it works so the chip is okay. There might be something wrong with the firmware I'm trying to upload.
« Last Edit: October 14, 2022, 08:18:26 pm by belzrebuth »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf