mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
improve flash target
This commit is contained in:
parent
270136e84a
commit
49d8d27770
@ -227,14 +227,19 @@ endif
|
||||
# Jlink Interface
|
||||
JLINK_IF ?= swd
|
||||
|
||||
# Jlink script
|
||||
define jlink_script
|
||||
halt
|
||||
loadfile $^
|
||||
r
|
||||
go
|
||||
exit
|
||||
endef
|
||||
export jlink_script
|
||||
|
||||
# Flash using jlink
|
||||
flash-jlink: $(BUILD)/$(PROJECT).hex
|
||||
@echo halt > $(BUILD)/$(BOARD).jlink
|
||||
@echo r >> $(BUILD)/$(BOARD).jlink
|
||||
@echo loadfile $^ >> $(BUILD)/$(BOARD).jlink
|
||||
@echo r >> $(BUILD)/$(BOARD).jlink
|
||||
@echo go >> $(BUILD)/$(BOARD).jlink
|
||||
@echo exit >> $(BUILD)/$(BOARD).jlink
|
||||
@echo "$$jlink_script" > $(BUILD)/$(BOARD).jlink
|
||||
$(JLINKEXE) -device $(JLINK_DEVICE) -if $(JLINK_IF) -JTAGConf -1,-1 -speed auto -CommandFile $(BUILD)/$(BOARD).jlink
|
||||
|
||||
# Flash STM32 MCU using stlink with STM32 Cube Programmer CLI
|
||||
|
@ -1,4 +1,7 @@
|
||||
if (NOT TARGET _family_support_marker)
|
||||
if (TARGET _family_support_marker)
|
||||
return()
|
||||
endif ()
|
||||
|
||||
add_library(_family_support_marker INTERFACE)
|
||||
|
||||
include(CMakePrintHelpers)
|
||||
@ -111,6 +114,10 @@ if (NOT TARGET _family_support_marker)
|
||||
)
|
||||
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0)
|
||||
target_link_options(${TARGET} PUBLIC "LINKER:--no-warn-rwx-segments")
|
||||
endif()
|
||||
|
||||
# GCC 10
|
||||
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)
|
||||
target_compile_options(${TARGET} PUBLIC -Wconversion)
|
||||
@ -128,6 +135,56 @@ if (NOT TARGET _family_support_marker)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Add flash jlink target
|
||||
function(family_flash_jlink TARGET)
|
||||
if (NOT DEFINED JLINKEXE)
|
||||
set(JLINKEXE JLinkExe)
|
||||
endif ()
|
||||
|
||||
file(GENERATE
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.jlink
|
||||
CONTENT "halt
|
||||
loadfile $<TARGET_FILE:${TARGET}>
|
||||
r
|
||||
go
|
||||
exit"
|
||||
)
|
||||
|
||||
add_custom_target(${TARGET}-jlink
|
||||
DEPENDS ${TARGET}
|
||||
COMMAND ${JLINKEXE} -device ${JLINK_DEVICE} -if swd -JTAGConf -1,-1 -speed auto -CommandFile ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.jlink
|
||||
)
|
||||
endfunction()
|
||||
|
||||
# Add flash pycod target
|
||||
function(family_flash_pyocd TARGET)
|
||||
if (NOT DEFINED PYOC)
|
||||
set(PYOCD pyocd)
|
||||
endif ()
|
||||
|
||||
add_custom_target(${TARGET}-pyocd
|
||||
DEPENDS ${TARGET}
|
||||
COMMAND ${PYOCD} flash -t ${PYOCD_TARGET} $<TARGET_FILE:${TARGET}>
|
||||
)
|
||||
endfunction()
|
||||
|
||||
# Add flash using NXP's LinkServer (redserver)
|
||||
# https://www.nxp.com/design/software/development-software/mcuxpresso-software-and-tools-/linkserver-for-microcontrollers:LINKERSERVER
|
||||
function(family_flash_nxplink TARGET)
|
||||
if (NOT DEFINED LINKSERVER)
|
||||
set(LINKSERVER LinkServer)
|
||||
endif ()
|
||||
|
||||
# LinkServer has a bug that can only execute with full path otherwise it throws:
|
||||
# realpath error: No such file or directory
|
||||
execute_process(COMMAND which ${LINKSERVER} OUTPUT_VARIABLE LINKSERVER_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
add_custom_target(${TARGET}-nxplink
|
||||
DEPENDS ${TARGET}
|
||||
COMMAND ${LINKSERVER_PATH} flash ${NXPLINK_DEVICE} load $<TARGET_FILE:${TARGET}>
|
||||
)
|
||||
endfunction()
|
||||
|
||||
# configure an executable target to link to tinyusb in device mode, and add the board implementation
|
||||
function(family_configure_device_example TARGET)
|
||||
# default implementation is empty, the function should be redefined in the FAMILY/family.cmake
|
||||
@ -146,4 +203,3 @@ if (NOT TARGET _family_support_marker)
|
||||
|
||||
# save it in case of re-inclusion
|
||||
set(FAMILY_MCUS ${FAMILY_MCUS} CACHE INTERNAL "")
|
||||
endif()
|
||||
|
@ -132,37 +132,9 @@ function(family_configure_target TARGET)
|
||||
)
|
||||
|
||||
#---------- Flash ----------
|
||||
# Flash using pyocd
|
||||
add_custom_target(${TARGET}-pyocd
|
||||
DEPENDS ${TARGET}
|
||||
COMMAND pyocd flash -t ${PYOCD_TARGET} $<TARGET_FILE:${TARGET}>
|
||||
)
|
||||
|
||||
# Flash using NXP LinkServer (redlink)
|
||||
# https://www.nxp.com/design/software/development-software/mcuxpresso-software-and-tools-/linkserver-for-microcontrollers:LINKERSERVER
|
||||
# LinkServer has a bug that can only execute with full path otherwise it throws:
|
||||
# realpath error: No such file or directory
|
||||
execute_process(COMMAND which LinkServer OUTPUT_VARIABLE LINKSERVER_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
add_custom_target(${TARGET}-nxplink
|
||||
DEPENDS ${TARGET}
|
||||
COMMAND ${LINKSERVER_PATH} flash ${NXPLINK_DEVICE} load $<TARGET_FILE:${TARGET}>
|
||||
)
|
||||
|
||||
# Flash using jlink
|
||||
set(JLINKEXE JLinkExe)
|
||||
file(GENERATE
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.jlink
|
||||
CONTENT "halt
|
||||
loadfile $<TARGET_FILE:${TARGET}>
|
||||
r
|
||||
go
|
||||
exit"
|
||||
)
|
||||
add_custom_target(${TARGET}-jlink
|
||||
DEPENDS ${TARGET}
|
||||
COMMAND ${JLINKEXE} -device ${JLINK_DEVICE} -if swd -JTAGConf -1,-1 -speed auto -CommandFile ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.jlink
|
||||
)
|
||||
|
||||
family_flash_jlink(${TARGET})
|
||||
family_flash_nxplink(${TARGET})
|
||||
family_flash_pyocd(${TARGET})
|
||||
endfunction()
|
||||
|
||||
|
||||
|
@ -128,20 +128,9 @@ function(family_configure_target TARGET)
|
||||
)
|
||||
|
||||
#---------- Flash ----------
|
||||
# Flash using pyocd
|
||||
add_custom_target(${TARGET}-pyocd
|
||||
COMMAND pyocd flash -t ${PYOCD_TARGET} $<TARGET_FILE:${TARGET}>
|
||||
)
|
||||
|
||||
# Flash using NXP LinkServer (redlink)
|
||||
# https://www.nxp.com/design/software/development-software/mcuxpresso-software-and-tools-/linkserver-for-microcontrollers:LINKERSERVER
|
||||
# LinkServer has a bug that can only execute with full path otherwise it throws:
|
||||
# realpath error: No such file or directory
|
||||
execute_process(COMMAND which LinkServer OUTPUT_VARIABLE LINKSERVER_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
add_custom_target(${TARGET}-nxplink
|
||||
COMMAND ${LINKSERVER_PATH} flash ${NXPLINK_DEVICE} load $<TARGET_FILE:${TARGET}>
|
||||
)
|
||||
|
||||
family_flash_jlink(${TARGET})
|
||||
family_flash_nxplink(${TARGET})
|
||||
family_flash_pyocd(${TARGET})
|
||||
endfunction()
|
||||
|
||||
|
||||
|
@ -132,26 +132,7 @@ function(family_configure_target TARGET)
|
||||
)
|
||||
|
||||
#---------- Flash ----------
|
||||
# Flash using pyocd
|
||||
add_custom_target(${TARGET}-pyocd
|
||||
DEPENDS ${TARGET}
|
||||
COMMAND pyocd flash -t ${PYOCD_TARGET} $<TARGET_FILE:${TARGET}>
|
||||
)
|
||||
|
||||
# Flash using jlink
|
||||
set(JLINKEXE JLinkExe)
|
||||
file(GENERATE
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.jlink
|
||||
CONTENT "halt
|
||||
loadfile $<TARGET_FILE:${TARGET}>
|
||||
r
|
||||
go
|
||||
exit"
|
||||
)
|
||||
add_custom_target(${TARGET}-jlink
|
||||
DEPENDS ${TARGET}
|
||||
COMMAND ${JLINKEXE} -device ${JLINK_DEVICE} -if swd -JTAGConf -1,-1 -speed auto -CommandFile ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.jlink
|
||||
)
|
||||
family_flash_jlink(${TARGET})
|
||||
|
||||
endfunction()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user