I'm trying to compile and upload arduino sketches via the command line. The Java IDE doesn't play nice with Xmonad and since I do all my editing in vim anyways it'd be nice to cut out the extra step of firing up a GUI.
I keep getting an error about build-cli/pins_arduino.o with the example blink sketch. If I load the same program in the arduino Java IDE it compiles without an issue.
Here's what I have so far:
OS: Linux Mint Debian 64 bit
arduino and required libs installed from debian unstable repo
arduino java IDE works
Directory layout:
me@laptop ~/sketchbook/Blink $ find
.
./Blink.pde
./makefile
me@laptop ~/sketchbook/Blink $
Compile error:
me@laptop ~/sketchbook/Blink $ make --debug
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for x86_64-pc-linux-gnu
Reading makefiles...
/usr/share/arduino/Arduino.mk:405: build-cli/depends.mk: No such file or directory
mkdir build-cli
echo \#include \"WProgram.h\" > build-cli/Blink.cpp
cat Blink.pde >> build-cli/Blink.cpp
/usr/bin/avr-g++ -MM -mmcu=atmega328p -DF_CPU= -I. -I/usr/share/arduino//hardware/arduino/cores/arduino -g -Os -w -Wall -ffunction-sections -fdata-sections -fno-exceptions build-cli/Blink.cpp -MF build-cli/Blink.d -MT build-cli/Blink.o
cat build-cli/Blink.d > build-cli/depends.mk
rm build-cli/Blink.cpp
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for x86_64-pc-linux-gnu
Reading makefiles...
Updating goal targets....
File `all' does not exist.
File `build-cli/Blink.hex' does not exist.
File `build-cli/Blink.elf' does not exist.
File `build-cli/Blink.o' does not exist.
File `build-cli/Blink.cpp' does not exist.
Must remake target `build-cli/Blink.cpp'.
echo \#include \"WProgram.h\" > build-cli/Blink.cpp
cat Blink.pde >> build-cli/Blink.cpp
Successfully remade target file `build-cli/Blink.cpp'.
Must remake target `build-cli/Blink.o'.
/usr/bin/avr-g++ -c -mmcu=atmega328p -DF_CPU= -I. -I/usr/share/arduino//hardware/arduino/cores/arduino -g -Os -w -Wall -ffunction-sections -fdata-sections -fno-exceptions build-cli/Blink.cpp -o build-cli/Blink.o
Successfully remade target file `build-cli/Blink.o'.
File `build-cli/pins_arduino.o' does not exist.
Must remake target `build-cli/pins_arduino.o'.
/usr/bin/avr-gcc -c -mmcu=atmega328p -DF_CPU= -I. -I/usr/share/arduino//hardware/arduino/cores/arduino -g -Os -w -Wall -ffunction-sections -fdata-sections -std=gnu99 /usr/share/arduino//hardware/arduino/cores/arduino/pins_arduino.c -o build-cli/pins_arduino.o
In file included from /usr/lib/gcc/avr/4.5.3/../../../avr/include/avr/delay.h:37:0,
from /usr/share/arduino//hardware/arduino/cores/arduino/wiring_private.h:30,
from /usr/share/arduino//hardware/arduino/cores/arduino/pins_arduino.c:26:
/usr/lib/gcc/avr/4.5.3/../../../avr/include/util/delay.h: In function ‘_delay_ms’:
/usr/lib/gcc/avr/4.5.3/../../../avr/include/util/delay.h:140:17: error: expected expression before ‘)’ token
/usr/lib/gcc/avr/4.5.3/../../../avr/include/util/delay.h: In function ‘_delay_us’:
/usr/lib/gcc/avr/4.5.3/../../../avr/include/util/delay.h:217:17: error: expected expression before ‘)’ token
make: *** [build-cli/pins_arduino.o] Error 1
me@laptop ~/sketchbook/Blink $
Makefile:
me@laptop ~/sketchbook/Blink $ cat makefile
ARDUINO_DIR = /usr/share/arduino/
TARGET = Blink
MCU = atmega328p
ARDUINO_PORT = /dev/ttyUSB0
include /usr/share/arduino/Arduino.mk
me@laptop ~/sketchbook/Blink $
Sketch:
me@laptop ~/sketchbook/Blink $ cat Blink.pde
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(13, LOW); // set the LED off
delay(1000); // wait for a second
}
me@laptop ~/sketchbook/Blink $