Skip to content

Commit 5495f20

Browse files
matetothpalnvlsianpu
authored andcommitted
travis: Build MCUBoot for Armv8-M
Build MCUBoot with TF-M build system for AN521 platform, and run it in QEMU. The result of the test run is not evaluated yet. Change-Id: I5fbfef8e6d8dec99a8e3e00d659a07ccfcaf0b5b Signed-off-by: Mate Toth-Pal <[email protected]>
1 parent b681028 commit 5495f20

File tree

6 files changed

+221
-0
lines changed

6 files changed

+221
-0
lines changed

.travis.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Travis configuration. Run FI hardening tests.
2+
3+
language: minimal
4+
5+
services:
6+
- docker
7+
8+
matrix:
9+
include:
10+
- os: linux
11+
language: minimal
12+
env: TEST=fih-tests
13+
14+
before_install:
15+
- |
16+
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
17+
./ci/check-signed-off-by.sh
18+
if [ $? -ne 0 ]; then
19+
exit 1
20+
fi
21+
fi
22+
23+
install:
24+
- ./ci/${TEST}_install.sh
25+
26+
script:
27+
- ./ci/${TEST}_run.sh
28+
29+
notifications:
30+
slack:
31+
rooms:
32+
- secure: "Tg9ZvJfb6e4QSEsxUvwW2MIqbuNRxD4nAOkgs8eopj/fRtqN6Zk06NVSeMmYcZunDFJXUSzYANBsF98OtaaUlm4WVt2T0ZFBJZrOYfIv18/zXCjYa04sDxur57F1ZYTYKyRpdUkfzPd/rGE4jKLQNcia+r/BTQbJkcZbXeg5/6cUeMP1so8/o0oMhSQP+GH0fLbyLzx3VPE8zu6+j2fCFC7R3idxtfO9VtsKlubfi3HgPgXTs+DEAAA8aoOku2esjFSFXTtdUFGz90YzyShZvtMcRg3Grp9+PZAsJwWk4eKSonKCO0DScfPUlMZbJcV7VsmyTxYKLLsGRZae6ZBH+XLfx5XeqgtgCor3FYx2dUXYfV9y8VvERDdossB0gZ/V2OUGePctDefiORytV6dMa7X3AfSdosgs/tjG4kbf+PMaVULzwF6dd3CdsxdClSl68UQPWA6wC2TEyo1EQea8jgZU6heLustZaQZhBkFkr/6j75XeGBjPw2fgVRkgg/OnTOYmo7N8181wOU+xORIEO1BtYmgRpc0cgpm4H9457diSHG1D2SoNy4tiQPCW2enN00QNGK5pZSL/FGA/ReUcALgAW0QcOljjU2bUSGPxo/VAi5ZyljWgVAGQ5qHJ4jgdfPf7VJUzCVH64G1S5+0gZPpO6vvvPdZtqeXrfBZMOBw="
33+
on_success: always

ci/fih-tests_install.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
# get mcuboot root; assumes running script is stored under REPO_DIR/ci/
20+
REPO_DIR=$(dirname $(dirname $(realpath $0)))
21+
pushd $(mktemp -d)
22+
23+
# copy mcuboot so that it is part of the docker build context
24+
cp -r $REPO_DIR .
25+
cp -r $REPO_DIR/ci/fih_test_docker/execute_test.sh .
26+
cp -r $REPO_DIR/ci/fih_test_docker/Dockerfile .
27+
./mcuboot/ci/fih_test_docker/build.sh
28+
popd

ci/fih-tests_run.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
docker run mcuboot/fih-test /bin/sh -c '/root/execute_test.sh'

ci/fih_test_docker/Dockerfile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright (c) 2020 Arm Limited
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
FROM ubuntu:focal
16+
17+
# get dependencies for retrieving and building TF-M with MCUBoot, and QEMU.
18+
RUN apt-get update && \
19+
DEBIAN_FRONTEND="noninteractive" \
20+
apt-get install -y \
21+
cmake \
22+
curl \
23+
gcc-arm-none-eabi \
24+
gdb-multiarch \
25+
git \
26+
libncurses5 \
27+
python3 \
28+
python3-pip \
29+
qemu-system-arm
30+
31+
RUN \
32+
# installing python packages
33+
python3 -m pip install \
34+
imgtool==1.6.0 \
35+
Jinja2==2.10 \
36+
PyYAML==3.12 \
37+
pyasn1==0.1.9
38+
39+
# Clone TF-M and dependencies
40+
RUN mkdir -p /root/work/tfm &&\
41+
cd /root/work/tfm &&\
42+
git clone https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git -b TF-Mv1.2-RC1 &&\
43+
mkdir mcuboot
44+
45+
# Copy the test execution script to the image
46+
COPY execute_test.sh /root
47+
# copy the MCUBoot under test to the image
48+
COPY mcuboot /root/work/tfm/mcuboot
49+
50+
# run the command
51+
CMD ["bash"]

ci/fih_test_docker/build.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
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+
trap cleanup_exit INT TERM EXIT
20+
21+
cleanup_exit()
22+
{
23+
rm -f *.list *.key
24+
}
25+
26+
export LANG=C
27+
28+
image=mcuboot/fih-test
29+
docker build --pull --tag=$image .
30+
echo $image > .docker-tag

ci/fih_test_docker/execute_test.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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

0 commit comments

Comments
 (0)