Reloading Bootloader on Nano with ATmega168PA Processor

My Nano board has an ATmega168PA processor.

The Arduino framework for the Arduino Nano ATmega168 is expecting the device ID of 0x1E9406.

Sadly my ATmega168PA processor generated a device ID of 0x1E940B.

It normally doesn’t matter as once loaded, the bootloader returns the expected 0x1E9406 device ID to keep AVRDUDE happy during subsequent program loads.

But if you need to re-load the bootloader (using Arduino as ISP) this will fail because of the device ID mismatch.

The solution is to locate the avrdude.conf being used. There were many instances of this on my PC so I checked

'Show verbose output during upload’

in the Arduino IDE File | Preferences menu and had a look to see where it was pulling this file from:
C:\Users\Peter\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17\etc

Edit the ATMEGA168 entry to temporarily modify the expected device ID.

signature = 0x1e 0x94 0x06; <- the default ID of an ATmega168
signature = 0x1e 0x94 0x0b; <- the device ID of the ATmega168PA

You should now be able to Burn Bootloader via an Arduino as ISP.

Remember to edit the file back again.

Proof is you can now connect to the USB port and use bootloader to upload a program directly.

1 Like

can you show the complete output of avrdude?

Sure thing but now I have reloaded my bootloader it all looks normal. When I tried to Burn Bootloader before, AVRDUDE was at least flagging the device ID error. I'll level with you, I measured the device ID being generated using Studio 7 connected via a Pololu USB AVR Programmer using the ISP 6 pin header on the Nano - it can handle ATmega168P processors but doesn't have a nice Arduino wrapper round stuff.

Here you go - uploading a classic Blinky sketch using the bootloader via USB port (note the device ID is back at 0x1e9406):

Sketch uses 924 bytes (6%) of program storage space. Maximum is 14336 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 1015 bytes for local variables. Maximum is 1024 bytes.
C:\Users\Peter\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\Peter\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -patmega168 -carduino -PCOM6 -b19200 -D -Uflash:w:C:\Users\Peter\AppData\Local\Temp\arduino_build_730263/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 "C:\Users\Peter\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM6
         Using Programmer              : arduino
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega168
         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        512    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     16384  128    128  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 : Arduino
         Description     : Arduino
         Hardware Version: 2
         Firmware Version: 1.16
         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.00s

avrdude: Device signature = 0x1e9406 (probably m168)
avrdude: reading input file "C:\Users\Peter\AppData\Local\Temp\arduino_build_730263/Blink.ino.hex"
avrdude: writing flash (924 bytes):

Writing | ################################################## | 100% 0.67s

avrdude: 924 bytes of flash written
avrdude: verifying flash memory against C:\Users\Peter\AppData\Local\Temp\arduino_build_730263/Blink.ino.hex:
avrdude: load data flash data from input file C:\Users\Peter\AppData\Local\Temp\arduino_build_730263/Blink.ino.hex:
avrdude: input file C:\Users\Peter\AppData\Local\Temp\arduino_build_730263/Blink.ino.hex contains 924 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.61s

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

avrdude done.  Thank you.


so I meant the failed bootloader burn avrdude ouput

Hi Juraj
OK - the config is now I have things back to normal so if I try to burn the Bootloader via Arduino as ISP, I get a device ID mismatch error as below:

C:\Users\Peter\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\Peter\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -patmega168 -cstk500v1 -PCOM8 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xF8:m -Uhfuse:w:0xdd:m -Ulfuse:w:0xff:m 

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\Peter\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM8
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega168
         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        512    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     16384  128    128  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

Error while burning bootloader.
Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e940b (probably m168p)
avrdude: Expected signature for ATmega168 is 1E 94 06
         Double check chip, or use -F to override this check.

avrdude done.  Thank you.

This also means I can't now load sketches via the ISP port (Upload Using Programmer with Programmer: "Arduino as ISP") using the Arduino IDE with a board selection of Arduino Nano with Processor ATmega168.

In practice this doesn't much matter as the Bootloader will spoof an ID of 1E 94 06 if you Upload a sketch directly from Arduino IDE with the Nano connected via the USB port.

Hope this helps some.

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