diff --git a/cmake/nuttx/px4_impl_nuttx.cmake b/cmake/nuttx/px4_impl_nuttx.cmake index 061e567d33..79b829881e 100644 --- a/cmake/nuttx/px4_impl_nuttx.cmake +++ b/cmake/nuttx/px4_impl_nuttx.cmake @@ -202,6 +202,16 @@ function(px4_nuttx_add_export) add_dependencies(nuttx_patch nuttx_patch_${patch_name}) endforeach() + # Read defconfig to see if CONFIG_ARMV7M_STACKCHECK is yes + # note: CONFIG will be BOARD in the future evaluation of ${hw_stack_check_${CONFIG} + file(STRINGS "${CMAKE_SOURCE_DIR}/nuttx-configs/${CONFIG}/${config_nuttx_config}/defconfig" + hw_stack_check_${CONFIG} + REGEX "CONFIG_ARMV7M_STACKCHECK=y" + ) + if ("${hw_stack_check_${CONFIG}}" STREQUAL "CONFIG_ARMV7M_STACKCHECK=y") + set(config_nuttx_hw_stack_check_${CONFIG} y CACHE INTERNAL "" FORCE) + endif() + # copy and export file(GLOB_RECURSE config_files ${CMAKE_SOURCE_DIR}/nuttx-configs/${CONFIG}/*) add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${CONFIG}.export @@ -428,6 +438,16 @@ function(px4_os_add_flags) set(added_exe_linker_flags) # none currently + set(instrument_flags) + if ("${config_nuttx_hw_stack_check_${BOARD}}" STREQUAL "y") + set(instrument_flags + -finstrument-functions + -ffixed-r10 + ) + list(APPEND c_flags ${instrument_flags}) + list(APPEND cxx_flags ${instrument_flags}) + endif() + set(cpu_flags) if (${BOARD} STREQUAL "px4fmu-v1") set(cpu_flags