|
1 | 1 | # Copyright (c) 2020 ARM Limited. All rights reserved. |
2 | 2 | # SPDX-License-Identifier: Apache-2.0 |
3 | 3 |
|
| 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 | + |
4 | 42 | # ---------------------------------------------- |
5 | 43 | # Load the upload method that the user selects |
6 | 44 |
|
|
0 commit comments