How do you cross compile Arduino code using Arduino-Makefile?
I have an Arduino attached to a Raspberry Pi. Compiling the Arduino C code on an x86 machine in about 2 seconds, but doing the same compilation on the Pi takes over a minute.
However, if I compile the code on my x86 machine and rsync the files to the Pi, when I run
make upload to install them onto the Arduino, I get errors like:
make: *** No rule to make target '/home/myuser/git/myproject/lib/ros_lib/ros.h', needed by 'build-leonardo/main.ino.o'. Stop.
Apparently, many of the files written to the build- directory by the make process include absolute pathnames relative to the filesystem they were compiled on, and these pathnames are then used during
I tried to a recursive search-and-replace on the Pi, to replace my x86 user's path with the equivalent path on the Pi with:
find /usr/local/myproject/build-leonardo -type f -print0 | xargs -0 sed -i 's/\/home\/myuser\/git/\/usr\/local/g'
And this fixed the initial error, but now I get the error:
lto1: internal compiler error: cannot read LTO decls from build-leonardo/main.ino.o Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. lto-wrapper: /usr/share/arduino/hardware/tools/avr/bin/avr-gcc returned 1 exit status /usr/share/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld: error: lto-wrapper failed collect2: error: ld returned 1 exit status /usr/share/arduino/Arduino.mk:1446: recipe for target 'build-leonardo/head2.elf' failed make: *** [build-leonardo/head2.elf] Error 1
Does this mean the object files built on the x86 are in a format that can't be used on an ARM platform...even though they're intended for an Arduino, which is neither? Is there any way to compile an Arduino sketch so it's portable and can be uploaded to the Arduino from any other machine?