Go Down

Topic: CLI compiling with Debian Sid: arduino-core (Read 26157 times) previous topic - next topic

eaman

Dec 28, 2011, 06:41 pm Last Edit: Dec 28, 2011, 06:56 pm by eaman Reason: 1
Hello I'm trying to compile sketches by Command Line, using make, instead of using the Arduino IDE.
This is on a Debain Sid AMD-64, using package arduino-core version 1:1.0+dfsg-4 . Compiling with the IDE works good. My board is an Arduino Uno v.2 .

My Makefile looks like:
Code: [Select]
ARDUINO_DIR = /usr/share/arduino

#TARGET       = CLItest
#ARDUINO_LIBS = LiquidCrystal

BOARD_TAG    = uno
MCU          = atmega328
F_CPU        = 16000000L
ARDUINO_PORT = /dev/ttyACM0

#AVR_TOOLS_PATH   = /usr/bin
#AVRDUDE_CONF     = /etc/avrdude.conf

AVRDUDE_ARD_PROGRAMMER = arduino
AVRDUDE_ARD_BAUDRATE   = 57600
#AVRDUDE_ARD_EXTRAOPTS  = -F

include /usr/share/arduino/Arduino.mk

I'm trying to compile the first example from /usr/share/doc/arduino-core/examples/1.Basics/Blink/
1st: I have to rename the sketch to Blink.pde from Blink.ino, then I get:
Code: [Select]
build-cli/Blink.cpp:1:22: fatal error: WProgram.h: No such file or directory
compilation terminated.

So I go in /usr/share/arduino/hardware/arduino/cores/arduino and make a symbolinc link:
Code: [Select]
ln -s Arduino.h WProgram.h
Then when I make I get:
Code: [Select]
/usr/share/arduino/hardware/arduino/cores/arduino/WProgram.h:212:26: fatal error: pins_arduino.h: No such file or directory
So I edit /usr/share/arduino/hardware/arduino/cores/arduino/WProgram.h:212 e comment the pin include.
I get:
Code: [Select]
/usr/share/arduino/hardware/arduino/cores/arduino/wiring_analog.c:28:26: fatal error: pins_arduino.h: No such file or directory
So i comment th pin include in wiring_analog.c too.
Now I get:
Code: [Select]

/usr/share/arduino/hardware/arduino/cores/arduino/wiring_digital.c:29:26: fatal error: pins_arduino.h: No such file or directory
compilation terminated

I comment out pins from wiring_digital.c:29
Code: [Select]
/usr/share/arduino/hardware/arduino/cores/arduino/wiring_pulse.c:26:26: fatal error: pins_arduino.h: No such file or directory
I comment out pins from wiring_pulse.c:26
Code: [Select]
make TARGET=Blink
cat build-cli/Blink.d > build-cli/depends.mk
/usr/bin/avr-gcc -mmcu=atmega328 -lm -Wl,--gc-sections -Os -o build-cli/Blink.elf build-cli/Blink.o  build-cli/WInterrupts.o  build-cli/wiring_analog.o  build-cli/wiring.o  build-cli/wiring_digital.o  build-cli/wiring_pulse.o  build-cli/wiring_shift.o  build-cli/CDC.o  build-cli/HardwareSerial.o  build-cli/HID.o  build-cli/IPAddress.o  build-cli/main.o  build-cli/new.o  build-cli/Print.o  build-cli/Stream.o  build-cli/Tone.o  build-cli/USBCore.o  build-cli/WMath.o  build-cli/WString.o 
build-cli/wiring_digital.o: In function `digitalRead':
/usr/share/arduino/hardware/arduino/cores/arduino/wiring_digital.c:154: undefined reference to `digital_pin_to_bit_mask_PGM'
/usr/share/arduino/hardware/arduino/cores/arduino/wiring_digital.c:154: undefined reference to `digital_pin_to_bit_mask_PGM'
/usr/share/arduino/hardware/arduino/cores/arduino/wiring_digital.c:154: undefined reference to `digital_pin_to_port_PGM'
/usr/share/arduino/hardware/arduino/cores/arduino/wiring_digital.c:154: undefined reference to `digital_pin_to_port_PGM'
/usr/share/arduino/hardware/arduino/cores/arduino/wiring_digital.c:156: undefined reference to `port_to_mode_PGM'
/usr/share/arduino/hardware/arduino/cores/arduino/wiring_digital.c:156: undefined reference to `port_to_mode_PGM'
/usr/share/arduino/hardware/arduino/cores/arduino/wiring_digital.c:155: undefined reference to `digital_pin_to_timer_PGM'
/usr/share/arduino/hardware/arduino/cores/arduino/wiring_digital.c:155: undefined reference to `digital_pin_to_timer_PGM'
/usr/share/arduino/hardware/arduino/cores/arduino/wiring_digital.c:156: undefined reference to `digital_pin_to_bit_mask_PGM'
/usr/share/arduino/hardware/arduino/cores/arduino/wiring_digital.c:156: undefined reference to `digital_pin_to_bit_mask_PGM'
/usr/share/arduino/hardware/arduino/cores/arduino/wiring_digital.c:158: undefined reference to `digital_pin_to_port_PGM'
/usr/share/arduino/hardware/arduino/cores/arduino/wiring_digital.c:162: undefined reference to `digital_pin_to_port_PGM'
/usr/share/arduino/hardware/arduino/cores/arduino/wiring_digital.c:158: undefined reference to `port_to_output_PGM'
/usr/share/arduino/hardware/arduino/cores/arduino/wiring_digital.c:158: undefined reference to `port_to_output_PGM'
collect2: ld returned 1 exit status
make: *** [build-cli/Blink.elf] Error 1



And I'm stuck. Any suggestion?


PaulS

Quote
So I go in /usr/share/arduino/hardware/arduino/cores/arduino and make a symbolinc link:

As opposed to fixing the library properly? Why?

Quote
So I edit /usr/share/arduino/hardware/arduino/cores/arduino/WProgram.h:212 e comment the pin include.

Which leads to all the other problems. I would have thought that it would have been obvious that this was not the right thing to do.
The art of getting good answers lies in asking good questions.

eaman


Quote
So I go in /usr/share/arduino/hardware/arduino/cores/arduino and make a symbolinc link:

As opposed to fixing the library properly? Why?

I'm afraid it's not that obvious to me, I see the compile failing in /usr/share/arduino/Arduino.mk:405  which just is "include $(DEP_FILE)" wich is still obscure to me.

I can tell the compile dies at the very beginning with:
Code: [Select]
make TARGET=Blink
/usr/share/arduino/Arduino.mk:405: build-cli/depends.mk: No such file or directory
echo \#include \"WProgram.h\" > build-cli/Blink.cpp
cat  Blink.pde >> build-cli/Blink.cpp
/usr/bin/avr-g++ -MM -mmcu=atmega328 -DF_CPU=16000000L -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
build-cli/Blink.cpp:1:22: fatal error: WProgram.h: No such file or directory
compilation terminated.

Should I make a proper build-cli/depends.mk or should I investigate in /usr/share/arduino/Arduino.mk ?
BTW: is at least my Makefile reasonable?

Thanks.

eaman

Today I was able to copile and upload, with package arduino-core 1:1.0+dfsg-4 .
I still had to create a symbolic link to Arduino.h
(or you can change /usr/share/arduino/Arduino.mk:220 to
[
Code: [Select]
# PDEHEADER     = \\\#include \"WProgram.h\"
PDEHEADER     = \\\#include \"Arduino.h\"


Then I had to change the include for pins_arduino.h (wich comes in different files) to #include "/usr/share/arduino//hardware/arduino/variants/standard/pins_arduino.h" . Can anyone suggest a more elegant way?

Now I'm having some problems with upload, with my make file:
Code: [Select]
ARDUINO_DIR = /usr/share/arduino

#TARGET       = Blink // Name of Sketch
#ARDUINO_LIBS = LiquidCrystal

BOARD_TAG    = uno // This is working on a Arduino uno r.2
MCU          = atmega328
F_CPU        = 16000000L
ARDUINO_PORT = /dev/ttyACM0

VARIANTS = $(INSTALL_DIR)/hardware/arduino/variants/standard

#AVR_TOOLS_PATH   = /usr/bin
#AVRDUDE_CONF     = /etc/avrdude.conf

AVRDUDE_ARD_PROGRAMMER = arduino
AVRDUDE_ARD_BAUDRATE   = 115200
#AVRDUDE_ARD_EXTRAOPTS  = -F

include /usr/share/arduino/Arduino.mk

I'm able to compile, but in order to upload I have to change
Code: [Select]
MCU          = atmega328P
(There's a 'P' of difference.)

Go Up