[SOLVED] Build failure for PH4-mini: nano.specs not found

I’m trying to build the firmware, without success. I’m running in an Ubuntu 18.04 docker image. I tried the following steps:

yes | Tools/environment_install/install-prereqs-ubuntu.sh
# open new terminal
./waf configure --board PH4-mini
./waf copter

This fails after a while with these errors:

[ 11/685] Compiling libraries/AC_AttitudeControl/AC_AttitudeControl_Sub.cpp
[ 12/685] Compiling libraries/AC_AttitudeControl/AC_AttitudeControl_Heli.cpp
[ 13/685] Compiling libraries/AC_AttitudeControl/ControlMonitor.cpp
[ 14/685] Compiling libraries/AC_AttitudeControl/AC_AttitudeControl_Multi.cpp
[ 15/685] Compiling libraries/AC_AttitudeControl/AC_PosControl_Sub.cpp
[ 16/685] Compiling libraries/AC_AutoTune/AC_AutoTune.cpp
g++: warning: '-mcpu=' is deprecated; use '-mtune=' or '-march=' instead
g++: error: nano.specs: No such file or directory

g++: warning: '-mcpu=' is deprecated; use '-mtune=' or '-march=' instead
g++: error: nano.specs: No such file or directory

g++: warning: '-mcpu=' is deprecated; use '-mtune=' or '-march=' instead
g++: error: nano.specs: No such file or directory

g++: warning: '-mcpu=' is deprecated; use '-mtune=' or '-march=' instead
g++: error: nano.specs: No such file or directory

g++: warning: '-mcpu=' is deprecated; use '-mtune=' or '-march=' instead
g++: error: nano.specs: No such file or directory

Waf: Leaving directory `/home/alex/workspaces/4/git/ardupilot/build/PH4-mini'
Build failed
 -> task in 'objs/AC_AttitudeControl' failed (exit status 1): 
        {task 140472954406480: cxx AC_AttitudeControl_Sub.cpp -> AC_AttitudeControl_Sub.cpp.0.o}
 (run with -v to display more information)
 -> task in 'objs/AC_AttitudeControl' failed (exit status 1): 
        {task 140472954406224: cxx AC_AttitudeControl_Heli.cpp -> AC_AttitudeControl_Heli.cpp.0.o}
 (run with -v to display more information)
 -> task in 'objs/AC_AttitudeControl' failed (exit status 1): 
        {task 140472954406736: cxx ControlMonitor.cpp -> ControlMonitor.cpp.0.o}
 (run with -v to display more information)
 -> task in 'objs/AC_AttitudeControl' failed (exit status 1): 
        {task 140472954406352: cxx AC_AttitudeControl_Multi.cpp -> AC_AttitudeControl_Multi.cpp.0.o}
 (run with -v to display more information)
 -> task in 'objs/AC_AttitudeControl' failed (exit status 1): 
        {task 140472954406608: cxx AC_PosControl_Sub.cpp -> AC_PosControl_Sub.cpp.0.o}
 (run with -v to display more information)

Running ./waf copter -v reveals that it is running /usr/bin/g++ instead of the arm-none-eabi-g++ toolchain that we specifically installed. This seems like a poor choice.

I read modules/waf/waflib/Tools/compiler_cxx.py and decided to try CXX=arm-none-eabi-g++ ./waf configure --board=PH4-mini before running ./waf copter -v. This resulted in different build errors, a bunch of these:

cc1plus: error: -Werror=implicit-fallthrough: no option -Wimplicit-fallthrough                                                                               
cc1plus: error: -Werror=implicit-fallthrough: no option -Wimplicit-fallthrough                                                                               
cc1plus: warning: unrecognized command line option '-Wno-expansion-to-defined'

Again this makes a bit of sense as these options don’t exist in GCC 6, so passing them seems like a poor choice.

So I seem to be stuck. I can force waf to use the correct compiler using this undocumented option, but that compiler is too old for the options being passed. What am I missing here?

Can you post the output of your ./waf configure --board PH4-mini ? We can check if your configuration is correct.

$ ./waf configure --board=PH4-mini                                                                       
Setting top to                           : /home/alex/workspaces/0/git/ardupilot                                                                             
Setting out to                           : /home/alex/workspaces/0/git/ardupilot/build                                                                       
Autoconfiguration                        : enabled                                                                                                           
Setting board to                         : PH4-mini                                                                                                          
Using toolchain                          : arm-none-eabi                                                                                                     
Checking for 'g++' (C++ compiler)        : /usr/bin/g++                                                                                                      
Checking for 'gcc' (C compiler)          : /usr/bin/gcc                                                                                                      
Checking for c flags '-MMD'              : yes                                                                                                               
Checking for cxx flags '-MMD'            : yes                                                                                                               
Checking for program 'make'              : /usr/bin/make                                                                                                     
Checking for program 'arm-none-eabi-objcopy' : /opt/gcc-arm-none-eabi-6-2017-q2-update/bin/arm-none-eabi-objcopy                                             
Including /home/alex/workspaces/0/git/ardupilot/libraries/AP_HAL_ChibiOS/hwdef/fmuv5/hwdef.dat                                                               
Adding environment OPTIMIZE -O2                                                                                                                              
Removing IOMCU_UART                                                                                                                                          
Removing UART8_TX                                                                                                                                            
Removing UART8_RX                                                                                                                                            
Removing AP_FEATURE_SBUS_OUT                                                                                                                                 
Removing PA5                                                                                                                                                 
Removing PB3                                                                                                                                                 
Removing PB11                                                                                                                                                
Removing FMU_CAP1                                                                                                                                            
Removing FMU_CAP2                                                                                                                                            
Removing FMU_CAP3                                                                                                                                            
Removing HAL_BATT_VOLT_SCALE                                                                                                                                 
Removing HAL_BATT_CURR_SCALE                                                                                                                                 
Setup for MCU STM32F767xx
Writing hwdef setup in /home/alex/workspaces/0/git/ardupilot/build/PH4-mini/hwdef.h
MCU Flags: cortex-m7 ['-mcpu=cortex-m7', '-mfpu=fpv5-d16', '-mfloat-abi=hard']
Writing DMA map
Generating ldscript.ld
Default parameters path from hwdef: /home/alex/workspaces/0/git/ardupilot/libraries/AP_HAL_ChibiOS/hwdef/PH4-mini/defaults.parm
Checking for env.py
env set DEFAULT_PARAMETERS=/home/alex/workspaces/0/git/ardupilot/libraries/AP_HAL_ChibiOS/hwdef/PH4-mini/defaults.parm
env set BOARD_FLASH_SIZE=2048
env set APJ_BOARD_TYPE=STM32F767xx
env set OPTIMIZE=-O2
env set USBID=0x1209/0x5740
env set MAIN_STACK=0x400
env set APJ_BOARD_ID=50
env set HAL_WITH_UAVCAN=1
env set CORTEX=cortex-m7
env set FLASH_RESERVE_START_KB=32
env set CHIBIOS_BUILD_FLAGS=USE_FATFS=yes MCU=cortex-m7 ENV_UDEFS=-DCHPRINTF_USE_FLOAT=1 CHIBIOS_PLATFORM_MK=os/hal/ports/STM32/STM32F7xx/platform.mk CHIBIOS_STARTUP_MK=os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32f7xx.mk
env set IOMCU_FW=0
env set CPU_FLAGS=['-mcpu=cortex-m7', '-mfpu=fpv5-d16', '-mfloat-abi=hard', '-DARM_MATH_CM7', '-u_printf_float']
env set PERIPH_FW=0
env set PROCESS_STACK=0x2000
Enabling ChibiOS asserts                     : no
Checking for intelhex module:                : OK
Checking for HAVE_CMATH_ISFINITE             : no
Checking for HAVE_CMATH_ISINF                : no
Checking for HAVE_CMATH_ISNAN                : no
Checking for NEED_CMATH_ISFINITE_STD_NAMESPACE : no
Checking for NEED_CMATH_ISINF_STD_NAMESPACE    : no
Checking for NEED_CMATH_ISNAN_STD_NAMESPACE    : no
Checking for header endian.h                   : not found
Checking for header byteswap.h                 : not found
Checking for HAVE_MEMRCHR                      : no
Checking for program 'python'                  : /usr/bin/python
Checking for python version >= 2.7.0           : 2.7.17
Checking for program 'python'                  : /usr/bin/python
Checking for python version >= 2.7.0           : 2.7.17
Source is git repository                       : yes
Update submodules                              : yes
Checking for program 'git'                     : /home/linuxbrew/.linuxbrew/bin/git
Gtest                                          : STM32 boards currently don't support compiling gtest
Checking for program 'arm-none-eabi-size'      : /opt/gcc-arm-none-eabi-6-2017-q2-update/bin/arm-none-eabi-size
Benchmarks                                     : disabled
Unit tests                                     : disabled
Scripting                                      : enabled
Scripting runtime checks                       : enabled
Checking for program 'rsync'                   : /usr/bin/rsync
'configure' finished successfully (0.347s)

This section indicates that waf is not able to find the arm-gcc compiler. It should be like this:

Using toolchain                          : arm-none-eabi
Checking for 'g++' (C++ compiler)        : /opt/gcc-arm-none-eabi-6-2017-q2-update/bin/arm-none-eabi-g++
Checking for 'gcc' (C compiler)          : /opt/gcc-arm-none-eabi-6-2017-q2-update/bin/arm-none-eabi-gcc

Can you check that you system is able to find the arm-gcc compiler?

This helped me get to the answer… Some other software was setting CC and CXX in the environment. After clearing those I can compile the firmware.