I'd like to know what went wrong

Hello,

Do you also hate the feeling when something went wrong, but you don't know what exactly happened? Here's the short story:

I uploaded the standard Blink.ino sketch on an ATMega328P using a breadboard and Arduino as ISP in Arduino IDE.
The led blinked very slowly, so I figured the chip was running on the factory clock setting of 8Mhz/8 = 1MHz. After that I tried uploading the bootloader. The process failed. Since then I can no longer communicate to the chip. (Yikes, invalid signature, check connections...)

Can anyone tell me if I did something wrong?

Also, the chip was given to me sitting on an old Arduino NG board, which doesn't use the 328P (as far as I know), that's why i tried it on a breadboard. Could the chip be damaged and did I just get lucky uploading the one program?

I'm clueless and I hate it :slight_smile:

UPDATE

The board is a VMA101 Atmega2560 mega development board.

Connections (328P --> 2560):

white - RESET (1) --> PIN 10
red - Vcc (7) --> Vcc on ICSP
black - GND (8) --> GND on ICSP
yellow - SCK (19) --> SCK on ICSP
brown - MISO (18) --> MISO on ICSP
green - MOSI (17) --> MOSI on ICSP

the ceramic cap is 100n (Vcc to GND)
the electrolytic cap is 4.7u (RESET to GND)

Arduino IDE v1.8.19 on linux with following settings:

Board: "Arduino Duemilanove or Diecimila"
Processor: "ATmega328P"
Port: "/dev/ttyACM0 (Arduino Mega or Mega 2560)"
Programmer: "Arduino as ISP"

When I "upload using programmer", avrdude says:

Arduino: 1.8.19 (Linux), Board:"Arduino Duemilanove or Diecimila, ATmega328P"

De schets gebruikt 924 bytes (3%)  programma-opslagruimte. Maximum is 30720 bytes.
Globale variabelen gebruiken 9 bytes (0%) van het dynamisch geheugen. Resteren 2039 bytes voor lokale variabelen. Maximum is 2048 bytes.
/home/user/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude -C/home/user/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf -v -patmega328p -cstk500v1 -P/dev/ttyACM0 -b19200 -Uflash:w:/tmp/arduino_build_775667/Blink.ino.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 "/home/user/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf"
         User configuration file is "/home/user/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyACM0
         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.02s

avrdude: Device signature = 0x000000 (retrying)

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

avrdude: Device signature = 0x000000 (retrying)

Er is een fout opgetreden bij het uploaden van de schets
Reading | ################################################## | 100% 0.02s

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


avrdude done.  Thank you.



Dit rapport zou meer informatie bevatten met
"Uitgebreide uitvoer weergeven tijden compilatie"
optie aan in Bestand -> Voorkeuren.

I also just ran this command in terminal (please, don't ask why :upside_down_face: ):
UPDATE2 (ran this again with Vcc disconnected from the chip and got identical output, so probably rubbish)

avrdude -v -F -V -c stk500v1 -p m328p -P /dev/ttyACM0 -b 19200 -U flash:r:flash_backup.hex:i

avrdude says:

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

         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/home/user/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyACM0
         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.02s

avrdude: Device signature = 0x000000 (retrying)

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

avrdude: Device signature = 0x000000 (retrying)

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

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
avrdude: Expected signature for ATmega328P is 1E 95 0F
avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: reading flash memory:

Reading | ################################################## | 100% 20.47s

avrdude: writing output file "flash_backup.hex"

avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done.  Thank you.

This does output a hexfile, containing mostly 0's.

1 :200000000000000000000000000000000000000000000000000000000000000000000000E0
2 :200020000000000000000000000000000000000000000000000000000000000000000000C0
3 :200040000000000000000000000000000000000000000000000000000000000000000000A0
3 :20006000000000000000000000000000000000000000000000000000000000000000000080
4 :20008000000000000000000000000000000000000000000000000000000000000000000060

...

1022 :207FA0000000000000000000000000000000000000000000000000000000000000000000C1
1023 :207FC0000000000000000000000000000000000000000000000000000000000000000000A1
1024 :207FE000000000000000000000000000000000000000000000000000000000000000000081
1025 :00000001FF

Did I successfully read the flash or did I just get rubbish?

Please provide a diagram.

Also some clear photots showing the wiring and component placement may be helpful.

@er_name_not_found @groundFungus

Hi guys,
I really appreciate your interest.
I posted an update with additional info. I hope this can give you a clue on where to go next...

If I posted irrelevant info, please tell me what to remove.
If you need more info, tell me what to add.
If I shouldn't tag you, also let me know. I don't want to be annoying.

To make this somewhat concrete: let's try to upload that blinky again?
Preferably using the my current 'setup'.

Big thanks in advance!

This is not good, right? Should I bother hooking up and external clock or is this something you need an HVPP for to reset the fuses. Or should I not use these words and just wait for the pro's? I'm tier 0...

Also, I am reading this thread I try hardest to answer a post when and now I'm terrified :smiley:

Don't worry about that, it's for old salts to vent.

Your post is looking good so far.

You really want at least a minimum circuit for your 328:


You can program it while it's in this circuit too.

1 Like

Hey, thanks for the input.
I'd have to desolder the crystal from the NG board I have to accomplish this circuit.
Would it be a good idea to put the chip back on the NG board and try programming through the icsp header instead of using a breadboard?
I was gonna try that last night, but I got tired and went to bed and honestly I forgot to try this today...
I'll try both and update...

Sounds like a good idea, but what is an NG board?


Some kind of old arduino board that used the atmega8 or atmega168, I can't find much about these myself and I don't know if many of these were made...
You can see the build-in led is not installed between GND and PIN13 but it has an internal 1k on PIN13.
When I put the chip in it blinked the led, before it went haywire...

Woah, careful with that thing, it's an antique.
I think that's meant for a 168.

I'd search "Uno Dip" on ebay and buy an Uno for that, or I'd buy the few components necessary to make the circuit I showed above.

If you desolder the clock, the pins might not be long enough to use with a breadboard.

That is a very good point you made there, and indeed, my brother told me to take care of this when he gave it to me a couple years ago.
I never got it working and just had it laying around until i started thinkering with an at85 recently.

This did the trick :smiley: and it blinks at the right speed now. Thanks for thinking along @er_name_not_found :pray:

Still don't know what went wrong, though...
But hey, I got a working chip now to figure that out.

Thanks again!

One more question:

How did you know a 16MHz clock would work? Because I think it ran on the internal clock when I first uploaded the sketch, it was running a lot slower on the same NG board.

You said it was a 328, check out the datasheet

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
avrdude: Expected signature for ATmega328P is 1E 95 0F
avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: reading flash memory:

Something with all fuses being zero and table 9-15 on page 44? Not sure...

That's a new one on me.
A more experienced used will be able to help, I'm sure.
Deselect the solution so others know to check out the thread.

1 Like

When you burn an UNO/Nano bootloader it is going to set the chip fuses to use a crystal or resonator. If you don't have a crystal or resonator (you didn't) the processor clock won't run and you can't do serial programming (like Burn Bootloader or Upload Using Programmer). The target processor system clock has to be running and at least four times as fast as the programmer clock.

Once you put the chip in a board with a crystal the system clock was able to run and serial programming was again possible.

Another way around the problem is to inject an external clock to the XTL1 pin. Adafruit produced an "ArduinoISP" sketch that generated an 8 MHz clock on Pin 9 to allow programming of UNO/Nano chips without a crystal.

1 Like

Thank you for the information @johnwasser!

So to conclude:
The bootloader did upload successfully. This switched the internal factory-set clock to an external clock that I needed to connect in order to program again.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.