Atmega32A not burning bootloader

Hello, I am working a a small project. I am hoping to upload code to the Atmega32A using a USBasp programmer. Now, my problem is when I try to burn the bootloader. Previously, I have gotten the avrdude: verification error; content mismatch. I have done some reasearch, and found that burning the bootloader is the best option. Now I am greeted with this error: avrdude: error: program enable: target doesn't answer. 1. Thank you for any guidance, and sorry if this is a absolutely newbie question :slight_smile: I am using arduino version 1.8.4.

BTW, Here is my addition to the boards.txt file:

##############################################################

mega32-16.name=ATmega32-External 16mhz
mega32-16.build.mcu=atmega32
mega32-16.build.f_cpu=16000000L
mega32-16.build.core=arduino:arduino
mega32-16.build.variant=mega32
mega32-16.upload.tool=avrdude
mega32-16.upload.maximum_size=32000
mega32-16.bootloader.low_fuses=0xEF
mega32-16.bootloader.high_fuses=0x89
mega32-16.bootloader.tool=avrdude
#mega32-16.bootloader.extended_fuses=0xFD

##############################################################

Make sure the programmer’s cable is correctly connected to the target board. Pin 1 on the cable is indicated by a small triangle embossed on the plastic.

Just brief look, this doesn't seem to be correct. Atmega32A isn't standard chip. Look here:
GitHub - MCUdude/MightyCore: Arduino hardware package for ATmega1284, ATmega644, ATmega324, ATmega324PB, ATmega164, ATmega32, ATmega16 and ATmega8535 .
Schematics would be helpful. For USBasp it is just about 6 wires in connection to the raw chip. Runnig with the bootloader, you have to have:

  1. power + decoupling,
  2. reset circuit,
  3. oscillator circuit,
  4. serial line Tx,Rx.

Hello, thank you for your quick response. Currently, I have:
USBasp RST to pin 9 on the atmega
USBasp SCK to pin 8 on the atmega
USBasp MISO to pin 7 on the atmega
USBasp VCC to pin VCC on the atmega
USBasp MOSI to pin 6 on the atmega
USBasp GND to pin GND on the atmega
On the atmega32, there is an external 16MHz occilator, and 2 22pf capacitors

What cable are you talking about?

Are you using the ATmega32A in DIP IC package format? If so, those connections look correct.

This one:

But perhaps you are using jumper wires directly between the pins on the USB and the ATmega32A?


If your USBasp programmer has the official firmware, you must short the JP3 jumper to program chips that are running at <=1 MHz clock speed. The factory default clock configuration is running on the internal oscillator at 1 MHz. Many of the common Chinese USBasp clones (such as the "Baite" brand ones like in the picture above) come with a modified firmware that is able to work with chips running at the slower clock speeds without needing to set the jumper. There is also a alternate open source firmware provided by the community that has this functionality.

This is the USBasp programmer I have: https://www.amazon.com/gp/product/B0885RKVMC/ref=ppx_yo_dt_b_asin_title_o03_s00?ie=UTF8&psc=1. I am using the 10 to 6 pin adapter and plugging those directly into the breadboard.


Try shorting the two plated through holes that are labeled "JP3" on the programmer together while you do a Burn Bootloader. You could use some wire or metal tweezers. Just try to hold the conductors pressed firmly against the sides of the holes so you get a reliable electrical connection.

Ok, will do.

Ok, now I am getting this error: avrdude: invalid byte value ({bootloader.unlock_bits}) specified for immediate mode avrdude: read from file '{bootloader.unlock_bits}' failed

This is because you didn't define a mega32-16.bootloader.unlock_bits property in your custom board definition in boards.txt. The {, } are the property reference syntax in the Arduino boards platform configuration files. When you have defined this property, the reference will be replaced ("expanded") with the value you set it to in the definition. But if the property is not defined then the Arduino build system just leaves the reference unexpanded and AVRDUDE chokes on this unexpected input.

If you are interested in learning about the Arduino boards platform system, then creating your own ATmega32A board definition is a valuable experience. But if you don't really care about that and only want to get to work on your project then you should definitely use MightyCore, which already provides excellent support for the ATmega32A:

Does this look rtight for what to add to boards.txt?

32.name=ATmega32
32.upload.tool=avrdude
32.upload.maximum_data_size=2048
32.bootloader.tool=avrdude
32.bootloader.unlock_bits=0x3f
32.bootloader.lock_bits=0x0f
32.bootloader.low_fuses=0b{bootloader.bod_bits}{bootloader.sut_cksel_bits}
32.bootloader.high_fuses=0b110{bootloader.ckopt_bit}{bootloader.eesave_bit}11{bootloader.bootrst_bit}
32.build.core=MCUdude_corefiles
32.build.board=AVR_ATmega32
32.build.mcu=atmega32

No. That relies on several other parts of the MightyCore project.

Do you see the property references in these lines?:

Those are for properties defined in another part of the MightyCore boards.txt. For example, the bootloader.bod_bits property is defined either here:
https://github.com/MCUdude/MightyCore/blob/v2.1.3/avr/boards.txt#L934

32.menu.BOD.2v7.bootloader.bod_bits=10

or here:

32.menu.BOD.4v0.bootloader.bod_bits=00

depending on which option the user has selected from the Tools > BOD custom board options menu in the Arduino IDE:

https://github.com/MCUdude/MightyCore/tree/master#bod-option

MightyCore is a very complex boards platform, so maybe not the best reference for a beginner. But the Arduino boards platform system is thoroughly documented in the "Arduino Platform Specification", so if you spend enough time studying it and experimenting with your own platform then you will get it figured out.

This line requires the presence of the MCUdude_corefiles core library:

Information about the core here:
https://arduino.github.io/arduino-cli/latest/platform-specification/#cores

I am having a similar issue with my "Atmega32A PU 1111", not uploading code nor is it burning the bootloader. I am using a "Pololu USB AVR Programmer v2.1" to do the programming.
These are the only connections right now on the board
image

Arduino: 1.8.15 (Windows 10), TD: 1.54, Board: "ATmega32, Yes (UART0), EEPROM retained, Standard pinout, BOD 2.7V, LTO disabled, External 16 MHz"

C:\Users\kkhaf\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino18/bin/avrdude -CC:\Users\kkhaf\AppData\Local\Arduino15\packages\MightyCore\hardware\avr\2.1.3/avrdude.conf -v -patmega32 -cstk500 -P COM4 -e -Ulock:w:0x3f:m -Uefuse:w:{bootloader.extended_fuses}:m -Uhfuse:w:0b11000110:m -Ulfuse:w:0b10111111: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\kkhaf\AppData\Local\Arduino15\packages\MightyCore\hardware\avr\2.1.3/avrdude.conf"



         Using Port                    : COM4

         Using Programmer              : stk500

         AVR Part                      : ATmega32

         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         4    10    64    0 no       1024    4      0  9000  9000 0xff 0xff

           flash         33     6    64    0 yes     32768  128    256  4500  4500 0xff 0xff

           lfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00

           hfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00

           efuse          0     0     0    0 no          0    0      0     0     0 0x00 0x00

           lock           0     0     0    0 no          1    0      0  2000  2000 0x00 0x00

           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

           calibration    0     0     0    0 no          4    0      0     0     0 0x00 0x00



         Programmer Type : STK500V2

         Description     : Atmel STK500

         Programmer Model: STK500

         Hardware Version: 15

         Firmware Version Master : 2.10

         Topcard         : Unknown

         Vtarget         : 4.8 V

         SCK period      : 8.7 us

         Varef           : 0.0 V

         Oscillator      : Off



avrdude: stk500v2_command(): command failed

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.