1#!/bin/bash -x 2 3# Copyright (c) 2020-2023 Arm Limited 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17set -e 18 19WORKING_DIRECTORY=/root/work/tfm 20MCUBOOT_PATH=$WORKING_DIRECTORY/mcuboot 21TFM_DIR=$WORKING_DIRECTORY/trusted-firmware-m 22TFM_BUILD_DIR=$TFM_DIR/build 23 24SKIP_SIZE=$1 25BUILD_TYPE=$2 26DAMAGE_TYPE=$3 27FIH_LEVEL=$4 28 29if test -z "$FIH_LEVEL"; then 30 # Use the default level 31 CMAKE_FIH_LEVEL="" 32else 33 CMAKE_FIH_LEVEL="-DMCUBOOT_FIH_PROFILE=\"$FIH_LEVEL\"" 34fi 35 36# build TF-M with MCUBoot 37mkdir -p $TFM_BUILD_DIR 38cd $TFM_DIR 39cmake -B $TFM_BUILD_DIR \ 40 -DTFM_SPM_LOG_LEVEL=TFM_SPM_LOG_LEVEL_INFO \ 41 -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ 42 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake \ 43 -DTFM_PLATFORM=arm/mps2/an521 \ 44 -DTEST_NS=ON \ 45 -DTEST_S=ON \ 46 -DTFM_PSA_API=ON \ 47 -DMCUBOOT_PATH=$MCUBOOT_PATH \ 48 -DMCUBOOT_LOG_LEVEL=INFO \ 49 $CMAKE_FIH_LEVEL \ 50 . 51cd $TFM_BUILD_DIR 52make -j install 53 54BOOTLOADER_AXF='./install/outputs/bl2.axf' 55 56$MCUBOOT_PATH/ci/fih_test_docker/run_fi_test.sh $BOOTLOADER_AXF $SKIP_SIZE $DAMAGE_TYPE> fih_test_output.yaml 57 58echo "" 59echo "test finished with" 60echo " - BUILD_TYPE: $BUILD_TYPE" 61echo " - FIH_LEVEL: $FIH_LEVEL" 62echo " - SKIP_SIZE: $SKIP_SIZE" 63echo " - DAMAGE_TYPE: $DAMAGE_TYPE" 64 65python3 $MCUBOOT_PATH/ci/fih_test_docker/generate_test_report.py fih_test_output.yaml 66python3 $MCUBOOT_PATH/ci/fih_test_docker/validate_output.py fih_test_output.yaml $SKIP_SIZE $FIH_LEVEL 67