Arduino Development on Ubuntu

· Embedded Software Development
Notes on programming the Arduino Uno R3 on Ubuntu 11.04, with and without the Arduino IDE.

My Setup

Hardware:

  • Arduino Uno R3 (ATmega328P-PU microcontroller)
  • USB cable: Standard-A plug to Standard-B plug
  • Power supply: 10 V regulated d.c., 500 mA, with 2.1×5.5 mm centre-pin positive plug
  • Samsung NP-N145 (N145 Plus) running Ubuntu 11.04

I used the Ubuntu Software Center to install: arduino, arduino-core, libjna-java, librxtx-java, binutils-avr, avr-libc, avrdude, gcc-avr.

These packages allow for both with and without Arduino IDE programming.

Programming with the Arduino IDE

Launch the Arduino IDE:

$ arduino &

Check that Tools|’Serial Port’ shows /dev/ttyACM0 ticked.

Enter a sketch, then hit the Upload button.

Programming without the Arduino IDE

For the Arduino Uno R3, use the following:

$ avr-gcc -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o blink.o blink.c
$ avr-gcc -mmcu=atmega328p blink.o -o blink
$ avr-objcopy -O ihex -R .eeprom blink blink.hex
$ avrdude -F -V -c arduino -p ATMEGA328P -P /dev/ttyACM0 -b 115200 -U flash:w:blink.hex

…with thanks to this blog.

Notes

Don’t rely on USB port power

Provide power to the Arduino board before connecting via USB. The USB port over-current protection prevented successful connection on my netbook. The Uno wasn’t appearing as /dev/ttyACM0 as expected and therefore wasn’t shown in the Arduino IDE as available for programming. The correct dmesg output should look something like:

usb 5-1: new full speed USB device using uhci_hcd and address 6
cdc_acm 5-1:1.0: ttyACM0: USB ACM device
usbcore: registered new interface driver cdc_acm
cdc_acm: v0.26:USB Abstract Control Model driver for USB modems and ISDN adapters

For more information

Go to the Installing Arduino on Linux page for up-to-date info.

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