Close

Death of atmega

A project log for F-35 air vent

An update to a mighty air vent

lion-mclionheadlion mclionhead 10/30/2022 at 18:440 Comments

There was a desire to have the boards all programmed over single wire UART.  The bootloader support on the Atmega328 is described on page 267.  Step 1 is programming the BOOTRST bit to make it boot from a bootloader address instead of 0x0000.  The 4 possible bootloader addresses are given on page 277.

There's no need to indirect the interrupt vectors.  The IVSEL bit in MCUCR relocates the interrupt vectors to the bootloader address.

It's actually impossible to write to flash from a program running outside the bootloader section.  This is a contrast to the PIC which can write anywhere.

The 1st thing lions noticed is the Atmega328 always ignored the value of BOOTRST, would not run anything in bootloader space & only ran programs at 0x0000.  The internet said the program counter was jumping over opcode 0xffff & looping around the memory until it hit the 1st program.  After much playing with this, the chip eventually bricked.  A corrupted DWEN bit, RSTDISBL bit, or clock source bit is the leading cause of bricked atmegas.

The lion kingdom has an Atmel ICE in which the debug menu has a "disable debugwire" option, but it requires adapting a 10 pin connector to the RESET pin.  Helas, Atmel studio only showed a debugwire failure.

An atmega88 scavenged from an RC transmitter similarly failed to program.  It's believed the atmega328 was bricked because it was soldered when it was live.  The atmega88 might have had ISP disabled in the factory.  High voltage programming would be the next step in restoring any of these chips in any case.


High voltage programming of the atmega is also called parallel programming.  There is a big old schematic on page 286 showing what it entails.

A new board would have to be made & the TQFP would have to be resoldered so it's basically a brick.  There would be a finite number of resolderings before a home made TQFP board wore out, but maybe a bunch of TQFP boards could be made.

Despite once being the world's most popular chip, the atmega328 is incredibly prone to bricking compared to a PIC.  It was end of lifed in 2020.  The lion kingdom has a few left from 10 years ago, when they were sold in packs of 10 for pennies.  Most of them have been bricked.

After burning several days on a bootloader & trying to recover dead chips, the decision was made to abandon the bootloader, just have temporary programming headers on the motor controller boards & a permanent header on the brain board.  2 boards are just dumb motor controllers taking in H bridge commands & sending encoder counts.  

An AVR bootloader is much more involved than a PIC bootloader & involves bricking many chips.  The best strategy for a bootloader is to use 2 arduinos to burn bootloaders on each other, capture the flashing commands arduino uses, & modify the arduino bootloader for a single wire serial interface.  

Whether or not they were ever made again, the lion kingdom would not use atmega328's in the future.  It's such a pain to use multiple architectures & development environments.  The only reason anyone does that is to pass job interviews.

Discussions