1# SPDX-License-Identifier: Apache-2.0
2
3zephyr_include_directories(.)
4zephyr_sources_ifdef(CONFIG_PM power.c)
5zephyr_sources(
6  scfg.c
7  registers.c
8)
9
10# Check for disabling header CRC.
11if (NOT DEFINED CONFIG_NPCX_HEADER_ENABLE_HEADER_CRC)
12    set(NPCX_HEADER_HCRC "-nohcrc")
13endif()
14
15# Check for disabling firmware CRC.
16if (NOT DEFINED CONFIG_NPCX_HEADER_ENABLE_FIRMWARE_CRC)
17    set(NPCX_HEADER_FCRC "-nofcrc")
18endif()
19
20if (DEFINED CONFIG_NPCX_IMAGE_OUTPUT_BIN)
21  set(NPCX_BIN_NAME ${CONFIG_KERNEL_BIN_NAME}.npcx.bin)
22  set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
23    COMMAND ${PYTHON_EXECUTABLE} ${SOC_DIR}/${ARCH}/${SOC_FAMILY}/common/ecst/ecst.py
24    -i ${KERNEL_BIN_NAME}
25    -o ${NPCX_BIN_NAME}
26    ${NPCX_HEADER_HCRC} ${NPCX_HEADER_FCRC}
27    -chip ${CONFIG_NPCX_HEADER_CHIP}
28    -flashsize ${CONFIG_NPCX_HEADER_FLASH_SIZE}
29    -spiclkratio ${CONFIG_NPCX_HEADER_CORE_CLOCK_SPI_CLOCK_RATIO}
30    -spimaxclk ${CONFIG_NPCX_HEADER_SPI_MAX_CLOCK}
31    -spireadmode ${CONFIG_NPCX_HEADER_SPI_READ_MODE}
32  )
33  if (DEFINED CONFIG_NPCX_IMAGE_OUTPUT_HEX)
34    set(NPCX_HEX_NAME ${CONFIG_KERNEL_BIN_NAME}.npcx.hex)
35    # Property magic which makes west flash choose right file.
36    set_property(TARGET runners_yaml_props_target PROPERTY hex_file "${CONFIG_KERNEL_BIN_NAME}.npcx.hex")
37    set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
38    COMMAND $<TARGET_PROPERTY:bintools,elfconvert_command>
39            $<TARGET_PROPERTY:bintools,elfconvert_flag>
40            $<TARGET_PROPERTY:bintools,elfconvert_flag_intarget>binary
41            $<TARGET_PROPERTY:bintools,elfconvert_flag_outtarget>ihex
42            $<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${NPCX_BIN_NAME}
43            $<TARGET_PROPERTY:bintools,elfconvert_flag_outfile>${NPCX_HEX_NAME}
44            $<TARGET_PROPERTY:bintools,elfconvert_flag_final>
45    )
46  endif()
47endif()
48