A FreeBSD port for the Eclipse AVR add-on has yet to be created and the Eclipse CDT add-on that is contained in even a recent ports tree is too outdated to use with the AVR add-on.
To fix this, I basically started with a naked Eclipse install from ports and installed the extra features manually using Eclipse's update mechanism and each add-on's respective update site.
Java
If you don't already have it, it's time to get the Java JDK installed so you can run the Eclipse platform. Unfortunately, we must jump through some licensing hoops that cause us to visit a few web pages and download a few files off a website the old fashioned way. Just go along with it until you have satisfied all of the dependencies it asks of you.
- /usr/ports/java/jdk16
- make install clean distclean
Installing Eclipse
Please note that we will be using Eclipse 3.4.x (Ganymede), therefore all our add-ons will have to be for Eclipse 3.4.x! For some reason, different versions of the add-ons are for different versions of Eclipse... don't get confused.
The most obvious thing we will need is the Eclipse platform. You can easily install it from ports as long as you have the latest Java JDK.
- # cd /usr/ports/java/eclipse
- # make install clean distclean
Installing the AVR GCC Compiler & Tools
avr-gcc is the compiler we will use on AVR/ATMEL projects. The rest of the ports we are installing include a host of development and header files that allow us to develop and further interact with ATMEL products. These header files also populate the AVR Eclipse plugin with the information it needs to gives the user options for a project.
Also worth mentioning, we use an awesome program, avrdude, to interface with the ATMEL/AVR microprocessor and to facilitate read/write/erase/flashing/etc. Read the man page after you install it and check out the plethora of options it offers.
- # cd /usr/ports/devel/avr-gcc
- # make install clean distclean
- # cd /usr/ports/devel/avr-binutils
- # make install clean distclean
- # cd /usr/ports/devel/avr-libc
- # make install clean distclean
- # cd /usr/ports/devel/avrdude
- # make install clean distclean
Installing the Eclipse Add-ons
The Eclipse developers made a handy utility to allow you to easily add "links" to get a directory of components that are related to a specific add-on. This makes it incredibly easy to manage, update, and install these add-ons.
To start this utility, simply open up Eclipse, pick your workspace, and go to Help -> Software Updates... in the top menu bar contained in Eclipse.
Add-ons We Will Need
Eclipse CDT Project
As mentioned earlier, the CDT Eclipse plugin turns Eclipse from a Java IDE into a powerful C/C++ development environment. Since we ultimately want to use the AVR Eclipse plugin that utilizes avr-gcc, this should be an obvious choice!
Eclipse AVR Project
This is ultimately what we are after! The Eclipse AVR project integrates items in Eclipse CDT that aid in developing for various ATMEL processors. For example, you can choose your target processor from their list and it presents you with a listing of corresponding registers, ports, interrupts, and various other helpful macros in easy to navigate pane.
Mylyn Eclipse Project
Mylyn is mainly a dependency for the things we need, but if you are actually interested in what it is, this is a blurb from their project website from above:
Mylyn is a task-focused interface for Eclipse that reduces information overload and makes multi-tasking easy. It does this by making tasks a first class part of Eclipse, and integrating rich and offline editing for repositories such as Bugzilla, Trac, and JIRA. Once your tasks are integrated, Mylyn monitors your work activity to identify relevant information, and uses this task context to focus the user interface on the task-at-hand. This puts the information you need at your fingertips and improves productivity by reducing searching, scrolling, and navigation. By making task context explicit Mylyn also facilitates multitasking, planning, reusing past efforts, and sharing expertise.
Prepare Updates
We have to add a few of those links I was talking about earlier to our Available Software tab in eclipse.
To get these links, I visited each project homepage and they are usually contained on the dowload page for the project. The following are relevant as of Dec 2009.
| Project | Link |
|---|---|
| CDT 5.0.x | http://download.eclipse.org/tools/cdt/releases/ganymede |
| AVR | http://avr-eclipse.sourceforge.net/updatesite/ |
| Mylyn | http://download.eclipse.org/tools/mylyn/update/e3.4 |
Simply go to the Available Software tap and input each link into the Add Site dialog box.
After all the links have been inputted, your Available Software pane should be populated with our 3 new update sites.
Now that we have the package repositories, check the boxes corresponding to the CDT and AVR projects (and make sure that all the boxes underneath them are checked... sometimes they do not get checked for some reason). DO NOT check the box for Mylyn, as it will create conflicts with some features in the CDT plugin. Dependencies will be automatically installed from it. Then click on the Install... button in the Available Software pane.
If there are no conflicts in the Details text area, click Next to proceed to the license agreement. Accept it if you want to use the software and now the plugins should start their respective download / install cycles.
Restart Eclipse so all of the installed add-ons can be properly initialized.
Loading the the AVR add-on into Eclipse
Start up Eclipse and start up the C/C++ perspective:
You should now be a C/C++ development environment. If you don't see the AVR Device Explorer anywhere in the IDE window, we will have to manually add it to our CDT view. It should be near the bottom of the IDE window in the tabbed section and it looks something like this:
If you do not see it, simply tell Eclipse to bring it into the view by going to Window -> Show View -> AVR Device Explorer and it should pop up somewhere in the IDE. You should be able to drag it around to different areas in the Eclipse IDE. I typically place it to match the above picture.
Helpful Eclipse Settings for AVR Add-on
We that we have the add-on installed, we need to make a few minor changes to let FreeBSD utilize the AVR add-ons helpful features.
- use the "Release" build settings
- use gmake instead of make for a Makefile
- avr-gcc compile in C99 mode
- specify the programmer
- override serial device parameter with USB serial device
- adjust permissions on device so a user can use it
The following tweaks imply that you have loaded Eclipse, CDT, the AVR add-on, and have a (C) project open.
If you are unfamiliar with Eclipse, follow along to get a C project started... otherwise skip to the next heading.
Give the new file a name and change to a C template, not a C++ template.
Throw an empty function in the new file: int main() { return 0; }
"Release" build settings
If you use the debug configuration settings for the C/C++ builder, you will not get a .hex file after the project build. We can fix this by manually checking a few check boxes in the AVR Build Settings or we can switch to a release build configuration.
Select Manage Configuration to select which build settings to use. We want to make the Release active.
Use gmake Instead of make
The AVR Eclipse plugin uses a generated Makefile that is incompatible with BSD's make utility. Also, many AVR Makefile examples on the web are, too, incompatible with FreeBSD's make utility. Lucky for us, we can simply install the gmake utility from FreeBSD ports.
Odds are you might have it already, so we'll check: Keep in mind that your version numbers will vary!
- # pkg_info | grep gmake
- gmake-3.81_3 GNU version of 'make' utility
If the previous query returned no results, simply take a trip over to ports and install.
- # cd /usr/ports/devel/gmake
- # make install clean distclean
Now that we have gmake on our system, we have to configure Eclipse to use
Replace make with gmake.
Test Project Build
Lets try to run the automatically generating Makefile via Eclipse's build feature. We can tell if our changes were successful by looking at the output of the make process.
If your output is locking references to HEX files, you might not have enabled the Release build settings. The following is lacking the HEX references because it is using the Debug build settings. Check out the heading before this one to get a fix!
avr-gcc Compile in C99 Mode
I prefer C99 mode as of recent and had to make a minor change to a parameter in the project build settings. Again, visit the Project -> Project Properties -> expand C/C++ Build -> Settings -> expand AVR Compiler -> Miscellaneous and append -std=c99 to the "Other Flags" input box.
avrdude Settings
Now we just need to specify which programmer we intend to use for the chip and, possibly, override the serial device name to a custom interface to interact with the chip/programmer. Obviously, start out in the usual Project Properties window.
Select the New... button and select your programmer.
Also, in my case I am using a USB Serial cable adapter, so my device name is /dev/cuaU0 that I will use to talk to my programmer. If you are using a standard DB9 serial cable, you can omit this step (default is /dev/cuaU0). Also, if you have some other custom device for your interface, use that (obviously). Input the device name into the Override default port input box.
Save and give the configuration and, optionally, give it a descriptive name (such as the programmer name). Save all the other screens and click on the Apply button.
We also need to select our target processor that we will be programming for. This argument is always used for a parameter for avrdude.
The Load from MCU button probably will not work at this point. We will use this at the very end of this guide to verify all that all the of settings we have previously set up are correct.
Adjust Permissions on Serial Device for User Access
As of right now, we should be good to go as long as your programmer works! The only bad thing is we can't use the AVR add-on to program our device due to that lack of privileges when it runs avrdude as a regular user. We can always run Eclipse with root privileges, or we can fix the problem by tweaking some permissions to allow all users access to the serial device (/dev/cuaU0 for DB9 serial, /dev/cuaU0 for USB serial).
- # echo 'own /dev/cuaU0 root:wheel' >> /etc/devfs.conf
- # echo 'perm /dev/cuaU0 0660' >> /etc/devfs.conf
- # echo 'devfs_enable="YES"' >> /etc/rc.conf
- # /etc/rc.d/devfs start
Verify Communication to Chip
Now, setup the ATMEL/AVR processor in a device and hook up the programmer. Double check everything.
Revisit Properties -> Project Properties -> AVR -> Target Hardware and click on the Load from MCU button. Eclipse should have populated the MCU Type selection box with the correct processor hooked up to the programmer. If not, (hopefully) you will get a verbose error message that you should attend to as necessary.
Verify Write Access to Chip
Obviously, the previous step should have completed successfully (or you otherwise know you can access the chip correctly). Now we will write a nonsense program to verify that we can write to the chips memory.
I am referring to the short program we made in a C source file in our project earlier. int main() { return 0; }
- Tags
- AI (1)
- ALIX (1)
- digitalfoo.net (2)
- embedded (6)
- FreeBSD (30)
- Java (1)
- Linux (26)
- misc (7)
- my projects (1)
- MySQL (2)
- NanoBSD (3)
- opensource (7)
- perl (1)
- PHP (3)
- programming (11)
- Python (1)
- security (4)
- Archives
- 2011
- February (1)
- March (1)
- June (1)
- July (1)
- August (1)
- 2010
- June (5)
- July (2)
- December (4)
- April (6)
- March (2)
- May (1)
- August (2)
- October (1)
- November (1)
- 2009
- August (7)
- July (8)
- April (4)
- May (4)
- December (2)
- June (1)
- September (1)
- November (4)
- October (1)
- Web Tools
- Index
- dig-shovel Live
- SQL Injection Encoder
- Links
-

