1# Copyright 2023 The ChromiumOS Authors
2# SPDX-License-Identifier: Apache-2.0
3
4zephyr_library_sources(soc.c irq.c mbox.c)
5
6zephyr_library_sources_ifdef(CONFIG_SOC_SERIES_MT8195 cpuclk.c)
7
8set(SOC_LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIG_SOC}/linker.ld CACHE INTERNAL "")
9
10add_custom_target(dsp_img ALL
11	DEPENDS ${ZEPHYR_FINAL_EXECUTABLE}
12	COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gen_img.py
13		${ZEPHYR_BINARY_DIR}/${KERNEL_ELF_NAME}
14		${CMAKE_BINARY_DIR}/zephyr/zephyr.img)
15
16# Sign zephyr.ri using west (if the underlying rimage tool is
17# available; generally it isn't except in SOF builds).  Note that the
18# "target" string to use for rimage is set at the board level as a
19# RIMAGE_TARGET cached (cached so that the python script can read it!)
20# cmake variable (not kconfig!).  See board_set_rimage_target().
21# Thankfully the SOC name and the rimage target names for these
22# platforms are identical.  The west sign integration similarly needs
23# a RIMAGE_CONFIG_PATH cmake cached (!) variable set to a directory
24# containing the .toml files for the platforms, which SOF will set on
25# its own at build time.  And likewise the signing key isn't provided
26# by Zephyr and needs tob e found by a SOF build by passing it in
27# RIMAGE_SIGN_KEY.
28#
29# The short version is that zephyr.ri can only realistically be
30# exercised from a SOF build and it doesn't belong here in Zephyr;
31# rimage is a SOF tool.  Signing audio firmware is only done for SOF
32# firmware and not general Zephyr apps for the same hardware. This
33# should live in SOF where it doesn't have to be duplicated for every
34# device and where it won't be forced to communicate via side channels.
35board_set_rimage_target(${CONFIG_SOC})
36set(RIMAGE_SIGN_KEY "otc_private_key_3k.pem" CACHE STRING "default rimage key")
37add_custom_target(zephyr.ri ALL DEPENDS ${CMAKE_BINARY_DIR}/zephyr/zephyr.ri)
38add_custom_command(
39	OUTPUT ${CMAKE_BINARY_DIR}/zephyr/zephyr.ri
40	COMMENT "Sign with rimage..."
41	COMMAND west $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose> sign
42                     --if-tool-available --tool rimage --build-dir ${CMAKE_BINARY_DIR}
43	DEPENDS ${CMAKE_BINARY_DIR}/zephyr/${KERNEL_ELF_NAME}
44)
45