Programming
To build Stubby's firmware (program) and upload it to the robot, we need a few tools:
- a git client to download the source code
- avr-gcc to compile the source code
- an ISP programmer that is compatible with avrdude to upload the compiled program to Stubby
Download source code
You can download all the source code for Stubby from Github. You can either click the "Download Zip" button to download a .zip file of the current revision, or you can clone the entire repository using a Git client. Either way, you will end up with a folder 'stubby' containing a number of folders 'avr', 'doc', 'frame', etc.
Compile the Source Code
If you don't already have it, you need to download an avr-gcc compiler. How to do this depends on what operating system you are running:
- On Debian Linux (and Debian derivatives like Mint and Ubuntu), install the packages 'gcc-avr', 'avr-libc', and 'avrdude'.
- On OSX, install Crosspack for AVR Development
- On Windows, install WinAVR (while testing I used the 2010-01-10 version and that worked fine; any more recent one should also work).
Once you have the compiler installed, open a command prompt and navigate to the stubby/avr folder (that you just downloaded). Type 'make'. You should see a bunch of stuff scroll by, ending in something like the following:
AVR Memory Usage
----------------
Device: atmega1284p
Program: 30586 bytes (23.3% Full)
(.text + .data + .bootloader)
Data: 4175 bytes (25.5% Full)
(.data + .bss + .noinit)
Upload the program
Finally, you need a way to upload the program to Stubby. I currently use LadyAda's USB Tiny ASP, but there are a million different options out there. Just make sure that whatever you use is compatile with avrdude.
To upload the program, you first need to modify the Makefile to specify what programmer you are using. Look for the line "AVRDUDE_PROGRAMMER=usbtiny" and change usbtiny to be the programmer that you are using. (To find a list of all programmers supported by your version of avrdude, type 'avrdude -c ?'). Once you have changed the Makefile to use your programmer, plug in the programmer to the 6 pin ISP headers on Stubby and type 'make program'.