Bricked Atmega328p – kein Oszillator

English Version below

Ich hatte einige Atmegas 328p auf eine Platine gesetzt, ohne ein Oszillator oder Quarz mit einzuplanen. Eigentlich ist es wie ein Arduino auf einem Breadboard. Nun, zunächst sind die Fuses zu setzen und ein Bootloader zu installieren.

Ich habe dazu die Arduino IDE genutzt, einen Arduino Uno als ISP und einen Pro Mini als Target ausgewählt, ein Fehler wie sich herausstellen sollte. Ein Pro Mini hat ein Quarz, der 328p auf meiner Platine nicht. Nun, die Fehlermeldung bei den Fuses / Bootloader war stets:

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
     Double check connections and try again, or use -F to override
     this check.

Mausetot, leider!

Nun, nach einiger Recherche im Internet fand ich heraus, dass der 328p nicht mehr tut, da er ein Quarz erwartet. Aber es gibt Abhilfe. Man muss ein Signal auf XTAL1 geben um ihn wiederzubeleben.

Ich habe einen alternativen Arduino ISP Script von https://github.com/adafruit/ArduinoISP heruntergeladen und auf den Arduino Uno als ISP geladen. Dieser Script hat den Vorteil, dass auf PIN 9 ein Clock Signal ausgegeben wird. Dieses Signal habe ich dann auf den Target Atmega 328p XTAL1 mittels eines Kabels gesetzt. Ansonsten habe ich die übliche Verdrahtung gewählt:

Arduino UNO328p
D10Reset
D11MOSI
D12MISO
D13SCK
5V5V
GNDGND

Dann habe ich die Fuses so gesetzt, dass er mit internem Taktgeber läuft.



C:\Users\xxxxx>C:\Users\xxxxx\Downloads\arduino-1.8.13\hardware\tools\avr/bin/avrdude -CC:\Users\xxxxx\Downloads\arduino-1.8.13\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -PCOM4 -b19200 -U lfuse:w:0xE2:m -U hfuse:w:0xD2:m -U efuse:w:0xFF:m -v

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\xxxxx\Downloads\arduino-1.8.13\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM4
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

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

         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.04s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: safemode: lfuse reads as E2
avrdude: safemode: hfuse reads as D2
avrdude: safemode: efuse reads as FF
avrdude: reading input file "0xE2"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xE2:
avrdude: load data lfuse data from input file 0xE2:
avrdude: input file 0xE2 contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file "0xD2"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xD2:
avrdude: load data hfuse data from input file 0xD2:
avrdude: input file 0xD2 contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xFF"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xFF:
avrdude: load data efuse data from input file 0xFF:
avrdude: input file 0xFF contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of efuse verified

avrdude: safemode: lfuse reads as E2
avrdude: safemode: hfuse reads as D2
avrdude: safemode: efuse reads as FF
avrdude: safemode: Fuses OK (E:FF, H:D2, L:E2)

avrdude done.  Thank you.

Fantastisch! Es hat geklappt. Das Kabel von PIN 9 konnte nun entfernt werden. Der 328p läuft nun mit internen Taktgeber. Dann schnell den Bootloader noch drauf.


C:\Users\xxxx\Downloads\arduino-1.8.13\hardware\tools\avr/bin/avrdude -CC:\Users\xxxxx\Downloads\arduino-1.8.13\hardware\tools\avr/etc/avrdude.conf -v -P COM4 -cstk500v1 -patmega328p -b 19200 -e -U flash:w:C:\Users\xxxx\Downloads\arduino-1.8.13\hardware\breadboard\avr\bootloaders\atmega\ATmegaBOOT_168_atmega328_pro_8MHz.hex:i

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\xxxx\Downloads\arduino-1.8.13\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM4
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

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

         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.05s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: safemode: lfuse reads as E2
avrdude: safemode: hfuse reads as D2
avrdude: safemode: efuse reads as FF
avrdude: erasing chip
avrdude: reading input file "C:\Users\xxx\Downloads\arduino-1.8.13\hardware\breadboard\avr\bootloaders\atmega\ATmegaBOOT_168_atmega328_pro_8MHz.hex"
avrdude: writing flash (32652 bytes):

Writing | ################################################## | 100% 0.08s

avrdude: 32652 bytes of flash written
avrdude: verifying flash memory against C:\Users\xxxx\Downloads\arduino-1.8.13\hardware\breadboard\avr\bootloaders\atmega\ATmegaBOOT_168_atmega328_pro_8MHz.hex:
avrdude: load data flash data from input file C:\Users\xxxx\Downloads\arduino-1.8.13\hardware\breadboard\avr\bootloaders\atmega\ATmegaBOOT_168_atmega328_pro_8MHz.hex:
avrdude: input file C:\Users\xxxx\Downloads\arduino-1.8.13\hardware\breadboard\avr\bootloaders\atmega\ATmegaBOOT_168_atmega328_pro_8MHz.hex contains 32652 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.09s

avrdude: verifying ...
avrdude: 32652 bytes of flash verified

avrdude: safemode: lfuse reads as E2
avrdude: safemode: hfuse reads as D2
avrdude: safemode: efuse reads as FF
avrdude: safemode: Fuses OK (E:FF, H:D2, L:E2)

avrdude done.  Thank you.

Fantastisch. Damit war der 328p wiederbelebt und konnte nun den eigentlichen Script aufnehmen.

English Version

I had put some Atmegas 328p on a board without including an oscillator or crystal. Actually, it’s like an Arduino on a breadboard. Well, first the fuses have to be set and a bootloader installed.

I used the Arduino IDE for this, selected an Arduino Uno as ISP and a Pro Mini as target, a mistake as it should turn out. A Pro Mini has a crystal, the 328p on my board does not. Well, the error message on the fuses / bootloader was always:

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
     Double check connections and try again, or use -F to override
     this check.

Completely dead, unfortunately!

Well, after some research on the internet, I found out that the 328p doesn’t do more, expecting a quartz. But there is a workaround. You have to put a signal on XTAL1 to revive it.

I downloaded an alternative Arduino ISP script from https://github.com/adafruit/ArduinoISP and loaded it onto the Arduino Uno as an ISP. This script has the advantage that a clock signal is output on PIN 9. I then put this signal on the Target Atmega 328p XTAL1 using a cable. Otherwise I chose the usual wiring:

Arduino UNO328p
D10Reset
D11MOSI
D12MISO
D13SCK
5V5V
GNDGND

Then I set the fuses so that it runs with internal clock.





C:\Users\xxxxx>C:\Users\xxxxx\Downloads\arduino-1.8.13\hardware\tools\avr/bin/avrdude -CC:\Users\xxxxx\Downloads\arduino-1.8.13\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -PCOM4 -b19200 -U lfuse:w:0xE2:m -U hfuse:w:0xD2:m -U efuse:w:0xFF:m -v

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\xxxxx\Downloads\arduino-1.8.13\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM4
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

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

         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.04s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: safemode: lfuse reads as E2
avrdude: safemode: hfuse reads as D2
avrdude: safemode: efuse reads as FF
avrdude: reading input file "0xE2"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xE2:
avrdude: load data lfuse data from input file 0xE2:
avrdude: input file 0xE2 contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file "0xD2"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xD2:
avrdude: load data hfuse data from input file 0xD2:
avrdude: input file 0xD2 contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xFF"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xFF:
avrdude: load data efuse data from input file 0xFF:
avrdude: input file 0xFF contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of efuse verified

avrdude: safemode: lfuse reads as E2
avrdude: safemode: hfuse reads as D2
avrdude: safemode: efuse reads as FF
avrdude: safemode: Fuses OK (E:FF, H:D2, L:E2)

avrdude done.  Thank you.


Fantastic! It worked. The cable from PIN 9 could now be removed. The 328p is now running with internal clock. Then quickly put the bootloader on it.



C:\Users\xxxx\Downloads\arduino-1.8.13\hardware\tools\avr/bin/avrdude -CC:\Users\xxxxx\Downloads\arduino-1.8.13\hardware\tools\avr/etc/avrdude.conf -v -P COM4 -cstk500v1 -patmega328p -b 19200 -e -U flash:w:C:\Users\xxxx\Downloads\arduino-1.8.13\hardware\breadboard\avr\bootloaders\atmega\ATmegaBOOT_168_atmega328_pro_8MHz.hex:i

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\xxxx\Downloads\arduino-1.8.13\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM4
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

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

         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.05s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: safemode: lfuse reads as E2
avrdude: safemode: hfuse reads as D2
avrdude: safemode: efuse reads as FF
avrdude: erasing chip
avrdude: reading input file "C:\Users\xxx\Downloads\arduino-1.8.13\hardware\breadboard\avr\bootloaders\atmega\ATmegaBOOT_168_atmega328_pro_8MHz.hex"
avrdude: writing flash (32652 bytes):

Writing | ################################################## | 100% 0.08s

avrdude: 32652 bytes of flash written
avrdude: verifying flash memory against C:\Users\xxxx\Downloads\arduino-1.8.13\hardware\breadboard\avr\bootloaders\atmega\ATmegaBOOT_168_atmega328_pro_8MHz.hex:
avrdude: load data flash data from input file C:\Users\xxxx\Downloads\arduino-1.8.13\hardware\breadboard\avr\bootloaders\atmega\ATmegaBOOT_168_atmega328_pro_8MHz.hex:
avrdude: input file C:\Users\xxxx\Downloads\arduino-1.8.13\hardware\breadboard\avr\bootloaders\atmega\ATmegaBOOT_168_atmega328_pro_8MHz.hex contains 32652 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.09s

avrdude: verifying ...
avrdude: 32652 bytes of flash verified

avrdude: safemode: lfuse reads as E2
avrdude: safemode: hfuse reads as D2
avrdude: safemode: efuse reads as FF
avrdude: safemode: Fuses OK (E:FF, H:D2, L:E2)

avrdude done.  Thank you.

Fantastic. With that, the 328p was revived and could now take up the actual script.

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden /  Ändern )

Google Foto

Du kommentierst mit Deinem Google-Konto. Abmelden /  Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden /  Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden /  Ändern )

Verbinde mit %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Nach oben ↑

%d Bloggern gefällt das: