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

Upload: NUVOTON: Fix GDB restart command for pyOCD #349

Closed
Closed
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
13 changes: 13 additions & 0 deletions targets/TARGET_NUVOTON/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good catch, but any reason not to adjust line 62 of UploadMethodPYOCD.cmake to just have monitor reset halt? That way it's fixed for all targets.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it locally with STM32H5 and it seems to work (though to be honest I have never really used the restart functionality and I'm not entirely sure how it's supposed to be different from reset)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure the restart command failure will happen on other targets. Anyway, I create another PR #350 to apply the change to all targets.

endif()
endfunction()

function(mbed_adjust_upload_debug_commands target)
mbed_upload_nuvoton_adjust_restart_command_for_pyocd(${target})
endfunction()
6 changes: 6 additions & 0 deletions tools/cmake/mbed_target_functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading