ATMega328 bricks after programming

USB AVR Programmer and SPI interface. Adafruit's USBtinyISP.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
kd6kca
 
Posts: 14
Joined: Sat Dec 17, 2016 6:39 pm

ATMega328 bricks after programming

Post by kd6kca »

After programming an ATMega328P with my (brand new) USBTinyISP the ATMega becomes bricked.
I get "initialization failed, rc=-1".
I'm programming a simple LED blink on SCK with AVRDudeSS (AVRDude 6.3), and I'm using Windows 10.
The LED blinks just fine with the correct blink rate after programming.
The driver loaded right up using the "adafruit_drivers.exe" program without any problem.
I'm using the internal RC oscillator @ 8 Mhz with no CLKOUT and no divisor..
I can read the AVR as much as I like until I program it, then it appears bricked.
I have jumpers across R4 and R7 in the USBTinyISP, it has a buffer so I assume it's the latest version.
And I tried the -B 32, and -B250 options.
I have the power jumper out of the USBTinyISP, and I have 5V applied to the AVR.
I tried connecting a 20 Mhz oscillator to the bricked AVR while programming, no luck.

Fuses follow:
All lock bits unchecked "1" (0x3E)
CKDIV8 = 1, CKOUT = 1, SUT1 = 1, SUT0 = 0, CLKSEL = 0010 (0xE2)
RSTDISBL = 0, DWEN = 1, SPIEN = 0, WDTON = 1, EESAVE = 1, BOOTSZ1 = 1, BOOTSZ0 = 1, BOOTRST = 1 (0x5F)
BODLEVEL2 = 1, BODLEVEL1 = 1, BODLEVEL0 = 1 (0xFF)
(HEX values reported by AVRDudeSS)

I'm running out of AVRs here and can sure use some help,
1 AVR = 1 try at programming.
I'm gonna make a parallel programmer with a PIC (yes I said PIC) with just Erase Device, and fuse default burn functions (an unbricker).

Has anyone else had this problem?
This never happened with my bit banger programmer (but man is it slow!!!).
I'll try the bit banger just to see if I can read the AVR after bricking.
As far as I can see the AVR shouldn't be bricked.

Ed

User avatar
russell 27
 
Posts: 242
Joined: Thu Sep 12, 2013 3:59 pm

Re: ATMega328 bricks after programming

Post by russell 27 »

Most of the time I set bit 6 and 7 to 1 and bit 5 to 0. Never had a problem. Actually you should be able to use, SPIEN only. 0xDF for high fuse.

I'd say you want RSTDISBL set to 1

User avatar
kd6kca
 
Posts: 14
Joined: Sat Dec 17, 2016 6:39 pm

Re: ATMega328 bricks after programming

Post by kd6kca »

Are those bits (5, 6 ,7) all in the high fuse byte?
If the chip is bricked (I can't read it after programming) I'll need a parallel unbricker.
Am I actually disabling SPIEN somehow?
That should be the only way to brick the chip.
I'll try setting bit 7 to 1. (0xDF)
Nope, still won't talk to the previously programmed AVR.

But with RSTDISBL = 1, and BOOTSZ1 = 0, and BOOTSZ0 = 0 (H = 0xD9, L = 0xE2, E = 0xFF, lock bits 0x3F) I can read my last new AVR after programming (not bricked).
I read the fuses in my last new ATMega328P and used those values except I set CKDIV8 = 1
But still can't read the bricked parts.
Any thoughts on that?
I never disabled SPIEN.
I can't see why the parts got bricked.
Shure would be nice to know what I did so I don't do it again.
Could it be some kind of firmware flaw in the programmer that disables SPIEN with the fuse settings I had?

Anyway I'm happy that my last part works ok.
But I bricked a bunch of AVRs and all my Pro Mini's and my Nano trying to figure this out.
Now I have 1 ATMega238P and 2 ATMege16A's that are still ok.

Fuses are so 80's.
I like AVRs but fuses not so much (not a fan of fuses).
An unbricker seems like a necessary tool to have in the tool box.

I have a SI4735 radio project based on a "radio operating system" I created.
That's what I want to use the ATmega328 chips for.
So my code can be used in an Arduino.
I use Great Cow Basic to compile my projects.
It supports almost all 8 bit PIC and AVR parts with almost no code changes.
My radio OS will support any radio hardware I want to put in it.
I'm putting a transmitter in after the SI4735 "BIOS" code is done.
My first HF rig will be totally my own design.
Way cool.

Just a heads up on what I'm doing.
Film @ 11
Ed

User avatar
russell 27
 
Posts: 242
Joined: Thu Sep 12, 2013 3:59 pm

Re: ATMega328 bricks after programming

Post by russell 27 »

Take a look at this fuse calculator. Fuses are nothing more than chip configuration settings. PIC micro controllers have the same type of configuration settings, just defined differently. Some prefer the way AVR config settings can be easily accessed. If you noticed from the calculator, there are four distinct bit word configuration settings (fuses) for ATmega 328P. LOW - HIGH - EXTENDED - LOCK. Believe me I've set the wrong config settings before. Most low voltage programmer communication problems occur from spien bit, or clock bit being set wrong. A high voltage communication device I built to reset the fuses, called ATmega fuse bit Doctor . A DIY project designed by a fellow from Poland. If you have interest I could try and elaborate on the version I built. Does the job well.

User avatar
kd6kca
 
Posts: 14
Joined: Sat Dec 17, 2016 6:39 pm

Re: ATMega328 bricks after programming

Post by kd6kca »

Now I got it!!
The link to the fuse calculator had the information.
It must have been RSTDISBL, I had that enabled as I wasn't using reset.
I don't use debug wire, but apparently that fuse also can brick.
And of course the SPIEN will always brick.

That's what I needed to know, never disable reset.

Thanks a bunch, now to fix my bricked parts.

Ed

User avatar
russell 27
 
Posts: 242
Joined: Thu Sep 12, 2013 3:59 pm

Re: ATMega328 bricks after programming

Post by russell 27 »

Amazing how important one bit is huh. Excellent.

User avatar
kd6kca
 
Posts: 14
Joined: Sat Dec 17, 2016 6:39 pm

Re: ATMega328 bricks after programming

Post by kd6kca »

Yup.
PIC uses a similar method of serial programming, but with a high voltage reset signal.
So no configuration will brick the part.
I think AVR started out as OTP, then UV erase.
So that's why they have "fuses".
They just made them re-programmable.
So the part can't distinguish between a reset and a programming cycle.
Just have to be careful.

Before this I used ATmega16A's.
They don't have the RSTDISBL, in fact they don't have an E fuse.
So never had the problem before.

Thanks
Happy Santa Day
Ed

Locked
Please be positive and constructive with your questions and comments.

Return to “USBtinyISP”