8Mhz bootloader for Arduino Micro

I have finished my project development and want to move to a standalone ATmega32.
I need to run this at 3.3V and I dont want to go down the overclocking road so I have an 8MHz crystal to put on it.

I still want to be able to upload sketches via USB and the Arduino compiler so I gather I need to burn a different bootloader.

For this purpose I have purchased a USBASP programmer.

I am slightly unsure of what to do next - everything I can find on the topic either relates to the ATmega328 or to burning bootloaders using another Arduino.

I have worked out that I need to modify boards.txt to point to the correct bootloader....but which is the correct bootloader for ATmega32 at 8Mhz?

Also do I need to change any fuses?

Thanks

You'll need to compile the caterina bootloader from source. It can be found on GitHub. I haven't tried it yet, but you should probably just edit the makefile (and maybe the micro files as well) to set the clock speed, and then run make, specifying which board you're compiling for.

You don't really have to point to the correct bootloader, only if you plan to upload it using the Arduino IDE. You just have to add a new option to the speed menu of the Micro, to let the compiler know that the speed is different. (micro.build.f_cpu=8000000L) This will set the right compiler flags in platform.txt.

Hope this helps!
Pieter

To add a new menu entry, comment out this line in boards.txt: # micro.build.f_cpu=16000000L
and add the following lines:

micro.menu.cpu.16MHz=16 MHz
micro.menu.cpu.8MHz=8 Mhz

micro.menu.cpu.16MHz.build.f_cpu=16000000L
micro.menu.cpu.8MHz.build.f_cpu=8000000L

Pieter

Hmm
I was wondering if maybe what I was creating was closer to a pro-micro than a micro.
The pro-micro uses an ATmega32u4 and runs at 8Mhz and 3.3V

Maybe I should just set the board to Pro-Micro in the Arduino IDE and select burn bootloader?
Would this work?
Except there does not appear to be a board option for Pro-Micro????????

What about Lilypad?
This also seems to use the same device and clock speeds?

thorntonforce:
Except there does not appear to be a board option for Pro-Micro????????

That's because it's not an official Arduino.cc board, check SparkFun's product page, I think they have Pro Micro core files for the IDE available.

Pieter

Keep in mind that the Micro and Pro Micro don't have all pins of the ATmega32U4 broken out, so you may want to compile your own bootloader anyway.

Pieter

Pieter
I know the pro micro board has less than the micro but that wont stop me accessing all the pins in the main program - will it?
All the bootloader needs to do load the program?

That depends. If you use the Arduino Micro core libraries, you won't be able to use these extra pins, since they are simply not defined. Direct port manipulation would still work though.
If you're using the Micro bootloader and a different Arduino core (e.g. Leonardo), you may run into trouble while uploading, since avr-dude gets an invalid response, because it's a different bootloader than it was expecting.
Some fiddling around with boards.txt or some core libraries could probably solve that though.
Or it could just work, I don't know, just use some trial and error, it's a proven technique :wink: .

Pieter

Hello, thorntonforce
I have the same problem on it, and I have got a method to deal with it.

As you said, burn the bootloader of Pro-Micro or LilyPadUSB could make the self-made ATMega32U4 arduino board work. But I need the system to recognize it as arduino-micro or leonardo, so that I could use the simulink coder to generate code for it(Simulink coder can't generate spi code for LilyPadUSB and don't support code generation for Pro-Micro).

First, download the caterina bootloader source code, and put the two .c files, two .h files and Makefile in the same folder.

Revise the makefile.

In the line 49, uncomment the VID and PID for leonardo

# USB vendor ID (VID)
# reuse of this VID by others is forbidden by USB-IF
# official Arduino LLC VID
VID = 0x2341


# USB product ID (PID)
# official Leonardo PID
PID = 0x0036
# official Micro PID
# PID = 0x0037
# official Esplora PID
# PID = 0x003C

In the line 88, change the f_cpu to 8000000

F_CPU = 8000000

In the line 130, change the path to the LUFA library

LUFA_PATH = LUFA-111009

Then download the LUFA library 111009:LUFA
The file could be find at 'Show/Hide Old Releases' at the bottom of the page.

Extract the LUFA-111009 to the caterina bootloader source code folder and change the name of the LUFA library folder to 'LUFA-111009'(as defined in the makefile)

Install winavr:Winavr
Note:The installation program of winavr would delete the system environment variables, so you should better backup the system environment variables before installation or do it in a virtual machine

Open the Windows Command Line, and enter the caterina bootloader source code folder. Type 'make' and the hex file of leonardo bootloader will be generated. It could be burned to the ATmega32 board by USBASP.

After I burned the bootloader, the board that I made is recognized as the ‘Arduino Leonardo Bootloader’. Since I haven't download program to the board, it stops at bootloader.

I tried to download a program to it, but after that, the board couldn't be recognized by computer. If I reset ATmega32U4. Computer could recognize the Leonardo Bootloader, but after a while, the board couldn't be recognized again.

I could set the board type as LilyPadUSB in arduino IDE and downloaded the program to the board, but the board was recognized as LilyPadUSB in computer. When I reset the ATmega32U4, the computer recognized the board as Leonardo Bootloader, after a while, it was recognized as LilyPadUSB.

It seems that after the reset, the ATmega32U4 entered the bootloader, after a while, the program began to run. It's like that there's some special parameter about cpu clock in the program that compiled by Arduino IDE.

I found a text file 'boards.txt' under $Arduino Installation Path$\hardware\arduino\avr.

I found the line

leonardo.build.f_cpu=16000000L

And changed the f_cpu to 8000000L.

This parameter will affect the build process of Arduino IDE. After I changed it, the program could work on my board, and it was recognized as leonardo.

Now the 8MHz bootloader for Arduino ATmega32U4 board has been done, but I still have some problems with it

I thought I could use simulink to generate code for my board. But when I tried to do it, after the program generated by simulink downloaded to the board, it wasn't recognized again. :frowning: :frowning:

There should be some file that defines the cpu clock of board under simulink support package folder, not the 'board.txt' file(I had revised it). Is there anyone know which is the file?

Sorry for my expression. I'm not a native speaker, so there meybe so many grammar faults. :cold_sweat: