Fix OpenOCD not working for L452RE, fix running tests with a non-default baudrate set, add warning about old stlink versions which may not work

pull/15339/head
Jamie Smith 2022-09-08 23:31:23 -07:00 committed by Jay Sridharan
parent d82838212b
commit d149b84786
5 changed files with 27 additions and 5 deletions

View File

@ -4,7 +4,7 @@
# Notes:
# 1. Using the JLINK upload method with your dev board requires converting its ST-LINK into a J-Link. See here for details: https://www.segger.com/products/debug-probes/j-link/models/other-j-links/st-link-on-board/
# 2. Using pyocd with this device requires installing a pack: `pyocd pack -i STM32L4xx_DFP`
# 2. Using pyocd with this device requires installing a pack: `pyocd pack -i STM32L4xx_DFP`. Warning: this can take 15+ min to download.
# General config parameters
# -------------------------------------------------------------

View File

@ -10,5 +10,3 @@ hla_vid_pid 0x0483 0x374b
transport select hla_swd
source [find target/stm32l4x.cfg]
reset_config srst_only

View File

@ -129,6 +129,16 @@ function(mbed_greentea_add_test)
list(APPEND MBED_HTRUN_ARGUMENTS "-R;${MBED_GREENTEA_TEST_RESET_TIMEOUT}")
endif()
# Greentea tests will run at whatever baudrate the stdio baudrate is set to.
# We need to find that information from MBED_CONFIG_DEFINITIONS.
set(MBED_STDIO_BAUD_CONFIG_DEFINITIONS ${MBED_CONFIG_DEFINITIONS})
list(FILTER MBED_STDIO_BAUD_CONFIG_DEFINITIONS INCLUDE REGEX "MBED_CONF_PLATFORM_STDIO_BAUD_RATE")
if(NOT "${MBED_STDIO_BAUD_CONFIG_DEFINITIONS}" STREQUAL "")
string(REGEX REPLACE "MBED_CONF_PLATFORM_STDIO_BAUD_RATE=([0-9]+)" "\\1" MBED_STDIO_BAUD ${MBED_STDIO_BAUD_CONFIG_DEFINITIONS})
list(APPEND MBED_HTRUN_ARGUMENTS "--baud-rate=${MBED_STDIO_BAUD}")
endif()
list(APPEND CONFIG_DEFS_COPY ${MBED_CONFIG_DEFINITIONS})
list(FILTER CONFIG_DEFS_COPY INCLUDE REGEX "MBED_CONF_PLATFORM_STDIO_BAUD_RATE")
if(NOT ${CONFIG_DEFS_COPY} STREQUAL "")

View File

@ -9,6 +9,7 @@
# st-util_PATH - full path to st-util executable
# st-flash_PATH - full path to st-flash executable
# stlink_FOUND - whether or not the stlink tools were found
# stlink_VERSION - if stlink was found, this is set to its version
# try to figure out where stlink may be installed.
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
@ -36,4 +37,13 @@ find_program(st-flash_PATH
DOC "Path to the st-flash executable"
HINTS ${stlink_HINTS})
find_package_handle_standard_args(stlink FOUND_VAR stlink_FOUND REQUIRED_VARS st-util_PATH st-flash_PATH)
if(EXISTS "${st-util_PATH}")
# Detect version
execute_process(COMMAND ${st-util_PATH} --version
OUTPUT_VARIABLE stlink_VERSION_OUTPUT)
# The output looks like "v1.2.3", so use a regex to trim off the v and anything else
string(REGEX REPLACE "v([0-9]+\\.[0-9]+\\.[0-9]+).*" "\\1" stlink_VERSION ${stlink_VERSION_OUTPUT})
endif()
find_package_handle_standard_args(stlink FOUND_VAR stlink_FOUND VERSION_VAR stlink_VERSION REQUIRED_VARS st-util_PATH st-flash_PATH)

View File

@ -10,6 +10,10 @@ set(UPLOAD_SUPPORTS_DEBUG TRUE)
find_package(stlink)
set(UPLOAD_STLINK_FOUND ${stlink_FOUND})
if(stlink_FOUND AND (stlink_VERSION VERSION_LESS 1.7.0))
message(WARNING "Mbed OS may not work properly with stlink versions older than 1.7.0 (yours is ${stlink_VERSION}), as its command line options have changed.")
endif()
### Figure out --serial argument
if(DEFINED STLINK_PROBE_SN AND NOT "${STLINK_PROBE_SN}" STREQUAL "")
set(STLINK_SERIAL_ARGUMENT --serial ${STLINK_PROBE_SN} CACHE INTERNAL "" FORCE)