Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace REDLINK upload method with LINKSERVER #186

Merged
merged 3 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions hal/tests/TESTS/mbed_hal/reset_reason/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ if(NOT "DEVICE_RESET_REASON=1" IN_LIST MBED_TARGET_DEFINITIONS)
set(TEST_SKIPPED "Reset Reason is not supported for this target")
endif()

if("TARGET_MIMXRT105X" IN_LIST MBED_TARGET_DEFINITIONS)
# 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-reset-reason
Expand Down
2 changes: 1 addition & 1 deletion hal/tests/TESTS/mbed_hal/rtc_reset/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if(NOT "DEVICE_RTC=1" IN_LIST MBED_TARGET_DEFINITIONS)
set(TEST_SKIPPED "RTC is not supported for this target")
endif()

if(MBED_TARGET STREQUAL "MIMXRT1050_EVK")
if("TARGET_MIMXRT105X" IN_LIST MBED_TARGET_DEFINITIONS)
# 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()
Expand Down
4 changes: 2 additions & 2 deletions hal/tests/TESTS/mbed_hal/sleep/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ void deepsleep_high_speed_clocks_turned_off_test()
/* High freqency ticker should be disabled in deep-sleep mode. We expect that time difference between
* ticker reads before and after the sleep represents only code execution time between calls.
* Since we went to sleep for about 20 ms check if time counted by high frequency timer does not
* exceed 1 ms.
* exceed the deep sleep enter/exit time.
*/
const unsigned int us_ticks_diff = (us_ticks_before_sleep <= us_ticks_after_sleep) ? (us_ticks_after_sleep - us_ticks_before_sleep) : (us_ticker_mask - us_ticks_before_sleep + us_ticks_after_sleep + 1);

TEST_ASSERT_UINT32_WITHIN(1000, 0, ticks_to_us(us_ticks_diff, us_ticker_freq));
TEST_ASSERT_UINT32_WITHIN(DEEP_SLEEP_TOLERANCE_US, 0, ticks_to_us(us_ticks_diff, us_ticker_freq));

sprintf(info, "Delta ticks: %u, Ticker width: %u, Expected wake up tick: %" PRIu32 ", Actual wake up tick: %d\n",
us_to_ticks(deepsleep_mode_delta_us, lp_ticker_freq), lp_ticker_width, wakeup_time, lp_ticks_after_sleep);
Expand Down
6 changes: 6 additions & 0 deletions hal/tests/TESTS/mbed_hal/sleep/sleep_test_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
*/
#define SERIAL_FLUSH_TIME_MS 150

// Tolerance for extra sleep time in the deep sleep test.
// This accounts for the time that the processor spends going to sleep and waking up.
// The hal_deepsleep() docs specify this to be less than 10ms
// Current leader is the MIMXRT105x, which takes almost 6ms to enter/exit deep sleep.
#define DEEP_SLEEP_TOLERANCE_US 6000ULL

#define US_PER_S 1000000

unsigned int ticks_to_us(unsigned int ticks, unsigned int freq)
Expand Down
6 changes: 0 additions & 6 deletions hal/tests/TESTS/mbed_hal/sleep_manager/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@

#define SLEEP_DURATION_US 50000ULL

// Tolerance for extra sleep time in the deep sleep test.
// This accounts for the time that the processor spends going to sleep and waking up.
// The hal_deepsleep() docs specify this to be less than 10ms
// Current leader is the MIMXRT105x, which takes almost 5ms to enter/exit deep sleep.
#define DEEP_SLEEP_TOLERANCE_US 5000ULL

#define DEEP_SLEEP_TEST_CHECK_WAIT_US 2000
// As sleep_manager_can_deep_sleep_test_check() is based on wait_ns
// and wait_ns can be up to 40% slower, use a 50% delta here.
Expand Down
15 changes: 4 additions & 11 deletions targets/upload_method_cfg/MIMXRT1050_EVK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,8 @@ 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
# Config options for LINKSERVER
# -------------------------------------------------------------
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)
set(LINKSERVER_UPLOAD_ENABLED TRUE)
# note: might need to change the below to MIMXRT1052xxxxx:EVK-IMXRT1050 if you have an EVK rev A
set(LINKSERVER_DEVICE MIMXRT1052xxxxB:EVKB-IMXRT1050)
14 changes: 3 additions & 11 deletions targets/upload_method_cfg/MIMXRT1060_EVK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,7 @@ set(PYOCD_UPLOAD_ENABLED TRUE)
set(PYOCD_TARGET_NAME mimxrt1060) # Note: This seems to use QSPI. There does not seem to be a pyocd equivalent for hyperflash.
set(PYOCD_CLOCK_SPEED 4000k)

# Config options for REDLINK
# Config options for LINKSERVER
# -------------------------------------------------------------
set(REDLINK_UPLOAD_ENABLED TRUE)
set(REDLINK_PART_NUMBER MIMXRT1062xxxxA)
set(REDLINK_PART_XML_DIR ${CMAKE_CURRENT_LIST_DIR}/redlink_cfgs)
set(REDLINK_CLOCK_SPEED 4000)
set(REDLINK_CONNECT_ARGS
--connectscript=RT1060_connect.scp
--reset=
--coreindex 0
--cache disable
--no-packed)
set(LINKSERVER_UPLOAD_ENABLED TRUE)
set(LINKSERVER_DEVICE MIMXRT1062xxxxx:MIMXRT1060-EVKB)
5 changes: 0 additions & 5 deletions targets/upload_method_cfg/redlink_cfgs/MIMXRT1052xxxxB.xml

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions targets/upload_method_cfg/redlink_cfgs/MIMXRT1062xxxxA.xml

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion tools/cmake/UploadMethodManager.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ endif()
# UPLOAD_GDBSERVER_DEBUG_COMMAND - Command to start a new GDB server
# UPLOAD_WANTS_EXTENDED_REMOTE - True iff GDB should use "target extended-remote" to connect to the GDB server
# UPLOAD_LAUNCH_COMMANDS - List of GDB commands to run after launching GDB.
# UPLOAD_RESTART_COMMANDS - List of commands to run when the "restart chip" function is used.
# UPLOAD_RESTART_COMMANDS - List of GDB commands to run when the "restart chip" function is used.
# See here for more info: https://github.com/mbed-ce/mbed-os/wiki/Debugger-Commands-and-State-in-Upload-Methods
include(UploadMethod${UPLOAD_METHOD})

Expand Down
31 changes: 31 additions & 0 deletions tools/cmake/upload_methods/FindLinkServer.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright (c) 2023 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

# ----------------------------------------------
# CMake finder for LinkServer, the NXP command-line flash and debug tool
#
# This module defines:
# LinkServer - Whether the reqested tools were found.
# LinkServer_PATH - full path to the LinkServer command line tool.

# Check for LinkServer install folders on Windows
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
# On Windows, LinkServer by default is installed into a subdirectory of
# C:/nxp
file(GLOB LINKSERVER_HINTS LIST_DIRECTORIES TRUE "C:/nxp/LinkServer_*")
elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Darwin")
# On Mac, it was observed to install into /Applications/LinkServer_1.2.45/dist
file(GLOB LINKSERVER_HINTS LIST_DIRECTORIES TRUE "/Applications/LinkServer_*/dist")
else()
set(LINKSERVER_HINTS /usr/local/LinkServer) # Linux package install location
endif()

find_program(LinkServer_PATH
NAMES LinkServer
DOC "Path to the LinkServer executable."
HINTS ${LINKSERVER_HINTS}
)

find_package_handle_standard_args(LinkServer REQUIRED_VARS LinkServer_PATH)


57 changes: 0 additions & 57 deletions tools/cmake/upload_methods/FindRedlink.cmake

This file was deleted.

66 changes: 66 additions & 0 deletions tools/cmake/upload_methods/UploadMethodLINKSERVER.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Copyright (c) 2022 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

### NXP LinkServer Upload Method
# This method needs the following parameters:
# LINKSERVER_DEVICE - Chip name and board to connect to, separated by a colon.
# LINKSERVER_PROBE_SN - Serial number, or serial number substring, of the debug probe to connect to. If blank, will connect to any probe.

set(UPLOAD_SUPPORTS_DEBUG TRUE)

### Handle options
set(LINKSERVER_PROBE_SN "" CACHE STRING "Serial number, or serial number substring, of the debug probe to connect to. If blank, will connect to any probe.")

if("${LINKSERVER_PROBE_SN}" STREQUAL "")
# This argument causes Redlink to connect to the first available debug probe
set(LINKSERVER_PROBE_ARGS "" CACHE INTERNAL "" FORCE)
else()
set(LINKSERVER_PROBE_ARGS --probe ${LINKSERVER_PROBE_SN} CACHE INTERNAL "" FORCE)
endif()

if("${LINKSERVER_DEVICE}" STREQUAL "")
message(FATAL_ERROR "You must set LINKSERVER_DEVICE in your CMake scripts to use REDLINK")
endif()

### Check if upload method can be enabled on this machine
find_package(LinkServer)
set(UPLOAD_LINKSERVER_FOUND ${LinkServer_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 LinkServer..."
COMMAND ${LinkServer_PATH}
flash
${LINKSERVER_PROBE_ARGS}
${LINKSERVER_DEVICE}
load
$<TARGET_FILE:${TARGET_NAME}>)

add_dependencies(flash-${TARGET_NAME} ${TARGET_NAME})

endfunction(gen_upload_target)

### Commands to run the debug server.
set(UPLOAD_GDBSERVER_DEBUG_COMMAND
${LinkServer_PATH}
gdbserver
${LINKSERVER_PROBE_ARGS}
--gdb-port ${GDB_PORT}
${LINKSERVER_DEVICE}
)

# request extended-remote GDB sessions
set(UPLOAD_WANTS_EXTENDED_REMOTE TRUE)

set(UPLOAD_LAUNCH_COMMANDS
"monitor reset" # undocumented, but works
"load"
"break main"
"monitor reset"
)
set(UPLOAD_RESTART_COMMANDS
"monitor reset"
)
92 changes: 0 additions & 92 deletions tools/cmake/upload_methods/UploadMethodREDLINK.cmake

This file was deleted.