Go Down

Topic: A couple bootloader modification questions (Read 1 time) previous topic - next topic


Dec 13, 2009, 04:11 pm Last Edit: Dec 13, 2009, 04:57 pm by pspkicks Reason: 1
Okay, I have 2 AtMega88s here, unprogrammed.

I need to burn a bootloader to them. Now, I need the sketch to start as soon as the chip turns on, with as minimal a delay as possible. How would I go about doing this? Would it be possible to make it so that if a button is held down on boot, then the sketch will delay and allow reprogramming? I have no clue about bootloaders so I REALLY need help with this one.

Another thing is that I need these to run at 4MHz, using either an external or internal Crystal. I have external ones if I HAVE to use them, but I'd prefer internal clock.
Would someone be able to help me, or guide me, with changing the bootloader so that the chip runs at 4MHz? I need this so I can utilize the 1.8v voltage requirement.

I really appreciate any help you guys give!

Can I just burn an extremely minimalistic "bootloader" that just sets the fuses? And then program using the Arduino IDE directly? Would I be able to use the Arduino commands (such as digitalWrite()) still, or would I definitely need a (modified) Arduino bootloader?


You could eliminate the bootloader and burn the chip with a programmer.


Dec 13, 2009, 08:37 pm Last Edit: Dec 13, 2009, 09:45 pm by pspkicks Reason: 1
Would I still be able to use Arduino commands? Like digitalWrite(), analogWrite(), etc?
Or do I NEED the bootloader for that?

How would I go about changing the clock speed then...?

I tried editing the make file and such, but I just don't get this stuff. I'm not used to messing with bootloaders.

I need to know how to make a bootloader for the AtMega88, set it to 4MHz clock, and reduce the delay time to 0 to go straight to a sketch...
Can ANYONE help me?


You've got a lot of questions there, I'll try to answer a few, and set you on the way to finding the answers to the rest of them yourself.

First of all, you are going to need an external ICSP programmer. Examples include the simple parallel port version, or the more powerful USBtinyISP from ladyada.

The fuses are NOT set by the bootloader. The arduino "system" burns the fuses at the same time as the bootloader, but the bootloader itself does not affect the fuses.

Here's some more info on fuses...

You can use a fuse calculator on the web to determine what fuses you need for a 4MHz clock. Then you'll use avrdude and your external programmer to burn the correct fuses on your micro.

Here's ladyada's tutorial on avrdude...

To use a 4Mhz clock, you'll need to create a new entry in the Arduino's Tools->Board menu. This new entry will specify that you are using a 4Mhz clock, and adjust the timing to suit.

You'll then write your code using all the usual digitalWrite() commands. When you compile your sektch, using the "play" button, the arduino IDE creates a compiled version of your sektch in machine-language, an intel-format .hex file.

Since you'll have no bootloader, you'll then use avrdude and your external programmer to upload the compiled sketch to your micro.


Hmm... so modifying a bootloader isn't necessarily needed. I guess the past few hours were for nothing  :D

I'll look into that. I took the time to start understanding the fuses for my mega, and wrote an entry in the makefile. I highly doubt it would've worked, anyway. Haha.

I didn't realize the Arduino IDE recompiled the sketch into a HEX file.
I thought interpretation was done using the bootloader on the mega. Boy was I wrong.

Thanks so much! I'll definitely look up on those.


Here's more info than you need on the Arduino build process


Here's how to upload directly from the Arduino IDE using an external programmer. Note you don't have to do this if you are willing to use the command-line avrdude process


Here's how to make your parallel programmer, if you go the cheapest way...


Already made the programmer, but I'm waiting for the sparkfun usb programmer to be in stock (cheapest place between price and shipping) and I'll get that.

Thanks so much for the help!


Dec 17, 2009, 01:31 am Last Edit: Dec 17, 2009, 01:33 am by pspkicks Reason: 1
Where does the hex file get saved...?
I saved a sketch to a folder, then compiled. No hex file.

Had to hit upload (even though I'm not using the IDE to upload) to get it to compile.


Go Up