| # Copyright 2021 The ChromiumOS Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE.makefile file. |
| |
| EAPI=7 |
| |
| CROS_WORKON_USE_VCSID=1 |
| CROS_WORKON_PROJECT=( |
| "chromiumos/third_party/zephyr" |
| "chromiumos/third_party/zephyr/cmsis" |
| "chromiumos/third_party/zephyr/hal_stm32" |
| "chromiumos/third_party/zephyr/nanopb" |
| "chromiumos/third_party/zephyr/picolibc" |
| "external/pigweed/pigweed/pigweed" |
| "chromiumos/platform/ec" |
| ) |
| |
| CROS_WORKON_LOCALNAME=( |
| "third_party/zephyr/main" |
| "third_party/zephyr/cmsis" |
| "third_party/zephyr/hal_stm32" |
| "third_party/zephyr/nanopb" |
| "third_party/zephyr/picolibc" |
| "third_party/pigweed" |
| "platform/ec" |
| ) |
| |
| CROS_WORKON_DESTDIR=( |
| "${S}/zephyr-base" |
| "${S}/modules/cmsis" |
| "${S}/modules/hal_stm32" |
| "${S}/modules/nanopb" |
| "${S}/modules/picolibc" |
| "${S}/modules/pigweed" |
| "${S}/modules/ec" |
| ) |
| |
| CROS_WORKON_EGIT_BRANCH=( |
| "main" |
| "chromeos-main" |
| "chromeos-main" |
| "main" |
| "main" |
| "upstream/main" |
| "main" |
| ) |
| |
| inherit cros-workon cros-zephyr-utils coreboot-sdk |
| |
| DESCRIPTION="Zephyr based Embedded Controller firmware" |
| KEYWORDS="~*" |
| |
| BDEPEND=" |
| cross-embedded-arm-eabi/coreboot-sdk |
| cross-embedded-riscv-elf/coreboot-sdk |
| " |
| |
| MERGED_DB="tokens.bin" |
| PROJECT_DB="database.bin" |
| PW_ROOT="${S}/modules/pigweed" |
| |
| # cros-zephyr-compile will generate individual project token databases. |
| # Find all individual project token databases and merge them into single |
| # merged database. |
| merge_token_db() { |
| if [[ -n $(find build -name "${PROJECT_DB}") ]]; then |
| find build -name "${PROJECT_DB}" -exec \ |
| "${PW_ROOT}"/pw_tokenizer/py/pw_tokenizer/database.py \ |
| create --type binary --force --database "build/${MERGED_DB}" {} + \ |
| || die |
| fi |
| } |
| |
| src_compile() { |
| cros-zephyr-compile zephyr-ec |
| merge_token_db |
| } |
| |
| src_install() { |
| local firmware_name project |
| local root_build_dir="build" |
| |
| while read -r firmware_name && read -r project; do |
| if [[ -z "${project}" ]]; then |
| continue |
| fi |
| |
| # Do not strip elf files so debug symbols are available |
| # in the firmware_from_source.tar.bz2 bundles from builders. |
| dostrip -x "/firmware/${firmware_name}"/zephyr.{rw,ro}.elf |
| |
| insinto "/firmware/${firmware_name}" |
| doins "${root_build_dir}/${project}"/output/* |
| |
| # Install token database to projects that enabled tokenization. |
| if [[ -n $(find "${root_build_dir}/${project}" -name "${PROJECT_DB}") ]]; then |
| # Install database into firmware binary output for release handling. |
| doins "${root_build_dir}/${MERGED_DB}" |
| # Install database into DUT location for timberslide detokenizing. |
| insinto "/usr/share/cros_ec/" |
| doins "${root_build_dir}/${MERGED_DB}" |
| fi |
| done < <(cros_config_host "get-firmware-build-combinations" zephyr-ec || die) |
| } |