AVR development on MAC OS


I am not a big fan of Windows but till now most of my software could only run on Windows, or is what I thought till recently. One of my latest interests is to do development for small embedded devices I build myself, mostly running with AVR microcontrollers. Sounds like cool stuff, right? But ATMEL (the company that made the chips) released their IDE (AVRStudio) running on Windows only as it seems to run on .Net.

Is not a big deal for many people, however, recently I bought myself a Macbook Pro “Retina display” and this “thing” when run Windows gets hot like hell cause will switch to Nvidia chipset and eats up battery like mad. No way to “switch” to the intel graphic chip, that will give you like 2 times more battery so only way is to get an IDE running on MAC OSX instead. So here we go…

A bit of research on the net and found out that can use Eclipse as IDE and then install an AVR plugin. So, first, download latest version of Eclipse from here (I use Junos). Once done, uncompress it and put it somewhere in Applications.

You will need to install CrossPack for AVR® Development from here to have all the toolchain (AVRDude, AVRGcc, etc) available on your system.

Open Eclipse then go to  Help > Install new software and in the new window that comes up, and enter in Work with field the following URL: http://avr-eclipse.sourceforge.net/updatesite/ then select the checkbox that says: AVR Eclipse Plugin then click on [Next] button. Follow the rest of the screens till the plugin is installed.

Now, the important part: setting up the ISP programmer (I am using  OLIMEX ISP500 USB) and creating first project, build it and upload the output to your board!

First, we need to be sure your programmer is seen by your machine. Connect your programmer to your machine, then go in command line (Finder > Applications > Utilities > Terminal) and type: sudo dmesg. You should see something like:

AppleUSBCDCACMData: Version number - 4.1.22, Input buffers 8, Output buffers 16
 AppleUSBCDC: Version number - 4.1.22

NOTE: If this does not come up, you will need to check and upgrade your programmer’s firmware first (for this will need a Windows machine…

Once this done we can then start configuring your AVR programmer. Check the name of the new device attached to your machine:

$ ls -al /dev/tty.*
crw-rw-rw- 1 root wheel 18, 2 Oct 3 17:01 /dev/tty.Bluetooth-Modem
crw-rw-rw- 1 root wheel 18, 0 Oct 3 17:01 /dev/tty.Bluetooth-PDA-Sync
crw-rw-rw- 1 root wheel 18, 4 Oct 3 17:40 /dev/tty.usbmodem1421

Go in Eclipse > Preferences… and from the left hand menu expand AVR section, choose AVRDude then, on the right panel click on [Add…] button. Enter Configuration name (e.g.: Olimex ISP500), select “Atmel STK500 Version 2.x firmware” on the list of programmers, enter your device in Override default port (-P) field (e.g.: /dev/tty.usbmodem1421) then click on [OK] button.

You should see something like:

Once this done, click [OK] button from bottom left.

Go then to File > New > C Project, enter your project name in Project name field and then select Empty Project in Project type > AVR Cross Target Application then click [Next] button to go to the next screen.

Here, click on [Advanced settings…] button:

In this new window, on left hand side panel, click on AVR > AVRDude and choose the programmer you defined before (e.g.: Olimex ISP500) in Programmer configuration select box.

Click on AVR > Target Hardware on left hand side panel then, in the right panel, click on [Load from MCU] button to detect your MCU type and MCU Clock Frequency and confirm your programmer is set properly:

Again, on left hand side panel, choose C/C++ Build > Settings and on right panel, in Additional Tools in Toolchain enable (check the box) Generate HEX file for Flash memory:

Then, go to AVR Compiler > Optimization and select “Moderate Optimizations (O2)” in Optimization Level field and type “-Os” in Other Optimization Flags field:

Then click [OK] button on the bottom of the the window and click [Finish] button in the parent window:

Now you can start working on your project. Once is ready, you will have to build it by selecting from  top menu Project > Build Project and you will see the results of the build in the Console panel, central-bottom of Eclipse window:

If no errors are thrown during the build can proceed to upload the project by selecting AVR > Upload Project to Target Device from top menu and will see the results also in the Console panel:

And now your code should be compiled and running on your board!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s