Mate Toth-Pal | 5495f20 | 2020-07-16 08:33:48 +0200 | [diff] [blame^] | 1 | #!/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 | |
| 17 | set -e |
| 18 | |
| 19 | WORKING_DIRECTORY=/root/work/tfm |
| 20 | MCUBOOT_PATH=$WORKING_DIRECTORY/mcuboot |
| 21 | |
| 22 | TFM_DIR=/root/work/tfm/trusted-firmware-m |
| 23 | TFM_BUILD_DIR=$TFM_DIR/build |
| 24 | MCUBOOT_AXF=install/outputs/MPS2/AN521/bl2.axf |
| 25 | SIGNED_TFM_BIN=install/outputs/MPS2/AN521/tfm_s_ns_signed.bin |
| 26 | QEMU_LOG_FILE=qemu.log |
| 27 | QEMU_PID_FILE=qemu_pid.txt |
| 28 | |
| 29 | source ~/.bashrc |
| 30 | |
| 31 | # build TF-M with MCUBoot |
| 32 | mkdir -p $TFM_BUILD_DIR |
| 33 | cd $TFM_DIR |
| 34 | cmake -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 | . |
| 44 | cd $TFM_BUILD_DIR |
| 45 | make -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 | |
| 58 | sleep 7 |
| 59 | |
| 60 | cat $QEMU_LOG_FILE |