The good old days were exactly that: Good. These days, there is a vast number of problems to deal with that our predesscors did not even dream of worrying about. I’m not talking about all that climate change stuff, but the technology issues: Which phone to buy next, should I follow such-and-such on Facebook and (the one I am about to tackle) Arduino bootloaders defaulting to 57600 baud.
Whilst running at 57600 baud makes perfect sense when you are operating with a crystal oscillator, not all applications necessarily require this. Sometimes, less is indeed more. The inaccuracy in the on board oscillator makes it difficult to operate at the higher baud rates.
There are a number of tutorials on the ‘tubes about configuring the ATMega328P chip (the Arduino chip) to work with the internal 8MHz oscillator. I’m not really trying to be user friendly with this post like most of the other authors aimed. This is more of a “this is what worked for me” information dump, that may make this process faster for some other person. The main changes that are required are:
- Change the Bootloader
- Change the Make File
- Recompile the Bootloader
- Program the Bootloader
- Modify the Arduino boards.txt to reflect this new configuration.
First and foremost – don’t do this unless you already know how to do this. You could break stuff. I am not responsible for that stuff or anything else you may break by following this incorrect not-instructions. You have been warned.
Change the Bootloader
I am using the hardware\arduino\bootloaders\atmega\ATmegaBOOT_168.c as the basis for these modifications. Your experience and choice may vary, but this works for me!
If you have a custom board with a custom blinky LED location – you can also change where the bootloader blinks in this file. Check around Line 131.
Other then that – follow the links and you should be good. The baud rate here does NOT need changing (Line 97)
Change the Make File
Copy and paste from a known good working one – I chose the atmega328_pro8 configuration. Change the baud rate setting to something slow, I am using 9600 which seems reliable. Done. Easy eh?
It should look something like this:
atmega328_pro8_nox: TARGET = atmega328_pro_8MHz
atmega328_pro8_nox: MCU_TARGET = atmega328p
atmega328_pro8_nox: CFLAGS += '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=1' -DBAUD_RATE=9600 -DDOUBLE_SPEED
atmega328_pro8_nox: AVR_FREQ = 8000000L
atmega328_pro8_nox: LDSECTION = --section-start=.text=0x7800
Recompile the Bootloader
I am not going to repeat this here, check that above mentioned link to here.
The gist is – make sure that all works with a known make configuration.
To compile the above modification is:
Following this, you should have the relevant hex file appear.
Program the Bootloader
Pick your favourite programmer, grab the above generated hex file and program away! If you have a blinky LED, it should be blinky after programming.
Modify the Arduino boards.txt to reflect this new configuration.
Again, copy the pro8 (or whatever you used as the starting point) configuration from hardware\arduino\boards.txt and paste into your user directory boards.txt.
Rename the configuration and then tweak the baud rate to the same number used in the make file and restart the Arduino software. This new configuration should now appear. The relevant lines that I added to my boards.txt file are:
pro328nox.name=Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328 & No Crystal
A final note on fuse settings. The ones I am using with the above configuration are:
Anyway, hopefully this makes the process a bit faster for somebody else!