Step 10: Preparing the Microcontroller
If you don't have the Arduino IDE, download it and install it. I am using version 0022.
The following steps are explained in detail in this wiki article: http://code.google.com/p/ro-4-copter/wiki/GeneralSoftwareSetup
This page is just a really short summary of what is already in the above wiki article!
The Arduino bootloader should be programmed into the microcontroller first. This step requires the use of an AVR programmer. However, after the bootloader is flashed into the microcontroller, you will only need an USB-to-serial cable (such as an FTDI cable) to upload code from the Arduino IDE.
The bootloader (I've attached it) is modified slightly since I'm using the ATmega644P instead of the usual Arduino's ATmega328P. The files are provided. The fuse-bits need to be written to the correct values as well.
AVRDUDE is the utility that we use to flash the bootloader .hex file into the microcontroller. The AVRDUDE commands you'll need is
"avrdude -c programmer_name -p atmega644p -U flash:w:bootloader_filename.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD8:m"
Pay attention to the programmer_name and the bootloader_filename! The fuses are to get the ATmega to use the 16 MHz resonator, set the bootloader size, enable the bootloader, disable JTAG and enable SPI downloading.
Also copy the bootloader folder "Ro4Copter_Boot" (remember to rename it without the date version) as .../arduino-0022/hardware/arduino/bootloaders/Ro4Copter_Boot.
Also, download the Arduino "core" I've provided here (called Ro4Copter_Core, remember to rename it without the date version), and place it into the "core" directory within Arduino so you get .../arduino-0022/hardware/arduino/cores/Ro4Copter_Core . Also modify the boards.txt file to include an entry to use this core. This will allow the Arduino IDE to compile for the ATmega644P instead of the original Arduino's ATmega328P. Be sure to select the correct board entry inside the Arduino IDE menus. For more details on this step, check out the wiki page I linked above.
The board.txt entry:
Here's a screenshot to show you where all these folders are:
The sketch you need to compile is provided in step 26. Compile it and upload it to the ATmega644P using the bootloader later.
The next few steps will help you understand what exactly the code is doing. Skip them if you don't care.