3 # This file is part of mbed TLS (https://tls.mbed.org)
5 # Copyright (c) 2015-2016, ARM Limited, All Rights Reserved
9 # This script determines ROM size (or code size) for the standard mbed TLS
10 # configurations, when built for a Cortex M3/M4 target.
12 # Configurations included:
13 # default include/mbedtls/config.h
14 # yotta yotta/module/mbedtls/config.h
15 # thread configs/config-thread.h
16 # suite-b configs/config-suite-b.h
17 # psk configs/config-ccm-psk-tls1_2.h
23 CONFIG_H='include/mbedtls/config.h'
25 if [ -r $CONFIG_H ]; then :; else
26 echo "$CONFIG_H not found" >&2
27 echo "This script needs to be run from the root of" >&2
28 echo "a git checkout or uncompressed tarball" >&2
32 if grep -i cmake Makefile >/dev/null; then
33 echo "Not compatible with CMake" >&2
37 if which arm-none-eabi-gcc >/dev/null 2>&1; then :; else
38 echo "You need the ARM-GCC toolchain in your path" >&2
39 echo "See https://launchpad.net/gcc-arm-embedded/" >&2
43 ARMGCC_FLAGS='-Os -march=armv7-m -mthumb'
44 OUTFILE='00-footprint-summary.txt'
49 echo "$@" >> "$OUTFILE"
60 cp $CONFIG_H ${CONFIG_H}.bak
61 if [ "$FILE" != $CONFIG_H ]; then
66 scripts/config.pl unset MBEDTLS_NET_C || true
67 scripts/config.pl unset MBEDTLS_TIMING_C || true
68 scripts/config.pl unset MBEDTLS_FS_IO || true
69 scripts/config.pl --force set MBEDTLS_NO_PLATFORM_ENTROPY || true
73 CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld \
74 CFLAGS="$ARMGCC_FLAGS" make lib >/dev/null
76 OUT="size-${NAME}.txt"
77 arm-none-eabi-size -t library/libmbed*.a > "$OUT"
78 log "$( head -n1 "$OUT" )"
79 log "$( tail -n1 "$OUT" )"
81 cp ${CONFIG_H}.bak $CONFIG_H
84 # truncate the file just this time
85 echo "(generated by $0)" > "$OUTFILE"
88 log "Footprint of standard configurations (minus net_sockets.c, timing.c, fs_io)"
89 log "for bare-metal ARM Cortex-M3/M4 microcontrollers."
91 VERSION_H="include/mbedtls/version.h"
92 MBEDTLS_VERSION=$( sed -n 's/.*VERSION_STRING *"\(.*\)"/\1/p' $VERSION_H )
93 if git rev-parse HEAD >/dev/null; then
94 GIT_HEAD=$( git rev-parse HEAD | head -c 10 )
95 GIT_VERSION=" (git head: $GIT_HEAD)"
101 log "mbed TLS $MBEDTLS_VERSION$GIT_VERSION"
102 log "$( arm-none-eabi-gcc --version | head -n1 )"
103 log "CFLAGS=$ARMGCC_FLAGS"
105 # creates the yotta config
106 yotta/create-module.sh >/dev/null
108 doit default include/mbedtls/config.h
109 doit yotta yotta/module/mbedtls/config.h
110 doit thread configs/config-thread.h
111 doit suite-b configs/config-suite-b.h
112 doit psk configs/config-ccm-psk-tls1_2.h
114 zip mbedtls-footprint.zip "$OUTFILE" size-*.txt >/dev/null