Code Blocks IDE for avr-gcc and avrdude (Ubuntu)
Posted by stringofthoughts on November 6, 2009
Code Blocks is very light weight, extensible and fully configurable C/C++ IDE. You can download code blocks from here. This post focuses on installation and configuration of code blocks on Ubuntu. Download the binary package codeblocks_8.02-0ubuntu1.deb.tar.gz. Inside the compressed file there is a folder with following packages.
Install the packages in bold letters. In case you are wondering how to install, just double click on the packages (damn it’s easy to install softwares in Ubuntu 😛 ) After the installing you can access code blocks from menu Applications -> Programming -> Code::Blocks IDE.
Click on Create a new project in home window to create your new project. Code blocks automatically adds an AVR Project option. Select that and click next. Fill the required informations like project name, path, crystal frequency etc and click finish.
In the Project Tab of management window (left side of the screen) you ‘ve your workspace. Inside the sources you ‘ve main.c. you can of-course add more files. Now your project is ready. congratulations !!! . There is still one thing left to do. Open build options from menu: Project -> Build options and in compiler flags tab check flag “Optimize generated code (for size) [-Os]”. You might wonder why? well compiler won’t compile your code and you ‘ll be stuck with warning(s) 🙂 ( I myself checked the flag after getting warnings )
# Make sure to switch to Release mode to generate hex file. Do all the debugging in debug mode and once it’s done switch to Release mode and build again to generate hex file. Project hex file is in <Project dir>/<bin>/<Release> and it’s the .elf.hex file you need.
Adding avrdude in code blocks tools. Follow the steps
Open the “User defined tools” window from menu: Tools -> configure tools.
Click on Add button to open Edit tool window.
Add the parameters for avrdude as shown in above image and you are done. After compiling in release mode just click on the avrdude option in tools menu and it will burn .elf.hex file in the microcontroller (Make sure the the target is powered on and programming cable is connected )
Have a nice time buring microcontrollers 😛