Hardware directory for arduino not found

I’m trying to compile the master-AVR branch to use on my APM 2.x board. I am running ArchLinux. However when running make from the APMrover2 directory I get the following error:

Hardware directory for arduino not found

I was under the impression that you can either use make or the Arduino software. But regardless I installed the Arduino IDE using pacaur -S arduino.

On Mac, I’m pretty sure the hardware directory is /Applications/Arduino.app/Contents/Java/hardware/.
On Linux, the equivalent seems to be /usr/share/arduino/hardware.
However while that folder on the Mac contains lots of subfolders and binaries but on Linux it is empty.

Thanks if anyone can help to diagnose this issue.

Okay if I open up Arduino, install the correct stuff using ‘Board Manager’, and then add ~/.arduino15/packages/arduino/hardware/avr/1.6.14 to the list of hardware directories in mk/board_avr.mk, then it works initially.

However another issue arises…

// BUILDROOT=/tmp/APMrover2.build HAL_BOARD=HAL_BOARD_APM2 HAL_BOARD_SUBTYPE=HAL_BOARD_SUBTYPE_AVR_APM2 TOOLCHAIN=AVR EXTRAFLAGS=-DGIT_VERSION="eb6f251e"
%% Parameters.o
/usr/bin/ccache: invalid option -- 'g'
Usage:
    ccache [options]
    ccache compiler [compiler options]
    compiler [compiler options]          (via symbolic link)

Options:
    -c, --cleanup         delete old files and recalculate size counters
                          (normally not needed as this is done automatically)
    -C, --clear           clear the cache completely (except configuration)
    -F, --max-files=N     set maximum number of files in cache to N (use 0 for
                          no limit)
    -M, --max-size=SIZE   set maximum size of cache to SIZE (use 0 for no
                          limit); available suffixes: k, M, G, T (decimal) and
                          Ki, Mi, Gi, Ti (binary); default suffix: G
    -o, --set-config=K=V  set configuration key K to value V
    -p, --print-config    print current configuration options
    -s, --show-stats      show statistics summary
    -z, --zero-stats      zero statistics counters

    -h, --help            print this help text
    -V, --version         print version and copyright information

See also <https://ccache.samba.org>.
make: *** [../mk/build_rules.mk:12: /tmp/APMrover2.build/Parameters.o] Error 1

I’m beginning to think this branch is so out of date it will take ages to fix all the issues so I can compile it. Is there a better option to get stuff working on an APM 2.x?

You should be able to do it all from the command line. In APMrover2 I run “make apm2” and it works fine for me from latest master. Have you worked your way through these instructions?

http://ardupilot.org/dev/docs/building-the-code-onlinux.html#building-the-code-onlinux

In case this helps in my .bashrc I have

export PATH=/usr/lib/ccache:$HOME/tools/gcc-arm-none-eabi-4_9-2015q3/bin/:$PATH:$HOME/.local/bin:$HOME/uav/ardupilot/Tools/autotest:$HOME/uav/MAVProxy:$HOME/uav/mavlink/pymavlink/examples:$HOME/uav/mavlink/pymavlink/tools:$HOME/uav/jsbsim/src

. $HOME/.bashrc_git

Thanks, Grant.

Thanks I’d looked through that guide before, but wrongly assumed that the install-prereqs-arch.sh script would do everything I needed. Apparently that is not the case.

I’ve now got to the point where I’m starting to compile code but there are errors.

// BUILDROOT=/tmp/APMrover2.build HAL_BOARD=HAL_BOARD_APM2 HAL_BOARD_SUBTYPE=HAL_BOARD_SUBTYPE_AVR_APM2 TOOLCHAIN=AVR EXTRAFLAGS=-DGIT_VERSION="eb6f251e"
%% Parameters.o
In file included from /home/chris/Code/ardupilot/libraries/AP_GPS/AP_GPS.h:420:0,
                 from Rover.h:36,
                 from Parameters.cpp:3:
/home/chris/Code/ardupilot/libraries/AP_GPS/AP_GPS_UBLOX.h:311:23: error: flexible array member in union
         uint8_t bytes[];
                       ^
In file included from /home/chris/Code/ardupilot/libraries/AP_GPS/AP_GPS.h:421:0,
                 from Rover.h:36,
                 from Parameters.cpp:3:
/home/chris/Code/ardupilot/libraries/AP_GPS/AP_GPS_MTK.h:75:23: error: flexible array member in union
         uint8_t bytes[];
                       ^
In file included from /home/chris/Code/ardupilot/libraries/AP_GPS/AP_GPS.h:422:0,
                 from Rover.h:36,
                 from Parameters.cpp:3:
/home/chris/Code/ardupilot/libraries/AP_GPS/AP_GPS_MTK19.h:81:23: error: flexible array member in union
         uint8_t bytes[];
                       ^
In file included from /home/chris/Code/ardupilot/libraries/AP_GPS/AP_GPS.h:424:0,
                 from Rover.h:36,
                 from Parameters.cpp:3:
/home/chris/Code/ardupilot/libraries/AP_GPS/AP_GPS_SIRF.h:100:23: error: flexible array member in union
         uint8_t bytes[];
                       ^
make: *** [../mk/build_rules.mk:12: /tmp/APMrover2.build/Parameters.o] Error 1

I know a bit of C but I feel like these sort of errors are still due to misconfiguration in the compiler toolchain rather than the code itself.

It works if I change those flexible arrays to arrays of zero length. (why should I have to do this though?)

The next issue stems from preprocessor variables being empty.

libraries/AP_HAL_AVR/UARTDriver.cpp: F_CPU isn’t defined
libraries/AP_HAL_AVR/I2CDriver.cpp: CPU_FREQ isn’t defined

I bet its your compiler version. Run

avr-g++ --version

It should say something like
avr-g++ (GCC) 4.9.2
Copyright © 2014 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.

Note the 4.9.2. That’s the version of compiler that’s supported for the code. If your running something else I’ll bet that’s why your getting those errors.

Thanks, Grant.

Yep I’m running version 6.2.0… Thank you Arch for keeping everything up to date - not. I got the code to compile by changing a few lines of code. I feel like that’s easier than trying to downgrade my packages.

You shouldn’t downgrade your packages. Just install the 4.9.2 version of the compiler as well.
Thanks, Grant.