Learning to use "make" files to compile a new Arduino bootloader
April 1, 2012
G'day everyone. I am not a professional programmer, I have not had any training in C language. Previously I had a lot of support from LMR and learned to write an Arduino Library. Now I am trying to compile a bootloader and need help again. I've installed WinAVR and AVR studio and have been trying to find out how to use them. It seems I need to learn to use a "make" file but I cannot find any good information on how to do this. Most information on the net assumes I am a programmer.
ATmel have stopped producing the older ATmega168 20-AU chip previously used for Arduino products. It has been replaced with a new ATmega168PA-AU chip with a lower power consumption and a different ID signature that plays havoc with avrdude when you try to write a bootloader using an Arduino as an ISP.
I admit the easiest solution is just to change over to the ATmega328P that is now the Arduino standard but where would be the fun in that? I'd learn nothing. Also the ATmega168 is still a little bit cheaper and has plenty of memory for most beginner robots. For some customers such as a school that wants to order a 100 controllers, saving a few dollars by not paying for memory the students are unlikely to use makes the ATmega168 a good choice.
The opti-boot bootloader has been available for some time now aand is the standard for the Arduino Uno. It allows the software to be downloaded much quicker and it gives back 1.5K of program space. I would like to use this with DAGU products.
So far I have managed to modify the avrdude.conf file to include a 168p processor with the different signiture ID. I have modified the boards.txt file to use an opti-boot bootloader for the Arduino pro mini 8MHz @ 3.3V and called it:
Micro Magician (3.3V, 8 MHz) w/ ATmega168PA
Check the attached files to see the modified files. Note: I had to add a .TXT extension to the avrdude.conf file so I could attach it on LMR. please re-name if you want to use/test it.
NOW I NEED YOUR HELP!
While the new board type I created worked fine for burning the bootloader using another Arduino as an ISP it will not work for uploading a sketch. To upload a sketch I must select the original Arduino "pro-mini board 8MHz @ 3.3V" otherwise I get the avrdude "invalid signiature ID" error.
I assume this is because I am using the original bootloader and that it is returning the wrong signature. Here are the signatures:
ID - ATmega168 20-AU: 1E 94 06
ID - ATmega168 PA-AU: 1E 94 0B
It would seem that I need to edit the "optiboot" bootloader to return the new signature ID (1E 94 0B). I have had a look at the code but I am not entirely sure how to edit it and then I still have not worked out how to use the make file. What program am I supposed to run?
I am hoping an experienced programmer can explain to me where the bootloader needs to be edited to return the correct ID and how exactly am I supposed to compile the optiboot.c file to get the correct HEX file. I have looked at both WinAVR and AVRstudio with no luck.