Retrointerfacing

- connecting past and future -

Arduino bootloader for ATmega32

The Arduino boards mainly use Atmega8 or ATmega168 controllers. For most of the projects and boards I have been working with in the last years, I have been using mega32 (more memory, more IO). In order to make use of the excellent Arduino resources, making my boards Arduino Compatible seems a logical choice. First thing to do was to rewrite the bootloader. In the following ZIP file you’ll find the modified source (untidied, but working) for an Atmega32 runnning at 16MHz. Also the modified ‘boards.txt’ file that resides in your Arduino hardware directory is in the ZIP. bootloader sources.

The bootloader can be compiled using the makefile in the zip archive, simply typing make in a console (from the correct directory, with correct path settings. I have WINavr as main avr compiler on my system)

In order to make code examples work, a re-mapping of input- and output pins is necessary. IN the discussion on the Arduino forum files where posted with a suggested re-mapping. (unfortunately they didn’t rewrite the bootloader for ATmega32, so I had to do that) I have tested uploading a serial-port example and a simple blinky, using the pin-mapping from AndreS from robotcraft.ca. Their arduino mega32 mapping sources have been posted in above forum. Overwriting the files with same names in hardware/cores/arduino directory does the trick.
I also recompiled bootloaders for other boards with ATmega8 running at 8MHz, see a page on http://www.edwindertien.nl/interactivos/index.html

Unfortunately the bootloader is rather large (2k). For an educational platform (MasterClass robot) we have been using a smaller bootloader (512K) which is AVR911 appnote compatible. (also using AVRdude to do the programming). More on this (mega32) platform can be found on http://www.ce.utwente.nl/e13 in the folder ‘education’.

A newer discussion on avrBootloaders, including the AVRdude commands used are on the wiki.

Comments

  1. mariano says:

    esto es posible ?? anda bien ??

    • edwin says:

      Sí, trabaja absolutamente bien. Usted necesitará un programador de la ISP del atmel programar al tablero con el cargador de arranque. Apenas transfiera el archivo de cierre relámpago e inténtelo.

  2. SRChiP says:

    What is the pin order? (when using to design the pcb)

    Is the order PD0 – PD7 –> 0-7
    PC0 – PC7 –> 8-15
    PB0 – PB7 –> 16-22

    PA0 – PA7 –> 0-7 (ADC) ?

    Or a different order?

  3. SRChiP says:

    Found it.
    It’s

    PD0 – PD7 –> 0-7
    PB0 – PB7 –> 8-15
    PC0 – PC7 –> 16-22

    PA0 – PA7 –> 0-7 (ADC)

    4, 5, 7, 11 seem to be with PWM.

  4. Ryan Dabhi says:

    Can you please tell me the fuses for Atmega32 and Atmega16 for 16 MHz crystal.

  5. Peter says:

    I have uploaded the bootloader to my Atmega32 using avrdude. I am now trying to upload a sketch from the arduino IDE via com1 through max232. This dosen’t work. ardunio IDE can’t detect the atmega32.

    max232 works for normal serial communications and the DTR is connected to reset via a 0.1uF cap.

    Any ideas?

    • edwin says:

      Hi Peter,
      Did you also set the fusebits when programming the bootloader using AVRdude? what kind of board-settings (boards.txt) do you use from Arduino IDE?

  6. [...] code for the other arduino boards. Now the boards.txt file mentions a bootloader. I found it at http://retrointerfacing.com/?p=30 and just used it. Actually you should not need a bootloader at all if you don’t program the [...]

  7. shahood says:

    i want to burn my at mega 32 to the arduino uno board tell me how to boatload my controller

  8. Dear Edwin,

    First of all your page seems to give confidence and a ray of hope to burn the ATmega32 with Arduino framework. As mentioned by you I have some difficulties in understanding certain steps. I wish to know

    * I have an USBASP programmer and understand that the makefile needs to be changed with usbasp and the port as usb. Am I rite?

    * Now after compiling using the makefile you had provided I have to burn the hex file to the flash of my ATmega32 rite?

    * Also the part that is not very clear is the one where you have mentioned about the pin mapping. Should I replace the files in my Arduino software directory with these file you have provided?

    Please help me on this.

    Thanks and Regards,

    Ashok Srinivasan.

  9. Edwin says:

    Hi Ashok, You only need to set your USBASP in the makefile if you use makefile to program the chip (as in make program). If you know how to use USBASP with avrdude (the default programmer) you can use the makefile just to compile the hex for the bootloader – and leave the programming to another tool. Even AVRstudio can be used for that.

    After compiling using the makefile, the hex file should be programmed first. After that, the mega32 can be programmed using the same serial protocols as for example Arduino is using.

    Since in Arduino also an option / structure is included in newer versions to have your own hardware descriptions, I’ll really have to look into an easy way of testing mega32 support for arduino. In fact the controller architecture is similar to the still supported ATmega8.

    The pin-mapping should be included or inserted in your arduino environment. This file tells arduino when you use digitalwrite(1,HIGH) which of the hardware pins you have named 1 …

Leave a Reply

Your email address will not be published. Required fields are marked *

*