|
| 1 | +# Copyright (c) 2022 ARM Limited. All rights reserved. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +# ---------------------------------------------- |
| 5 | +# CMake finder for Redlink, the NXP MCUXpresso debug tool |
| 6 | +# |
| 7 | +# This module defines: |
| 8 | +# Redlink_FOUND - Whether the reqested tools were found. |
| 9 | +# crt_emu_cm_redlink_PATH - full path to the Redlink command line tool (crt_emu_cm_redlink). |
| 10 | +# REDLINK_FLASH_LOADER_PATH - path to the directory where flash loaders are (contains MIMXRT1050_SFDP_HYPERFLASH.cfx) |
| 11 | + |
| 12 | +# first try to locate MCUXpresso IDE in its default location |
| 13 | +set(MCUXPRESSO_IDE_LINUX_HINTS "") |
| 14 | +set(MCUXPRESSO_IDE_WINDOWS_HINTS "") |
| 15 | +if(EXISTS "C:/nxp/") |
| 16 | + # On Windows, MCUXpresso by default is installed into a subdirectory of |
| 17 | + # C:/nxp |
| 18 | + file(GLOB MCUXPRESSO_IDE_WINDOWS_HINTS LIST_DIRECTORIES TRUE "C:/nxp/MCUXpressoIDE_*/ide") |
| 19 | +endif() |
| 20 | + |
| 21 | +find_path(MCUXPRESSO_IDE_PATH |
| 22 | + NAMES mcuxpressoide.ini |
| 23 | + DOC "Path to MCUXPresso IDE. This directory should contain mcuxpressoide.ini. Used to find Redlink" |
| 24 | + PATHS |
| 25 | + ${MCUXPRESSO_IDE_WINDOWS_HINTS} # Windows |
| 26 | + /usr/local/mcuxpressoide/ide # Linux |
| 27 | + /Applications/MCUXpressoIDE.app/Contents/Eclipse # OS X |
| 28 | + ) |
| 29 | + |
| 30 | +set(Redlink_HINTS "") |
| 31 | +if(EXISTS "${MCUXPRESSO_IDE_PATH}") |
| 32 | + message(STATUS "Located MCUXpresso IDE: ${MCUXPRESSO_IDE_PATH}") |
| 33 | + |
| 34 | + # find install dirs inside IDE, which also have version numbers |
| 35 | + file(GLOB REDLINK_INSTALL_DIRS LIST_DIRECTORIES TRUE "${MCUXPRESSO_IDE_PATH}/plugins/com.nxp.mcuxpresso.tools.bin.*/binaries") |
| 36 | + list(GET REDLINK_INSTALL_DIRS 0 REDLINK_INSTALL_DIR) # If glob returns multiple just pick one |
| 37 | + if(EXISTS "${REDLINK_INSTALL_DIR}") |
| 38 | + list(APPEND Redlink_HINTS ${REDLINK_INSTALL_DIR}) |
| 39 | + endif() |
| 40 | +elseif() |
| 41 | + 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.") |
| 42 | +endif() |
| 43 | + |
| 44 | +find_program(crt_emu_cm_redlink_PATH |
| 45 | + NAMES crt_emu_cm_redlink |
| 46 | + DOC "Path to the Redlink crt_emu_cm_redlink executable." |
| 47 | + HINTS ${Redlink_HINTS}) |
| 48 | + |
| 49 | +find_path(REDLINK_FLASH_LOADER_PATH |
| 50 | + NAMES MIMXRT1050_SFDP_HYPERFLASH.cfx |
| 51 | + DOC "Path to the directory where the Redlink flash loaders are (contains MIMXRT1050_SFDP_HYPERFLASH.cfx)." |
| 52 | + HINTS ${Redlink_HINTS} |
| 53 | + PATH_SUFFIXES Flash) |
| 54 | + |
| 55 | +find_package_handle_standard_args(Redlink REQUIRED_VARS crt_emu_cm_redlink_PATH REDLINK_FLASH_LOADER_PATH) |
| 56 | + |
| 57 | + |
0 commit comments