mirror of https://github.com/ARMmbed/mbed-os.git
Tweak upload method dependencies to be specified at a higher level, add LinkServer version check (#404)
parent
156cd15c50
commit
15ab0c38fd
|
@ -146,4 +146,10 @@ function(mbed_generate_upload_target target)
|
||||||
else()
|
else()
|
||||||
gen_upload_target(${target} ${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_FILE_BASE_NAME:${target}>.hex)
|
gen_upload_target(${target} ${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_FILE_BASE_NAME:${target}>.hex)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Make sure building the upload target causes the target to be built first
|
||||||
|
if(TARGET flash-${target})
|
||||||
|
add_dependencies(flash-${target} ${target})
|
||||||
|
endif()
|
||||||
|
|
||||||
endfunction()
|
endfunction()
|
|
@ -7,6 +7,7 @@
|
||||||
# This module defines:
|
# This module defines:
|
||||||
# LinkServer - Whether the reqested tools were found.
|
# LinkServer - Whether the reqested tools were found.
|
||||||
# LinkServer_PATH - full path to the LinkServer command line tool.
|
# LinkServer_PATH - full path to the LinkServer command line tool.
|
||||||
|
# LinkServer_VERSION - version number of LinkServer
|
||||||
|
|
||||||
# Check for LinkServer install folders on Windows
|
# Check for LinkServer install folders on Windows
|
||||||
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
|
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
|
||||||
|
@ -26,6 +27,16 @@ find_program(LinkServer_PATH
|
||||||
HINTS ${LINKSERVER_HINTS}
|
HINTS ${LINKSERVER_HINTS}
|
||||||
)
|
)
|
||||||
|
|
||||||
find_package_handle_standard_args(LinkServer REQUIRED_VARS LinkServer_PATH)
|
if(EXISTS "${LinkServer_PATH}")
|
||||||
|
# Detect version
|
||||||
|
execute_process(COMMAND ${LinkServer_PATH} --version
|
||||||
|
OUTPUT_VARIABLE LinkServer_VERSION_OUTPUT)
|
||||||
|
|
||||||
|
# The output looks like "LinkServer v1.2.45 [Build 45] [2023-07-25 09:54:50]", so use a regex to grab the version
|
||||||
|
string(REGEX REPLACE "LinkServer v([0-9]+\\.[0-9]+\\.[0-9]+).*" "\\1" LinkServer_VERSION ${LinkServer_VERSION_OUTPUT})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
find_package_handle_standard_args(LinkServer REQUIRED_VARS LinkServer_PATH VERSION_VAR LinkServer_VERSION)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,4 @@ function(gen_upload_target TARGET_NAME BINARY_FILE)
|
||||||
--write ${BINARY_FILE}
|
--write ${BINARY_FILE}
|
||||||
--reset)
|
--reset)
|
||||||
|
|
||||||
add_dependencies(flash-${TARGET_NAME} ${TARGET_NAME})
|
|
||||||
|
|
||||||
endfunction(gen_upload_target)
|
endfunction(gen_upload_target)
|
||||||
|
|
|
@ -71,9 +71,6 @@ exit
|
||||||
-ExitOnError
|
-ExitOnError
|
||||||
-CommandFile ${COMMAND_FILE_PATH})
|
-CommandFile ${COMMAND_FILE_PATH})
|
||||||
|
|
||||||
|
|
||||||
add_dependencies(flash-${TARGET_NAME} ${TARGET_NAME})
|
|
||||||
|
|
||||||
endfunction(gen_upload_target)
|
endfunction(gen_upload_target)
|
||||||
|
|
||||||
### Commands to run the debug server.
|
### Commands to run the debug server.
|
||||||
|
|
|
@ -23,6 +23,12 @@ endif()
|
||||||
find_package(LinkServer)
|
find_package(LinkServer)
|
||||||
set(UPLOAD_LINKSERVER_FOUND ${LinkServer_FOUND})
|
set(UPLOAD_LINKSERVER_FOUND ${LinkServer_FOUND})
|
||||||
|
|
||||||
|
if(LinkServer_FOUND)
|
||||||
|
if(${LinkServer_VERSION} VERSION_LESS 1.5.30 AND "${MBED_OUTPUT_EXT}" STREQUAL "hex")
|
||||||
|
message(FATAL_ERROR "LinkServer <1.5.30 does not support flashing hex files! Please upgrade LinkServer and then clean and rebuild the project.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
### Function to generate upload target
|
### Function to generate upload target
|
||||||
|
|
||||||
function(gen_upload_target TARGET_NAME BINARY_FILE)
|
function(gen_upload_target TARGET_NAME BINARY_FILE)
|
||||||
|
@ -37,8 +43,6 @@ function(gen_upload_target TARGET_NAME BINARY_FILE)
|
||||||
--addr ${MBED_UPLOAD_BASE_ADDR}
|
--addr ${MBED_UPLOAD_BASE_ADDR}
|
||||||
${BINARY_FILE})
|
${BINARY_FILE})
|
||||||
|
|
||||||
add_dependencies(flash-${TARGET_NAME} ${TARGET_NAME})
|
|
||||||
|
|
||||||
endfunction(gen_upload_target)
|
endfunction(gen_upload_target)
|
||||||
|
|
||||||
### Commands to run the debug server.
|
### Commands to run the debug server.
|
||||||
|
|
|
@ -25,6 +25,4 @@ function(gen_upload_target TARGET_NAME BINARY_FILE)
|
||||||
${mbed-os_SOURCE_DIR}/tools/python
|
${mbed-os_SOURCE_DIR}/tools/python
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
|
|
||||||
add_dependencies(flash-${TARGET_NAME} ${TARGET_NAME})
|
|
||||||
|
|
||||||
endfunction(gen_upload_target)
|
endfunction(gen_upload_target)
|
||||||
|
|
|
@ -41,7 +41,6 @@ endif()
|
||||||
|
|
||||||
function(gen_upload_target TARGET_NAME BINARY_FILE)
|
function(gen_upload_target TARGET_NAME BINARY_FILE)
|
||||||
|
|
||||||
# unlike other upload methods, OpenOCD uses the elf file
|
|
||||||
add_custom_target(flash-${TARGET_NAME}
|
add_custom_target(flash-${TARGET_NAME}
|
||||||
COMMENT "Flashing ${TARGET_NAME} with OpenOCD..."
|
COMMENT "Flashing ${TARGET_NAME} with OpenOCD..."
|
||||||
COMMAND ${OpenOCD}
|
COMMAND ${OpenOCD}
|
||||||
|
@ -51,7 +50,6 @@ function(gen_upload_target TARGET_NAME BINARY_FILE)
|
||||||
-c "program ${BINARY_FILE} ${MBED_UPLOAD_BASE_ADDR} reset exit"
|
-c "program ${BINARY_FILE} ${MBED_UPLOAD_BASE_ADDR} reset exit"
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
|
|
||||||
add_dependencies(flash-${TARGET_NAME} ${TARGET_NAME})
|
|
||||||
endfunction(gen_upload_target)
|
endfunction(gen_upload_target)
|
||||||
|
|
||||||
### Commands to run the debug server.
|
### Commands to run the debug server.
|
||||||
|
|
|
@ -29,12 +29,16 @@ function(gen_upload_target TARGET_NAME BINARY_FILE)
|
||||||
list(APPEND PICOTOOL_TARGET_ARGS --address ${PICOTOOL_TARGET_ADDRESS})
|
list(APPEND PICOTOOL_TARGET_ARGS --address ${PICOTOOL_TARGET_ADDRESS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if("${MBED_OUTPUT_EXT}" STREQUAL "hex")
|
||||||
|
message(FATAL_ERROR "Bin file output must be enabled to use picotool. Set MBED_OUTPUT_EXT to empty string or to 'bin' in your top level CMakeLists.txt!")
|
||||||
|
endif()
|
||||||
|
|
||||||
add_custom_target(flash-${TARGET_NAME}
|
add_custom_target(flash-${TARGET_NAME}
|
||||||
COMMAND ${Picotool}
|
COMMAND ${Picotool}
|
||||||
load
|
load
|
||||||
|
--verify
|
||||||
--execute
|
--execute
|
||||||
$<TARGET_FILE:${TARGET_NAME}>)
|
--offset ${MBED_UPLOAD_BASE_ADDR}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_FILE_BASE_NAME:${TARGET_NAME}>.bin)
|
||||||
add_dependencies(flash-${TARGET_NAME} ${TARGET_NAME})
|
|
||||||
|
|
||||||
endfunction(gen_upload_target)
|
endfunction(gen_upload_target)
|
||||||
|
|
|
@ -34,7 +34,6 @@ function(gen_upload_target TARGET_NAME BINARY_FILE)
|
||||||
--base-address ${MBED_UPLOAD_BASE_ADDR}
|
--base-address ${MBED_UPLOAD_BASE_ADDR}
|
||||||
${BINARY_FILE})
|
${BINARY_FILE})
|
||||||
|
|
||||||
add_dependencies(flash-${TARGET_NAME} ${TARGET_NAME})
|
|
||||||
endfunction(gen_upload_target)
|
endfunction(gen_upload_target)
|
||||||
|
|
||||||
### Commands to run the debug server.
|
### Commands to run the debug server.
|
||||||
|
|
|
@ -32,7 +32,6 @@ function(gen_upload_target TARGET_NAME BINARY_FILE)
|
||||||
${STLINK_ARGS}
|
${STLINK_ARGS}
|
||||||
write ${BINARY_FILE} ${MBED_UPLOAD_BASE_ADDR})
|
write ${BINARY_FILE} ${MBED_UPLOAD_BASE_ADDR})
|
||||||
|
|
||||||
add_dependencies(flash-${TARGET_NAME} ${TARGET_NAME})
|
|
||||||
endfunction(gen_upload_target)
|
endfunction(gen_upload_target)
|
||||||
|
|
||||||
### Commands to run the debug server.
|
### Commands to run the debug server.
|
||||||
|
|
|
@ -36,8 +36,6 @@ function(gen_upload_target TARGET_NAME BINARY_FILE)
|
||||||
-w ${BINARY_FILE} ${MBED_UPLOAD_BASE_ADDR}
|
-w ${BINARY_FILE} ${MBED_UPLOAD_BASE_ADDR}
|
||||||
-rst)
|
-rst)
|
||||||
|
|
||||||
add_dependencies(flash-${TARGET_NAME} ${TARGET_NAME})
|
|
||||||
|
|
||||||
endfunction(gen_upload_target)
|
endfunction(gen_upload_target)
|
||||||
|
|
||||||
### Commands to run the debug server.
|
### Commands to run the debug server.
|
||||||
|
|
Loading…
Reference in New Issue