Burning Arduino to ATmega32A

Dear Friends,

I have an USBASP programmer and a couple of ATmega32A(unfortunately this is the most sold controller at my place) lying around. I wish to know if i can burn an Arduino Bootloader onto it to take advantage of using Arduino framework for writing my applications. Because more than AVR, Arduino suits me better for the greater society, ease in learning curve on the programming front (sorry i find Arduino a bit easier than AVR). Also I found a site where they have given the pin mapping of the ATMega32 www.retrointerfacing.com.

Can someone help me through this? I do not mind burning my application hex files manually or to discard the Arduino IDE. All i need is a way to figure out running my Arduino framework based programs on my ATmega32 for which I believe the Arduino bootloader has to be burned into before.


Ashok Srinivasan.

Go to www.avr-developers.com and download the files for ATMega32.
May need to create a new board type in boards.txt and make an entry in avrdude.conf after that.
IDE 1.0.1 has an updated structure that supports "variants" of microcontrollers. I'm not knowledgeable enough really descibe it better for you.

Go to www.avr-developers.com and download the files for ATMega32.
May need to create a new board type in boards.txt and make an entry in avrdude.conf after that.
IDE 1.0.1 has an updated structure that supports "variants" of microcontrollers. I'm not knowledgeable enough really descibe it better for you.

Firstly, thanks for your time and reply. Got it boss. One more thing to boot up the process, will this version work under 1.0.1 or do I have to use any specific version(ex., in the site you have mentioned 0.20)


Ashok Srinivasan

Give it a try with 1.0.1, can always go back to -0020 if it doesn't work.

avrdude.conf already has the info for atmega32.
You'll have to make a new boards.txt entry for the device.

Thanks for the link. But the website seems to be old enough. Cant find the proper files. The described link is also dead. Any help on that, please?
Cant find ATmega32A core files in Arduino-extras.zip file.
Any solutions?


Found another page with ATmega32 configuration files. www.retrointerfacing.com
Downloaded the .zip files.
In the boards.txt file included in the zip, it shows the configuration for mega32 chip. But the 32 & 32A are different chips. I used that page to find out the fusebit config. AVR® Fuse Calculator – The Engbedded Blog
Well, they have also listed 2 different pages for 2 different chips.

What should I do in that situation? I'll be using the 32A chip trying to implement the "playing tones based on micros()" playing tones based on micros() - Audio - Arduino Forum

Both the ATmega1284 & 32A are 40 pin IC with same port pin numbers. 32A is having few less pwm pins & other functionalities.

Will the code run on my 32A chip anyhow? any suggestions please.
Thanks for the support.
Good day.


I tried to upload the ATmega32 bootloader on my ATmega32A chip using arduino & usbasp programmer.

The error I’m getting is

"efuse" memory type not defined for part "ATMEGA32"

Procedure followed:
Downloaded the attached zip file. (included in the post)
copied the ATmegaBOOT_32.hex & .c file to “C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\bootloaders\atmega32”
Added the modified code to boards.txt
Opened arduino 1.0.5
Tools> Boards> ATmega32board
Tools> Programmer> USBasp

The modified & added part of boards.txt


atmega32.upload.protocol=arduino  // Changed it from "STK500" to "arduino"
atmega32.upload.speed=115200 // changed it from "19200" to "115200"
atmega32.bootloader.path=atmega32            // default was "atmega8", I created an atmega32 folder under  the 
atmega32.bootloader.file=ATmegaBOOT.hex             //bootloader folder & changed the path.


It is the issue I suppose.


The fusecalc web page doesn’t show any trace of extended fuse feature in both ATmega32 & 32A.

ArduinoBootloader.zip (15.3 KB)

Deleted the efuse configuration & the bootloader successfully uploaded to ATmega32A.
Having issue with uploading the blink sketch into that chip. The error report says...

In file included from Blink.ino:10:
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino/Arduino.h:213:26: error: pins_arduino.h: No such file or directory

Any suggestions?

I put the arduino-mega32-mod.zip file (included in the post) contents to the arduino core directory “C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino”. The zip has the “pins_arduino.h” file that was to be there in the “core” folder. I overlooked the step then finally fixed it. now the issue lies on an other point.

I am trying to upload the blink sketch & now the error shown is…

In file included from C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino/Arduino.h:213,
                 from Blink.ino:10:
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino/pins_arduino.h:45: error: conflicting declaration 'const uint8_t port_to_mode_PGM []'
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino/Arduino.h:127: error: 'port_to_mode_PGM' has a previous declaration as 'const uint16_t port_to_mode_PGM []'
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino/pins_arduino.h:46: error: conflicting declaration 'const uint8_t port_to_input_PGM []'
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino/Arduino.h:128: error: 'port_to_input_PGM' has a previous declaration as 'const uint16_t port_to_input_PGM []'
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino/pins_arduino.h:47: error: conflicting declaration 'const uint8_t port_to_output_PGM []'
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino/Arduino.h:129: error: 'port_to_output_PGM' has a previous declaration as 'const uint16_t port_to_output_PGM []'

The page from where I get the ATmega32 arduino files is…

Any clue on how to fix that?
Thanks for the co-operation.

arduino-mega32-mod.zip (11.8 KB)

Keep slogging away! You’ll get the little things fixed …

Thanks for your reply CrossRoads. Well, I think that there is somekind of conflict in between Arduino.h & pins_Arduino.h file. I opened the pins_Arduino.h file in notepad++ tried to find out whats wrong but the contents are like huge mountains of puzzles. Still searching for the right direction.

Should I try with the 0020 version? Need to find it over internet. Official download page (http://arduino.cc/en/Main/Software) does not have the older versions before 1.0.

Give it a try with 1.0.1, can always go back to -0020 if it doesn't work.
avrdude.conf already has the info for atmega32.
You'll have to make a new boards.txt entry for the device.

Found something relevant... http://wiki.edwindertien.nl/doku.php?id=software:bootloaders
The mod.zip file is non existent http://www.robotcraft.ca/webshop/download/zip/arduino-mega32-644-mod.zip
Tried this thread too..
Ok, on to Atmega32 - Development - Arduino Forum (2nd post)
Still no trace of the mod file. If anyone have saved this , kindly repost the mod.

After a long search finally get the mod file from 4shared. arduino-mega32-644 - Download - 4shared - chantichai namthongdee
put the content in the arduino core folder & overwrote the existing files. Then tried the described step of relacing the #if defined(__ATmega8__) in all .c files. Unfortunately the ctrl+F cant find anything as such. & finally the arduino IDE is showing the same error report while I'm trying to upload any sketch to ATmega328p chips with either the default settings "ARVISP mkII" or "USBasp". :frowning:
I also tried that page USBASP ICSP Programmer Quickstart Guide | Freetronics for Zadig solution. No way out.
At this point I'm really perplexed. Please help.
Should I try modifying the preference.txt? I'm using Arduino IDE 1.0.5

Tried Gen7
The same error with pins_arduino.h

In file included from C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino\/Arduino.h:220,
                 from C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino\/wiring_private.h:33,
                 from C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino\wiring_digital.c:28:
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino\/pins_arduino.h:103: error: 'DDRA' undeclared here (not in a function)
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino\/pins_arduino.h:111: error: 'PORTA' undeclared here (not in a function)
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino\/pins_arduino.h:111: error: initializer element is not constant
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino\/pins_arduino.h:111: error: (near initialization for 'port_to_output_PGM[1]')
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino\/pins_arduino.h:119: error: 'PINA' undeclared here (not in a function)
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino\/pins_arduino.h:119: error: initializer element is not constant
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\cores\arduino\/pins_arduino.h:119: error: (near initialization for 'port_to_input_PGM[1]')

I've read your post in this thread Programming ATmega32 using Arduino - Microcontrollers - Arduino Forum (3rd from bottom). I made those changes but due to that pin mapping file, the blink sketch wont even compile. Any updated repository of those configuration files? Any clue or any hints please?

Woke up & get started again to get things fixed. Found a number of threads on this topic.
Found temporary solution. https://github.com/eaconner/ATmega32-Arduino
Now my 32A is accepting the blink sketch. It is working BUT the pinmapping is…

//                       +---\/---+
//           (D 0) PB0  1|        |40  PA0 (AI 0 / D24)
//           (D 1) PB1  2|        |39  PA1 (AI 1 / D25)
//      INT2 (D 2) PB2  3|        |38  PA2 (AI 2 / D26)
//       PWM (D 3) PB3  4|        |37  PA3 (AI 3 / D27)
//       /SS (D 4) PB4  5|        |36  PA4 (AI 4 / D28)
//      MOSI (D 5) PB5  6|        |35  PA5 (AI 5 / D29)
//     /MISO (D 6) PB6  7|        |34  PA6 (AI 6 / D30)
//      /SCK (D 7) PB7  8|        |33  PA7 (AI 7 / D31)
//                 RST  9|        |32  AREF
//                 VCC 10|        |31  GND 
//                 GND 11|        |30  AVCC
//               XTAL2 12|        |29  PC7 (D 23)
//               XTAL1 13|        |28  PC6 (D 22)
//      RX0 (D 8)  PD0 14|        |27  PC5 (D 21) TDI
//      TX0 (D 9)  PD1 15|        |26  PC4 (D 20) TDO
// RX1/INT0 (D 10) PD2 16|        |25  PC3 (D 19) TMS
// TX1/INT1 (D 11) PD3 17|        |24  PC2 (D 18) TCK
//      PWM (D 12) PD4 18|        |23  PC1 (D 17) SDA
//      PWM (D 13) PD5 19|        |22  PC0 (D 16) SCL
//          (D 14) PD6 20|        |21  PD7 (D 15) PWM
//                       +--------+

Then followed this thread http://forum.arduino.cc/index.php?topic=174311.15 & found the 1284 core files including Bobuino pin mapping file. GitHub - maniacbug/mighty-1284p: Mighty 1284P Platform for Arduino

// ATMEL ATMEGA1284P on Bobuino
//                       +---\/---+
//           (D 4) PB0 1 |        | 40 PA0 (D 21) AI 7
//           (D 5) PB1 2 |        | 39 PA1 (D 20) AI 6
//      INT2 (D 6) PB2 3 |        | 38 PA2 (D 19) AI 5
//       PWM (D 7) PB3 4 |        | 37 PA3 (D 18) AI 4
//   PWM/SS (D 10) PB4 5 |        | 36 PA4 (D 17) AI 3
//     MOSI (D 11) PB5 6 |        | 35 PA5 (D 16) AI 2
// PWM/MISO (D 12) PB6 7 |        | 34 PA6 (D 15) AI 1
//  PWM/SCK (D 13) PB7 8 |        | 33 PA7 (D 14) AI 0
//                 RST 9 |        | 32 AREF
//                VCC 10 |        | 31 GND 
//                GND 11 |        | 30 AVCC
//              XTAL2 12 |        | 29 PC7 (D 29) 
//              XTAL1 13 |        | 28 PC6 (D 28) 
//      RX0 (D 0) PD0 14 |        | 27 PC5 (D 27) TDI
//      TX0 (D 1) PD1 15 |        | 26 PC4 (D 26) TDO
// INT0 RX1 (D 2) PD2 16 |        | 25 PC3 (D 25) TMS
// INT1 TX1 (D 3) PD3 17 |        | 24 PC2 (D 24) TCK
//     PWM (D 30) PD4 18 |        | 23 PC1 (D 23) SDA
//      PWM (D 8) PD5 19 |        | 22 PC0 (D 22) SCL
//      PWM (D 9) PD6 20 |        | 21 PD7 (D 31) PWM
//                       +--------+

Can’t get the bobuino pin_arduino.h work with my mega32A.

Procedure Followed for mega32 pin_arduino.h:
Put the pins_arduino.h file from the downloaded directory to arduino “core” folder.
Select board > ATmega32
Programmer > USBasp
File > Upload using programmer

Yes, It works Without needing any additional core files. BUT to make life easier I found the bobuino pin mapping is the best way to use a 40 pin AVR because it already optimised the port pin numbering to a standard uno interface, like the spi, serial ports, ADC ports etc.
I am unable to port the pin configuration in pins_arduino.h, from mega32 to bobuino pin mapping. May I get any help at that stage. The mega32 & bobuino pin mapping .h files are included here.
Your guidance is highly anticipated.

pins_arduino.h (6.08 KB)

mega32_pins_arduino.h (4.39 KB)

Have you put the pins_arduino.h in the right place?
You see how both the /arduino and /mighty1284 have a bootloaders.txt, and each has a /variants and a /bootloader folder? In each /variants folder there is a board type folder with a name that matches a name from a boards.txt section, and the /bootloader folder has a folder for each board type as well with the bootloader for that card.
Set yours up the same way, under the arduino path if that is what you are using, or under the mighty1284 path.

Thanks CrossRoads, I did mistake & put the "variant" folder contents into the "core" folder. I'm going to delete the existing extracted 1.0.5 IDE & unzip it again & start from the beginning.

Yes, can be a little tricky. I had it worked out under -0023, maniacbug got it worked out for IDE 1.0 & later.
This is what I have for Bobuino now, fixes PCINT mapping, might need similar for Atmega32 if PCINT & Analog are same pins as 1284.

These other 2 made changes to fix INPUT_PULLUP, definition was missing.
If you are Arduino/core, check them.
If you are in mighty1284 core, replace them.

pins_arduino.h (6.9 KB)

wiring_digital.c (5.18 KB)

Arduino.h (5.56 KB)

Hello, I have followed two methods

First Method
I have put the mighty folder under “C:\Users\Roy\Desktop\arduino-1.0.5\hardware\mighty-1284p” location.
Added 2 entries to boards.txt ( to the boards.txt preloaded with arduino, I did nothing with the mighty’s board.txt) [ http://forum.arduino.cc/index.php?topic=174311.15 (First post) ]
copied the mentioned optiboot .HEX files to C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\bootloaders\optiboot


atmega32_at16e.name=ATmega32/32A (16MHz, external)


#make atmega32 AVR_FREQ=16000000L BAUD_RATE=115200 UART=0 LED=B7 LED_START_FLASHES=3

atmega32_at16e.build.variant=bobuino // I put the Bobuino folder to "C:\Users\Roy\Desktop\arduino-1.0.5\hardware\arduino\variants"


atmega32_at8i.name=ATmega32/32A (8MHz, internal)


#make atmega32 AVR_FREQ=8000000L BAUD_RATE=115200 UART=0 LED=B7 LED_START_FLASHES=3


selected the “ATmega32/32A (16MHz, external)” board option & burnt the bootloader. It was successful.
Tools> boards> ATmega32/32A (16MHz, external)
Tools> programmers> USBasp
Tools> Burn Bootloader

Then tried to upload the blink sketch
Tools> boards> ATmega32/32A (16MHz, external)
Tools> programmers> USBasp
File> Upload Using Programmer

The error shows

In file included from C:\Users\Roy\Desktop\arduino-1.0.5\hardware\mighty-1284p\cores\standard\/Arduino.h:213,
                 from C:\Users\Roy\Desktop\arduino-1.0.5\hardware\mighty-1284p\cores\standard\/wiring_private.h:33,
                 from C:\Users\Roy\Desktop\arduino-1.0.5\hardware\mighty-1284p\cores\standard\wiring_digital.c:28:
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\mighty-1284p\cores\standard\/pins_arduino.h:128: error: 'PCMSK0' undeclared here (not in a function)
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\mighty-1284p\cores\standard\/pins_arduino.h:129: error: 'PCMSK1' undeclared here (not in a function)
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\mighty-1284p\cores\standard\/pins_arduino.h:130: error: 'PCMSK2' undeclared here (not in a function)
C:\Users\Roy\Desktop\arduino-1.0.5\hardware\mighty-1284p\cores\standard\/pins_arduino.h:131: error: 'PCMSK3' undeclared here (not in a function)

All the errors are regarding “PCMSK” & after googling a bit I find it out to be something related to the pinchange interrupt. Then opened the pins_arduino.h file & get this

const uint16_t __pcmsk[] = 

I stopped here.

Second Method
Leaving all the changes done in the first attempt untouched except restoring the Bobuino folder to “C:\Users\Roy\Desktop\arduino-1.0.5\hardware\mighty-1284p\variants”. I put & overwrite the attached files (arduino.h, wiring_digital.c & pins_arduino.h) to the following folder “C:\Users\Roy\Desktop\arduino-1.0.5\hardware\mighty-1284p\cores\standard”
then selected
Then tried to upload the blink sketch
Tools> boards> Bobuino
Tools> programmers> USBasp
File> Upload Using Programmer

As I am using the wrong chip (Mega32A), IDE shows error stating “Wrong microcontroller found”

Binary sketch size: 1,246 bytes (of a 130,048 byte maximum)
avrdude: Expected signature for ATMEGA1284P is 1E 97 05
         Double check chip, or use -F to override this check.

I stopped here.

I suppose I am doing something wrong with the “PCMSK” while using the bobuino pins_arduino.h with Mega32A.
Should I delete the “PCMSK” part from the bobuino pinmapping .h file?

“mighty” folder location

Board selected in the first attempt

Board selected in the second attempt.

I can successfully upload sketches to Mega32A using the mega32 core files but I have to compromise with the pinmappings, I guess in that case I have to alter all the pin configurations for every arduino library. On the other hand bobuino features all the pin numbers including the spi, i2c, uart, adc etc. in a standard manner that will make the use of arduino libraries less complicated. That’s why I want to alter the pin mappings in my mega32A.