Having an issue bootloading custom PCB - Page 1
Forum section: electronics / general

author: dreece2498
author_rank: Contributor
timestamp: February 04, 2024, 09:04:39 pm
content: I made a custom PCB with the ATMEGA32U4-AU and referenced a similar design where I was able to bootload and upload code, yet despite trying everything nothing seems to work. The reset line is pulled high at 3.3V, the ICSP header is plugged in properly, the USBasp programmer can bootload and upload code to another board no problem at 3.3V, the MCU and USB C connector I had JLCPCB solder on for me, but I'm starting to wonder if they gave me defective chips. I'm programming the project in the Arduino Ide, and hand soldered everything but the USB-C connector and MCU, Checked the scope with the MISO, MOSI, and SCK, but don't see anything. The RESET line is high and gets pulled low but when choosing USBasp as my programmer and Arduino Leonardo as the board, the bootloading process fails instantaneously.Here is the failed code:Code:Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Arduino Leonardo"C:\Users\ricci\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\ricci\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -patmega32u4 -cusbasp -Pusb -e -Ulock:w:0x3F:m -Uefuse:w:0xcb:m -Uhfuse:w:0xd8:m -Ulfuse:w:0xff:mavrdude: Version 6.3-20190619Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/Copyright (c) 2007-2014 Joerg WunschSystem wide configuration file is "C:\Users\ricci\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"Using Port : usbUsing Programmer : usbaspAVR Part : ATmega32U4Chip Erase delay : 9000 usPAGEL : PD7BS2 : PA0RESET disposition : dedicatedRETRY pulse : SCKserial program mode : yesparallel program mode : yesTimeout : 200StabDelay : 100CmdexeDelay : 25SyncLoops : 32ByteDelay : 0PollIndex : 3PollValue : 0x53Memory Detail :Block Poll Page PolledMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------eeprom 65 20 4 0 no 1024 4 0 9000 9000 0x00 0x00flash 65 6 128 0 yes 32768 128 256 4500 4500 0x00 0x00lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00Programmer Type : usbaspDescription : USBasp, http://www.fischl.de/usbasp/avrdude: auto set sck period (because given equals null)avrdude: error: program enable: target doesn't answer. 1avrdude: initialization failed, rc=-1Double check connections and try again, or use -F to overridethis check.avrdude done. Thank you.Error while burning bootloader.For full context, please see my post on the Ki CAD forums:https://forum.kicad.info/t/design-review-request-rgb-sign/47894/14

author: JLCPCB Official
author_rank: Regular Contributor
timestamp: February 06, 2024, 01:20:11 am
content: Quote from: dreece2498 on February 04, 2024, 09:04:39 pmhello, you can give me your order number rebecca@jlcpcb.com to relieve your concerns about component quality.

author: NorthGuy
author_rank: Super Contributor
timestamp: February 08, 2024, 03:52:04 pm
content: This is very easy to verify. Replace the MCU on one of the boards with your own and see if this works.

author: pcprogrammer
author_rank: Super Contributor
timestamp: February 08, 2024, 07:38:55 pm
content: Quote from: dreece2498 on February 04, 2024, 09:04:39 pmYou should see activity on at least SCK and MOSI unless these are pulled low by the target. Set scope to single shot with trigger on SCK and start the programming. Do this with and without a target connected, or with a target that works, just to know what it should look like.

author: Nominal Animal
author_rank: Super Contributor
timestamp: February 09, 2024, 02:27:30 am
content: Arduino Leonardo uses its own bootloader, whereas ATMEGA32U4-AU comes from the factory with the USB DFU bootloader. With the Arduino Leonardo bootloader, avrdude uploads firmware (but not a new bootloader) using USB directly. The ATMEGA32U4-AU pin numbers start at the corner with the dot, and go around the IC counterclockwise (1-11 from the dot counterclockwise, then 12-22, then 23-33, and finally 34-44), when looking at the chip soldered to the board.To replace the bootloader, you can use either the JTAG interface (PF4/TCK, PF5/TMS, PF6/TDO, PF7/TDI) plus /RESET, or the ICSP interface (PB1/SCK, PB2/MOSI, PB3/MISO, /RESET). I'm assuming you are using the ICSP interface.The 6-pin and 10-pin ICSP connector headers, when you look at the connector with pins towards your eyes (NOT the female connector with holes), are┌── ──┐ ┌──── ────┐│ R C I │ │ I C R . O │ R=RST C=SCK I=MISO│ G O V │ │ G G G G V │ G=GND V=VCC O=MOSI└───────┘ └───────────┘Please check your board with a multimeter, when the board is not powered, that these are connected to the correct pins on the ATMEGA32U4-AU: R=13, C=9, I=11, O=10, G=15,23,35,43, V=14,34. It is easy to accidentally confuse the MISO/MOSI pins, and to trust pin header numbering – but in the above text diagrams, pin 1 is top right, 2 bottom right, 5/9 top left, and 6/10 bottom left; these rarely match the pin numbering in connector footprints.(If it is unclear, I too am a hobbyist, having made a booboo hereabouts myself.)

author: pcprogrammer
author_rank: Super Contributor
timestamp: February 09, 2024, 07:17:10 am
content: Swapping MISO and MOSI would stop the process, but you should still see activity on SCK when the host tries to program the MCU via the ICSP interface.According to the datasheet the RESET pin needs to be held low, and this is what you checked so should be ok.

author: Psi
author_rank: Super Contributor
timestamp: February 09, 2024, 09:42:25 am
content: What speed external xtal are you running?You have the CKDIV8 setting disabled so the CPU core will be trying to clock at whatever your xtal speed is. That is not an issue in itself but I have seen issues where programming the chip gets more flaky and sensitive to bad wiring and noise when clocked at higher speeds.Usually under 8Mhz it's fine and very forgiving. But around 16mhz and over you really need to make sure your wires to the programmer are shortish and your programmer is good quality. It was a long time ago, but I've had issues with usbasp style programmers in the past being a bit flaky when programming chips clocked at 16-20mhzAnother thing that would cause your issues is a problem with your external xtal not running for some reason.Since you have set the fuse bits for external xtal you need that external xtal running before the chip will respond to any attempt to program it.Once you set the fuse bits for external xtal the chip will stop working entirely unless you have correctly connected an external xtal and it is oscillating.And the last issue that could cause your problem is a bad ground between your MCU and your programmer/PC