Software Development Tools
The following tools are used for hardware development of the OpenServo.
WinAVR
WinAVR (pronounced "whenever") is a suite of executable, open source software development tools including GNU GCC C and C++ compiler for the Atmel AVR microcontrollers hosted on the Windows platform. It includes the AVR Libc which is a Free Software project that provides a high quality C library for use with GCC on Atmel AVR microcontrollers.
Atmel AVR Studio 4
AVR Studio 4 is a free professional Integrated Development Environment for writing and debugging Atmel AVR applications in Windows environments. It includes an assembler and a simulator as well as integration with the WinAVR GNU GCC C and C++ compiler for AVR microcontrollers.
Installation Notes
Compiling the OpenServo software and bootloader requires the latest version of WinAVR and AVR Studio 4. Earlier versions of these software packages didn't properly support C development for the AVR ATtiny45 MCU without patches to the development environment. It is recommended the latest versions of these software packages be used for OpenServo development. Step 1: Uninstall WinAVR and AVR Studio
- Be sure to uninstall any previous versions of WinAVR and AVR Studio on your Windows development system before installing the new versions.
Step 2: Download WinAVR 20060125
Download the latest WinAVR release (WinAVR-20060125-install.exe) from the SourceForge.net WinAVR download page.
Step 3: Download AVR Studio 4.12 Software and Upgrades
Download the following AVR Studio 4.12 software and upgrades from the Atmel AVR Tools Beta Site:
AVR Studio 4.12, Build 460 (AvrStudio4Setup.exe) AVR Studio 4.12, Service Pack 2, Build 472 (AVRStudio412SP2.exe)
Step 4: Install WinAVR
- WinAVR must be installed before AVR Studio. Run the WinAVR-20060125-install.exe program to install WinAVR Release 20060125 in the default location of C:/WINAVR.
Step 5: Install AVR Studio 4.12 Software and Upgrades
- Run the AVR Studio installation programs in the following order:
AvrStudio4Setup.exe AVRStudio412SP2.exe
Step 6: Install WinCVS (Optional)
It is recommended that you install WinCVS as described on the WinCVS Notes Page to access the OpenServo software directly from the OpenServo CVS repository.
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
