Skip to content

Commit 176ebe6

Browse files
committed
Upload: Change GDB load command to flash post-build processed image
With this adjustment, GDB load command changes to "load <app>.hex" from just "load": 1. "Load" will load <app>.elf and is inappropriate for targets like bootloader or TF-M enabled which need to post-build process images. 2. "load <app>.bin" is not considered because GDB load command doesn't support binary format.
1 parent 4cd3662 commit 176ebe6

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tools/cmake/UploadMethodManager.cmake

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,44 @@
11
# Copyright (c) 2020 ARM Limited. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4+
# Change GDB load command to flash post-build processed image in debug launch.
5+
# With this adjustment, GDB load command changes to "load <app>.hex" from
6+
# just "load":
7+
# 1. "Load" will load <app>.elf and is inappropriate for targets like
8+
# bootloader or TF-M enabled which need to post-build process images.
9+
# 2. "load <app>.bin" is not considered because GDB load command
10+
# doesn't support binary format.
11+
#
12+
# NOTE: Place at the very start so that it can override by the below loaded
13+
# upload method if need be.
14+
function(mbed_adjust_upload_debug_commands target)
15+
# MBED_UPLOAD_LAUNCH_COMMANDS defined?
16+
if(NOT DEFINED MBED_UPLOAD_LAUNCH_COMMANDS)
17+
return()
18+
endif()
19+
20+
# GDB load command in MBED_UPLOAD_LAUNCH_COMMANDS?
21+
list(FIND MBED_UPLOAD_LAUNCH_COMMANDS "load" LOAD_INDEX)
22+
if(${LOAD_INDEX} LESS "0")
23+
return()
24+
endif()
25+
26+
# <app>.hex for debug launch load
27+
set(HEX_FILE ${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_FILE_BASE_NAME:${target}>.hex)
28+
29+
# "load" -> "load <app>.hex"
30+
#
31+
# GDB load command doesn't support binary format. Ignore OUTPUT_EXT
32+
# and fix to Intel Hex format.
33+
#
34+
# NOTE: The <app>.hex file name needs to be quoted (\\\") to pass along
35+
# to gdb correctly.
36+
list(TRANSFORM MBED_UPLOAD_LAUNCH_COMMANDS APPEND " \\\"${HEX_FILE}\\\"" AT ${LOAD_INDEX})
37+
38+
# Update MBED_UPLOAD_LAUNCH_COMMANDS in cache
39+
set(MBED_UPLOAD_LAUNCH_COMMANDS ${MBED_UPLOAD_LAUNCH_COMMANDS} CACHE INTERNAL "" FORCE)
40+
endfunction()
41+
442
# ----------------------------------------------
543
# Load the upload method that the user selects
644

0 commit comments

Comments
 (0)