ICSP Wiring Problems on the ATMega32u4

I'm trying to program a bootloader into my ATMega32u4. It's on a custom PCB, And here are the schematic files:


and here's the full avrdude log:

>>>: avrdude -c usbasp -p m32u4 -P usb -b 115200 -B 20.96 -F -v -v -v -v -V 
 
avrdude: Version 7.1
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS
 
         System wide configuration file is C:\Users\Administrator\Documents\avrdude\avrdude.conf
 
         Using Port                    : usb
         Using Programmer              : usbasp
         Overriding Baud Rate          : 115200
         Setting bit clk period        : 21.0
avrdude: usbasp_open("usb")
avrdude: seen device from vendor >www.fischl.de<
avrdude: seen product >USBasp<
         AVR Part                      : ATmega32U4
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : possible i/o
         RETRY pulse                   : SCK
         Serial program mode           : yes
         Parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :
 
                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom                 65    20     4    0 no       1024    4      0  9000  9000 0x00 0x00
                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           flash                  65     6   128    0 yes     32768  128    256  4500  4500 0x00 0x00
                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lfuse                   0     0     0    0 no          1    1      0  9000  9000 0x00 0x00
                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           hfuse                   0     0     0    0 no          1    1      0  9000  9000 0x00 0x00
                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           efuse                   0     0     0    0 no          1    1      0  9000  9000 0x00 0x00
                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lock                    0     0     0    0 no          1    1      0  9000  9000 0x00 0x00
                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature               0     0     0    0 no          3    1      0     0     0 0x00 0x00
                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           calibration             0     0     0    0 no          1    1      0     0     0 0x00 0x00
 
         Programmer Type : usbasp
         Description     : USBasp, http://www.fischl.de/usbasp/
 
avrdude: usbasp_initialize()
avrdude: usbasp_transmit("USBASP_FUNC_GETCAPABILITIES", 0x00, 0x00, 0x00, 0x00)
avrdude: usbasp_spi_set_sck_period(2.096e-05)
avrdude: try to set SCK period to 2.096e-05 s (= 47709 Hz)
avrdude: connected USBasp is not cabable of 3 MHz SCK
avrdude: set SCK frequency to 32000 Hz
avrdude: usbasp_transmit("USBASP_FUNC_SETISPSCK", 0x07, 0x00, 0x00, 0x00)
avrdude usbasp_spi_set_sck_period() [usbasp.c:971] error: cannot set sck period; please check for usbasp firmware update
avrdude: usbasp_transmit("USBASP_FUNC_CONNECT", 0x00, 0x00, 0x00, 0x00)
avrdude: usbasp_program_enable()
avrdude: usbasp_transmit("USBASP_FUNC_ENABLEPROG", 0x00, 0x00, 0x00, 0x00)
         <= [01] 
avrdude usbasp_spi_program_enable() [usbasp.c:726] error: program enable: target does not answer (0x01)
avrdude main() [main.c:1246] error: initialization failed, rc=-1
        - double check the connections and try again
        - use -B to set lower ISP clock frequency, e.g. -B 125kHz
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x000000 (retrying)
avrdude: device signature = 0x000000 (retrying)
avrdude: device signature = 0x000000
avrdude main() [main.c:1349] error: Yikes!  Invalid device signature.
avrdude main() [main.c:1365] warning: expected signature for ATmega32U4 is 1E 95 87
avrdude: usbasp_close()
avrdude: usbasp_transmit("USBASP_FUNC_DISCONNECT", 0x00, 0x00, 0x00, 0x00)
 
avrdude done.  Thank you.

I've tried using an Arduino Uno and an usbasp programmer(this one: https://www.amazon.com/dp/B07NZ59VK2?psc=1&ref=ppx_yo2ov_dt_b_product_details), I removed D4 & U4, and I checked the voltage on the processor power pins. All of them are 3.3V. I've also double-checked my double-checking of the wiring between the programmer and the target device. All to no avail. I just need to program the bootloader onto the device so I can get it running with USB.

Thanks.

Hi @charleychap. Please always post content directly here in the forum instead of on a separate file hosting site. Some of the helpers here can't or won't visit an external site so you significantly harm your chances of getting help by doing that.

Please provide a detailed description of what you mean by "Avrice programmer". There is a programmer named "AVR ISP" and another named "AVRISP mkII", yet you have configured your avrdude command to use a USBasp programmer. So this is a very ambiguous statement.

Hey @ptillisch. I've edited the post accordingly. Thanks for the advice! I'm actually using a USBasp programmer(this one: https://amazon.com/dp/B07NZ59VK2?ref=ppx_yo2ov_dt_b_product_details&th=1). That was a mistake on my part.

There are several different variants of the USBasp firmware. The programmer you purchased might have come with any one of them. For the purposes of this discussion, they can be put into one of two categories:

  • Automatic SCK (serial clock) frequency adjustment
  • SCK frequency adjustment via the "Slow SCK" jumper

I see your USBasp programmer has three jumpers. I take this as an indicator that it came with a firmware variant that requires SCK frequency adjustment via jumper (since otherwise there would be no reason to provide the "Slow SCK" jumper).

On this model, the "Slow SCK" jumper is the one labeled "JP3" on the PCB silkscreen.

I see you did use the -B flag in your avrdude command to increase the bitclock period. However, this only has an effect if the firmware on the USB supports that feature. Older versions of the firmware did not. So I think the jumper will be a more reliable way to ensure the appropriate SCK frequency is used for provisioning your fresh chip.

People sometimes flash a different firmware to their USBasp programmers. In this case, the presence or absence of three jumpers will not be a reliable indicator of whether the USBasp has automatic SCK frequency adjustment. The official USBasp firmware downloaded from the fischl.de website does not have automatic SCK frequency adjustment. Some of the community created firmwares (example) do have automatic SCK frequency adjustment.

The "initialization failed, rc=-1" error can occur under the following conditions:

  • The target microcontroller's clock is running at <=1 MHz.
  • The USBasp firmware does not have automatic SCK frequency adjustment.
  • The "Slow SCK" jumper on the USBasp programmer is not shorted.

When you buy a new bare microcontroller chip, it is configured to run at 1 MHz.

Under these conditions, the solution will be to short the jumper and then try the operation again:

  1. Disconnect the USBasp and the USB cable of the target board from your computer.
  2. Short the jumper on the USBasp.
  3. Plug the USBasp into the USB socket on your computer.
  4. Attempt the programming operation again.

The most reliable way to short the jumper is to solder a male pin header and then connect the two pins with something like a female to female jumper wire. If you don't have the necessary equipment then you can accomplish it by holding a wire or male to male jumper wire with one end in contact with each of the through holes. This will not provide a reliable connection so you might need to make multiple attempts at the programming operation before it is successful.

If the operation still fails even after you short the jumper, add a reply here on this forum thread to let us know. If the error message is no longer "initialization failed, rc=-1" then make sure to include the full and exact text of the new error message in your reply.

Just soldered the jumper together and I still have the same error. Here's the full log:

>>>: avrdude -c usbasp -P usb -b 19200 -B 93.75 -v -v -v -v -p m8 
WARNING: Unable to detect MCU


avrdude: Version 7.1
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

         System wide configuration file is C:\Users\Administrator\Documents\avrdude\avrdude.conf

         Using Port                    : usb
         Using Programmer              : usbasp
         Overriding Baud Rate          : 19200
         Setting bit clk period        : 93.8
avrdude: usbasp_open("usb")
avrdude: seen device from vendor >www.fischl.de<
avrdude: seen product >USBasp<
         AVR Part                      : ATmega8
         Chip Erase delay              : 10000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : possible i/o
         RETRY pulse                   : SCK
         Serial program mode           : yes
         Parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom                  4    20   128    0 no        512    4      0  9000  9000 0xff 0xff
                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           flash                  33    10    64    0 yes      8192   64    128  4500  4500 0xff 0x00
                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lfuse                   0     0     0    0 no          1    1      0  2000  2000 0x00 0x00
                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           hfuse                   0     0     0    0 no          1    1      0  2000  2000 0x00 0x00
                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lock                    0     0     0    0 no          1    1      0  2000  2000 0x00 0x00
                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature               0     0     0    0 no          3    1      0     0     0 0x00 0x00
                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           calibration             0     0     0    0 no          4    1      0     0     0 0x00 0x00

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

avrdude: usbasp_initialize()
avrdude: usbasp_transmit("USBASP_FUNC_GETCAPABILITIES", 0x00, 0x00, 0x00, 0x00)
avrdude: usbasp_spi_set_sck_period(9.375e-05)
avrdude: try to set SCK period to 9.375e-05 s (= 10666 Hz)
avrdude: connected USBasp is not cabable of 3 MHz SCK
avrdude: set SCK frequency to 8000 Hz
avrdude: usbasp_transmit("USBASP_FUNC_SETISPSCK", 0x05, 0x00, 0x00, 0x00)
avrdude usbasp_spi_set_sck_period() [usbasp.c:971] error: cannot set sck period; please check for usbasp firmware update
avrdude: usbasp_transmit("USBASP_FUNC_CONNECT", 0x00, 0x00, 0x00, 0x00)
avrdude: usbasp_program_enable()
avrdude: usbasp_transmit("USBASP_FUNC_ENABLEPROG", 0x00, 0x00, 0x00, 0x00)
         <= [01] 
avrdude usbasp_spi_program_enable() [usbasp.c:726] error: program enable: target does not answer (0x01)
avrdude main() [main.c:1246] error: initialization failed, rc=-1
        - double check the connections and try again
        - use -B to set lower ISP clock frequency, e.g. -B 125kHz
        - use -F to override this check

avrdude: usbasp_close()
avrdude: usbasp_transmit("USBASP_FUNC_DISCONNECT", 0x00, 0x00, 0x00, 0x00)

avrdude done.  Thank you.

This board's design was based on a development board I made for the atmega32u4 to test whether I could get it working. That design worked, so I based this one on that one. Here is the known working design of the dev board:



The copper pour is GND on layer 1.

I then tried uploading new firmware to the USBasp programmer by shorting JP2 and uploading through the ICSP pins of another programmer. I tried to get a device ID before programming and it gave me the same error about clock speeds. I tried uploading using an uno and I tried a nano. Both Failed.

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