From edf13ff1a118d6159a0acdbb1f355b355a7d2165 Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Thu, 10 Oct 2024 01:54:19 -0700 Subject: [PATCH] Fix a few CMake issues after the recent changes (#371) --- tools/cmake/mbed_ide_debug_cfg_generator.cmake | 6 +++--- tools/cmake/mbed_target_functions.cmake | 11 ++++++++--- tools/cmake/upload_methods/UploadMethodJLINK.cmake | 2 +- .../cmake/upload_methods/UploadMethodLINKSERVER.cmake | 2 +- tools/cmake/upload_methods/UploadMethodOPENOCD.cmake | 2 +- tools/cmake/upload_methods/UploadMethodPYOCD.cmake | 2 +- tools/cmake/upload_methods/UploadMethodSTLINK.cmake | 2 +- .../cmake/upload_methods/UploadMethodSTM32CUBE.cmake | 2 +- 8 files changed, 17 insertions(+), 12 deletions(-) diff --git a/tools/cmake/mbed_ide_debug_cfg_generator.cmake b/tools/cmake/mbed_ide_debug_cfg_generator.cmake index eb75c28b526..58d489eabe1 100644 --- a/tools/cmake/mbed_ide_debug_cfg_generator.cmake +++ b/tools/cmake/mbed_ide_debug_cfg_generator.cmake @@ -75,7 +75,7 @@ if(MBED_GENERATE_CLION_DEBUG_CFGS) " - + @@ -135,7 +135,7 @@ elseif(MBED_GENERATE_VS_CODE_DEBUG_CFGS) \"gdbPath\": \"${MBED_GDB}\", \"objdumpPath\": \"${MBED_OBJDUMP}\", \"servertype\": \"external\", - \"gdbTarget\": \"127.0.0.1:${GDB_PORT}\", + \"gdbTarget\": \"127.0.0.1:${MBED_GDB_PORT}\", \"request\": \"launch\", \"preLaunchTask\": \"Build ${CMAKE_TARGET} and start GDB server\", // Override the command sequences used by VS Code to be correct for this GDB server @@ -266,7 +266,7 @@ elseif(MBED_UPLOAD_SUPPORTS_DEBUG) file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/mbed-cmake.gdbinit CONTENT "# connect to GDB server -target ${UPLOAD_GDB_REMOTE_KEYWORD} 127.0.0.1:${GDB_PORT} +target ${UPLOAD_GDB_REMOTE_KEYWORD} 127.0.0.1:${MBED_GDB_PORT} ${MBED_UPLOAD_LAUNCH_COMMANDS_FOR_GDBINIT} c" ) diff --git a/tools/cmake/mbed_target_functions.cmake b/tools/cmake/mbed_target_functions.cmake index 6f6f1c8e9c5..01c53782013 100644 --- a/tools/cmake/mbed_target_functions.cmake +++ b/tools/cmake/mbed_target_functions.cmake @@ -50,6 +50,10 @@ function(mbed_generate_map_file target) # Config process saves the JSON file here set(MEMORY_BANKS_JSON_PATH ${CMAKE_BINARY_DIR}/memory_banks.json) + set(MEMORY_BANKS_ARG "") + if(EXISTS ${MEMORY_BANKS_JSON_PATH}) + set(MEMORY_BANKS_ARG --memory-banks-json ${MEMORY_BANKS_JSON_PATH}) + endif() # generate table for screen add_custom_command( @@ -58,7 +62,8 @@ function(mbed_generate_map_file target) POST_BUILD COMMAND ${Python3_EXECUTABLE} -m memap.memap -t ${MBED_TOOLCHAIN} ${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map - --depth ${MBED_MEMAP_DEPTH} --memory-banks-json ${MEMORY_BANKS_JSON_PATH} + --depth ${MBED_MEMAP_DEPTH} + ${MEMORY_BANKS_ARG} WORKING_DIRECTORY ${mbed-os_SOURCE_DIR}/tools/python ) @@ -74,7 +79,7 @@ function(mbed_generate_map_file target) --depth ${MBED_MEMAP_DEPTH} -e json -o ${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.memmap.json - --memory-banks-json ${MEMORY_BANKS_JSON_PATH} + ${MEMORY_BANKS_ARG} WORKING_DIRECTORY ${mbed-os_SOURCE_DIR}/tools/python ) @@ -91,7 +96,7 @@ function(mbed_generate_map_file target) --depth ${MBED_MEMAP_DEPTH} -e html -o ${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.memmap.html - --memory-banks-json ${MEMORY_BANKS_JSON_PATH} + ${MEMORY_BANKS_ARG} WORKING_DIRECTORY ${mbed-os_SOURCE_DIR}/tools/python ) diff --git a/tools/cmake/upload_methods/UploadMethodJLINK.cmake b/tools/cmake/upload_methods/UploadMethodJLINK.cmake index cdfa86ccf68..19b06a21b6b 100644 --- a/tools/cmake/upload_methods/UploadMethodJLINK.cmake +++ b/tools/cmake/upload_methods/UploadMethodJLINK.cmake @@ -90,7 +90,7 @@ set(UPLOAD_GDBSERVER_DEBUG_COMMAND -JTAGConf -1,-1 -LocalhostOnly -noIR - -port ${GDB_PORT} + -port ${MBED_GDB_PORT} -singlerun # Terminate GDB server after GDB disconnects ) diff --git a/tools/cmake/upload_methods/UploadMethodLINKSERVER.cmake b/tools/cmake/upload_methods/UploadMethodLINKSERVER.cmake index 2f28b90c968..edc46a76040 100644 --- a/tools/cmake/upload_methods/UploadMethodLINKSERVER.cmake +++ b/tools/cmake/upload_methods/UploadMethodLINKSERVER.cmake @@ -46,7 +46,7 @@ set(UPLOAD_GDBSERVER_DEBUG_COMMAND ${LinkServer_PATH} gdbserver ${LINKSERVER_PROBE_ARGS} - --gdb-port ${GDB_PORT} + --gdb-port ${MBED_GDB_PORT} ${LINKSERVER_DEVICE} ) diff --git a/tools/cmake/upload_methods/UploadMethodOPENOCD.cmake b/tools/cmake/upload_methods/UploadMethodOPENOCD.cmake index db7733ec653..34f6fed9fdc 100644 --- a/tools/cmake/upload_methods/UploadMethodOPENOCD.cmake +++ b/tools/cmake/upload_methods/UploadMethodOPENOCD.cmake @@ -62,7 +62,7 @@ set(UPLOAD_GDBSERVER_DEBUG_COMMAND # Shut down OpenOCD when GDB disconnects. # see https://github.com/Marus/cortex-debug/issues/371#issuecomment-999727626 -c "[target current] configure -event gdb-detach {shutdown}" - -c "gdb_port ${GDB_PORT}") + -c "gdb_port ${MBED_GDB_PORT}") # request extended-remote GDB sessions set(UPLOAD_WANTS_EXTENDED_REMOTE TRUE) diff --git a/tools/cmake/upload_methods/UploadMethodPYOCD.cmake b/tools/cmake/upload_methods/UploadMethodPYOCD.cmake index c873a983819..4926a4c065e 100644 --- a/tools/cmake/upload_methods/UploadMethodPYOCD.cmake +++ b/tools/cmake/upload_methods/UploadMethodPYOCD.cmake @@ -46,7 +46,7 @@ set(UPLOAD_GDBSERVER_DEBUG_COMMAND -t ${PYOCD_TARGET_NAME} ${PYOCD_PROBE_ARGS} -f ${PYOCD_CLOCK_SPEED} - -p ${GDB_PORT}) + -p ${MBED_GDB_PORT}) # Reference: https://github.com/Marus/cortex-debug/blob/056c03f01e008828e6527c571ef5c9adaf64083f/src/pyocd.ts#L40 set(UPLOAD_LAUNCH_COMMANDS diff --git a/tools/cmake/upload_methods/UploadMethodSTLINK.cmake b/tools/cmake/upload_methods/UploadMethodSTLINK.cmake index a5d78875b3f..a7a40117d88 100644 --- a/tools/cmake/upload_methods/UploadMethodSTLINK.cmake +++ b/tools/cmake/upload_methods/UploadMethodSTLINK.cmake @@ -41,7 +41,7 @@ set(UPLOAD_GDBSERVER_DEBUG_COMMAND ${st-util_PATH} ${STLINK_SERIAL_ARGUMENT} ${STLINK_ARGS} - --listen_port=${GDB_PORT} + --listen_port=${MBED_GDB_PORT} --multi) # Reference: https://github.com/Marus/cortex-debug/blob/056c03f01e008828e6527c571ef5c9adaf64083f/src/stutil.ts#L39 diff --git a/tools/cmake/upload_methods/UploadMethodSTM32CUBE.cmake b/tools/cmake/upload_methods/UploadMethodSTM32CUBE.cmake index 65b37fac3d0..f6229fe8776 100644 --- a/tools/cmake/upload_methods/UploadMethodSTM32CUBE.cmake +++ b/tools/cmake/upload_methods/UploadMethodSTM32CUBE.cmake @@ -49,7 +49,7 @@ set(UPLOAD_GDBSERVER_DEBUG_COMMAND ${STLINK_gdbserver_COMMAND} ${STM32CUBE_GDBSERVER_ARGS} -cp "${CUBE_PROG_DIR}" - -p ${GDB_PORT} + -p ${MBED_GDB_PORT} --halt ${STM32CUBE_GDB_PROBE_ARGS})