Custom Arduino Bootloader for custom Board

Hi everybody!

I'm actually working on a project which needs to have a low energy consumption. For this reason I develop a custom board based on Arduino.
At the beginning I used a atmega328 with the 16Mhz quartz and the original bootloader.
But the current was to high. I changed it by a 4MHz quartz and it's ok for consumption but of course timming are 4 time slower than before.

I think that the only way is to flash my chip with a custom boot configured for 4MHz quartz. I success to flash a standard boot with the arduino ISP method (http://arduino.cc/en/Tutorial/ArduinoISP) (before trying to do it for 4MHz)

I tried to create a new board changing the boards.txt file

##############################################################

atmega328c.name=Custom ATmega328 4mhz

atmega328c.upload.protocol=stk500
atmega328c.upload.maximum_size=30720
atmega328c.upload.speed=57600

atmega328c.bootloader.low_fuses=0xFF
atmega328c.bootloader.high_fuses=0xDA
atmega328c.bootloader.extended_fuses=0x07
atmega328c.bootloader.path=atmega
atmega328c.bootloader.file=ATmegaBOOT_168_atmega328.hex
atmega328c.bootloader.unlock_bits=0x3F
atmega328c.bootloader.lock_bits=0x0F

atmega328c.build.mcu=atmega328p
atmega328c.build.f_cpu=4000000L
atmega328c.build.core=arduino

I also modify fuses bits to have a lower brown out voltage.

But the problem is that I can't observe timming changes...
Do I need to rebuild the boot and change some code or it could be ok by this way ...

NB: I'm using a LCD screen and so the ShiftOut function. Maybe change build.f_cpu is not enough to have an influence on this function ?

Thanks for your help ! :slight_smile:

If you can flash a bootloader you already have an ISP. Why do you need a bootloader then? Just configure the IDE to directly use the ISP for flashing.

I think I didn't not explain my problem very well ...

What I need in fact is not a bootloader. As you said my arduino is used as an ISP and it works !
What I need is a boot for atmega328 working with a 4MHz quartz. I need it because I don't want to have a wrong timebase when executing my software.

Do I have to modify and rebuild boot source code or just modify boards.txt should be ok ?

What I need in fact is not a bootloader.

What I need is a boot for atmega328

Well you are going to have to define better what you mean by “a boot” for us to figure out what
you think you need. Those two statements contradict each other.

Lefty

Ok !
So let's start from the beginnig ...
I made a card based on atmega328 and a 4MHz quartz instead of 16MHz on duemilnove.
The question is : what can i do to resolve timming problem due to a slower quartz. (example: millis is slowerthan before ...)

I usually ignore boot loader issues if I have an ISP. If you have an ISP double check if you REALLY need a bootloader. With regard to the other timing stuff: go through the Arduino libraries and search for everything timing related and fix the constants. There may be another way but that's what I would do.

The question is : what can i do to resolve timming problem due to a slower quartz. (example: millis is slowerthan before ...)

Let your events run 4 times as long.
Set your Serial.begin(speed) to 4 times what the end is using.