diff --git a/Tools/adb_upload_to_bebop.sh b/Tools/adb_upload_to_bebop.sh index 3bc6f3a210..48edf0007e 100755 --- a/Tools/adb_upload_to_bebop.sh +++ b/Tools/adb_upload_to_bebop.sh @@ -42,10 +42,6 @@ if [[ $adb_return == "" ]]; then restart_px4=true fi -${PX4_TOOLCHAIN_DIR}/gcc-linaro-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-strip \ - -R .comment -R .gnu.version \ - ../build_posix_bebop_default/src/firmware/posix/px4 - ../Tools/adb_upload.sh $@ # restart the process after uploading diff --git a/cmake/configs/posix_bebop_default.cmake b/cmake/configs/posix_bebop_default.cmake index 664a6c6933..638f88a0b3 100644 --- a/cmake/configs/posix_bebop_default.cmake +++ b/cmake/configs/posix_bebop_default.cmake @@ -8,11 +8,6 @@ add_definitions( -D__DF_BEBOP # Define needed DriverFramework ) -set(CMAKE_PROGRAM_PATH - "${PX4_TOOLCHAIN_DIR}/gcc-linaro-arm-linux-gnueabihf/bin" - ${CMAKE_PROGRAM_PATH} - ) - set(config_module_list # examples/px4_simple_app diff --git a/cmake/configs/posix_rpi_cross.cmake b/cmake/configs/posix_rpi_cross.cmake index 6d5220f227..46626ac8f6 100644 --- a/cmake/configs/posix_rpi_cross.cmake +++ b/cmake/configs/posix_rpi_cross.cmake @@ -1,13 +1,3 @@ include(configs/posix_rpi_common) -if("$ENV{RPI_USE_CLANG}" STREQUAL "1") - set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-linux-gnueabihf-clang.cmake) -else() - set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake) -endif() - - -set(CMAKE_PROGRAM_PATH - "${PX4_TOOLCHAIN_DIR}/gcc-linaro-arm-linux-gnueabihf/bin" - ${CMAKE_PROGRAM_PATH} -) +SET(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake) diff --git a/cmake/posix/px4_impl_posix.cmake b/cmake/posix/px4_impl_posix.cmake index caff485447..2d797137a4 100644 --- a/cmake/posix/px4_impl_posix.cmake +++ b/cmake/posix/px4_impl_posix.cmake @@ -267,22 +267,36 @@ elseif ("${BOARD}" STREQUAL "excelsior") --sysroot=${HEXAGON_ARM_SYSROOT}/lib32-apq8096 -mfloat-abi=softfp -mfpu=neon -mthumb-interwork ) -elseif ("${BOARD}" STREQUAL "rpi" AND "$ENV{RPI_USE_CLANG}" STREQUAL "1") +elseif ("${BOARD}" STREQUAL "rpi") + SET(RPI_COMPILE_FLAGS + -mcpu=cortex-a53 + -mfpu=neon + -mfloat-abi=hard + ) + LIST(APPEND added_c_flags ${RPI_COMPILE_FLAGS}) + LIST(APPEND added_cxx_flags ${RPI_COMPILE_FLAGS}) - # Add the toolchain specific flags - set(clang_added_flags - -m32 - --target=arm-linux-gnueabihf - -ccc-gcc-name arm-linux-gnueabihf - --sysroot=${PX4_TOOLCHAIN_DIR}/gcc-linaro-arm-linux-gnueabihf/arm-linux-gnueabihf/libc/) + FIND_PROGRAM(CXX_COMPILER_PATH ${CMAKE_CXX_COMPILER}) - set(added_c_flags ${POSIX_CMAKE_C_FLAGS} ${clang_added_flags}) - list(APPEND added_cxx_flags ${POSIX_CMAKE_CXX_FLAGS} ${clang_added_flags}) - list(APPEND added_exe_linker_flags ${POSIX_CMAKE_EXE_LINKER_FLAGS} ${clang_added_flags}) + GET_FILENAME_COMPONENT(CXX_COMPILER_PATH ${CXX_COMPILER_PATH} DIRECTORY) + GET_FILENAME_COMPONENT(CXX_COMPILER_PATH "${CXX_COMPILER_PATH}/../" ABSOLUTE) + + IF ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") + set(CLANG_COMPILE_FLAGS + --target=arm-pc-linux-gnueabihf + -ccc-gcc-name arm-linux-gnueabihf-gcc + --sysroot=${CXX_COMPILER_PATH}/arm-linux-gnueabihf/libc + -I${CXX_COMPILER_PATH}/arm-linux-gnueabihf/libc/usr/include/ + ) + + set(added_c_flags ${POSIX_CMAKE_C_FLAGS} ${CLANG_COMPILE_FLAGS}) + list(APPEND added_cxx_flags ${POSIX_CMAKE_CXX_FLAGS} ${CLANG_COMPILE_FLAGS}) + list(APPEND added_exe_linker_flags ${POSIX_CMAKE_EXE_LINKER_FLAGS} ${CLANG_COMPILE_FLAGS} + -B${CXX_COMPILER_PATH}/arm-linux-gnueabihf/libc/usr/lib + -L${CXX_COMPILER_PATH}/arm-linux-gnueabihf/libc/usr/lib + ) + ENDIF() else() - # Add the toolchain specific flags - set(added_cflags ${POSIX_CMAKE_C_FLAGS}) - list(APPEND added_cxx_flags ${POSIX_CMAKE_CXX_FLAGS}) endif() # output diff --git a/cmake/toolchains/Toolchain-arm-linux-gnueabihf-clang.cmake b/cmake/toolchains/Toolchain-arm-linux-gnueabihf-clang.cmake deleted file mode 100644 index fbe06b3aff..0000000000 --- a/cmake/toolchains/Toolchain-arm-linux-gnueabihf-clang.cmake +++ /dev/null @@ -1,65 +0,0 @@ -include(CMakeForceCompiler) - -if ($ENV{PX4_TOOLCHAIN_DIR} STREQUAL "") - message(FATAL_ERROR "PX4_TOOLCHAIN_DIR not set") -else() - set(PX4_TOOLCHAIN_DIR $ENV{PX4_TOOLCHAIN_DIR}) -endif() - -# this one is important -set(CMAKE_SYSTEM_NAME Generic) - -#this one not so much -set(CMAKE_SYSTEM_VERSION 1) - -# specify the cross compiler -# requires a symbolic link typically from /usr/bin/clang -find_program(C_COMPILER clang - PATHS ${PX4_TOOLCHAIN_DIR}/gcc-linaro-arm-linux-gnueabihf/bin - NO_DEFAULT_PATH - ) - -if(NOT C_COMPILER) - message(FATAL_ERROR "could not find C compiler") -endif() -cmake_force_c_compiler(${C_COMPILER} Clang) - -find_program(CXX_COMPILER clang++ - PATHS ${PX4_TOOLCHAIN_DIR}/gcc-linaro-arm-linux-gnueabihf/bin - NO_DEFAULT_PATH - ) - -if(NOT CXX_COMPILER) - message(FATAL_ERROR "could not find C++ compiler") -endif() -cmake_force_cxx_compiler(${CXX_COMPILER} Clang) - -# compiler tools -foreach(tool objcopy nm ld) - string(TOUPPER ${tool} TOOL) - find_program(${TOOL} arm-linux-gnueabihf-${tool} - PATHS ${PX4_TOOLCHAIN_DIR}/gcc-linaro-arm-linux-gnueabihf/bin - NO_DEFAULT_PATH - ) - if(NOT ${TOOL}) - message(FATAL_ERROR "could not find arm-linux-gnueabihf-${tool}") - endif() -endforeach() - -# os tools -foreach(tool echo grep rm mkdir nm cp touch make unzip) - string(TOUPPER ${tool} TOOL) - find_program(${TOOL} ${tool}) - if(NOT ${TOOL}) - message(FATAL_ERROR "could not find ${TOOL}") - endif() -endforeach() - -# where is the target environment -set(CMAKE_FIND_ROOT_PATH get_file_component(${C_COMPILER} PATH)) - -# search for programs in the build host directories -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -# for libraries and headers in the target directories -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake b/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake index 77949d3206..1ca1a542ea 100644 --- a/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake +++ b/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake @@ -1,65 +1,13 @@ -# defines: -# -# NM -# OBJCOPY -# LD -# CXX_COMPILER -# C_COMPILER -# CMAKE_SYSTEM_NAME -# CMAKE_SYSTEM_VERSION -# LINKER_FLAGS -# CMAKE_EXE_LINKER_FLAGS -# CMAKE_FIND_ROOT_PATH -# CMAKE_FIND_ROOT_PATH_MODE_PROGRAM -# CMAKE_FIND_ROOT_PATH_MODE_LIBRARY -# CMAKE_FIND_ROOT_PATH_MODE_INCLUDE +# More on cross-compilation: https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html -include(CMakeForceCompiler) - -if ("$ENV{PX4_TOOLCHAIN_DIR}" STREQUAL "") - message(FATAL_ERROR "PX4_TOOLCHAIN_DIR not set") -else() - set(PX4_TOOLCHAIN_DIR $ENV{PX4_TOOLCHAIN_DIR}) -endif() - -# this one is important -set(CMAKE_SYSTEM_NAME Generic) - -#this one not so much +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR arm) set(CMAKE_SYSTEM_VERSION 1) -# specify the cross compiler -find_program(C_COMPILER arm-linux-gnueabihf-gcc - PATHS ${PX4_TOOLCHAIN_DIR}/gcc-linaro-arm-linux-gnueabihf/bin - NO_DEFAULT_PATH - ) - -if(NOT C_COMPILER) - message(FATAL_ERROR "could not find arm-linux-gnueabihf-gcc compiler") -endif() -cmake_force_c_compiler(${C_COMPILER} GNU) - -find_program(CXX_COMPILER arm-linux-gnueabihf-g++ - PATHS ${PX4_TOOLCHAIN_DIR}/gcc-linaro-arm-linux-gnueabihf/bin - NO_DEFAULT_PATH - ) - -if(NOT CXX_COMPILER) - message(FATAL_ERROR "could not find arm-linux-gnueabihf-g++ compiler") -endif() -cmake_force_cxx_compiler(${CXX_COMPILER} GNU) - -# compiler tools -foreach(tool objcopy nm ld) - string(TOUPPER ${tool} TOOL) - find_program(${TOOL} arm-linux-gnueabihf-${tool} - PATHS ${PX4_TOOLCHAIN_DIR}/gcc-linaro-arm-linux-gnueabihf/bin - NO_DEFAULT_PATH - ) - if(NOT ${TOOL}) - message(FATAL_ERROR "could not find arm-linux-gnueabihf-${tool}") - endif() -endforeach() +IF (NOT CMAKE_C_COMPILER OR NOT CMAKE_CXX_COMPILER) + SET(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) + SET(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) +ENDIF() # os tools foreach(tool echo grep rm mkdir nm cp touch make unzip) @@ -70,16 +18,11 @@ foreach(tool echo grep rm mkdir nm cp touch make unzip) endif() endforeach() -set(LINKER_FLAGS "-Wl,-gc-sections") -set(CMAKE_EXE_LINKER_FLAGS ${LINKER_FLAGS}) -set(CMAKE_C_FLAGS ${C_FLAGS}) -set(CMAKE_CXX_LINKER_FLAGS ${C_FLAGS}) +set(CMAKE_EXE_LINKER_FLAGS "-Wl,-gc-sections") +#set(CMAKE_C_FLAGS ${C_FLAGS}) +#set(CMAKE_CXX_LINKER_FLAGS ${C_FLAGS}) -# where is the target environment -set(CMAKE_FIND_ROOT_PATH get_file_component(${C_COMPILER} PATH)) - -# search for programs in the build host directories set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -# for libraries and headers in the target directories set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) diff --git a/src/firmware/posix/CMakeLists.txt b/src/firmware/posix/CMakeLists.txt index d1a50c84ad..b152517cd0 100644 --- a/src/firmware/posix/CMakeLists.txt +++ b/src/firmware/posix/CMakeLists.txt @@ -140,4 +140,14 @@ install(TARGETS px4 DESTINATION ${CMAKE_INSTALL_BINDIR}) install(DIRECTORY ${PROJECT_SOURCE_DIR}/ROMFS DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}) install(DIRECTORY ${PROJECT_SOURCE_DIR}/posix-configs DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}) +FIND_PROGRAM(STRIP_TOOL "arm-linux-gnueabihf-strip") + +add_custom_target(strip + DEPENDS px4.stripped +) + +add_custom_command(OUTPUT px4.stripped + COMMAND arm-linux-gnueabihf-strip -R .comment -R .gnu.version $ + DEPENDS px4) + # vim: set noet ft=cmake fenc=utf-8 ff=unix :