PhotoStation

February 6th, 2011 1 comment
0
Vote

Categories: Projects Tags:

Ardupilot Mega 1.0

January 21st, 2011 No comments
0
Vote

Ardupilot mega is here! …

Coming soon a new proyect of UAV airplane.

Categories: Purchases Tags:

Arduino from Command Line

January 19th, 2011 1 comment
0
Vote

Hi all. After a long time without arduino by work/family problems, yesterday i get back into arduino.cc to download the latest version of arduino’s ide (0022) and i find that in the section Hacking, the link to Arduino Command Line has been removed. As i read on some posts they also dropped support to Makefile.

So, after spend a time compiling my older sketches from command line, i decided write a mini how-to explaining how to compile under command line with the new version of arduino. Reminder 0022.

First, we need the avr-libc and avrdude packages.

apt-get install avrdude avr-libc

Avrdude help us to upload the code to arduino and avr-libc (whith its dependencies gcc-avr) will install the necessary AVR libraries and avr-gcc needed to compile

Once we have installed these packages we’ll download arduino’s ide 0022 and put our fingers to work.

Decompress the file into a temporal dir and look for the folder “hardware/arduino/core/arduino” where are stored the arduino libraries. Copy this folder to /usr/lib, for example.

cp -a arduino-0022/hardware/arduino/core/arduino /usr/lib

Programming without IDE and Makefile.

At this point imagine that we have our application “demo”. We’ll create a dir into our workdir (/home/user/demo) for example, where we will store the source code. If we list the folder, we’ll see:

applet(dir)

demo.pde

Makefile

As we can see, the source code of the application is written sames as in the IDE, using a .pde file. When we use the make command the Makefile create a folder called “applet” with the file .cpp required by the avr-gcc. Makefile do it for us.

In the next link you can download an example Makefile . This Makefile is the Makefile provided in older version of arduino’s ide. In this example Makefile, at the top of the file we can see the configuration section:

#CONFIG

TARGET = $(notdir $(CURDIR))

PORT = /dev/ttyUSB0

UPLOAD_RATE = 19200

AVRDUDE_PROGRAMMER = stk500v1

MCU = atmega168

F_CPU = 16000000

#PATHS
ARDUINO = /usr/lib/arduino
AVR_TOOLS_PATH = /usr/bin
#LIBRARIES

SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \

$(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \

$(ARDUINO)/wiring_pulse.c $(ARDUINO)/wiring_serial.c \

$(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c

CXXSRC = $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WMath.cpp $(ARDUINO)/Print.cpp

We need configure these variables to match our environment.

If we try compile with this Makefile in the new arduino’s ide it give us an error because there are libraries included in the older version that there are not included in the new version, for example, wiring_serial.c, so we need remove references to older libraries. Also need include the $(ARDUINO)/WString.cpp library
In the SRC variable we have the C libraries and in the CXXSRC we have the C++ libraries needed to compile.

These libraries are compiled by Makefile and output their object files in “corelibs” so if we modify these libraries we’ll have in mind that we need remove object files in “corelibs” to let Makefile update these libraries. If our application need another libraries we need copy them to corelibs and reference it in the Makefile configuration section.

When we retry compile it give us another error:

applet/core.a(Print.o):(.data+0×6): more undefined references to `__cxa_pure_virtual` follow

To solve it we need add these lines to ($ARDUINO)/main.cpp

extern “C” void __cxa_pure_virtual()
{
while(1);
}

At this point we can do:

make clean
make
make upload

Categories: General Tags: