Showing posts with label Mac. Show all posts
Showing posts with label Mac. Show all posts

Monday, June 7, 2010

AVR development on Mac OS X with XCODE


Are you an AVR fan who has recently migrated to Mac and disappointed by the lack of AVR support for Mac users? Specially if you have been working on CVAVR and AVRStudio for development, and now you realise that there is no such GUI available for Mac.
A closer look at the situation reveals that there is ample support and resources available for here which I will list one by one.

Alternative 1 :
Install VMware on Mac and run all your old windows programs without a glitch. The disadvantage is that running another OS like XP, more so if its Windows 7, consumes a lot of resources and your system performance goes down. Nevertheless, you can give it a try if you have a free/ trial copy of VMware, and of course XP.

Alternative 2 :
As we all know avr-gcc compilers are available for linux and Mac as well. So you can download and install them and start writing programs and burning them from Terminal command line. This might turn out to be a tedious task if you are new to command line. You are bound to falter once while changing fuse bits through command line and this results in killing your poor Atmel chip.

To burn fuses without burning the chip, there is a nice application available for Mac called the AVR Fuses . This application provides the same interface as your AVRStudio for changing fuses and programming your chip.





This GUI uses avrdude to program the fuses as well as the program memory. (I will explain installing that later). Just go to the preferences and set the right path to avrdude and the programmer port and it begins to work.

Note : If you plan to use a USB to serial converter like the one from prolific you need to install a PL2303 prolific mac driver which is readily available on the web.

Alternative 3 :
A similar but more useful app called the AVR Tools also has a built in serial terminal. So this eliminates the need for XTerm etc. The environment is slowly building up to give you a good experience. This app has a whole list of programmer support ranging form USBasp to the simple sercon mini programmers. Select the port form the dropdown list which is automatically populated depending on the available serial ports (USB to serial adapters, bluetooth serial ports etc.). This as well requires installing avr-gcc and avrdude. I would recommend AVR-Crosspack for installing the avr-gcc toolchains etc. To configure it rightly, please follow Lady Ada's tutorial . Please follow it step by step.



Alternative 4 :
Till now we haven't come across a native IDE for AVR development on Mac. We haven't yet explored the beauty of development on Mac. If you are not familiar with Xcode, its the native development environment for Mac. It has an amazing GUI. Yes, you are thinking in the right direction. We are about to use Xcode for AVR development. Please install and test AVR-CrossPack and configure it correctly before you proceed.
Xcode provides you option for creating project templates. A great person has created a nice AVR template for us. Download the template folder from the following link:

and copy the folder into the directory:

/Developer/Library/Xcode/Project Templates/Others/
or,

/Library/Application Support/Developer/Shared/Xcode/Project Templates/

Now run the Xcode and click open a new project. A template chooser like one of the following will appear depending on where you had copied the folder in the previous step.



Select the AVR project or the Atmega project. On the left pane you see firmware folder. Expand it and you will see 2-3 files including main.c and makefile. main.c is the file you need to edit and write your project in. After writing the code click on build and a hex file will be created in the project folder. From the Release dropdown list on top left, you can choose to flash the microcontroller if the write programmer and options are set in the makefile.

You can also edit this template to include some default things by opening the project file from the directory you copied in the first step. For example, I edited the template so as
1. to use particular serial port by default by editing the make file
AVRDUDE_PORT = /dev/cu.STK500-1-GenericSerial
2. to use a particular programmer type by editing the make file

AVRDUDE_PROGRAMMERID = stk500v2

3. I often use delay functions. So I made a delay.h header file and included it in main.


I made some more changes in the make file to write all the build files in a subdirectory of the project file to prevent it from unnecessary cluttering.

Later, I connected a bluetooth serial module to the programming port of my STK500 board and began flashing it wirelessly from my Mac. So now when I press the build button, it automatically compiles the code and burns it on the microcontroller wirelessly :P . Details about it in the next blog.


Hope you have a good AVR+Mac experience.

Thursday, March 26, 2009

AVR fuse programmer for MAC

Flashing MCUs or programming fuses in MAC doesn't have much GUI support except for the java based Burn-o-mat. Someone has really taken pain this time to make an open source cocoa based app for burning the AVR (old .NET based version also available). The good part is that he has tried to make the GUI exactly similar to the AVR studio fuse programmer. The software can be downloaded from:
http://www.vonnieda.org/software/avrfuses

During the setup it will ask for the path to avrdude. If you are using AVRMacPack, avrdude is a hidden file with path similar to :
/usr/local/AVRMacPack-20080721/bin/avrdude

Note: Please confirm the location before specifying the path. e.g. you can do so by right clicking the AVRMacPack manual in application folder and clicking show original.

If you are using prolific based USB to serial converter don't forget to install the driver. Interestingly, an open source driver is available for the same which performs better than the one provided by prolific. Its available at :
http://sourceforge.net/projects/osx-pl2303/

Below are some of the screen shots:



Tuesday, March 3, 2009

Writing to NTFS from Mac

One major problem which most of us face while switching between windows and any other operating system is the incompatibility of file systems. While I had read access to the NTFS drive from my Mac, I did not have write access. The problem became more prominent after I recently bought an external hard drive for porting data between my mac and my other windows computers.
One solution was to keep all my disks in FAT format which is the universal format for read/write for all OS. The only drawback being that it can not handle files greater than 4 GB. Someone suggested to me to use a software called MAC drive on my windows machine. This software allows windows machine to access HFS+ partitions seamlessly. It was a good alternative just that there are more windows machine than MACs so one needs to install them on every machine being used.
Today while browsing through heap of topics on Wikipedia, I came across an open source project called NTFS 3G which installs a user space driver on MAC for reading/writing to NTFS partitions. You can actually format a NTFS partition using this. Even the disk utility shows an integrated option of NTFS format after installing this.

http://www.ntfs-3g.org/



Not only MAC, it is available for other operating systems like Linux also. It actually rids one of lot of hassles. Do not forget to install MAC Fuse library package to make it functional.

Saturday, November 15, 2008

SeisMac - Seismograph on MacBook



I came across this awesome OSX app which fetches the data from the Macbook's inertial sensors and displays the various acceleration components of your laptop in real time. The axes scale can be changed interactively and sample rate varied upto 500 Hz. There are supports available on the site to even calibrate it for accuracy and offset. It might just be a fun app for people but probably its going to be of great use to me in my thesis as it revolves around someting similar :)

Its a freeware available at http://www.suitable.com/tools/seismac.html

PS: I am wondering if it can be used to detect earthquakes or other seismic motions :P
It depends highly on the accuracy and precision of the sensors.