MCUdude / MightyCore

Arduino hardware package for ATmega1284, ATmega644, ATmega324, ATmega324PB, ATmega164, ATmega32, ATmega16 and ATmega8535
Other
649 stars 182 forks source link

Can't burn bootloader to 324PB #225

Closed scrouthtv closed 1 year ago

scrouthtv commented 3 years ago

Hello,

I am currently trying to burn the bootloader to an atmega 324PB using an Arduino Uno.

It is wired up like this: image On my PCB, each of the capacitors is directly behind one of the Vcc pins of the IC.

I am not able to burn the bootloader using an Arduino Uno. I connected

If I try to upload, I get this error

C:\Users\lenni\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino18/bin/avrdude -CC:\Users\lenni\AppData\Local\Arduino15\packages\MightyCore\hardware\avr\2.1.3/avrdude.conf -v -patmega324pb -cstk500v1 -PCOM12 -b19200 -e -Ulock:w:0x3f:m -Uefuse:w:0b11110101:m -Uhfuse:w:0b11010110:m -Ulfuse:w:0b11111111:m avrdude: Version 6.3-20201216 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2014 Joerg Wunsch System wide configuration file is "C:\Users\lenni\AppData\Local\Arduino15\packages\MightyCore\hardware\avr\2.1.3/avrdude.conf" Using Port : COM12 Using Programmer : stk500v1 Overriding Baud Rate : 19200 AVR Part : ATmega324PB Chip Erase delay : 55000 us PAGEL : PD7 BS2 : PA0 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 10 128 0 no 1024 4 0 9000 9000 0xff 0xff flash 33 6 256 0 yes 32768 128 256 4500 4500 0xff 0xff lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00 lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00 hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00 signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00 calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00 efuse 0 0 0 0 no 1 0 0 4500 4500 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.

I triple-checked all soldered connections and parts. Did I wire up something wrong?

Is it possible that the chip got destroyed during reflow? I used a hot-air gun set to 300C and fixed some things manually with 350C.

Do you have any ideas how I would go about troubleshooting?

Edit: The chip is TQFP package. I also tried it again with a new PCB and new chip, same error.

tomaskovacik commented 3 years ago

in old times, there was required 100uF capacitor on RESET line of arduino which runs ArduinoISP, try it

scrouthtv commented 3 years ago

in old times, there was required 100uF capacitor on RESET line of arduino which runs ArduinoISP, try it

I thought it was a 100 nF + a 10k Pullup on the slave side

tomaskovacik commented 3 years ago

100u to ground to disable autoreset

scrouthtv commented 3 years ago

With the capacitor, I tried to burn it 4 times, and one out of the four worked. The other three runs gave me the same error. Any idea why it's so inconsistent?

tomaskovacik commented 3 years ago

strange, you can try disable auto-reset on UNO board the correct way: cutting the trace in pad marked "RST EN" image

scrouthtv commented 3 years ago

I also tried burning with a bare atmega 328 board with SS of the master connected to reset of the slave

scrouthtv commented 3 years ago

cutting the trace in pad marked "RST EN"

Same error

Hamza-arch commented 3 years ago

I am currently trying to upload the bootloader in atmega 16A using arduino UNO and it is giving the same error as you have mentioned. I have tried it with internal as well as external oscillator. Also, tried it with capacitor and pullup resistor. But still did not worked. I hope we can find a solution to this.

MCUdude commented 3 years ago

This isn't really a MightyCore related issue, because there's nothing wrong with the core itself, it's your programmer that can't communicate with your hardware.

I usually see issues like this when users are using Arduino as ISP. I strongly recommend getting a "proper" programmer such as the USBasp and USBtinyISP. I've used the USBasp programmer as a batch programmer for years, and it has never failed due to an issue with the programmer itself.

Is the ATmega324PB brand new, or has it been used with a 16 MHz crystal before? If you have an oscilloscope available, is there a 16 MHz sine wave on the XTAL1 pin? The ATmega324PB doesn't have a "full swing oscillator" option, so it can't drive the crystal "as hard" as other, older AVRs can. This means it's very sensitive to the load capacitors. How many pF's are the capacitors attached to the crystal?

tomaskovacik commented 3 years ago

they can also try my old trick, select internal oscillator 1 or 8MHz and burn the bootloader, then select external 16MHZ crystal and burn new bootloader again but I do not think it will help.

scrouthtv commented 2 years ago

is there a 16 MHz sine wave on the XTAL1 pin?

Yes. minimum 620, maximum 840 mV.

How many pF's are the capacitors attached to the crystal?

I'm using this resonator. The datasheet doesn't specify a capacitance, but according to this product listing, it has 16 pF

Is the ATmega324PB brand new

Yes. I guess I destroyed it during reflow?

This isn't really a MightyCore related issue

Do you know any other place where someone could help me with troubleshooting this?

Hamza-arch commented 2 years ago

This isn't really a MightyCore related issue, because there's nothing wrong with the core itself, it's your programmer that can't communicate with your hardware.

I usually see issues like this when users are using Arduino as ISP. I strongly recommend getting a "proper" programmer such as the USBasp and USBtinyISP. I've used the USBasp programmer as a batch programmer for years, and it has never failed due to an issue with the programmer itself.

Is the ATmega324PB brand new, or has it been used with a 16 MHz crystal before? If you have an oscilloscope available, is there a 16 MHz sine wave on the XTAL1 pin? The ATmega324PB doesn't have a "full swing oscillator" option, so it can't drive the crystal "as hard" as other, older AVRs can. This means it's very sensitive to the load capacitors. How many pF's are the capacitors attached to the crystal?

I have procured a USBASP AVR micro-controller. Initially it was giving issues regarding firmware update. However, after much struggle I was able to updae the firmware, but have to buy another USBASP for it. Now, the USBASP is working fine. I have checked it by uploading code in arduino UNO. However, when I tried it with ATMEGA 16A, it is giving following error.

avrdude: auto set sck period (because given equals null) avrdude: error: program enable: target doesn't answer. 1 avrdude: initialization failed, rc=-1 Double check connections and try again, or use -F to override this check

I am using the following connections. GND Pin11 & Pin31 5V Pin10 & Pin30 Reset Pin9 SCK Pin8 MISO Pin7 MOSI Pin6 16 MHZ Crystal oscillator at pin 12 & 13 with 22pf capacitors. I have tried the same configuration at ATMEGA 328p which worked fine. Am I making some error or is the chip dead? I have treid a lot of youtube tutorials before shifting to USBASP and it might be dead now. WhatsApp Image 2021-10-08 at 4 54 46 PM

tomaskovacik commented 2 years ago

simplify your setup, you have power and ground cables going to one location and then to chip pins, no need for this. Move crystal directly to pins, caps should reach ground pin without a problem ....

Hamza-arch commented 2 years ago

they can also try my old trick, select internal oscillator 1 or 8MHz and burn the bootloader, then select external 16MHZ crystal and burn new bootloader again but I do not think it will help.

I have simplified my setup as explained by you and also have tried using internal oscillator as well. It has not worked. Can you describe the error I am facing??

tomaskovacik commented 2 years ago

oh, you have usasp, then select usbasp slow, and try that, and also you can try to select "internal oscillator 1Mhz". To be honest, I did not study what it changes, but it works for me to boot up new chips, so I do not care :)))

Hamza-arch commented 2 years ago

I have been able to upload the bootloader using a new atmega16A chip. I think I have made some mistakes on last one. So, I might need to reflash it. I was searching it and I think it is easy to do using avrdudess but I was not able to find out the fuse settings to flash. If someone has a good tutorial regarding it, it can be very helpful. Also, I am trying to upload code uisng arduino Rx and Tx pins. I have not been successful in this regard. It is giving the errors of not in sync. I have removed the atmega chip from arduino uno. However, arduino is still reading it as arduino uno. Can anyone explain it. Now it is giving the similar error as the last one. When I uploaded the code, the port was detecting it as arduino uno, however, I have selected ATMEAGA 16 from mighty core.

avrdude: error: program enable: target doesn't answer. 1 avrdude: initialization failed, rc=-1

rocifier commented 2 years ago

What are your crystal oscillator cap values? The datasheet gives a very specific range for the fuse selector you've chosen:

image

rocifier commented 2 years ago

Sorry just confirmed your resonator part is 15-16pF so that's fine

rocifier commented 2 years ago

I think probably the reason is that you need to power it externally and not depend on the power that comes from the Arduino Uno as ISP

scrouthtv commented 2 years ago

the power that comes from the Arduino Uno as ISP

Shouldn't that simply be the 5V from USB? And that power should be fine as it is always on as soon as you plug it into the PC, right?

rocifier commented 2 years ago

from my experience it's not always enough to power the programmer and the board at the same time during programming from USB

MCUdude commented 1 year ago

I'm closing this issue because it's most likely a hardware issue. I've designed a commercial product in the past, based on an aTmega324PB. I've been having so much trouble with the external oscillator because the 324PB isn't strong enough to properly drive a crystal that's slightly too capacitive. After several board revisions, I ended up replacing the crystal and load capacitors with a dedicated clock that outputs a clean clock signal that is wired straight to the XTAL1 pin on the 324PB. No more issues!