blob: b0363e17ec79f3ae69069f4387449ff856b9f2e6 [file] [log] [blame] [edit]
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Support for running OTTF tests on sencha
OTTF_FLASH_RELEASE := $(CHERIOT_OUT_RELEASE)/ottf_flash.tar
# Bazel target for the test case to run; override this on the cmd line; e.g.
# m sencha-ottf OTTF_SMC=smc_tlul_mailbox_test_cheri
OTTF_SEC := tlul_mailbox_test
OTTF_SMC := smc_tlul_mailbox_test_cheri
# NB: the SEC fw image is named "matcha-tock-bundle.bin" to satisfy elfloader
__sencha_ottf_sec: | ${TMP_RELEASE}
cd $(SENCHA_SRC_DIR) && \
bazel build //sw/device/tests:${OTTF_SEC}
cd $(SENCHA_SRC_DIR) && \
find "bazel-matcha/" -wholename "*tests/${OTTF_SEC}_fpga_nexus.bin" \
-exec cp -f '{}' "${TMP_RELEASE}"/ottf_sec.bin \;
# Helper to build the ELF image for the SMC and copy it to the tmp dir
# for constructing the tarball used during boot.
# NB: the SMC fw image is named "kernel" to satisfy elfloader
__sencha_ottf_smc: | ${TMP_RELEASE}
cd $(SENCHA_SRC_DIR) && \
bazel build -s //sw/device/tests/smc:${OTTF_SMC}
cd $(SENCHA_SRC_DIR) && \
find "bazel-bin/" -wholename "*smc/${OTTF_SMC}.elf" \
-exec cp -f '{}' "${TMP_RELEASE}"/ottf_smc.elf \;
cd $(SENCHA_SRC_DIR) && \
find "bazel-matcha/" -wholename "*smc/${OTTF_SMC}.elf" \
-exec $(CACHE)/cheriot-tools/bin/llvm-objdump -glxsdrS --demangle '{}' \
> $(TMP_RELEASE)/$(OTTF_SMC).dump \;
__sencha_ottf_smc-clean:
cd $(SENCHA_SRC_DIR) && bazel clean --expunge
$(OTTF_FLASH_RELEASE): __sencha_ottf_sec __sencha_ottf_smc
tar -C $(TMP_RELEASE) -cvhf $@ ottf_sec.bin ottf_smc.elf
ottf_flash_release: $(OTTF_FLASH_RELEASE)
SENCHA_OTTF_RESC := sim/config/sencha-ottf.resc
# OTTF-specific scripts that side-load the SMC firmware. We
# construct them in make to avoid shell quoting/escape issues.
# The only part done in the shell uses OTTF_FLASH_RELEASE
# which is a dynamically calculated make variable.
OTTF_SCRIPT:= $$repl_file = @${SENCHA_REPL};
OTTF_SCRIPT+= $$sc_bin =@$(TMP_RELEASE)/ottf_sec.bin;
OTTF_SCRIPT+= $$cheriot_elf = @${TMP_RELEASE}/ottf_smc.elf;
OTTF_SCRIPT+= i @${SENCHA_OTTF_RESC};
OTTF_SCRIPT+= $(RENODE_PRESTART_CMDS)
OTTF_CLI_SCRIPT:= $$repl_file = @${SENCHA_REPL};
OTTF_CLI_SCRIPT+= $$sc_bin =@$(TMP_RELEASE)/ottf_sec.bin;
OTTF_CLI_SCRIPT+= $$cheriot_elf = @${TMP_RELEASE}/ottf_smc.elf;
OTTF_CLI_SCRIPT+= $$cli_port=4567;
OTTF_CLI_SCRIPT+= $$wait_for_cli=true;
OTTF_CLI_SCRIPT+= i @${SENCHA_OTTF_RESC};
OTTF_CLI_SCRIPT+= $(RENODE_PRESTART_CMDS)
# XXX $tar is not needed but the .resc loads it
sencha-ottf: renode cheriot_sim kelvin_sim multihart_boot_rom ottf_flash_release
$(RENODE_CMD) -e '$$tar=@${OTTF_FLASH_RELEASE}; ${OTTF_SCRIPT} start'
sencha-ottf+cli: renode cheriot_sim kelvin_sim multihart_boot_rom ottf_flash_release
$(RENODE_CMD) -e '$$tar=@${OTTF_FLASH_RELEASE}; ${OTTF_CLI_SCRIPT} start'
sencha-ottf-clean:
cd $(SENCHA_SRC_DIR) && bazel clean --expunge
rm -rf ${TMP_RELEASE}