1# 2# Copyright (c) 2022 Microchip Technology Inc. 3# 4# SPDX-License-Identifier: Apache-2.0 5# 6 7zephyr_library() 8 9#Allow users to pre-specify the tool using '-DMEC172X_SPI_GEN=<path-to-tool>/toolname' 10if (NOT DEFINED MEC172X_SPI_GEN) 11 set(MEC172X_SPI_GEN $ENV{MEC172X_SPI_GEN}) 12endif() 13find_program (MEC172X_SPI_GEN NAMES mec172x_spi_gen_lin_x86_64 mec172x_spi_gen) 14if(MEC172X_SPI_GEN STREQUAL MEC172X_SPI_GEN-NOTFOUND) 15 message(WARNING "Microchip SPI Image Generation tool is not available. SPI Image will not be generated.") 16endif() 17 18if (NOT DEFINED MEC172X_SPI_CFG) 19 set(MEC172X_SPI_CFG $ENV{MEC172X_SPI_CFG}) 20endif() 21find_file (MEC172X_SPI_CFG NAMES spi_cfg_4MBit.txt spi_cfg_128MBit.txt spi_cfg.txt PATHS ${BOARD_DIR}/support) 22if(MEC172X_SPI_CFG STREQUAL MEC172X_SPI_CFG-NOTFOUND) 23 message(WARNING "Microchip SPI Image Generation tool configuration file is not available. SPI Image will not be generated.") 24endif() 25 26if (NOT MEC172X_SPI_GEN STREQUAL MEC172X_SPI_GEN-NOTFOUND AND NOT MEC172X_SPI_CFG STREQUAL MEC172X_SPI_CFG-NOTFOUND) 27 set_property(GLOBAL APPEND PROPERTY extra_post_build_commands 28 COMMAND ${MEC172X_SPI_GEN} 29 -i ${MEC172X_SPI_CFG} 30 -o ${PROJECT_BINARY_DIR}/${SPI_IMAGE_NAME} 31 ) 32 33 unset(MEC172X_SPI_GEN) 34 unset(MEC172X_SPI_CFG) 35endif() 36