Software Development Tools

The following tools are used for hardware development of the OpenServo.

WinAVR

Atmel AVR Studio 4

Installation Notes

Generating Machine Language (Hex) Files Using AVR Studio

Programs written in C or Assembly language can be built (converted) into a file known as a hex file. To ensure your program will function within the OpenServo, please follow these steps when building your files:

1. Create a new project, or open an old one.

You can add source code by opening a .aps file or by creating a new project and adding the files manually. If you open a .aps file, you can skip to step 2. To create a new project, start by clicking Project -> New Project. Select your Project type and Project name, as below. Be sure to uncheck "Create initial file". Browse to the location you want to store your project. Ensure that your source files (if they already exist) are in this directory.

. 2. Configure the project

If you opened a .aps file, then these settings should be set already, but you should always double check them. Click Project -> Configuration Options, then make sure your setting match those below (with an appropriate name for the Output File name.) Ensure that the Device matches the MCU that you are using (the latest release of the OpenServo uses an ATmega168.) The latest release also uses a 20 MHz (20,000,000 Hz) ceramic oscillator, so set the frequency to match this. Ensure the "create hex file" box is checked. The best optimization is typically -0s, but you are welcome to experiment (to learn more about the optimization settings click here.) Click "OK" when finished.

Next, you'll need to specify the linker options (if necessary.) Usually, you will not need to perform this procedure. But for this example, I am building the OpenServo bootloader, the supplemental README file that comes with the source code explains the appropriate linker settings. In this example, the bootloader sits in a special area of memory that we need to tell AVR GCC to put the program into. Normally, the program can just sit in the default location, but because we want to allow the bootloader to reprogrammed itself (if necessary,) we need to move it to a special location. The OpenServo mantra is: ALWAYS read any README files before working with source code. This will ensure that your build goes smoothly. To edit linker options, click the Custom Options icon on the left side of the Project Options dialog box. Then click "[Linker Options]", type the linker options you want to use, and click "Add" to add a linker option to the list. In this case, the bootloader instructs to use the following:

-nostartfiles

-Wl,-Ttext,0x3C00

3. Add source files

Right-click the "Source Files" folder in the AVR GCC panel to the left. (If you've closed this window by accident, re-open it by clicking View -> Toolbars -> AVR GCC.) Select the source files that you wish to add to your project (if they exist) as below. Again, your files all need to be in the same folder that you specified in step 1.

Then add the header files in the same manner.

4. Build the project

Click Build -> Build to compile and build your project. If all goes well, you should receive something similar to this:

That's it! Your newly created hex file is in a new subdirectory of your project called "default". Use this hex file to flash your OpenServo with the code of your desire.

Up next: Flash an OpenServo using AVR Studio.

Return to OpenServo Software