diff --git a/targets/upload_method_cfg/NUCLEO_L452RE_P.cmake b/targets/upload_method_cfg/NUCLEO_L452RE_P.cmake index 5d135c5..10e2034 100644 --- a/targets/upload_method_cfg/NUCLEO_L452RE_P.cmake +++ b/targets/upload_method_cfg/NUCLEO_L452RE_P.cmake @@ -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 # ------------------------------------------------------------- diff --git a/targets/upload_method_cfg/openocd_cfgs/stm32l452re.cfg b/targets/upload_method_cfg/openocd_cfgs/stm32l452re.cfg index bbe91b9..72c0e73 100644 --- a/targets/upload_method_cfg/openocd_cfgs/stm32l452re.cfg +++ b/targets/upload_method_cfg/openocd_cfgs/stm32l452re.cfg @@ -9,6 +9,4 @@ transport select hla_swd -source [find target/stm32l4x.cfg] - -reset_config srst_only \ No newline at end of file +source [find target/stm32l4x.cfg] \ No newline at end of file diff --git a/tools/cmake/mbed_greentea.cmake b/tools/cmake/mbed_greentea.cmake index 295fd1d..7805292 100644 --- a/tools/cmake/mbed_greentea.cmake +++ b/tools/cmake/mbed_greentea.cmake @@ -129,6 +129,16 @@ 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 "") diff --git a/tools/cmake/upload_methods/Findstlink.cmake b/tools/cmake/upload_methods/Findstlink.cmake index dec8c5e..dad6b90 100644 --- a/tools/cmake/upload_methods/Findstlink.cmake +++ b/tools/cmake/upload_methods/Findstlink.cmake @@ -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 @@ 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) \ No newline at end of file +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) \ No newline at end of file diff --git a/tools/cmake/upload_methods/UploadMethodSTLINK.cmake b/tools/cmake/upload_methods/UploadMethodSTLINK.cmake index 04758fd..afc728b 100644 --- a/tools/cmake/upload_methods/UploadMethodSTLINK.cmake +++ b/tools/cmake/upload_methods/UploadMethodSTLINK.cmake @@ -10,6 +10,10 @@ 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)