compiling

This commit is contained in:
Robin Müller 2021-07-14 18:08:29 +02:00
parent 421b36b64b
commit 6a70a6297b
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
13 changed files with 54 additions and 113 deletions

View File

@ -27,7 +27,7 @@ include(${CMAKE_SCRIPT_PATH}/PreProjectConfig.cmake)
pre_project_config()
# Project Name
project(fsfw-example ASM C CXX)
project(fsfw-example-linux-mcu ASM C CXX)
################################################################################
@ -156,11 +156,6 @@ target_compile_options(${TARGET_NAME} PRIVATE
${WARNING_FLAGS}
)
if(CMAKE_CROSSCOMPILING)
include(${CMAKE_SCRIPT_PATH}/HardwareOsPostConfig.cmake)
post_source_hw_os_config()
endif()
if(TGT_BSP)
set(TARGET_STRING "Target BSP: ${TGT_BSP}")
else()
@ -174,12 +169,22 @@ string(CONCAT POST_BUILD_COMMENT
"${TARGET_STRING}"
)
message(STATUS ${CMAKE_SIZE})
message(STATUS ${CMAKE_OBJCOPY})
add_custom_command(
TARGET ${TARGET_NAME}
POST_BUILD
COMMAND ${CMAKE_SIZE} ${TARGET_NAME}${FILE_SUFFIX}
COMMAND ${CMAKE_SIZE} ${TARGET_NAME}
COMMENT ${POST_BUILD_COMMENT}
)
add_custom_command(
TARGET ${TARGET_NAME}
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -O binary ${TARGET_NAME} ${TARGET_NAME}.bin
COMMENT "Generating binary file ${TARGET_NAME}.bin.."
)
include (${CMAKE_SCRIPT_PATH}/BuildType.cmake)
set_build_type()

View File

@ -13,7 +13,7 @@
#include <fsfw/datapoollocal/LocalDataPoolManager.h>
#include <fsfw/monitoring/MonitoringMessageContent.h>
#include <fsfw/storagemanager/PoolManager.h>
#include <fsfw/tmtcpacket/pus/TmPacketStored.h>
#include <fsfw/tmtcpacket/pus/tm.h>
#include <fsfw/tmtcservices/CommandingServiceBase.h>
#include <fsfw/tmtcservices/PusServiceBase.h>
#include <fsfw/osal/common/UdpTcPollingTask.h>

View File

@ -67,6 +67,8 @@ static constexpr uint8_t FSFW_CSB_FIFO_DEPTH = 6;
static constexpr size_t FSFW_PRINT_BUFFER_SIZE = 124;
static constexpr size_t FSFW_MAX_TM_PACKET_SIZE = 2048;
}
#endif /* CONFIG_FSFWCONFIG_H_ */

View File

@ -47,6 +47,9 @@ set(CROSS_COMPILE_SIZE "${CROSS_COMPILE}-size")
find_program (CROSS_COMPILE_CC_FOUND ${CROSS_COMPILE_CC} REQUIRED)
find_program (CROSS_COMPILE_CXX_FOUND ${CROSS_COMPILE_CXX} REQUIRED)
find_program(CROSS_COMPILE_SIZE ${CROSS_COMPILE_SIZE})
find_program(CROSS_COMPILE_OBJCOY ${CROSS_COMPILE_OBJCOPY})
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_SYSROOT "${SYSROOT_PATH}")
@ -57,6 +60,8 @@ set(CMAKE_SYSTEM_PROCESSOR "arm")
# Define the compiler
set(CMAKE_C_COMPILER ${CROSS_COMPILE_CC})
set(CMAKE_CXX_COMPILER ${CROSS_COMPILE_CXX})
set(CMAKE_SIZE ${CROSS_COMPILE_SIZE})
set(CMAKE_OBJCOPY ${CROSS_COMPILE_OBJCOPY})
# List of library dirs where LD has to look. Pass them directly through gcc.
# LD_LIBRARY_PATH is not evaluated by arm-*-ld

View File

@ -1,34 +0,0 @@
function(post_source_hw_os_config)
set(C_FLAGS "" CACHE INTERNAL "C flags")
set(C_DEFS ""
CACHE INTERNAL
"C Defines"
)
set(CXX_FLAGS ${C_FLAGS})
set(CXX_DEFS ${C_DEFS})
if(CMAKE_VERBOSE)
message(STATUS "C Flags: ${C_FLAGS}")
message(STATUS "CXX Flags: ${CXX_FLAGS}")
message(STATUS "C Defs: ${C_DEFS}")
message(STATUS "CXX Defs: ${CXX_DEFS}")
endif()
# Generator expression. Can be used to set different C, CXX and ASM flags.
target_compile_options(${TARGET_NAME} PRIVATE
$<$<COMPILE_LANGUAGE:C>:${C_DEFS} ${C_FLAGS}>
$<$<COMPILE_LANGUAGE:CXX>:${CXX_DEFS} ${CXX_FLAGS}>
$<$<COMPILE_LANGUAGE:ASM>:${ASM_FLAGS}>
)
add_custom_command(
TARGET ${TARGET_NAME}
POST_BUILD
COMMAND echo Generating binary file ${CMAKE_PROJECT_NAME}.bin..
COMMAND ${CMAKE_OBJCOPY} -O binary ${TARGET_NAME} ${TARGET_NAME}.bin
)
endfunction()

View File

@ -1,6 +1,6 @@
function(pre_source_hw_os_config)
if(${OS_FSFW} STREQUAL linux)
if(FSFW_OSAL MATCHES linux)
find_package(Threads REQUIRED)
set(BSP_PATH "bsp_linux")
# Hosted

View File

@ -5,25 +5,27 @@ if(DEFINED TGT_BSP)
if(${TGT_BSP} MATCHES "arm/raspberrypi" AND NOT ${OS_FSFW} MATCHES linux)
message(STATUS "FSFW OSAL invalid for specified target BSP ${TGT_BSP}!")
message(STATUS "Setting valid OS_FSFW: linux")
set(OS_FSFW "linux")
set(FSFW_OSAL "linux")
endif()
endif()
if(${OS_FSFW} STREQUAL linux AND TGT_BSP)
if(FSFW_OSAL MATCHES linux AND TGT_BSP)
if(${TGT_BSP} MATCHES "host/none")
elseif(${TGT_BSP} MATCHES "arm/raspberrypi")
if(NOT DEFINED ENV{LINUX_ROOTFS})
if(NOT RASPBIAN_ROOTFS)
message(FATAL_ERROR "LINUX_ROOTFS must be set to Raspberry Pi rootfs location")
else()
set(ENV{LINUX_ROOTFS} "${LINUX_ROOTFS}")
endif()
else()
message(STATUS
"LINUX_ROOTFS from environmental variables used: "
"$ENV{LINUX_ROOTFS}"
)
endif()
if(NOT SYSROOT_PATH)
if(NOT DEFINED ENV{LINUX_ROOTFS})
if(NOT LINUX_ROOTFS)
message(FATAL_ERROR "LINUX_ROOTFS must be set to Raspberry Pi rootfs location")
else()
set(ENV{LINUX_ROOTFS} "${LINUX_ROOTFS}")
endif()
else()
message(STATUS
"LINUX_ROOTFS from environmental variables used: "
"$ENV{LINUX_ROOTFS}"
)
endif()
endif()
if(NOT DEFINED ENV{RASPBERRY_VERSION})
if(NOT RASPBERRY_VERSION)

View File

@ -18,14 +18,16 @@ endif()
# 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{LINUX_ROOTFS})
message(FATAL_ERROR
"Define the LINUX_ROOTFS variable to point to the Raspberry Pi rootfs."
)
# Sysroot has not been cached yet and was not set in environment either
if(NOT SYSROOT_PATH)
message(FATAL_ERROR
"Define the LINUX_ROOTFS variable to point to the Raspberry Pi rootfs."
)
endif()
else()
set(SYSROOT_PATH "$ENV{LINUX_ROOTFS}" CACHE PATH "Local linux root filesystem path")
message(STATUS "Raspberry Pi sysroot: ${SYSROOT_PATH}")
message(STATUS "Raspberry Pi sysroot: ${SYSROOT_PATH}")
endif()
if(NOT DEFINED ENV{CROSS_COMPILE})
@ -55,8 +57,11 @@ 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)
find_program(CROSS_COMPILE_CC_FOUND ${CROSS_COMPILE_CC} REQUIRED)
find_program(CROSS_COMPILE_CXX_FOUND ${CROSS_COMPILE_CXX} REQUIRED)
find_program(CROSS_COMPILE_SIZE ${CROSS_COMPILE_SIZE})
find_program(CROSS_COMPILE_OBJCOY ${CROSS_COMPILE_OBJCOPY})
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_SYSROOT "${SYSROOT_PATH}")
@ -72,6 +77,8 @@ endif()
# Define the compiler
set(CMAKE_C_COMPILER ${CROSS_COMPILE_CC})
set(CMAKE_CXX_COMPILER ${CROSS_COMPILE_CXX})
set(CMAKE_SIZE ${CROSS_COMPILE_SIZE})
set(CMAKE_OBJCOPY ${CROSS_COMPILE_OBJCOPY})
# List of library dirs where LD has to look. Pass them directly through gcc.
# LD_LIBRARY_PATH is not evaluated by arm-*-ld

View File

@ -1,24 +0,0 @@
#!/bin/sh
# This script can be used to set the path to the cross-compile toolchain
# A default path is set if the path is not supplied via command line
if [ $# -eq 1 ];then
export PATH=$PATH:"$1"
else
# TODO: make version configurable via shell argument
export PATH=$PATH:"/opt/cross-pi-gcc/bin"
export CROSS_COMPILE="arm-linux-gnueabihf"
export RASPBERRY_VERSION="4"
export RASPBIAN_ROOTFS="${HOME}/raspberrypi/rootfs"
fi
# It is also recommended to set up a custom shell script to perform the
# sysroot synchronization so that any software is built with the library and
# headers of the Raspberry Pi. This can for example be dome with the rsync
# command.
# The following command can be used, <ip-address> and the local
# <rootfs-path> need to be set accordingly.
# rsync -vR --progress -rl --delete-after --safe-links pi@<ip-address>:/{lib,usr,opt/vc/lib} <rootfs-path>
# It is recommended to use $HOME/raspberrypi/rootfs as the rootfs path,
# so the default RASPBIAN_ROOTFS variable set in the CMakeLists.txt is correct.

View File

@ -1,22 +0,0 @@
#!/bin/sh
# This script can be used to set the path to the cross-compile toolchain
# A default path is set if the path is not supplied via command line
if [ $# -eq 1 ];then
export PATH=$PATH:"$1"
else
# TODO: make version configurable via shell argument
export PATH=$PATH:"/c/SysGCC/raspberry/bin"
export CROSS_COMPILE="arm-linux-gnueabihf"
export RASPBERRY_VERSION="4"
export RASPBIAN_ROOTFS="/c/Users/<UserName>/raspberrypi/rootfs"
fi
# It is also recommended to set up a custom shell script to perform the
# sysroot synchronization so that any software is built with the library and
# headers of the Raspberry Pi. This can for example be dome with the rsync
# command.
# The following command can be used, <ip-address> and the local
# <rootfs-path> need to be set accordingly.
# rsync -vR --progress -rl --delete-after --safe-links pi@<ip-address>:/{lib,usr,opt/vc/lib} <rootfs-path>

View File

@ -101,7 +101,7 @@ def main():
print(f"Navigating into build directory: {build_path}")
os.chdir(cmake_build_folder)
cmake_command = f"cmake {generator_cmake_arg} -DOS_FSFW=\"{cmake_fsfw_osal}\" " \
cmake_command = f"cmake {generator_cmake_arg} -DFSFW_OSAL=\"{cmake_fsfw_osal}\" " \
f"-DCMAKE_BUILD_TYPE=\"{cmake_build_type}\" {cmake_target_cfg_cmd} " \
f"{define_string} {source_location}"
# Remove redundant spaces

@ -1 +1 @@
Subproject commit d79ab3df3548f4020cb763bac800765b53f07716
Subproject commit 0ad5c91fc7ce64b04b1d9742a54929d79acfc722

2
fsfw

@ -1 +1 @@
Subproject commit 22693eee50aa85fccc9a1bd45aca4bca6b5dd62b
Subproject commit a3e6b1018b88f6e1e848f49e8f566026e88b98e8