(SOLVED) Trouble burning bootloader to Atmega328p-AU

I have made a custom Atmega328p-AU board with some sensors and storage. The schematic and PCB layout is attached. The purpose of the board is to collect imu data from BMX160 IMU, timestamp it using M41T62 RTC and store the data on SD card. The board is rated at 3.3V and the crystal is 8 MHz.

To make sure I have access to the SPI pins for burning bootloader, I added jumpers on MISO, MOSI and SCK pins (which normally go to the SD card), which I keep open during programming to disconnect the MCU chip from SD card module.

I connected an Arduino Uno to the computer and uploaded the ArduinoISP sketch to it. Then I wired the board and the Arduino as follows:

Board - Arduino
VCC - 3.3V
GND - GND
SCK (D13) - D13
MISO (D12) - D12
MOSI (D11) - D11
Reset - D10 (there is a 10k pull up resistor on-board if you see the schematic, along with a capacitor).

In the Arduino IDE, I chose the board as Arduino Pro Mini and processor as Atmega328p (3.3V, 8 MHz). I chose the programmer as Arduino as ISP. However, when I try to burn the bootloader, I get the following error message:

avrdude: Expected signature for ATmega328P is 1E 95 0F
Double check chip, or use -F to override this check.
Error while burning bootloader.

To make sure the chip is alive, I disconnected everything from the Arduino and it reports a different error:

avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check.
Error while burning bootloader.

I checked the datasheet and the chip and if I am not wrong, Atmega328P-AU is just the SMD version of Atmega328p-PU, so the signatures should match.

I tried using Gammon's programmer: Gammon Forum : Electronics : Microprocessors : Atmega bootloader programmer. When I run board detector sketch, the sketch says it fails to enter programming mode.

I tried to repeat the steps using an Arduino Nano as the programmer but get the same errors.

Any help would be appreciated.

imu_logger_pcb.png

imu_logger_pcb.png

Please do this:

  • (In the Arduino IDE) File > Preferences
  • Check the checkbox next to “Show verbose output during: upload”.
  • Click the “OK” button.
  • Tools > Burn Bootloader
  • After the Burn Bootloader process fails, you’ll see a button on the right side of the orange bar: “Copy error messages”. Click that button.
  • In a forum reply here, click on the reply field.
  • Click the </> button on the forum toolbar. This will add the forum’s code tags markup to your reply.
  • Press “Ctrl + V”. This will paste the Burn Bootloader output between the code tags.
  • Move the cursor outside of the code tags before you add any additional text to your reply.

Not sure if the chip just died while I was trying all the stuff, but now I am getting only the 2nd error message and not the chip ID error message. :confused:

Arduino: 1.8.10 (Mac OS X), Board: "Arduino Pro or Pro Mini, ATmega328P (3.3V, 8 MHz)"

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -P/dev/cu.usbserial-0001 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDA: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 "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/Users/swapnilsayansaha/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/cu.usbserial-0001
         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)

Error while burning bootloader.
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.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Your Uno is a 5V device. I think for flashing you need to also power your board at 5V, not 3.3V. I use a Nano as ISP, and connect the Nano's 5V pin to the target's Vcc - a "3.3V" 8MHz Pro Mini, and that works for me. Since it's running at 8MHz, the target doesn't care what Vcc is. But that may damage your sensors and other parts. If so, it might be possible to use a real 3.3V 8MHz Pro Mini as the ISP instead of the Uno.

Also, while it isn't necessary for Nick Gammon's utility, if you use the IDE's Burn Bootloader function, you'll need to add a 10uF capacitor to the Uno's Reset pin. At least I have found that to be the case with my Nano as ISP.

My experience is that the reset disabling capacitor is very rarely needed. A few years ago, a change was made to the Arduino as ISP programmer definition that did make it more likely to be needed, but that change was reverted, so it's no longer an issue as long as people aren't using an outdated version of the Arduino AVR Boards platform. I see that @swapnilsayansaha is using a significantly outdated version, but fortunately it's the one after the fix was made (1.8.1).

swapnilsayansaha:

avrdude: Device signature = 0x000000 (retrying)

Carefully check the wiring between the programmer and target. If using an “Arduino as ISP” programmer, note that not all boards have the SPI bus on Arduino pins 11, 12, 13. Refer to the “Connections” table on the SPI library reference page to determine your board’s SPI pins.

If the target’s fuses were set to use an external clock/resonator/crystal, but no external clock source is attached, you will not be able to program the target. The solution is to connect a clock source to the target long enough to set the fuses to use the internal oscillator, after which the external clock source will no longer be required. The Arduino IDE’s Burn Bootloader process sets the fuses according to the definition of the currently selected board.

Make sure you have selected your target board from the Tools > Board menu.

pert:
My experience is that the reset disabling capacitor is very rarely needed. A few years ago, a change was made to the Arduino as ISP programmer definition that did make it more likely to be needed, but that change was reverted, so it’s no longer an issue as long as people aren’t using an outdated version of the Arduino AVR Boards platform. I see that @swapnilsayansaha is using a significantly outdated version, but fortunately it’s the one after the fix was made (1.8.1).
Carefully check the wiring between the programmer and target. If using an “Arduino as ISP” programmer, note that not all boards have the SPI bus on Arduino pins 11, 12, 13. Refer to the “Connections” table on the SPI library reference page to determine your board’s SPI pins.

If the target’s fuses were set to use an external clock/resonator/crystal, but no external clock source is attached, you will not be able to program the target. The solution is to connect a clock source to the target long enough to set the fuses to use the internal oscillator, after which the external clock source will no longer be required. The Arduino IDE’s Burn Bootloader process sets the fuses according to the definition of the currently selected board.

Make sure you have selected your target board from the Tools > Board menu.

" I see that @swapnilsayansaha is using a significantly outdated version, but fortunately it’s the one after the fix was made (1.8.1)." << I use Arduino 1.8.10 if you see the debug log, not sure how it can be significantly outdated when the latest version is 1.8.13.

“Carefully check the wiring between the programmer and target. If using an “Arduino as ISP” programmer, note that not all boards have the SPI bus on Arduino pins 11, 12, 13. Refer to the “Connections” table on the SPI library reference page to determine your board’s SPI pins.” << I made the board myself using Atmega328p if you see the schematic. The pins I used are fine (PB3, PB4 and PB5 for MOSI, MISO and SCK), as well as Reset pin (PC6). I will however see if there are signal integrity issues.

“If the target’s fuses were set to use an external clock/resonator/crystal, but no external clock source is attached, you will not be able to program the target. The solution is to connect a clock source to the target long enough to set the fuses to use the internal oscillator, after which the external clock source will no longer be required. The Arduino IDE’s Burn Bootloader process sets the fuses according to the definition of the currently selected board.” << There is a 8 MHz oscillator present on the board I designed if you see the schematic.

ShermanP:
Your Uno is a 5V device. I think for flashing you need to also power your board at 5V, not 3.3V. I use a Nano as ISP, and connect the Nano's 5V pin to the target's Vcc - a "3.3V" 8MHz Pro Mini, and that works for me. Since it's running at 8MHz, the target doesn't care what Vcc is. But that may damage your sensors and other parts. If so, it might be possible to use a real 3.3V 8MHz Pro Mini as the ISP instead of the Uno.

Also, while it isn't necessary for Nick Gammon's utility, if you use the IDE's Burn Bootloader function, you'll need to add a 10uF capacitor to the Uno's Reset pin. At least I have found that to be the case with my Nano as ISP.

I will see if the capacitor works, but as @pert pointed out, it was fixed recently.

Have you checked the system oscillator to make sure it is starting up when you get power? It is required before Serial Programming will work. That's one of the reasons you might read 000000 for the signature bytes.

swapnilsayansaha:
I use Arduino 1.8.10

The relevant version is the Arduino AVR Boards platform version, which is not the same as the Arduino IDE version. The confusing thing is that the two are somewhat coupled because the Arduino IDE installation comes with a bundled version of Arduino AVR Boards preinstalled, which is the latest version of Arduino AVR Boards at the time of the IDE release. However, The Arduino IDE's Boards Manager allows you to install any version of Arduino AVR Boards with any version of the Arduino IDE (well, OK, not ancient versions).

From the output you posted, I can see that the bundled version of Arduino AVR Boards (/Applications/Arduino.app/Contents/Java/hardware/arduino/avr) is being used. Arduino AVR Boards 1.8.1 was bundled with Arduino IDE 1.8.10.

Ok I did some tests and this is what I found out:

  1. As @pert pointed out I checked wiring issues. All wiring seems fine (continuity is there).

  2. As @pert and @johnwasser, I checked the 8 Mhz oscillator, it seems there are power problems. So I ditched the regulator output and instead powered through VCC pin of the board via 3.3V from lab bench supply, the oscillator now outputs a sine waves.

  3. To be on safe side, I updated Arduino IDE from 1.8.10 to 1.8.13.

I am now getting a new error message, the one I was able to get originally. Note that adding a capacitor to the programming Arduino's RST pin doesn't make a difference (@ShermanP):

Arduino: 1.8.13 (Mac OS X), Board: "Arduino Pro or Pro Mini, ATmega328P (3.3V, 8 MHz)"

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -P/dev/cu.usbserial-0001 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDA: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 "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/Users/swapnilsayansaha/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/cu.usbserial-0001
         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

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

avrdude: Device signature = 0x00ff00
avrdude: Expected signature for ATmega328P is 1E 95 0F
         Double check chip, or use -F to override this check.

avrdude done.  Thank you.



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Another weird thing.. The oscillator seems to be outputting a sine wave of time period 16 ms. That certainly does not seem to be the time period of a 8 mhz xtal. This happens when I power the board through lab bench supply.

When I power through the battery, the oscillator does not show any output.

OK I SOLVED IT FINALLY.

Issue was neither with clock nor wiring. But this: https://forum.arduino.cc/index.php?topic=619382.0

I directly held the D10 pin of programming arduino to RESET pin of the MCU (earlier i was connecting D10 to DTR, which the forum post pointed out is not right).

This solved the issue.

swapnilsayansaha:
OK I SOLVED IT FINALLY.

Issue was neither with clock nor wiring. But this: https://forum.arduino.cc/index.php?topic=619382.0

I directly held the D10 pin of programming arduino to RESET pin of the MCU (earlier i was connecting D10 to DTR, which the forum post pointed out is not right).

This solved the issue.

Your original post said you had D10 connected to the reset pin. That was not the case?

So you are powering the target device at 3.3V, but sending 5V signals from the Uno to it? Can someone explain why significant current does not flow through the target's protection diodes, and why it's ok to exceed the absolute maximum voltage that can be applied to a GPIO pin? Or maybe explain why I'm looking at it wrong, and this is ok.

As for the capacitor on Reset, all I can say is that running whatever came with IDE v1.8.8, the cap is needed for a Nano to work as an ISP through the IDE. I've tried it both ways, and it only works with the cap installed.