diff --git a/.gitignore b/.gitignore index 2ccfca61..f9bfaa1d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ -_obj -_bin -_dep +/build* Debug Debug* diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e4eb527..f32d4e3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,10 @@ if(NOT OS_FSFW) set(OS_FSFW host CACHE STRING "OS for the FSFW.") endif() +if(TGT_BSP MATCHES "arm/raspberrypi" OR TGT_BSP MATCHES "arm/beagleboneblack") + option(LINUX_CROSS_COMPILE ON) +endif() + # Perform steps like loading toolchain files where applicable. include(${CMAKE_SCRIPT_PATH}/PreProjectConfig.cmake) pre_project_config() @@ -65,7 +69,9 @@ include (${CMAKE_SCRIPT_PATH}/HardwareOsPreConfig.cmake) pre_source_hw_os_config() if(TGT_BSP) - if(${TGT_BSP} MATCHES "arm/q7s" OR ${TGT_BSP} MATCHES "arm/raspberrypi") + if(${TGT_BSP} MATCHES "arm/q7s" OR ${TGT_BSP} MATCHES "arm/raspberrypi" + OR ${TGT_BSP} MATCHES "arm/beagleboneblack" + ) set(ROOT_CONFIG_FOLDER TRUE) set(FSFW_CONFIG_PATH "fsfwconfig") set(ADD_LINUX_FILES TRUE) @@ -78,6 +84,10 @@ if(TGT_BSP) set(FSFW_HAL_ADD_RASPBERRY_PI ON) endif() + if(${TGT_BSP} MATCHES "arm/beagleboneblack") + add_definitions(-DBEAGLEBONEBLACK) + endif() + if(${TGT_BSP} MATCHES "arm/q7s") add_definitions(-DXIPHOS_Q7S) endif() diff --git a/bsp_rpi/CMakeLists.txt b/bsp_linux_board/CMakeLists.txt similarity index 83% rename from bsp_rpi/CMakeLists.txt rename to bsp_linux_board/CMakeLists.txt index da35633d..5963d48c 100644 --- a/bsp_rpi/CMakeLists.txt +++ b/bsp_linux_board/CMakeLists.txt @@ -6,9 +6,3 @@ target_sources(${TARGET_NAME} PUBLIC add_subdirectory(boardconfig) add_subdirectory(boardtest) -add_subdirectory(gpio) - - - - - diff --git a/bsp_rpi/InitMission.cpp b/bsp_linux_board/InitMission.cpp similarity index 100% rename from bsp_rpi/InitMission.cpp rename to bsp_linux_board/InitMission.cpp diff --git a/bsp_rpi/InitMission.h b/bsp_linux_board/InitMission.h similarity index 100% rename from bsp_rpi/InitMission.h rename to bsp_linux_board/InitMission.h diff --git a/bsp_rpi/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp similarity index 100% rename from bsp_rpi/ObjectFactory.cpp rename to bsp_linux_board/ObjectFactory.cpp diff --git a/bsp_rpi/ObjectFactory.h b/bsp_linux_board/ObjectFactory.h similarity index 100% rename from bsp_rpi/ObjectFactory.h rename to bsp_linux_board/ObjectFactory.h diff --git a/bsp_rpi/boardconfig/CMakeLists.txt b/bsp_linux_board/boardconfig/CMakeLists.txt similarity index 100% rename from bsp_rpi/boardconfig/CMakeLists.txt rename to bsp_linux_board/boardconfig/CMakeLists.txt diff --git a/bsp_rpi/boardconfig/etl_profile.h b/bsp_linux_board/boardconfig/etl_profile.h similarity index 100% rename from bsp_rpi/boardconfig/etl_profile.h rename to bsp_linux_board/boardconfig/etl_profile.h diff --git a/bsp_rpi/boardconfig/gcov.h b/bsp_linux_board/boardconfig/gcov.h similarity index 100% rename from bsp_rpi/boardconfig/gcov.h rename to bsp_linux_board/boardconfig/gcov.h diff --git a/bsp_rpi/boardconfig/print.c b/bsp_linux_board/boardconfig/print.c similarity index 100% rename from bsp_rpi/boardconfig/print.c rename to bsp_linux_board/boardconfig/print.c diff --git a/bsp_rpi/boardconfig/print.h b/bsp_linux_board/boardconfig/print.h similarity index 100% rename from bsp_rpi/boardconfig/print.h rename to bsp_linux_board/boardconfig/print.h diff --git a/bsp_rpi/boardconfig/rpi_config.h b/bsp_linux_board/boardconfig/rpi_config.h similarity index 100% rename from bsp_rpi/boardconfig/rpi_config.h rename to bsp_linux_board/boardconfig/rpi_config.h diff --git a/bsp_rpi/boardtest/CMakeLists.txt b/bsp_linux_board/boardtest/CMakeLists.txt similarity index 100% rename from bsp_rpi/boardtest/CMakeLists.txt rename to bsp_linux_board/boardtest/CMakeLists.txt diff --git a/bsp_rpi/main.cpp b/bsp_linux_board/main.cpp similarity index 100% rename from bsp_rpi/main.cpp rename to bsp_linux_board/main.cpp diff --git a/bsp_rpi/gpio/CMakeLists.txt b/bsp_rpi/gpio/CMakeLists.txt deleted file mode 100644 index b816684d..00000000 --- a/bsp_rpi/gpio/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -target_sources(${TARGET_NAME} PUBLIC -) - - - - - - diff --git a/cmake/BBBCrossCompileConfig.cmake b/cmake/BBBCrossCompileConfig.cmake new file mode 100644 index 00000000..b32897f5 --- /dev/null +++ b/cmake/BBBCrossCompileConfig.cmake @@ -0,0 +1,98 @@ +# BBB_ROOTFS should point to the local directory which contains all the +# libraries and includes from the target raspi. +# The following command can be used to do this, replace and the +# local accordingly: +# rsync -vR --progress -rl --delete-after --safe-links pi@:/{lib,usr,opt/vc/lib} +# RASPBIAN_ROOTFS needs to be passed to the CMake command or defined in the +# application CMakeLists.txt before loading the toolchain file. + +# CROSS_COMPILE also needs to be set accordingly or passed to the CMake command + +if(NOT DEFINED ENV{BBB_ROOTFS}) + message(FATAL_ERROR + "Define the BBB_ROOTFS variable to point to the Beagle Bone Black rootfs." + ) +else() + set(SYSROOT_PATH "$ENV{BBB_ROOTFS}") + message(STATUS "Beagle Bone Black sysroot: ${SYSROOT_PATH}") +endif() + +if(NOT DEFINED ENV{CROSS_COMPILE}) + set(CROSS_COMPILE "arm-linux-gnueabihf") + message(STATUS + "No CROSS_COMPILE environmental variable set, using default ARM linux " + "cross compiler name ${CROSS_COMPILE}" + ) +else() + set(CROSS_COMPILE "$ENV{CROSS_COMPILE}") + message(STATUS + "Using environmental variable CROSS_COMPILE as cross-compiler: " + "$ENV{CROSS_COMPILE}" + ) +endif() + +message(STATUS "Using sysroot path: ${SYSROOT_PATH}") + +set(CROSS_COMPILE_CC "${CROSS_COMPILE}-gcc") +set(CROSS_COMPILE_CXX "${CROSS_COMPILE}-g++") +set(CROSS_COMPILE_LD "${CROSS_COMPILE}-ld") +set(CROSS_COMPILE_AR "${CROSS_COMPILE}-ar") +set(CROSS_COMPILE_RANLIB "${CROSS_COMPILE}-ranlib") +set(CROSS_COMPILE_STRIP "${CROSS_COMPILE}-strip") +set(CROSS_COMPILE_NM "${CROSS_COMPILE}-nm") +set(CROSS_COMPILE_OBJCOPY "${CROSS_COMPILE}-objcopy") +set(CROSS_COMPILE_SIZE "${CROSS_COMPILE}-size") + +# At the very least, cross compile gcc and g++ have to be set! +find_program (CROSS_COMPILE_CC_FOUND ${CROSS_COMPILE_CC} REQUIRED) +find_program (CROSS_COMPILE_CXX_FOUND ${CROSS_COMPILE_CXX} REQUIRED) + +set(CMAKE_CROSSCOMPILING TRUE) +set(CMAKE_SYSROOT "${SYSROOT_PATH}") + +# Define name of the target system +set(CMAKE_SYSTEM_NAME "Linux") +set(CMAKE_SYSTEM_PROCESSOR "arm") + +# Define the compiler +set(CMAKE_C_COMPILER ${CROSS_COMPILE_CC}) +set(CMAKE_CXX_COMPILER ${CROSS_COMPILE_CXX}) + +# List of library dirs where LD has to look. Pass them directly through gcc. +# LD_LIBRARY_PATH is not evaluated by arm-*-ld +set(LIB_DIRS + "${SYSROOT_PATH}/lib/${CROSS_COMPILE}" + "${SYSROOT_PATH}/usr/local/lib" + "${SYSROOT_PATH}/usr/lib/${CROSS_COMPILE}" + "${SYSROOT_PATH}/usr/lib" +) +# You can additionally check the linker paths if you add the +# flags ' -Xlinker --verbose' +set(COMMON_FLAGS "-I${SYSROOT_PATH}/usr/include") +foreach(LIB ${LIB_DIRS}) + set(COMMON_FLAGS "${COMMON_FLAGS} -L${LIB} -Wl,-rpath-link,${LIB}") +endforeach() + +set(CMAKE_PREFIX_PATH + "${CMAKE_PREFIX_PATH}" + "${SYSROOT_PATH}/usr/lib/${CROSS_COMPILE}" +) + +set(CMAKE_C_FLAGS + "-march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=hard ${COMMON_FLAGS}" + CACHE STRING "Flags for Beagle Bone Black" +) +set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}" + CACHE STRING "Flags for Beagle Bone Black" +) + +set(CMAKE_FIND_ROOT_PATH + "${CMAKE_INSTALL_PREFIX};${CMAKE_PREFIX_PATH};${CMAKE_SYSROOT}" +) + +# 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/cmake/HardwareOsPreConfig.cmake b/cmake/HardwareOsPreConfig.cmake index ab5c16fd..38248fce 100644 --- a/cmake/HardwareOsPreConfig.cmake +++ b/cmake/HardwareOsPreConfig.cmake @@ -53,8 +53,8 @@ endif() if(TGT_BSP) - if (${TGT_BSP} MATCHES "arm/raspberrypi") - set(BSP_PATH "bsp_rpi") + if (${TGT_BSP} MATCHES "arm/raspberrypi" OR ${TGT_BSP} MATCHES "arm/beagleboneblack") + set(BSP_PATH "bsp_linux_board") elseif(${TGT_BSP} MATCHES "arm/q7s") set(BSP_PATH "bsp_q7s") else() diff --git a/cmake/PreProjectConfig.cmake b/cmake/PreProjectConfig.cmake index f54da048..b78b9d33 100644 --- a/cmake/PreProjectConfig.cmake +++ b/cmake/PreProjectConfig.cmake @@ -51,7 +51,14 @@ if(${OS_FSFW} STREQUAL linux AND TGT_BSP) "${CMAKE_SCRIPT_PATH}/RPiCrossCompileConfig.cmake" PARENT_SCOPE ) - else() + elseif(${TGT_BSP} MATCHES "arm/beagleboneblack") + if(LINUX_CROSS_COMPILE) + set(CMAKE_TOOLCHAIN_FILE + "${CMAKE_SCRIPT_PATH}/BBBCrossCompileConfig.cmake" + PARENT_SCOPE + ) + endif() + else() message(WARNING "Target BSP (TGT_BSP) ${TGT_BSP} unknown!") endif() endif() diff --git a/cmake/scripts/BeagleBoneBlack/create_cmake_debug_cfg.sh b/cmake/scripts/BeagleBoneBlack/create_cmake_debug_cfg.sh new file mode 100644 index 00000000..cfa71d02 --- /dev/null +++ b/cmake/scripts/BeagleBoneBlack/create_cmake_debug_cfg.sh @@ -0,0 +1,30 @@ +#!/bin/sh +counter=0 +while [ ${counter} -lt 5 ] +do + cd .. + if [ -f "cmake_build_config.py" ];then + break + fi + counter=$((counter=counter + 1)) +done + +if [ "${counter}" -ge 5 ];then + echo "cmake_build_config.py not found in upper directories!" + exit 1 +fi + +os_fsfw="linux" +tgt_bsp="arm/beagleboneblack" +build_generator="" +builddir="build-Debug-BBB" +defines="LINUX_CROSS_COMPILE=OFF" +if [ "${OS}" = "Windows_NT" ]; then + build_generator="MinGW Makefiles" +# Could be other OS but this works for now. +else + build_generator="Unix Makefiles" +fi + +python3 cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -t "${tgt_bsp}" \ + -l "${builddir}" -d "${defines}" diff --git a/cmake/scripts/BeagleBoneBlack/crosscompile/bbb_path_helper.sh b/cmake/scripts/BeagleBoneBlack/crosscompile/bbb_path_helper.sh new file mode 100644 index 00000000..340713e1 --- /dev/null +++ b/cmake/scripts/BeagleBoneBlack/crosscompile/bbb_path_helper.sh @@ -0,0 +1,3 @@ +export PATH=$PATH:"$HOME/beaglebone//bin" +export CROSS_COMPILE="arm-linux-gnueabihf" +export BBB_ROOTFS="${HOME}/raspberrypi/rootfs" diff --git a/cmake/scripts/BeagleBoneBlack/crosscompile/create_cmake_debug_cfg.sh b/cmake/scripts/BeagleBoneBlack/crosscompile/create_cmake_debug_cfg.sh new file mode 100644 index 00000000..b413d07f --- /dev/null +++ b/cmake/scripts/BeagleBoneBlack/crosscompile/create_cmake_debug_cfg.sh @@ -0,0 +1,30 @@ +#!/bin/sh +counter=0 +while [ ${counter} -lt 5 ] +do + cd .. + if [ -f "cmake_build_config.py" ];then + break + fi + counter=$((counter=counter + 1)) +done + +if [ "${counter}" -ge 5 ];then + echo "cmake_build_config.py not found in upper directories!" + exit 1 +fi + +os_fsfw="linux" +tgt_bsp="arm/beagleboneblack" +build_generator="" +builddir="build-Debug-BBB" +defines="LINUX_CROSS_COMPILE=ON" +if [ "${OS}" = "Windows_NT" ]; then + build_generator="MinGW Makefiles" +# Could be other OS but this works for now. +else + build_generator="Unix Makefiles" +fi + +python3 cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -t "${tgt_bsp}" \ + -l "${builddir}" -d "${defines}" diff --git a/cmake/scripts/BeagleBoneBlack/crosscompile/create_cmake_release_cfg.sh b/cmake/scripts/BeagleBoneBlack/crosscompile/create_cmake_release_cfg.sh new file mode 100644 index 00000000..81e3322d --- /dev/null +++ b/cmake/scripts/BeagleBoneBlack/crosscompile/create_cmake_release_cfg.sh @@ -0,0 +1,30 @@ +#!/bin/sh +counter=0 +while [ ${counter} -lt 5 ] +do + cd .. + if [ -f "cmake_build_config.py" ];then + break + fi + counter=$((counter=counter + 1)) +done + +if [ "${counter}" -ge 5 ];then + echo "cmake_build_config.py not found in upper directories!" + exit 1 +fi + +os_fsfw="linux" +tgt_bsp="arm/beagleboneblack" +build_generator="" +builddir="build-Release-BBB" +defines="LINUX_CROSS_COMPILE=ON" +if [ "${OS}" = "Windows_NT" ]; then + build_generator="MinGW Makefiles" +# Could be other OS but this works for now. +else + build_generator="Unix Makefiles" +fi + +python3 cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -t "${tgt_bsp}" \ + -l "${builddir}" -d "${defines}" diff --git a/cmake/scripts/BeagleBoneBlack/crosscompile/create_cmake_relwithdeb_cfg.sh b/cmake/scripts/BeagleBoneBlack/crosscompile/create_cmake_relwithdeb_cfg.sh new file mode 100644 index 00000000..81e3322d --- /dev/null +++ b/cmake/scripts/BeagleBoneBlack/crosscompile/create_cmake_relwithdeb_cfg.sh @@ -0,0 +1,30 @@ +#!/bin/sh +counter=0 +while [ ${counter} -lt 5 ] +do + cd .. + if [ -f "cmake_build_config.py" ];then + break + fi + counter=$((counter=counter + 1)) +done + +if [ "${counter}" -ge 5 ];then + echo "cmake_build_config.py not found in upper directories!" + exit 1 +fi + +os_fsfw="linux" +tgt_bsp="arm/beagleboneblack" +build_generator="" +builddir="build-Release-BBB" +defines="LINUX_CROSS_COMPILE=ON" +if [ "${OS}" = "Windows_NT" ]; then + build_generator="MinGW Makefiles" +# Could be other OS but this works for now. +else + build_generator="Unix Makefiles" +fi + +python3 cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -t "${tgt_bsp}" \ + -l "${builddir}" -d "${defines}"