From 1ba35e4f290173259db353c2070f1a8ce754f839 Mon Sep 17 00:00:00 2001 From: Chun-Chieh Li Date: Tue, 27 Aug 2024 17:12:36 +0800 Subject: [PATCH 1/2] Upload: Support adjustment of debug commands for debug launch This gives chance to adjust GDB commands MBED_UPLOAD_LAUNCH_COMMANDS or MBED_UPLOAD_RESTART_COMMANDS for debug launch by implementing mbed_adjust_upload_debug_commands cmake function. --- tools/cmake/mbed_target_functions.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/cmake/mbed_target_functions.cmake b/tools/cmake/mbed_target_functions.cmake index 11a8e203b98..c63c33c5789 100644 --- a/tools/cmake/mbed_target_functions.cmake +++ b/tools/cmake/mbed_target_functions.cmake @@ -169,6 +169,12 @@ function(mbed_set_post_build target) mbed_generate_map_file(${target}) endif() + # Give chance to adjust MBED_UPLOAD_LAUNCH_COMMANDS or MBED_UPLOAD_RESTART_COMMANDS + # for debug launch + if(COMMAND mbed_adjust_upload_debug_commands) + mbed_adjust_upload_debug_commands(${target}) + endif() + mbed_generate_upload_target(${target}) mbed_generate_ide_debug_configuration(${target}) endfunction() From c4b72ff8451d4ebb1257513c5f0163803cc3eebd Mon Sep 17 00:00:00 2001 From: Chun-Chieh Li Date: Fri, 30 Aug 2024 16:35:53 +0800 Subject: [PATCH 2/2] Upload: NUVOTON: Fix GDB restart command for pyOCD PyOCD debug restart is failed without this somehow. It appears the device under debug must be halted after MBED_UPLOAD_RESTART_COMMANDS, but this is broken. Change to "monitor reset halt" to fix it. --- targets/TARGET_NUVOTON/CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/targets/TARGET_NUVOTON/CMakeLists.txt b/targets/TARGET_NUVOTON/CMakeLists.txt index 2119a105478..861aa00e707 100644 --- a/targets/TARGET_NUVOTON/CMakeLists.txt +++ b/targets/TARGET_NUVOTON/CMakeLists.txt @@ -27,3 +27,16 @@ target_sources(mbed-nuvoton target_link_libraries(mbed-nuvoton INTERFACE mbed-cmsis-cortex-m) +# PyOCD debug restart is failed without this somehow. It appears the device +# under debug must be halted after MBED_UPLOAD_RESTART_COMMANDS, but this is +# broken. Change to "monitor reset halt" to fix it. +function(mbed_upload_nuvoton_adjust_restart_command_for_pyocd target) + if(DEFINED MBED_UPLOAD_RESTART_COMMANDS AND + "${UPLOAD_METHOD}" STREQUAL "PYOCD") + set(MBED_UPLOAD_RESTART_COMMANDS "monitor reset halt" CACHE INTERNAL "" FORCE) + endif() +endfunction() + +function(mbed_adjust_upload_debug_commands target) + mbed_upload_nuvoton_adjust_restart_command_for_pyocd(${target}) +endfunction()