Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NuttX cmake bug fixes and improvements #13490

Merged
merged 1 commit into from
Nov 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ endif()
# external modules
set(EXTERNAL_MODULES_LOCATION "" CACHE STRING "External modules source location")

if (NOT EXTERNAL_MODULES_LOCATION STREQUAL "")
if(NOT EXTERNAL_MODULES_LOCATION STREQUAL "")
get_filename_component(EXTERNAL_MODULES_LOCATION "${EXTERNAL_MODULES_LOCATION}" ABSOLUTE)
endif()

Expand All @@ -170,8 +170,8 @@ if(EXISTS "${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/cmake/init.cmake")
endif()

# CMake build type (Debug Release RelWithDebInfo MinSizeRel Coverage)
if (NOT CMAKE_BUILD_TYPE)
if (${PX4_PLATFORM} STREQUAL "nuttx")
if(NOT CMAKE_BUILD_TYPE)
if(${PX4_PLATFORM} STREQUAL "nuttx")
set(PX4_BUILD_TYPE "MinSizeRel")
else()
set(PX4_BUILD_TYPE "RelWithDebInfo")
Expand Down Expand Up @@ -228,8 +228,7 @@ endif()
#=============================================================================

# Setup install paths
if (${PX4_PLATFORM} STREQUAL "posix")

if(${PX4_PLATFORM} STREQUAL "posix")
# This makes it possible to dynamically load code which depends on symbols
# inside the px4 executable.
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Expand Down Expand Up @@ -422,7 +421,7 @@ endforeach()

add_custom_command(OUTPUT ${uorb_graph_config}
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/uorb_graph/create.py
${module_list}
${graph_module_list}
--exclude-path src/examples
--file ${PX4_SOURCE_DIR}/Tools/uorb_graph/graph_${uorb_graph_config}
WORKING_DIRECTORY ${PX4_SOURCE_DIR}
Expand Down
7 changes: 4 additions & 3 deletions cmake/ccache.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,18 @@

option(CCACHE "Use ccache if available" ON)
find_program(CCACHE_PROGRAM ccache)
if (CCACHE AND CCACHE_PROGRAM AND NOT DEFINED ENV{CCACHE_DISABLE})

if(CCACHE AND CCACHE_PROGRAM AND NOT DEFINED ENV{CCACHE_DISABLE})
get_filename_component(ccache_real_path ${CCACHE_PROGRAM} REALPATH)
get_filename_component(cxx_real_path ${CMAKE_CXX_COMPILER} REALPATH)
get_filename_component(cxx_abs_path ${CMAKE_CXX_COMPILER} ABSOLUTE)

if ("${ccache_real_path}" STREQUAL "${cxx_real_path}")
message(STATUS "ccache enabled via symlink (${cxx_abs_path} -> ${cxx_real_path})")
set(CCACHE_PROGRAM "" CACHE INTERNAL "ccache program" FORCE)
else()
message(STATUS "ccache enabled (export CCACHE_DISABLE=1 to disable)")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif()

else()
set(CCACHE_PROGRAM "" CACHE INTERNAL "ccache program" FORCE)
endif()
3 changes: 2 additions & 1 deletion platforms/nuttx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ get_property(module_libraries GLOBAL PROPERTY PX4_MODULE_LIBRARIES)
add_subdirectory(NuttX ${PX4_BINARY_DIR}/NuttX)

set(nuttx_libs)
set(SCRIPT_PREFIX)
if("${PX4_BOARD_LABEL}" STREQUAL "bootloader")
set(SCRIPT_PREFIX ${PX4_BOARD_LABEL}_)
add_subdirectory(src/bootloader)
Expand Down Expand Up @@ -230,7 +231,7 @@ if(NOT PX4_BUILD MATCHES "px4_io-v2")
endif()

add_custom_target(debug
COMMAND ${GDB} -iex 'set auto-load safe-path ${PX4_BINARY_DIR}' $<TARGET_FILE:px4>
COMMAND ${CMAKE_GDB} -iex 'set auto-load safe-path ${PX4_BINARY_DIR}' $<TARGET_FILE:px4>
DEPENDS px4 ${PX4_BINARY_DIR}/.gdbinit
WORKING_DIRECTORY ${PX4_BINARY_DIR}
USES_TERMINAL
Expand Down
22 changes: 9 additions & 13 deletions platforms/nuttx/NuttX/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,33 +147,30 @@ add_custom_command(
add_custom_target(nuttx_copy_config_dir_target DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/nuttx_copy_config_dir.stamp)


# NuttX defconfig
# cmake should trigger reconfigure if defconfig changes
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${NUTTX_DEFCONFIG})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Make.defs.in ${NUTTX_DIR}/Make.defs)

# copy compressed PX4 defconfig into nuttx and inflate
add_custom_command(
OUTPUT
${NUTTX_DIR}/.config
${CMAKE_CURRENT_BINARY_DIR}/nuttx_olddefconfig.stamp
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${NUTTX_DEFCONFIG} ${NUTTX_DIR}/.config
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/px4_nuttx_make_olddefconfig.sh ${NUTTX_DIR}
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/px4_nuttx_make_olddefconfig.sh > nuttx_olddefconfig.log
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/nuttx_olddefconfig.stamp
DEPENDS
${NUTTX_DIR}/Make.defs
${NUTTX_DEFCONFIG}
nuttx_copy_config_dir_target ${CMAKE_CURRENT_BINARY_DIR}/nuttx_copy_config_dir.stamp
${CMAKE_CURRENT_SOURCE_DIR}/tools/px4_nuttx_make_olddefconfig.sh
WORKING_DIRECTORY ${NUTTX_DIR}
COMMENT "Copying NuttX compressed config ${NUTTX_CONFIG} and inflating"
COMMENT "Copying NuttX compressed config ${NUTTX_CONFIG} and inflating (make olddefconfig)"
)
add_custom_target(nuttx_config_target DEPENDS ${NUTTX_DIR}/.config ${CMAKE_CURRENT_BINARY_DIR}/nuttx_olddefconfig.stamp)

###############################################################################
# NuttX build
###############################################################################

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Make.defs.in ${NUTTX_DIR}/Make.defs)

# verbose build settings (V=1 or VERBOSE=1)
option(PX4_NUTTX_VERBOSE "PX4 NuttX verbose build" off)

Expand All @@ -184,11 +181,9 @@ endif()

if(PX4_NUTTX_VERBOSE)
set(nuttx_build_options)
set(nuttx_build_output)
set(nuttx_build_uses_terminal "USES_TERMINAL")
else()
set(nuttx_build_options "--quiet")
set(nuttx_build_output ">nuttx_build.log")
set(nuttx_build_uses_terminal)
endif()

Expand All @@ -198,8 +193,9 @@ add_custom_command(
${NUTTX_DIR}/include/nuttx/config.h
${NUTTX_DIR}/include/nuttx/version.h
COMMAND
make ${nuttx_build_options} --no-print-directory CONFIG_ARCH_BOARD_CUSTOM=y context > nuttx_context.log
make ${nuttx_build_options} --no-print-directory CONFIG_ARCH_BOARD_CUSTOM=y pass1dep > nuttx_context.log
DEPENDS
${NUTTX_DIR}/Make.defs
nuttx_config_target ${NUTTX_DIR}/.config ${CMAKE_CURRENT_BINARY_DIR}/nuttx_olddefconfig.stamp
WORKING_DIRECTORY ${NUTTX_DIR}
${nuttx_build_uses_terminal}
Expand Down Expand Up @@ -264,11 +260,11 @@ add_custom_target(nuttx_builtin_list_target DEPENDS ${nuttx_builtin_list})
# libapps.a
add_custom_command(OUTPUT ${APPS_DIR}/libapps.a ${APPS_DIR}/platform/.built
COMMAND find ${APPS_DIR} -name \*.o -delete
COMMAND make ${nuttx_build_options} --no-print-directory TOPDIR="${NUTTX_DIR}" ../apps/libapps.a > nuttx_apps.log
COMMAND make ${nuttx_build_options} --no-print-directory TOPDIR="${NUTTX_DIR}"
DEPENDS
nuttx_builtin_list_target ${nuttx_builtin_list}
nuttx_context ${NUTTX_DIR}/include/nuttx/config.h ${NUTTX_DIR}/include/nuttx/version.h
WORKING_DIRECTORY ${NUTTX_DIR}
WORKING_DIRECTORY ${APPS_DIR}
${nuttx_build_uses_terminal}
)
add_custom_target(nuttx_apps_build DEPENDS ${APPS_DIR}/libapps.a)
Expand All @@ -285,7 +281,7 @@ function(add_nuttx_dir nuttx_lib nuttx_lib_dir kernel extra)

add_custom_command(OUTPUT ${NUTTX_DIR}/${nuttx_lib_dir}/lib${nuttx_lib}.a
COMMAND find ${nuttx_lib_dir} -type f -name *.o -delete
COMMAND make -C ${nuttx_lib_dir} ${nuttx_build_options} --no-print-directory all TOPDIR=${NUTTX_DIR} KERNEL=${kernel} EXTRADEFINES=${extra} ${nuttx_build_output}
COMMAND make -C ${nuttx_lib_dir} ${nuttx_build_options} --no-print-directory all TOPDIR=${NUTTX_DIR} KERNEL=${kernel} EXTRADEFINES=${extra}
DEPENDS
${nuttx_lib_files}
nuttx_context ${NUTTX_DIR}/include/nuttx/config.h ${NUTTX_DIR}/include/nuttx/version.h
Expand Down
24 changes: 24 additions & 0 deletions platforms/nuttx/NuttX/Make.defs.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ CC = ${CMAKE_C_COMPILER}
CXX = ${CMAKE_CXX_COMPILER}
CPP = ${CMAKE_C_COMPILER} -E
LD = ${CMAKE_LD}
STRIP = ${CMAKE_STRIP} --strip-unneeded
AR = ${CMAKE_AR} rcs
NM = ${CMAKE_NM}
OBJCOPY = ${CMAKE_OBJCOPY}
Expand All @@ -51,6 +52,7 @@ ifneq (, $(findstring CYGWIN, $(shell uname)))
ARCHINCLUDES = -I. -isystem "$(shell cygpath -w $(TOPDIR)/include)"
ARCHXXINCLUDES = $(ARCHINCLUDES) -isystem "$(shell cygpath -w $(TOPDIR)/include/cxx)"
else
MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT)
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
ARCHXXINCLUDES = $(ARCHINCLUDES) -isystem $(TOPDIR)/include/cxx
endif
Expand Down Expand Up @@ -119,4 +121,26 @@ CXXFLAGS = $(ARCHXXINCLUDES) \
-Wno-double-promotion \
-Wno-missing-declarations

CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
AFLAGS = $(CFLAGS) -D__ASSEMBLY__

ASMEXT = .S
OBJEXT = .o
LIBEXT = .a
EXEEXT =

define COMPILE
$(Q) ${CCACHE_PROGRAM} $(CC) -c $(CFLAGS) $($(strip $1)_CFLAGS) $1 -o $2
endef

define COMPILEXX
$(Q) ${CCACHE_PROGRAM} $(CXX) -c $(CXXFLAGS) $($(strip $1)_CXXFLAGS) $1 -o $2
endef

define ASSEMBLE
$(Q) ${CCACHE_PROGRAM} $(CC) -c $(AFLAGS) $1 $($(strip $1)_AFLAGS) -o $2
endef

define ARCHIVE
$(Q) $(AR) $1 $(2)
endef
4 changes: 1 addition & 3 deletions platforms/nuttx/NuttX/tools/px4_nuttx_make_olddefconfig.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#! /bin/bash

NUTTX_DIR=${1}

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

# update PATH to include kconfiglib scripts
export PATH=${DIR}:${PATH}

make --no-print-directory --silent -C ${NUTTX_DIR} CONFIG_ARCH_BOARD_CUSTOM=y CONFIG_APPS_DIR="../apps" olddefconfig > nuttx_olddefconfig.log
make --no-print-directory --silent CONFIG_ARCH_BOARD_CUSTOM=y CONFIG_APPS_DIR="../apps" olddefconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

if (CONFIG_ARCH_DPFPU)
if(CONFIG_ARCH_DPFPU)
message(STATUS "Enabling double FP precision hardware instructions")
set(mfpu_type "fpv5-d16")
else()
Expand Down
24 changes: 10 additions & 14 deletions platforms/nuttx/cmake/Toolchain-arm-none-eabi.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
set(CMAKE_CXX_COMPILER_TARGET ${triple})

set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
set(CMAKE_ASM_COMPILER ${TOOLCHAIN_PREFIX}-gcc)

# needed for test compilation
set(CMAKE_EXE_LINKER_FLAGS_INIT "--specs=nosys.specs")

# compiler tools
foreach(tool nm ld objcopy ranlib strip)
string(TOUPPER ${tool} TOOL)
find_program(CMAKE_${TOOL} ${TOOLCHAIN_PREFIX}-${tool})
if(CMAKE-${TOOL} MATCHES "NOTFOUND")
message(FATAL_ERROR "could not find ${TOOLCHAIN_PREFIX}-${tool}")
endif()
endforeach()
find_program(CMAKE_AR ${TOOLCHAIN_PREFIX}-gcc-ar)
find_program(CMAKE_GDB ${TOOLCHAIN_PREFIX}-gdb)
find_program(CMAKE_LD ${TOOLCHAIN_PREFIX}-ld)
find_program(CMAKE_LINKER ${TOOLCHAIN_PREFIX}-ld)
find_program(CMAKE_NM ${TOOLCHAIN_PREFIX}-gcc-nm)
find_program(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}-objcopy)
find_program(CMAKE_OBJDUMP ${TOOLCHAIN_PREFIX}-objdump)
find_program(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}-gcc-ranlib)
find_program(CMAKE_STRIP ${TOOLCHAIN_PREFIX}-strip)

set(CMAKE_FIND_ROOT_PATH get_file_component(${CMAKE_C_COMPILER} PATH))
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
Expand All @@ -40,9 +42,3 @@ foreach(tool grep make)
message(FATAL_ERROR "could not find ${tool}")
endif()
endforeach()

# optional compiler tools
foreach(tool gdb gdbtui)
string(TOUPPER ${tool} TOOL)
find_program(${TOOL} arm-none-eabi-${tool})
endforeach()
4 changes: 2 additions & 2 deletions platforms/nuttx/cmake/blackmagic.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ file(GLOB_RECURSE black_magic_probe_console_path
if(black_magic_probe_path)

add_custom_target(blackmagic_debug
COMMAND ${GDB} --nh
COMMAND ${CMAKE_GDB} --nh
-iex 'set auto-load safe-path ${PX4_BINARY_DIR}'
-ex 'target extended-remote ${black_magic_probe_path}'
-ex 'monitor version'
Expand All @@ -59,7 +59,7 @@ if(black_magic_probe_path)
)

add_custom_target(blackmagic_upload
COMMAND ${GDB} --nx --batch
COMMAND ${CMAKE_GDB} --nx --batch
-ex 'target extended-remote ${black_magic_probe_path}'
-ex 'monitor version'
-ex 'monitor connect_srst enable'
Expand Down
40 changes: 19 additions & 21 deletions platforms/nuttx/cmake/init.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ endif()

set(NUTTX_CONFIG_DIR ${PX4_BOARD_DIR}/nuttx-config CACHE FILEPATH "PX4 NuttX config" FORCE)

# NuttX defconfig
# cmake should trigger reconfigure if defconfig changes
set(NUTTX_DEFCONFIG ${NUTTX_CONFIG_DIR}/${NUTTX_CONFIG}/defconfig CACHE FILEPATH "path to defconfig" FORCE)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${NUTTX_DEFCONFIG})

set(NUTTX_SRC_DIR ${CMAKE_CURRENT_LIST_DIR}/../NuttX)
set(NUTTX_DIR ${PX4_BINARY_DIR}/NuttX/nuttx CACHE FILEPATH "NuttX directory" FORCE)
set(NUTTX_APPS_DIR ${PX4_BINARY_DIR}/NuttX/apps CACHE FILEPATH "NuttX apps directory" FORCE)
Expand All @@ -67,27 +72,24 @@ else()
set(NUTTX_COPY_CMD_OPTS "-aRfl")
endif()

execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${PX4_BINARY_DIR}/NuttX)

###############################################################################
# NuttX: copy to build directory
###############################################################################
file(RELATIVE_PATH CP_SRC ${CMAKE_SOURCE_DIR} ${NUTTX_SRC_DIR}/nuttx)
file(RELATIVE_PATH CP_DST ${CMAKE_SOURCE_DIR} ${PX4_BINARY_DIR}/NuttX)

# copy nuttx during cmake configure
if(NOT EXISTS ${NUTTX_DIR}/nuttx_copy.stamp)
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${NUTTX_DIR})
if(NOT EXISTS ${PX4_BINARY_DIR}/NuttX/nuttx_copy.stamp)
file(RELATIVE_PATH CP_SRC ${CMAKE_SOURCE_DIR} ${NUTTX_SRC_DIR}/nuttx)
file(RELATIVE_PATH CP_DST ${CMAKE_SOURCE_DIR} ${PX4_BINARY_DIR}/NuttX)
execute_process(COMMAND ${NUTTX_COPY_CMD} ${NUTTX_COPY_CMD_OPTS} ${CP_SRC} ${CP_DST} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${PX4_BINARY_DIR}/NuttX/nuttx_copy.stamp)
endif()

###############################################################################
# NuttX apps: copy to build directory
###############################################################################
file(RELATIVE_PATH CP_SRC ${CMAKE_SOURCE_DIR} ${NUTTX_SRC_DIR}/apps)
file(RELATIVE_PATH CP_DST ${CMAKE_SOURCE_DIR} ${PX4_BINARY_DIR}/NuttX)

# copy apps during cmake configure
if(NOT EXISTS ${NUTTX_DIR}/apps_copy.stamp)
if(NOT EXISTS ${PX4_BINARY_DIR}/NuttX/apps_copy.stamp)
file(RELATIVE_PATH CP_SRC ${CMAKE_SOURCE_DIR} ${NUTTX_SRC_DIR}/apps)
file(RELATIVE_PATH CP_DST ${CMAKE_SOURCE_DIR} ${PX4_BINARY_DIR}/NuttX)
execute_process(COMMAND ${NUTTX_COPY_CMD} ${NUTTX_COPY_CMD_OPTS} ${CP_SRC} ${CP_DST} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${PX4_BINARY_DIR}/NuttX/apps_copy.stamp)
endif()
Expand All @@ -97,7 +99,7 @@ endif()
###############################################################################

# If the board provides a Kconfig Use it or create an empty one
if(NOT EXISTS ${NUTTX_DIR}/nuttx_config_kconfig.stamp)
if(NOT EXISTS ${PX4_BINARY_DIR}/NuttX/nuttx_config_kconfig.stamp)
if(EXISTS ${NUTTX_CONFIG_DIR}/Kconfig)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${NUTTX_CONFIG_DIR}/Kconfig ${NUTTX_DIR}/boards/dummy/Kconfig)
else()
Expand All @@ -107,8 +109,7 @@ if(NOT EXISTS ${NUTTX_DIR}/nuttx_config_kconfig.stamp)
execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${PX4_BINARY_DIR}/NuttX/nuttx_config_kconfig.stamp)
endif()

if(NOT EXISTS ${NUTTX_DIR}/nuttx_copy_config_dir.stamp)

if(NOT EXISTS ${PX4_BINARY_DIR}/NuttX/nuttx_copy_config_dir.stamp)
# copy board's nuttx-config to NuttX/nuttx-config
file(RELATIVE_PATH CP_SRC ${CMAKE_SOURCE_DIR} ${PX4_BOARD_DIR}/nuttx-config)
file(RELATIVE_PATH CP_DST ${CMAKE_SOURCE_DIR} ${PX4_BINARY_DIR}/NuttX)
Expand All @@ -120,17 +121,14 @@ if(NOT EXISTS ${NUTTX_DIR}/nuttx_copy_config_dir.stamp)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${NUTTX_SRC_DIR}/nsh_romfsimg.h ${PX4_BINARY_DIR}/NuttX/nuttx-config/include/nsh_romfsimg.h)

execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${PX4_BINARY_DIR}/NuttX/nuttx_copy_config_dir.stamp)

endif()

# make olddefconfig (inflate defconfig to full .config)
if(NOT EXISTS ${NUTTX_DIR}/.config)
set(NUTTX_DEFCONFIG ${NUTTX_CONFIG_DIR}/${NUTTX_CONFIG}/defconfig CACHE FILEPATH "path to defconfig" FORCE)
configure_file(${NUTTX_SRC_DIR}/Make.defs.in ${NUTTX_DIR}/Make.defs) # Create a temporary Toplevel Make.defs for the oldconfig step
if(NOT EXISTS ${PX4_BINARY_DIR}/NuttX/nuttx_olddefconfig.stamp)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${NUTTX_SRC_DIR}/Make.defs.in ${NUTTX_DIR}/Make.defs) # Create a temporary Toplevel Make.defs for the oldconfig step
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${NUTTX_DEFCONFIG} ${NUTTX_DIR}/.config)
set(ENV{PATH} "${PX4_SOURCE_DIR}/platforms/nuttx/NuttX/tools:$ENV{PATH}")
execute_process(
COMMAND make --no-print-directory --silent -C ${NUTTX_DIR} CONFIG_ARCH_BOARD_CUSTOM=y olddefconfig
COMMAND ${NUTTX_SRC_DIR}/tools/px4_nuttx_make_olddefconfig.sh
WORKING_DIRECTORY ${NUTTX_DIR}
OUTPUT_FILE nuttx_olddefconfig.log
ERROR_FILE nuttx_olddefconfig.log
Expand All @@ -146,7 +144,7 @@ if(NOT EXISTS ${NUTTX_DIR}/.config)
execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${PX4_BINARY_DIR}/NuttX/nuttx_olddefconfig.stamp)
endif()
# remove Toplevel Make.defs
file(REMOVE ${NUTTX_DIR}/Make.defs)
execute_process(COMMAND ${CMAKE_COMMAND} -E remove -f ${NUTTX_DIR}/Make.defs)
endif()

###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion platforms/nuttx/cmake/jlink.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ add_custom_target(jlink_upload

add_custom_target(jlink_debug
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/Debug/jlink_gdb_start.sh
COMMAND ${GDB} -nh
COMMAND ${CMAKE_GDB} -nh
-iex 'set auto-load safe-path ${PX4_BINARY_DIR}'
-ex 'target remote localhost:2331'
-ex 'monitor reset 0'
Expand Down