blob: 88067766a28bc299e71b55e6c71f1f27e6f9645e [file] [log] [blame]
Mate Toth-Pal5495f202020-07-16 08:33:48 +02001#!/bin/bash -x
2
3# Copyright (c) 2020 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
21
22TFM_DIR=/root/work/tfm/trusted-firmware-m
23TFM_BUILD_DIR=$TFM_DIR/build
24MCUBOOT_AXF=install/outputs/MPS2/AN521/bl2.axf
25SIGNED_TFM_BIN=install/outputs/MPS2/AN521/tfm_s_ns_signed.bin
26QEMU_LOG_FILE=qemu.log
27QEMU_PID_FILE=qemu_pid.txt
28
29source ~/.bashrc
30
31# build TF-M with MCUBoot
32mkdir -p $TFM_BUILD_DIR
33cd $TFM_DIR
34cmake -B $TFM_BUILD_DIR \
35 -DCMAKE_BUILD_TYPE=Release \
36 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake \
37 -DTFM_PLATFORM=mps2/an521 \
38 -DTEST_NS=ON \
39 -DTEST_S=ON \
40 -DTFM_PSA_API=ON \
41 -DMCUBOOT_PATH=$MCUBOOT_PATH \
42 -DMCUBOOT_LOG_LEVEL=INFO \
43 .
44cd $TFM_BUILD_DIR
45make -j install
46
47# Run MCUBoot and TF-M in QEMU
48/usr/bin/qemu-system-arm \
49 -M mps2-an521 \
50 -kernel $MCUBOOT_AXF \
51 -device loader,file=$SIGNED_TFM_BIN,addr=0x10080000 \
52 -chardev file,id=char0,path=$QEMU_LOG_FILE \
53 -serial chardev:char0 \
54 -display none \
55 -pidfile $QEMU_PID_FILE \
56 -daemonize
57
58sleep 7
59
60cat $QEMU_LOG_FILE