Author Topic: Having an issue bootloading custom PCB  (Read 1030 times)

0 Members and 1 Guest are viewing this topic.

Offline dreece2498Topic starter

  • Contributor
  • Posts: 15
  • Country: us
Having an issue bootloading custom PCB
« on: February 04, 2024, 09:04:39 pm »
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: [Select]
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: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\ricci\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"



         Using Port                    : usb

         Using Programmer              : usbasp

         AVR Part                      : ATmega32U4

         Chip Erase delay              : 9000 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    20     4    0 no       1024    4      0  9000  9000 0x00 0x00

           flash         65     6   128    0 yes     32768  128    256  4500  4500 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

           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00

           lock           0     0     0    0 no          1    0      0  9000  9000 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 : usbasp

         Description     : USBasp, http://www.fischl.de/usbasp/



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.





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
 

Offline JLCPCB Official

  • Regular Contributor
  • *
  • Posts: 128
  • Country: hk
Re: Having an issue bootloading custom PCB
« Reply #1 on: February 06, 2024, 01:20:11 am »
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: [Select]
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: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\ricci\Documents\ArduinoData\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"



         Using Port                    : usb

         Using Programmer              : usbasp

         AVR Part                      : ATmega32U4

         Chip Erase delay              : 9000 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    20     4    0 no       1024    4      0  9000  9000 0x00 0x00

           flash         65     6   128    0 yes     32768  128    256  4500  4500 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

           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00

           lock           0     0     0    0 no          1    0      0  9000  9000 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 : usbasp

         Description     : USBasp, http://www.fischl.de/usbasp/



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.





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

hello, you can give me your order number rebecca@jlcpcb.com to relieve your concerns about component quality.
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 3146
  • Country: ca
Re: Having an issue bootloading custom PCB
« Reply #2 on: February 08, 2024, 03:52:04 pm »
This is very easy to verify. Replace the MCU on one of the boards with your own and see if this works.
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3710
  • Country: nl
Re: Having an issue bootloading custom PCB
« Reply #3 on: February 08, 2024, 07:38:55 pm »
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.

You 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.

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6264
  • Country: fi
    • My home page and email address
Re: Having an issue bootloading custom PCB
« Reply #4 on: February 09, 2024, 02:27:30 am »
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.)
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3710
  • Country: nl
Re: Having an issue bootloading custom PCB
« Reply #5 on: February 09, 2024, 07:17:10 am »
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.

Online Psi

  • Super Contributor
  • ***
  • Posts: 9953
  • Country: nz
Re: Having an issue bootloading custom PCB
« Reply #6 on: February 09, 2024, 09:42:25 am »
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-20mhz

Another 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
« Last Edit: February 09, 2024, 09:45:33 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf