diff --git a/hal/tests/TESTS/mbed_hal/rtc_reset/CMakeLists.txt b/hal/tests/TESTS/mbed_hal/rtc_reset/CMakeLists.txt index 594de38..35db199 100644 --- a/hal/tests/TESTS/mbed_hal/rtc_reset/CMakeLists.txt +++ b/hal/tests/TESTS/mbed_hal/rtc_reset/CMakeLists.txt @@ -5,6 +5,11 @@ set(TEST_SKIPPED "RTC is not supported for this target") endif() +if(MBED_TARGET STREQUAL "MIMXRT1050_EVK") + # This test causes this target to die. See https://github.com/mbed-ce/mbed-os/issues/83 + set(TEST_SKIPPED "Temporarily disabled for this target, see #83") +endif() + mbed_greentea_add_test( TEST_NAME mbed-hal-rtc-reset diff --git a/targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/TARGET_EVK/flash_api.c b/targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/TARGET_EVK/flash_api.c index 352529c..5a04864 100644 --- a/targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/TARGET_EVK/flash_api.c +++ b/targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/TARGET_EVK/flash_api.c @@ -604,8 +604,8 @@ uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address) { uint32_t sectorsize = MBED_FLASH_INVALID_SIZE; - uint32_t devicesize = BOARD_FLASH_SIZE; - uint32_t startaddr = BOARD_FLASH_START_ADDR; + uint32_t devicesize = BOARD_FLASHIAP_SIZE; + uint32_t startaddr = BOARD_FLASHIAP_START_ADDR; if ((address >= startaddr) && (address < (startaddr + devicesize))) { sectorsize = BOARD_FLASH_SECTOR_SIZE; diff --git a/targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/device/cmsis_nvic.h b/targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/device/cmsis_nvic.h index 1fe4565..f2a763a 100644 --- a/targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/device/cmsis_nvic.h +++ b/targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/device/cmsis_nvic.h @@ -42,4 +42,6 @@ #define NVIC_NUM_VECTORS (16 + 160) // CORE + MCU Peripherals #define NVIC_RAM_VECTOR_ADDRESS (__VECTOR_RAM) // Vectors positioned at start of RAM +#define MBED_RAM_SIZE 0x01E00000 // from linker script + #endif diff --git a/targets/upload_method_cfg/MIMXRT1050_EVK.cmake b/targets/upload_method_cfg/MIMXRT1050_EVK.cmake new file mode 100644 index 0000000..58b1088 --- /dev/null +++ b/targets/upload_method_cfg/MIMXRT1050_EVK.cmake @@ -0,0 +1,31 @@ +# Mbed OS upload method configuration file for target MIMXRT1050_EVK. +# To change any of these parameters from their default values, set them in your build script between where you +# include app.cmake and where you add mbed os as a subdirectory. + +# General config parameters +# ------------------------------------------------------------- +set(UPLOAD_METHOD_DEFAULT MBED) + +# Config options for MBED +# ------------------------------------------------------------- +set(MBED_UPLOAD_ENABLED TRUE) +set(MBED_RESET_BAUDRATE 115200) + +# Config options for PYOCD +# ------------------------------------------------------------- +set(PYOCD_UPLOAD_ENABLED TRUE) +set(PYOCD_TARGET_NAME mimxrt1050_hyperflash) # Note: change to "mimxrt1050_quadspi" if onboard QSPI flash is used +set(PYOCD_CLOCK_SPEED 4000k) + +# Config options for REDLINK +# ------------------------------------------------------------- +set(REDLINK_UPLOAD_ENABLED TRUE) +set(REDLINK_PART_NUMBER MIMXRT1052xxxxB) +set(REDLINK_PART_XML_DIR ${CMAKE_CURRENT_LIST_DIR}/redlink_cfgs) +set(REDLINK_CLOCK_SPEED 4000) +set(REDLINK_CONNECT_ARGS + --connectscript=RT1050_connect.scp + --reset= + --coreindex 0 + --cache disable + --no-packed) \ No newline at end of file diff --git a/targets/upload_method_cfg/redlink_cfgs/MIMXRT1052xxxxB.xml b/targets/upload_method_cfg/redlink_cfgs/MIMXRT1052xxxxB.xml new file mode 100644 index 0000000..22a0405 --- /dev/null +++ b/targets/upload_method_cfg/redlink_cfgs/MIMXRT1052xxxxB.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/targets/upload_method_cfg/redlink_cfgs/MIMXRT1052xxxxB_part.xml b/targets/upload_method_cfg/redlink_cfgs/MIMXRT1052xxxxB_part.xml new file mode 100644 index 0000000..5c7e710 --- /dev/null +++ b/targets/upload_method_cfg/redlink_cfgs/MIMXRT1052xxxxB_part.xml @@ -0,0 +1,3 @@ + + + MIMXRT1052xxxxB MIMXRT1050 NXP Cortex-M7 Cortex-M diff --git a/tools/cmake/UploadMethodManager.cmake b/tools/cmake/UploadMethodManager.cmake index 4c3a69f..5dfd0aa 100644 --- a/tools/cmake/UploadMethodManager.cmake +++ b/tools/cmake/UploadMethodManager.cmake @@ -31,9 +31,15 @@ if(UPLOAD_SUPPORTS_DEBUG) # create init file for GDB client + if(UPLOAD_WANTS_EXTENDED_REMOTE) + set(UPLOAD_GDB_REMOTE_KEYWORD "extended-remote") + else() + set(UPLOAD_GDB_REMOTE_KEYWORD "remote") + endif() + file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/mbed-cmake.gdbinit CONTENT "# connect to GDB server -target remote localhost:${GDB_PORT} +target ${UPLOAD_GDB_REMOTE_KEYWORD} localhost:${GDB_PORT} ") endif() diff --git a/tools/cmake/upload_methods/FindRedlink.cmake b/tools/cmake/upload_methods/FindRedlink.cmake new file mode 100644 index 0000000..2ce1d19 --- /dev/null +++ b/tools/cmake/upload_methods/FindRedlink.cmake @@ -0,0 +1,57 @@ +# Copyright (c) 2022 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# ---------------------------------------------- +# CMake finder for Redlink, the NXP MCUXpresso debug tool +# +# This module defines: +# Redlink_FOUND - Whether the reqested tools were found. +# crt_emu_cm_redlink_PATH - full path to the Redlink command line tool (crt_emu_cm_redlink). +# REDLINK_FLASH_LOADER_PATH - path to the directory where flash loaders are (contains MIMXRT1050_SFDP_HYPERFLASH.cfx) + +# first try to locate MCUXpresso IDE in its default location +set(MCUXPRESSO_IDE_LINUX_HINTS "") +set(MCUXPRESSO_IDE_WINDOWS_HINTS "") +if(EXISTS "C:/nxp/") + # On Windows, MCUXpresso by default is installed into a subdirectory of + # C:/nxp + file(GLOB MCUXPRESSO_IDE_WINDOWS_HINTS LIST_DIRECTORIES TRUE "C:/nxp/MCUXpressoIDE_*/ide") +endif() + +find_path(MCUXPRESSO_IDE_PATH + NAMES mcuxpressoide.ini + DOC "Path to MCUXPresso IDE. This directory should contain mcuxpressoide.ini. Used to find Redlink" + PATHS + ${MCUXPRESSO_IDE_WINDOWS_HINTS} # Windows + /usr/local/mcuxpressoide/ide # Linux + /Applications/MCUXpressoIDE.app/Contents/Eclipse # OS X + ) + +set(Redlink_HINTS "") +if(EXISTS "${MCUXPRESSO_IDE_PATH}") + message(STATUS "Located MCUXpresso IDE: ${MCUXPRESSO_IDE_PATH}") + + # find install dirs inside IDE, which also have version numbers + file(GLOB REDLINK_INSTALL_DIRS LIST_DIRECTORIES TRUE "${MCUXPRESSO_IDE_PATH}/plugins/com.nxp.mcuxpresso.tools.bin.*/binaries") + list(GET REDLINK_INSTALL_DIRS 0 REDLINK_INSTALL_DIR) # If glob returns multiple just pick one + if(EXISTS "${REDLINK_INSTALL_DIR}") + list(APPEND Redlink_HINTS ${REDLINK_INSTALL_DIR}) + endif() +elseif() + message(WARNING "Failed to find MCUXpresso IDE, will still look for Redlink (crt_emu_cm_redlink) on your PATH. Recommend setting MCUXPRESSO_IDE_PATH to the location of MCUXpresso IDE.") +endif() + +find_program(crt_emu_cm_redlink_PATH + NAMES crt_emu_cm_redlink + DOC "Path to the Redlink crt_emu_cm_redlink executable." + HINTS ${Redlink_HINTS}) + +find_path(REDLINK_FLASH_LOADER_PATH + NAMES MIMXRT1050_SFDP_HYPERFLASH.cfx + DOC "Path to the directory where the Redlink flash loaders are (contains MIMXRT1050_SFDP_HYPERFLASH.cfx)." + HINTS ${Redlink_HINTS} + PATH_SUFFIXES Flash) + +find_package_handle_standard_args(Redlink REQUIRED_VARS crt_emu_cm_redlink_PATH REDLINK_FLASH_LOADER_PATH) + + diff --git a/tools/cmake/upload_methods/UploadMethodJLINK.cmake b/tools/cmake/upload_methods/UploadMethodJLINK.cmake index 9b70d96..198487f 100644 --- a/tools/cmake/upload_methods/UploadMethodJLINK.cmake +++ b/tools/cmake/upload_methods/UploadMethodJLINK.cmake @@ -15,7 +15,7 @@ # default to JTAG if(NOT DEFINED JLINK_UPLOAD_INTERFACE) - set(JLINK_UPLOAD_INTERFACE JTAG) + set(JLINK_UPLOAD_INTERFACE JTAG CACHE INTERNAL "" FORCE) endif() ### Function to generate upload target diff --git a/tools/cmake/upload_methods/UploadMethodOPENOCD.cmake b/tools/cmake/upload_methods/UploadMethodOPENOCD.cmake index 83cc61f..22ca676 100644 --- a/tools/cmake/upload_methods/UploadMethodOPENOCD.cmake +++ b/tools/cmake/upload_methods/UploadMethodOPENOCD.cmake @@ -17,7 +17,7 @@ set(OPENOCD_ADAPTER_SERIAL "" CACHE STRING "Serial number of the debug adapter to select for OpenOCD. Set to empty to detect any matching adapter.") ### Function to generate upload target -set(OPENOCD_ADAPTER_SERIAL_COMMAND "") +set(OPENOCD_ADAPTER_SERIAL_COMMAND "" CACHE INTERNAL "" FORCE) if(NOT "${OPENOCD_ADAPTER_SERIAL}" STREQUAL "") # Generate script file that tells OpenOCD how to find the correct debug adapter. @@ -36,7 +36,7 @@ adapter serial $adapter_serial }") - set(OPENOCD_ADAPTER_SERIAL_COMMAND -f ${CMAKE_BINARY_DIR}/openocd_adapter_config.cfg) + set(OPENOCD_ADAPTER_SERIAL_COMMAND -f ${CMAKE_BINARY_DIR}/openocd_adapter_config.cfg CACHE INTERNAL "" FORCE) endif() function(gen_upload_target TARGET_NAME BIN_FILE) @@ -63,3 +63,6 @@ -c "gdb_port ${GDB_PORT}" USES_TERMINAL VERBATIM) + +# request extended-remote GDB sessions +set(UPLOAD_WANTS_EXTENDED_REMOTE TRUE) diff --git a/tools/cmake/upload_methods/UploadMethodPYOCD.cmake b/tools/cmake/upload_methods/UploadMethodPYOCD.cmake index da855a0..994acd9 100644 --- a/tools/cmake/upload_methods/UploadMethodPYOCD.cmake +++ b/tools/cmake/upload_methods/UploadMethodPYOCD.cmake @@ -21,7 +21,7 @@ ### Function to generate upload target set(PYOCD_PROBE_ARGS "") if(NOT "${PYOCD_PROBE_UID}" STREQUAL "") - set(PYOCD_PROBE_ARGS --probe ${PYOCD_PROBE_UID}) + set(PYOCD_PROBE_ARGS --probe ${PYOCD_PROBE_UID} CACHE INTERNAL "" FORCE) endif() function(gen_upload_target TARGET_NAME BIN_FILE) diff --git a/tools/cmake/upload_methods/UploadMethodREDLINK.cmake b/tools/cmake/upload_methods/UploadMethodREDLINK.cmake new file mode 100644 index 0000000..95c5e94 --- /dev/null +++ b/tools/cmake/upload_methods/UploadMethodREDLINK.cmake @@ -0,0 +1,83 @@ +# Copyright (c) 2022 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +### Redlink Upload Method +# This method needs the following parameters: +# REDLINK_PART_NUMBER - Part number (-p) argument to pass to the upload tool +# REDLINK_PART_XML_DIR - Directory where the XML files for this MCU can be found. +# REDLINK_CLOCK_SPEED - JTAG/SWD clock speed to talk to the target at. +# REDLINK_CONNECT_ARGS - Extra connect arguments to pass to Redlink tool. These can be gotten by watching the command that MCUXpresso IDE executes when you start a debug session. +# This method creates the following options: +# REDLINK_PROBE_SN - Serial number of the debug probe to connect to. If blank, will connect to any probe. + +### Handle options +set(REDLINK_PROBE_SN "" CACHE STRING "Serial number of the debug probe to connect to for Redlink. Set to empty to detect any matching adapter.") + +if("${REDLINK_PROBE_SN}" STREQUAL "") + # This argument causes Redlink to connect to the first available debug probe + set(REDLINK_PROBE_ARGS --probehandle 1 CACHE INTERNAL "" FORCE) +else() + set(REDLINK_PROBE_ARGS --probeserial ${REDLINK_PROBE_SN} CACHE INTERNAL "" FORCE) +endif() + +if("${REDLINK_PART_NUMBER}" STREQUAL "") + message(FATAL_ERROR "You must set REDLINK_PART_NUMBER in your CMake scripts to use REDLINK") +endif() + +if("${REDLINK_PART_XML_DIR}" STREQUAL "") + message(FATAL_ERROR "You must set REDLINK_PART_XML_DIR in your CMake scripts to use REDLINK") +endif() + +if("${REDLINK_CLOCK_SPEED}" STREQUAL "") + message(FATAL_ERROR "You must set REDLINK_CLOCK_SPEED in your CMake scripts to use REDLINK") +endif() + +### Check if upload method can be enabled on this machine +find_package(Redlink) +set(UPLOAD_REDLINK_FOUND ${Redlink_FOUND}) + +### Function to generate upload target + +function(gen_upload_target TARGET_NAME BIN_FILE HEX_FILE) + + add_custom_target(flash-${TARGET_NAME} + COMMENT "Flashing ${TARGET_NAME} with Redlink..." + COMMAND ${crt_emu_cm_redlink_PATH} + -p ${REDLINK_PART_NUMBER} + --flash-hashing + -x ${REDLINK_PART_XML_DIR} + --flash-dir ${REDLINK_FLASH_LOADER_PATH} + -g + -s ${REDLINK_CLOCK_SPEED} + ${REDLINK_CONNECT_ARGS} + ${REDLINK_PROBE_ARGS} + --flash-load-exec $) + + add_dependencies(flash-${TARGET_NAME} ${TARGET_NAME}) + +endfunction(gen_upload_target) + +### Function to generate debug target +add_custom_target(gdbserver + COMMENT "Starting Redlink GDB server" + COMMAND + ${crt_emu_cm_redlink_PATH} + -p ${REDLINK_PART_NUMBER} + --flash-hashing + -x ${REDLINK_PART_XML_DIR} + --flash-dir ${REDLINK_FLASH_LOADER_PATH} + -g + -s ${REDLINK_CLOCK_SPEED} + -2 + ${REDLINK_CONNECT_ARGS} + ${REDLINK_PROBE_ARGS} + --server :${GDB_PORT} + --vc + --connect-reset system + --kill-server # Because redlink seems to not handle Ctrl-C, we use this to close it when GDB exits + USES_TERMINAL + VERBATIM) + + +# request extended-remote GDB sessions +set(UPLOAD_WANTS_EXTENDED_REMOTE TRUE) \ No newline at end of file diff --git a/tools/cmake/upload_methods/UploadMethodSTM32CUBE.cmake b/tools/cmake/upload_methods/UploadMethodSTM32CUBE.cmake index f3b7cac..44d05ec 100644 --- a/tools/cmake/upload_methods/UploadMethodSTM32CUBE.cmake +++ b/tools/cmake/upload_methods/UploadMethodSTM32CUBE.cmake @@ -22,12 +22,12 @@ ### Function to generate upload target -set(STM32CUBE_UPLOAD_PROBE_ARGS "") -set(STM32CUBE_GDB_PROBE_ARGS "") +set(STM32CUBE_UPLOAD_PROBE_ARGS "" CACHE INTERNAL "" FORCE) +set(STM32CUBE_GDB_PROBE_ARGS "" CACHE INTERNAL "" FORCE) if(NOT "${STM32CUBE_PROBE_SN}" STREQUAL "") - set(STM32CUBE_UPLOAD_PROBE_ARGS sn=${STM32CUBE_PROBE_SN}) - set(STM32CUBE_GDB_PROBE_ARGS --serial-number ${STM32CUBE_PROBE_SN}) + set(STM32CUBE_UPLOAD_PROBE_ARGS sn=${STM32CUBE_PROBE_SN} CACHE INTERNAL "" FORCE) + set(STM32CUBE_GDB_PROBE_ARGS --serial-number ${STM32CUBE_PROBE_SN} CACHE INTERNAL "" FORCE) endif() function(gen_upload_target TARGET_NAME BIN_FILE HEX_FILE)