Adding Nuttx Build infrastructure

This commit is contained in:
David Sidrane 2016-12-12 13:11:51 -10:00 committed by Lorenz Meier
parent cb9517486d
commit d6098c8226
7 changed files with 360 additions and 96 deletions

View File

@ -101,9 +101,14 @@ include(CMakeParseArguments)
function(px4_parse_function_args) function(px4_parse_function_args)
cmake_parse_arguments(IN "" "NAME" "OPTIONS;ONE_VALUE;MULTI_VALUE;REQUIRED;ARGN" "${ARGN}") cmake_parse_arguments(IN "" "NAME" "OPTIONS;ONE_VALUE;MULTI_VALUE;REQUIRED;ARGN" "${ARGN}")
cmake_parse_arguments(OUT "${IN_OPTIONS}" "${IN_ONE_VALUE}" "${IN_MULTI_VALUE}" "${IN_ARGN}") cmake_parse_arguments(OUT "${IN_OPTIONS}" "${IN_ONE_VALUE}" "${IN_MULTI_VALUE}" "${IN_ARGN}")
if (OUT_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "${IN_NAME}: unparsed ${OUT_UNPARSED_ARGUMENTS}")
endif()
foreach(arg ${IN_REQUIRED}) foreach(arg ${IN_REQUIRED})
if (NOT OUT_${arg}) if (NOT OUT_${arg})
message(FATAL_ERROR "${IN_NAME} requires argument ${arg}\nARGN: ${IN_ARGN}") if (NOT "${OUT_${arg}}" STREQUAL "0")
message(FATAL_ERROR "${IN_NAME} requires argument ${arg}\nARGN: ${IN_ARGN}")
endif()
endif() endif()
endforeach() endforeach()
foreach(arg ${IN_OPTIONS} ${IN_ONE_VALUE} ${IN_MULTI_VALUE}) foreach(arg ${IN_OPTIONS} ${IN_ONE_VALUE} ${IN_MULTI_VALUE})
@ -143,6 +148,9 @@ function(px4_add_git_submodule)
) )
add_custom_target(${TARGET} add_custom_target(${TARGET}
WORKING_DIRECTORY ${PX4_SOURCE_DIR} WORKING_DIRECTORY ${PX4_SOURCE_DIR}
# todo:Not have 2 list of submodues one (see the end of Tools/check_submodules.sh and Firmware/CMakeLists.txt)
# using the list of submodules from the CMake file to drive the test
# COMMAND Tools/check_submodules.sh ${PATH}
DEPENDS ${PX4_BINARY_DIR}/git_init_${NAME}.stamp DEPENDS ${PX4_BINARY_DIR}/git_init_${NAME}.stamp
) )
endfunction() endfunction()
@ -240,7 +248,7 @@ endfunction()
# STACK : deprecated use stack main instead # STACK : deprecated use stack main instead
# STACK_MAIN : size of stack for main function # STACK_MAIN : size of stack for main function
# STACK_MAX : maximum stack size of any frame # STACK_MAX : maximum stack size of any frame
# COMPILE_FLAGS : compile flags # COMPILE_FLAGS : compile flags
# LINK_FLAGS : link flags # LINK_FLAGS : link flags
# SRCS : source files # SRCS : source files
# INCLUDES : include directories # INCLUDES : include directories
@ -375,6 +383,8 @@ function(px4_generate_messages)
MULTI_VALUE MSG_FILES DEPENDS INCLUDES MULTI_VALUE MSG_FILES DEPENDS INCLUDES
REQUIRED MSG_FILES OS TARGET REQUIRED MSG_FILES OS TARGET
ARGN ${ARGN}) ARGN ${ARGN})
if("${config_nuttx_config}" STREQUAL "bootloader")
else()
set(QUIET) set(QUIET)
if(NOT VERBOSE) if(NOT VERBOSE)
set(QUIET "-q") set(QUIET "-q")
@ -463,7 +473,7 @@ function(px4_generate_messages)
${msg_multi_files_out} ${msg_multi_files_out}
${msg_files_out} ${msg_files_out}
) )
endif()
endfunction() endfunction()
#============================================================================= #=============================================================================
@ -1043,7 +1053,7 @@ function(px4_generate_airframes_xml)
set(process_airframes ${PX4_SOURCE_DIR}/Tools/px_process_airframes.py) set(process_airframes ${PX4_SOURCE_DIR}/Tools/px_process_airframes.py)
add_custom_command(OUTPUT ${OUT} add_custom_command(OUTPUT ${OUT}
COMMAND ${PYTHON_EXECUTABLE} ${process_airframes} COMMAND ${PYTHON_EXECUTABLE} ${process_airframes}
-a ${PX4_SOURCE_DIR}/ROMFS/px4fmu_common/init.d -a ${PX4_SOURCE_DIR}/ROMFS/${config_romfs_root}/init.d
--board CONFIG_ARCH_BOARD_${BOARD} --xml --board CONFIG_ARCH_BOARD_${BOARD} --xml
) )
set(${OUT} ${${OUT}} PARENT_SCOPE) set(${OUT} ${${OUT}} PARENT_SCOPE)
@ -1098,6 +1108,34 @@ function(px4_copy_tracked)
set(${OUT} ${_files_out} PARENT_SCOPE) set(${OUT} ${_files_out} PARENT_SCOPE)
endfunction() endfunction()
#=============================================================================
#
# px4_share_subdirectory
#
# This function simplifes sharing a sub directory
#
# Usage:
# px4_share_subdirectory(RELDIR <relative path> ARGS <args>)
#
# Input:
# RELDIR : The relitive path to share.
# ARGS : Any optional arguments to pass to add_subdirectory
#
# Output:
# : None
#
# Example:
# px4_share_subdirectory(RELDIR ../uavcan/libuavcan ARGS EXCLUDE_FROM_ALL)
#
function(px4_share_subdirectory)
px4_parse_function_args(
NAME px4_share_subdirectory
ONE_VALUE OUT RELDIR
MULTI_VALUE ARGS
REQUIRED RELDIR
ARGN ${ARGN})
add_subdirectory(${RELDIR} ${RELDIR}/${RELDIR} ${ARGS})
endfunction()
#============================================================================= #=============================================================================
# #
# px4_strip_optimization # px4_strip_optimization

View File

@ -38,6 +38,7 @@
# OS Specific Functions # OS Specific Functions
# #
# * px4_nuttx_add_firmware # * px4_nuttx_add_firmware
# * px4_nuttx_make_uavcan_bootloadable
# * px4_nuttx_generate_builtin_commands # * px4_nuttx_generate_builtin_commands
# * px4_nuttx_add_export # * px4_nuttx_add_export
# * px4_nuttx_add_romfs # * px4_nuttx_add_romfs
@ -93,7 +94,7 @@ function(px4_nuttx_add_firmware)
) )
endif() endif()
add_custom_command(OUTPUT ${OUT} add_custom_command(OUTPUT ${OUT} ${EXE}.bin
COMMAND ${OBJCOPY} -O binary ${EXE} ${EXE}.bin COMMAND ${OBJCOPY} -O binary ${EXE} ${EXE}.bin
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_mkfw.py COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_mkfw.py
--prototype ${PX4_SOURCE_DIR}/Images/${BOARD}.prototype --prototype ${PX4_SOURCE_DIR}/Images/${BOARD}.prototype
@ -105,6 +106,70 @@ function(px4_nuttx_add_firmware)
add_custom_target(build_firmware_${BOARD} ALL DEPENDS ${OUT}) add_custom_target(build_firmware_${BOARD} ALL DEPENDS ${OUT})
endfunction() endfunction()
#=============================================================================
#
# px4_nuttx_make_uavcan_bootloadable
#
# This function adds a uavcan boot loadable target.
#
# Usage:
# px4_nuttx_make_uavcan_bootloadable(
# BOARD <board>
# BIN <input bin file>)
# HWNAME <uavcan name>
# HW_MAJOR <number>
# HW_MINOR <number>
# SW_MAJOR <number>
# SW_MINOR <number>)
#
# Input:
# BOARD : the board
# BIN : the bin file to generate the bootloadable image from
# HWNAME : the uavcan name
# HW_MAJOR : the major hardware revision
# HW_MINOR : the minor hardware revision
# SW_MAJOR : the major software revision
# SW_MINOR : the minor software revision
#
# Output:
# OUT : None
#
# Example:
# px4_nuttx_make_uavcan_bootloadable(
# BOARD ${BOARD}
# BIN ${CMAKE_CURRENT_BINARY_DIR}/firmware_nuttx
# HWNAME ${uavcanblid_name}
# HW_MAJOR ${uavcanblid_hw_version_major}
# HW_MINOR ${uavcanblid_hw_version_minor}
# SW_MAJOR ${uavcanblid_sw_version_major}
# SW_MINOR ${uavcanblid_sw_version_minor}
# )
#
function(px4_nuttx_make_uavcan_bootloadable)
px4_parse_function_args(
NAME px4_nuttx_make_uavcan_bootloadable
ONE_VALUE BOARD BIN HWNAME HW_MAJOR HW_MINOR SW_MAJOR SW_MINOR
REQUIRED BOARD BIN HWNAME HW_MAJOR HW_MINOR SW_MAJOR SW_MINOR
ARGN ${ARGN})
string(REPLACE "\"" "" HWNAME ${HWNAME})
execute_process(
COMMAND git rev-list HEAD --max-count=1 --abbrev=8 --abbrev-commit
OUTPUT_VARIABLE uavcanbl_git_desc
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${PX4_SOURCE_DIR}
)
if ("${uavcanbl_git_desc}" STREQUAL "")
set(uavcanbl_git_desc ffffffff)
endif()
set(uavcan_bl_imange_name ${HWNAME}-${HW_MAJOR}.${HW_MINOR}-${SW_MAJOR}.${SW_MINOR}.${uavcanbl_git_desc}.uavcan.bin)
message(STATUS "Generating UAVCAN Bootable as ${uavcan_bl_imange_name}")
add_custom_command(OUTPUT ${uavcan_bl_imange_name}
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/make_can_boot_descriptor.py
-v --use-git-hash ${BIN} ${uavcan_bl_imange_name}
DEPENDS ${BIN})
add_custom_target(build_uavcan_bl_${BOARD} ALL DEPENDS ${uavcan_bl_imange_name})
endfunction()
#============================================================================= #=============================================================================
# #
# px4_nuttx_generate_builtin_commands # px4_nuttx_generate_builtin_commands
@ -185,60 +250,75 @@ function(px4_nuttx_add_export)
set(nuttx_src ${PX4_BINARY_DIR}/${CONFIG}/NuttX) set(nuttx_src ${PX4_BINARY_DIR}/${CONFIG}/NuttX)
# all patches
file(GLOB nuttx_patches ${PX4_SOURCE_DIR}/nuttx-patches/*.patch)
# copy
file(GLOB_RECURSE nuttx_all_files ${PX4_SOURCE_DIR}/NuttX/*)
add_custom_command(OUTPUT nuttx_copy_${CONFIG}.stamp
COMMAND ${MKDIR} -p ${nuttx_src}
COMMAND rsync -a --delete --exclude=.git ${PX4_SOURCE_DIR}/NuttX/ ${nuttx_src}/
COMMAND ${TOUCH} nuttx_copy_${CONFIG}.stamp
DEPENDS ${DEPENDS} ${nuttx_patches} ${nuttx_all_files}
COMMENT "Copying NuttX for ${CONFIG} with ${config_nuttx_config}")
# patch # patch
add_custom_target(__nuttx_patch_${CONFIG}) add_custom_target(nuttx_patch_${CONFIG})
file(GLOB nuttx_patches RELATIVE ${PX4_SOURCE_DIR}
${PX4_SOURCE_DIR}/nuttx-patches/*.patch)
foreach(patch ${nuttx_patches}) foreach(patch ${nuttx_patches})
string(REPLACE "/" "_" patch_name "${patch}-${CONFIG}") get_filename_component(patch_file_name ${patch} NAME)
message(STATUS "nuttx-patch: ${patch}") message(STATUS "NuttX patch: nuttx-patches/${patch_file_name}")
add_custom_command(OUTPUT nuttx_patch_${patch_name}.stamp string(REPLACE "/" "_" patch_name "nuttx_patch_${patch_file_name}-${CONFIG}")
COMMAND ${PATCH} -p0 -N < ${PX4_SOURCE_DIR}/${patch} set(patch_stamp ${nuttx_src}/${patch_name}.stamp)
COMMAND ${TOUCH} nuttx_patch_${patch_name}.stamp
DEPENDS ${DEPENDS} add_custom_command(OUTPUT ${patch_stamp}
) COMMAND ${PATCH} -d ${nuttx_src} -s -p1 -N < ${patch}
add_custom_target(nuttx_patch_${patch_name} COMMAND ${TOUCH} ${patch_stamp}
DEPENDS nuttx_patch_${patch_name}.stamp) DEPENDS ${DEPENDS} nuttx_copy_${CONFIG}.stamp ${patch}
add_dependencies(nuttx_patch nuttx_patch_${patch_name}) COMMENT "Applying ${patch}")
add_custom_target(${patch_name} DEPENDS ${patch_stamp})
add_dependencies(nuttx_patch_${CONFIG} ${patch_name})
endforeach() endforeach()
# Read defconfig to see if CONFIG_ARMV7M_STACKCHECK is yes # Read defconfig to see if CONFIG_ARMV7M_STACKCHECK is yes
# note: CONFIG will be BOARD in the future evaluation of ${hw_stack_check_${CONFIG} # note: CONFIG will be BOARD in the future evaluation of ${hw_stack_check_${CONFIG}
file(STRINGS "${PX4_SOURCE_DIR}/nuttx-configs/${CONFIG}/nsh/defconfig" file(STRINGS "${PX4_SOURCE_DIR}/nuttx-configs/${CONFIG}/${config_nuttx_config}/defconfig"
hw_stack_check_${CONFIG} hw_stack_check_${CONFIG}
REGEX "CONFIG_ARMV7M_STACKCHECK=y" REGEX "CONFIG_ARMV7M_STACKCHECK=y"
) )
if ("${hw_stack_check_${CONFIG}}" STREQUAL "CONFIG_ARMV7M_STACKCHECK=y") if ("${hw_stack_check_${CONFIG}}" STREQUAL "CONFIG_ARMV7M_STACKCHECK=y")
set(config_nuttx_hw_stack_check_${CONFIG} y CACHE INTERNAL "") set(config_nuttx_hw_stack_check_${CONFIG} y CACHE INTERNAL "" FORCE)
endif() endif()
# copy and export # configure
file(RELATIVE_PATH nuttx_cp_src ${PX4_BINARY_DIR} ${PX4_SOURCE_DIR}/NuttX)
file(GLOB_RECURSE config_files ${PX4_SOURCE_DIR}/nuttx-configs/${CONFIG}/*) file(GLOB_RECURSE config_files ${PX4_SOURCE_DIR}/nuttx-configs/${CONFIG}/*)
add_custom_command(OUTPUT ${PX4_BINARY_DIR}/${CONFIG}.export add_custom_command(OUTPUT ${nuttx_src}/nuttx/.config
COMMAND ${MKDIR} -p ${nuttx_src} COMMAND ${CP} -rp ${PX4_SOURCE_DIR}/nuttx-configs/*.mk ${nuttx_src}/nuttx/
COMMAND rsync -a --delete --exclude=.git ${nuttx_cp_src}/ ${CONFIG}/NuttX/ COMMAND ${CP} -rp ${PX4_SOURCE_DIR}/nuttx-configs/${CONFIG} ${nuttx_src}/nuttx/configs
#COMMAND ${ECHO} Configuring NuttX for ${CONFIG} COMMAND cd ${nuttx_src}/nuttx/tools && ./configure.sh ${CONFIG}/${config_nuttx_config}
COMMAND ${MAKE} --no-print-directory -C${nuttx_src}/nuttx -r --quiet distclean DEPENDS ${DEPENDS} nuttx_patch_${CONFIG} ${config_files}
COMMAND ${CP} -r ${PX4_SOURCE_DIR}/nuttx-configs/PX4_Warnings.mk ${nuttx_src}/nuttx/
COMMAND ${CP} -r ${PX4_SOURCE_DIR}/nuttx-configs/${CONFIG} ${nuttx_src}/nuttx/configs
COMMAND cd ${nuttx_src}/nuttx/tools && ./configure.sh ${CONFIG}/nsh && cd ..
#COMMAND ${ECHO} Exporting NuttX for ${CONFIG}
COMMAND ${MAKE} --no-print-directory --quiet -C ${nuttx_src}/nuttx -j${THREADS} -r CONFIG_ARCH_BOARD=${CONFIG} export > nuttx_build.log
COMMAND ${CP} -r ${nuttx_src}/nuttx/nuttx-export.zip ${PX4_BINARY_DIR}/${CONFIG}.export
DEPENDS ${config_files} "${PX4_SOURCE_DIR}/nuttx-configs/${CONFIG}/nsh/defconfig" ${DEPENDS}
WORKING_DIRECTORY ${PX4_BINARY_DIR} WORKING_DIRECTORY ${PX4_BINARY_DIR}
COMMENT "Building NuttX for ${CONFIG}") COMMENT "Configuring NuttX for ${CONFIG} with ${config_nuttx_config}")
# extract # manual reconfigure helper
add_custom_command(OUTPUT nuttx_export_${CONFIG}.stamp add_custom_target(reconfigure_nuttx_${CONFIG}
COMMAND ${RM} -rf ${nuttx_src}/nuttx-export COMMAND cd ${nuttx_src}/nuttx
COMMAND ${UNZIP} -q ${PX4_BINARY_DIR}/${CONFIG}.export -d ${nuttx_src} COMMAND ${MAKE} -C ${nuttx_src}/nuttx CONFIG_ARCH_BOARD=${CONFIG} oldconfig
COMMAND ${TOUCH} nuttx_export_${CONFIG}.stamp COMMAND ${MAKE} -C ${nuttx_src}/nuttx CONFIG_ARCH_BOARD=${CONFIG} menuconfig
DEPENDS ${DEPENDS} ${PX4_BINARY_DIR}/${CONFIG}.export) COMMAND ${CP} ${nuttx_src}/nuttx/.config ${PX4_SOURCE_DIR}/nuttx-configs/${CONFIG}/${config_nuttx_config}/defconfig
DEPENDS ${nuttx_src}/nuttx/.config
COMMENT "Reconfiguring NuttX for ${CONFIG} with ${config_nuttx_config}"
USES_TERMINAL)
add_custom_target(${OUT} # build and export
DEPENDS nuttx_export_${CONFIG}.stamp) add_custom_command(OUTPUT ${nuttx_src}/nuttx/nuttx-export/include/nuttx/config.h
COMMAND ${RM} -rf ${nuttx_src}/nuttx/nuttx-export
COMMAND ${MAKE} --no-print-directory --quiet -C ${nuttx_src}/nuttx -r CONFIG_ARCH_BOARD=${CONFIG} export > nuttx_build.log
DEPENDS ${DEPENDS} ${nuttx_src}/nuttx/.config
WORKING_DIRECTORY ${PX4_BINARY_DIR}
COMMENT "Building NuttX for ${CONFIG} with ${config_nuttx_config}")
add_custom_target(${OUT} DEPENDS ${nuttx_src}/nuttx/nuttx-export/include/nuttx/config.h)
endfunction() endfunction()
@ -308,6 +388,7 @@ function(px4_nuttx_add_romfs)
REQUIRED OUT ROOT REQUIRED OUT ROOT
ARGN ${ARGN}) ARGN ${ARGN})
set(romfs_used y PARENT_SCOPE)
set(romfs_temp_dir ${PX4_BINARY_DIR}/tmp/${ROOT}) set(romfs_temp_dir ${PX4_BINARY_DIR}/tmp/${ROOT})
set(romfs_src_dir ${PX4_SOURCE_DIR}/${ROOT}) set(romfs_src_dir ${PX4_SOURCE_DIR}/${ROOT})
set(romfs_autostart ${PX4_SOURCE_DIR}/Tools/px_process_airframes.py) set(romfs_autostart ${PX4_SOURCE_DIR}/Tools/px_process_airframes.py)
@ -422,20 +503,27 @@ function(px4_os_add_flags)
LINK_DIRS ${LINK_DIRS} LINK_DIRS ${LINK_DIRS}
DEFINITIONS ${DEFINITIONS}) DEFINITIONS ${DEFINITIONS})
set(nuttx_export_dir ${PX4_BINARY_DIR}/${BOARD}/NuttX/nuttx-export) set(nuttx_export_root ${PX4_BINARY_DIR}/${BOARD}/NuttX)
set(nuttx_export_dir ${nuttx_export_root}/nuttx/nuttx-export)
set(added_include_dirs set(added_include_dirs
${nuttx_export_dir}/include ${nuttx_export_dir}/include
${nuttx_export_dir}/include/cxx ${nuttx_export_dir}/include/cxx
${nuttx_export_dir}/arch/chip ${nuttx_export_dir}/arch/chip
${nuttx_export_dir}/arch/common ${nuttx_export_dir}/arch/common
${nuttx_export_dir}/arch/armv7-m
${nuttx_export_root}/apps/include
) )
set(added_link_dirs set(added_link_dirs
${nuttx_export_dir}/libs ${nuttx_export_dir}/libs
) )
set(added_definitions set(added_definitions
-D__PX4_NUTTX -D__PX4_NUTTX
-D__DF_NUTTX # Define for DriverFramework
) )
if(NOT "${config_nuttx_config}" STREQUAL "bootloader")
list(APPEND added_definitions -D__DF_NUTTX)
endif()
set(added_c_flags set(added_c_flags
-nodefaultlibs -nodefaultlibs
-nostdlib -nostdlib
@ -458,27 +546,27 @@ function(px4_os_add_flags)
endif() endif()
set(cpu_flags) set(cpu_flags)
# Handle non-F4 boards specifically here if (${config_nuttx_hw} STREQUAL "m7")
if (${BOARD} STREQUAL "px4io-v1")
set(cpu_flags set(cpu_flags
-mcpu=cortex-m3 -mcpu=cortex-m7
-mthumb -mthumb
-march=armv7-m -mfpu=fpv5-sp-d16
-mfloat-abi=hard
) )
elseif (${BOARD} STREQUAL "px4io-v2") elseif (${config_nuttx_hw} STREQUAL "m4")
set(cpu_flags set(cpu_flags
-mcpu=cortex-m3
-mthumb
-march=armv7-m
)
else ()
set(cpu_flags
-mcpu=cortex-m4 -mcpu=cortex-m4
-mthumb -mthumb
-march=armv7e-m -march=armv7e-m
-mfpu=fpv4-sp-d16 -mfpu=fpv4-sp-d16
-mfloat-abi=hard -mfloat-abi=hard
) )
elseif (${config_nuttx_hw} STREQUAL "m3")
set(cpu_flags
-mcpu=cortex-m3
-mthumb
-march=armv7-m
)
endif() endif()
list(APPEND c_flags ${cpu_flags}) list(APPEND c_flags ${cpu_flags})
list(APPEND cxx_flags ${cpu_flags}) list(APPEND cxx_flags ${cpu_flags})
@ -527,4 +615,51 @@ function(px4_os_prebuild_targets)
add_custom_target(${OUT} DEPENDS nuttx_export_${BOARD}) add_custom_target(${OUT} DEPENDS nuttx_export_${BOARD})
endfunction() endfunction()
#=============================================================================
#
# px4_nuttx_configure
#
# This function sets the nuttx configuration
#
# Usage:
# px4_nuttx_configure(
# HWCLASS <m3|m4>
# CONFIG <nsh|bootloader
# [ROMFS <y|n>
# ROMFSROOT <root>]
# )
#
# Input:
# HWCLASS : the class of hardware
# CONFIG : the nuttx condufiguration to use
# ROMFS : whether or not to use incllude theROMFS
# ROMFSROOT : If ROMFS used set the root the default is px4fmu_common
#
# Output:
# OUT : None
#
# Example:
# px4_nuttx_configure(HWCLASS m4 CONFIG nsh ROMFS y)
#
function(px4_nuttx_configure)
px4_parse_function_args(
NAME px4_nuttx_configure
ONE_VALUE HWCLASS CONFIG ROMFS ROMFSROOT
REQUIRED HWCLASS CONFIG
ARGN ${ARGN})
set(config_nuttx_config ${CONFIG} PARENT_SCOPE)
set(config_nuttx_hw ${HWCLASS} PARENT_SCOPE)
if ("${ROMFS}" STREQUAL "y")
set(romfs_used ${ROMFS} PARENT_SCOPE)
if (NOT DEFINED ROMFSROOT)
set(config_romfs_root px4fmu_common)
else()
set(config_romfs_root ${ROMFSROOT})
endif()
set(HASROMFS "with ROMFS on ${config_romfs_root}")
set(config_romfs_root ${config_romfs_root} PARENT_SCOPE)
endif()
message(STATUS "Nuttx build for ${BOARD} on ${HWCLASS} hardware, using ${CONFIG} ${HASROMFS}")
endfunction()
# vim: set noet fenc=utf-8 ff=unix nowrap: # vim: set noet fenc=utf-8 ff=unix nowrap:

View File

@ -189,6 +189,8 @@ function(px4_os_add_flags)
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
set(DF_TARGET "qurt" PARENT_SCOPE)
# output # output
foreach(var ${inout_vars}) foreach(var ${inout_vars})
string(TOLOWER ${var} lower_var) string(TOLOWER ${var} lower_var)

View File

@ -0,0 +1,45 @@
############################################################################
# nuttx-configs/PX4_Config.mk
#
# Copyright (c) 2016 PX4 Development Team. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name PX4 nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
# Nuttx GNU builds now use GNU_EABI<L|W> to set the toolchaine
# PX4 uses the host OS to decide if it is Linux, Darwin or Windows
ifeq ($(OS),Windows_NT)
OS_DETECTED := Windows
HOST_OS_FIRST_LETTER:= W
else
OS_DETECTED := $(shell uname -s)
# Clump Dawin and Linux as L to set GNU_EABI<L|W>
HOST_OS_FIRST_LETTER := L
endif

View File

@ -1,5 +1,5 @@
############################################################################ ############################################################################
# configs/PX4_Warnings.mk # nuttx-configs/PX4_Warnings.mk
# #
# Copyright (C) 2011 Gregory Nutt. All rights reserved. # Copyright (C) 2011 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org> # Author: Gregory Nutt <gnutt@nuttx.org>

View File

@ -10,16 +10,49 @@ add_executable(firmware_nuttx
builtin_commands.c) builtin_commands.c)
set(nuttx_export_dir ${PX4_BINARY_DIR}/${BOARD}/NuttX/nuttx-export) set(nuttx_export_dir ${PX4_BINARY_DIR}/${BOARD}/NuttX/nuttx/nuttx-export)
set(link_libs set(link_libs
romfs apps nuttx m gcc apps nuttx m gcc
) )
if("${romfs_used}" STREQUAL "y")
list(APPEND link_libs romfs)
endif()
#
# Bootloaders use a different ld file, a seperate startup file
# and need to override the os version of sched_process_timer
#
set(startup_libs)
if("${config_nuttx_config}" STREQUAL "bootloader")
set(nuttx_ld_prefix "bootloader")
set(nuttx_startup_files ${nuttx_export_dir}/startup/${nuttx_startup_files})
set(nuttx_bootloader_wrapers "-Wl,-wrap,sched_process_timer")
add_custom_command(OUTPUT
${nuttx_startup_files}
DEPENDS nuttx_export_${BOARD})
set_source_files_properties(
${nuttx_startup_files}
PROPERTIES
EXTERNAL_OBJECT true
GENERATED true)
add_library(startup
${nuttx_startup_files})
set_target_properties(startup
PROPERTIES
LINKER_LANGUAGE C)
list(APPEND startup_libs startup)
endif()
if(NOT ${BOARD} STREQUAL "sim") if(NOT ${BOARD} STREQUAL "sim")
list(APPEND link_libs nosys)
set(main_link_flags set(main_link_flags
"-T${nuttx_export_dir}/build/ld.script" "-T${nuttx_export_dir}/build/${nuttx_ld_prefix}ld.script"
"-Wl,-Map=${PX4_BINARY_DIR}/${BOARD}/main.map" "-Wl,-Map=${PX4_BINARY_DIR}/${BOARD}/main.map"
) )
px4_join(OUT main_link_flags LIST ${main_link_flags} GLUE " ") px4_join(OUT main_link_flags LIST ${main_link_flags} GLUE " ")
@ -27,10 +60,14 @@ if(NOT ${BOARD} STREQUAL "sim")
endif() endif()
target_link_libraries(firmware_nuttx target_link_libraries(firmware_nuttx
-Wl,--warn-common
-Wl,--gc-sections
-Wl,--start-group -Wl,--start-group
${startup_libs}
${module_libraries} ${module_libraries}
${df_driver_libs} ${df_driver_libs}
${config_extra_libs} ${config_extra_libs}
${nuttx_bootloader_wrapers}
${link_libs} ${link_libs}
-Wl,--end-group) -Wl,--end-group)
@ -42,35 +79,36 @@ add_custom_target(check_weak
if(NOT ${BOARD} STREQUAL "sim") if(NOT ${BOARD} STREQUAL "sim")
if (config_io_board) if ("${romfs_used}" STREQUAL "y")
set(extras "${PX4_BINARY_DIR}/src/modules/px4iofirmware/${config_io_board}.bin")
if (config_io_board)
set(extras "${CMAKE_BINARY_DIR}/src/modules/px4iofirmware/${config_io_board}.bin")
endif()
message(STATUS "Adding ROMFS on ${BOARD}")
px4_nuttx_add_romfs(OUT romfs
ROOT ROMFS/${config_romfs_root}
EXTRAS ${extras}
)
if (config_io_board)
add_dependencies(romfs fw_io)
endif()
endif() endif()
set(romfs_dir "ROMFS/px4fmu_common") set(fw_file
if (${BOARD} STREQUAL "tap-v1") ${CMAKE_CURRENT_BINARY_DIR}/${OS}-${BOARD}-${LABEL}.px4)
set(romfs_dir "ROMFS/tap_common")
#
# Bootloaders do not need .px4 or xml
#
if(NOT "${config_nuttx_config}" STREQUAL "bootloader")
px4_nuttx_add_firmware(OUT ${fw_file}
BOARD ${BOARD}
EXE ${CMAKE_CURRENT_BINARY_DIR}/firmware_nuttx
PARAM_XML ${PX4_BINARY_DIR}/parameters.xml
AIRFRAMES_XML ${PX4_BINARY_DIR}/airframes.xml
)
endif() endif()
if (${BOARD} STREQUAL "px4fmu-v2" AND ${LABEL} STREQUAL "test")
set(romfs_dir "ROMFS/px4fmu_test")
endif()
px4_nuttx_add_romfs(OUT romfs
ROOT ${romfs_dir}
EXTRAS ${extras}
)
if (config_io_board)
add_dependencies(romfs fw_io)
endif()
set(fw_file ${CMAKE_CURRENT_BINARY_DIR}/${OS}-${BOARD}-${LABEL}.px4)
px4_nuttx_add_firmware(OUT ${fw_file}
BOARD ${BOARD}
EXE ${CMAKE_CURRENT_BINARY_DIR}/firmware_nuttx
PARAM_XML ${PX4_BINARY_DIR}/parameters.xml
AIRFRAMES_XML ${PX4_BINARY_DIR}/airframes.xml
)
configure_file(gdbinit.in .gdbinit) configure_file(gdbinit.in .gdbinit)
@ -113,15 +151,19 @@ if(NOT ${BOARD} STREQUAL "sim")
${CMAKE_CURRENT_BINARY_DIR}/.gdbinit ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit
) )
if ("${BOARD}" STREQUAL "aerofc-v1") if(NOT "${config_nuttx_config}" STREQUAL "bootloader")
px4_add_upload_aero(OUT upload OS ${OS} BOARD ${BOARD} if ("${BOARD}" STREQUAL "aerofc-v1")
BUNDLE ${fw_file}) px4_add_upload_aero(OUT upload OS ${OS} BOARD ${BOARD}
else() BUNDLE ${fw_file})
px4_add_upload(OUT upload OS ${OS} BOARD ${BOARD} else()
BUNDLE ${fw_file}) px4_add_upload(OUT upload OS ${OS} BOARD ${BOARD}
BUNDLE ${fw_file})
endif()
endif() endif()
endif() endif()
install(FILES ${fw_file} DESTINATION .) if(NOT "${config_nuttx_config}" STREQUAL "bootloader")
install(FILES ${fw_file} DESTINATION .)
endif()
# vim: set noet ft=cmake fenc=utf-8 ff=unix : # vim: set noet ft=cmake fenc=utf-8 ff=unix :

View File

@ -45,6 +45,8 @@ set(include_dirs)
set(link_dirs) set(link_dirs)
set(definitions) set(definitions)
px4_nuttx_configure(HWCLASS m3 CONFIG nsh)
px4_os_prebuild_targets(OUT io_prebuild_targets px4_os_prebuild_targets(OUT io_prebuild_targets
BOARD ${config_io_board} BOARD ${config_io_board}
THREADS ${THREADS}) THREADS ${THREADS})
@ -120,7 +122,7 @@ add_dependencies(${fw_io_name}
mixer_gen mixer_gen
) )
set(nuttx_export_dir ${PX4_BINARY_DIR}/${config_io_board}/NuttX/nuttx-export) set(nuttx_export_dir ${PX4_BINARY_DIR}/${config_io_board}/NuttX/nuttx/nuttx-export)
set(main_link_flags set(main_link_flags
"-T${nuttx_export_dir}/build/ld.script" "-T${nuttx_export_dir}/build/ld.script"
"-Wl,-Map=${PX4_BINARY_DIR}/${config_io_board}/main.map" "-Wl,-Map=${PX4_BINARY_DIR}/${config_io_board}/main.map"