| 1 | #!/bin/sh
|
|---|
| 2 |
|
|---|
| 3 | set -eu
|
|---|
| 4 |
|
|---|
| 5 | CONFIG_H='include/mbedtls/config.h'
|
|---|
| 6 |
|
|---|
| 7 | if [ -r $CONFIG_H ]; then :; else
|
|---|
| 8 | echo "$CONFIG_H not found" >&2
|
|---|
| 9 | echo "This script needs to be run from the root of" >&2
|
|---|
| 10 | echo "a git checkout or uncompressed tarball" >&2
|
|---|
| 11 | exit 1
|
|---|
| 12 | fi
|
|---|
| 13 |
|
|---|
| 14 | if grep -i cmake Makefile >/dev/null; then
|
|---|
| 15 | echo "Not compatible with CMake" >&2
|
|---|
| 16 | exit 1
|
|---|
| 17 | fi
|
|---|
| 18 |
|
|---|
| 19 | if which arm-none-eabi-gcc >/dev/null 2>&1; then :; else
|
|---|
| 20 | echo "You need the ARM-GCC toolchain in your path" >&2
|
|---|
| 21 | echo "See https://launchpad.net/gcc-arm-embedded/" >&2
|
|---|
| 22 | exit 1
|
|---|
| 23 | fi
|
|---|
| 24 |
|
|---|
| 25 | ARMGCC_FLAGS='-Os -march=armv7-m -mthumb'
|
|---|
| 26 | OUTFILE='00-footprint-summary.txt'
|
|---|
| 27 |
|
|---|
| 28 | log()
|
|---|
| 29 | {
|
|---|
| 30 | echo "$@"
|
|---|
| 31 | echo "$@" >> "$OUTFILE"
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | doit()
|
|---|
| 35 | {
|
|---|
| 36 | NAME="$1"
|
|---|
| 37 | FILE="$2"
|
|---|
| 38 |
|
|---|
| 39 | log ""
|
|---|
| 40 | log "$NAME ($FILE):"
|
|---|
| 41 |
|
|---|
| 42 | cp $CONFIG_H ${CONFIG_H}.bak
|
|---|
| 43 | if [ "$FILE" != $CONFIG_H ]; then
|
|---|
| 44 | cp "$FILE" $CONFIG_H
|
|---|
| 45 | fi
|
|---|
| 46 |
|
|---|
| 47 | {
|
|---|
| 48 | scripts/config.pl unset MBEDTLS_NET_C || true
|
|---|
| 49 | scripts/config.pl unset MBEDTLS_TIMING_C || true
|
|---|
| 50 | scripts/config.pl unset MBEDTLS_FS_IO || true
|
|---|
| 51 | } >/dev/null 2>&1
|
|---|
| 52 |
|
|---|
| 53 | CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld \
|
|---|
| 54 | CFLAGS="$ARMGCC_FLAGS" make clean lib >/dev/null
|
|---|
| 55 |
|
|---|
| 56 | OUT="size-${NAME}.txt"
|
|---|
| 57 | arm-none-eabi-size -t library/libmbed*.a > "$OUT"
|
|---|
| 58 | log "$( head -n1 "$OUT" )"
|
|---|
| 59 | log "$( tail -n1 "$OUT" )"
|
|---|
| 60 |
|
|---|
| 61 | cp ${CONFIG_H}.bak $CONFIG_H
|
|---|
| 62 | }
|
|---|
| 63 |
|
|---|
| 64 | # truncate the file just this time
|
|---|
| 65 | echo "(generated by $0)" > "$OUTFILE"
|
|---|
| 66 | echo "" >> "$OUTFILE"
|
|---|
| 67 |
|
|---|
| 68 | log "Footprint of standard configurations (minus net.c, timing.c, fs_io)"
|
|---|
| 69 | log "for bare-metal ARM Cortex-M3/M4 microcontrollers."
|
|---|
| 70 |
|
|---|
| 71 | VERSION_H="include/mbedtls/version.h"
|
|---|
| 72 | MBEDTLS_VERSION=$( sed -n 's/.*VERSION_STRING *"\(.*\)"/\1/p' $VERSION_H )
|
|---|
| 73 | if git rev-parse HEAD >/dev/null; then
|
|---|
| 74 | GIT_HEAD=$( git rev-parse HEAD | head -c 10 )
|
|---|
| 75 | GIT_VERSION=" (git head: $GIT_HEAD)"
|
|---|
| 76 | else
|
|---|
| 77 | GIT_VERSION=""
|
|---|
| 78 | fi
|
|---|
| 79 |
|
|---|
| 80 | log ""
|
|---|
| 81 | log "mbed TLS $MBEDTLS_VERSION$GIT_VERSION"
|
|---|
| 82 | log "$( arm-none-eabi-gcc --version | head -n1 )"
|
|---|
| 83 | log "CFLAGS=$ARMGCC_FLAGS"
|
|---|
| 84 |
|
|---|
| 85 | # creates the yotta config
|
|---|
| 86 | yotta/create-module.sh >/dev/null
|
|---|
| 87 |
|
|---|
| 88 | doit default include/mbedtls/config.h
|
|---|
| 89 | doit yotta yotta/module/mbedtls/config.h
|
|---|
| 90 | doit thread configs/config-thread.h
|
|---|
| 91 | doit suite-b configs/config-suite-b.h
|
|---|
| 92 | doit psk configs/config-ccm-psk-tls1_2.h
|
|---|
| 93 |
|
|---|
| 94 | zip mbedtls-footprint.zip "$OUTFILE" size-*.txt >/dev/null
|
|---|