aboutsummaryrefslogtreecommitdiff
path: root/lite-tf-m/tfm-build.sh
blob: edb440f892b95e67074901721b8f5a74a1bc7b7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# Copyright (c) 2020, Linaro. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause

# Exit on error
set -e

# Cleanup previous build artifacts
rm -rf CMakeCache.txt CMakeFiles cmake_install.cmake install bl2 secure_fw app unit_test test

# Set the readlink binary name:
if [ "$(uname)" == "Darwin" ]; then
    # For OS X this should be be 'greadlink' (brew install coreutils)
    readlink=greadlink
else
    # For Linux this should be 'readlink'
    readlink=readlink
fi

# Set the config file to use
#configfile=ConfigRegression

#target=AN521

# Generate the S and NS makefiles
#cmake -G"Unix Makefiles" \
#        -DPROJ_CONFIG=`$readlink -f ../configs/$configfile.cmake` \
#        -DTARGET_PLATFORM=$target \
#        -DCMAKE_BUILD_TYPE=Debug \
#        -DBL2=False \
#        -DCOMPILER=GNUARM \
#        ../

cmake -DTFM_PLATFORM=mps2/an521 \
      -DTFM_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake \
      -DCMAKE_BUILD_TYPE=Debug \
      -DBL2=False \
      -DTEST_S=ON -DTEST_NS=ON \
      -DTFM_TEST_REPO_PATH=../../tf-m-tests \
      ../

# Build the binaries
make install

# Convert S and NS binaries to .hex file
arm-none-eabi-objcopy -S --gap-fill 0xff -O ihex \
        install/outputs/*/*/tfm_s.axf tfm_s.hex
arm-none-eabi-objcopy -S --gap-fill 0xff -O ihex \
        install/outputs/*/*/tfm_ns.axf tfm_ns.hex

# Generate a single hex file for convenience/QEMU sake
srec_cat tfm_s.hex -Intel tfm_ns.hex -Intel -o tfm_full.hex -Intel