Manuel Pégourié-Gonnard | ac8673c | 2015-10-16 13:03:04 +0200 | [diff] [blame] | 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 |
Manuel Pégourié-Gonnard | 4553a6c | 2015-11-25 10:39:00 +0000 | [diff] [blame] | 9 | echo "This script needs to be run from the root of" >&2 |
| 10 | echo "a git checkout or uncompressed tarball" >&2 |
Manuel Pégourié-Gonnard | ac8673c | 2015-10-16 13:03:04 +0200 | [diff] [blame] | 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 | |
Manuel Pégourié-Gonnard | 4553a6c | 2015-11-25 10:39:00 +0000 | [diff] [blame] | 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 | |
Manuel Pégourié-Gonnard | ac8673c | 2015-10-16 13:03:04 +0200 | [diff] [blame] | 34 | doit() |
| 35 | { |
| 36 | NAME="$1" |
| 37 | FILE="$2" |
| 38 | |
Manuel Pégourié-Gonnard | 4553a6c | 2015-11-25 10:39:00 +0000 | [diff] [blame] | 39 | log "" |
| 40 | log "$NAME ($FILE):" |
Manuel Pégourié-Gonnard | ac8673c | 2015-10-16 13:03:04 +0200 | [diff] [blame] | 41 | |
| 42 | cp $CONFIG_H ${CONFIG_H}.bak |
Manuel Pégourié-Gonnard | 4553a6c | 2015-11-25 10:39:00 +0000 | [diff] [blame] | 43 | if [ "$FILE" != $CONFIG_H ]; then |
| 44 | cp "$FILE" $CONFIG_H |
| 45 | fi |
Manuel Pégourié-Gonnard | ac8673c | 2015-10-16 13:03:04 +0200 | [diff] [blame] | 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 \ |
Manuel Pégourié-Gonnard | 4553a6c | 2015-11-25 10:39:00 +0000 | [diff] [blame] | 54 | CFLAGS="$ARMGCC_FLAGS" make clean lib >/dev/null |
Manuel Pégourié-Gonnard | ac8673c | 2015-10-16 13:03:04 +0200 | [diff] [blame] | 55 | |
| 56 | OUT="size-${NAME}.txt" |
| 57 | arm-none-eabi-size -t library/libmbed*.a > "$OUT" |
Manuel Pégourié-Gonnard | 4553a6c | 2015-11-25 10:39:00 +0000 | [diff] [blame] | 58 | log "$( head -n1 "$OUT" )" |
| 59 | log "$( tail -n1 "$OUT" )" |
Manuel Pégourié-Gonnard | ac8673c | 2015-10-16 13:03:04 +0200 | [diff] [blame] | 60 | |
| 61 | cp ${CONFIG_H}.bak $CONFIG_H |
| 62 | } |
| 63 | |
Manuel Pégourié-Gonnard | 4553a6c | 2015-11-25 10:39:00 +0000 | [diff] [blame] | 64 | # truncate the file just this time |
| 65 | echo "(generated by $0)" > "$OUTFILE" |
| 66 | echo "" >> "$OUTFILE" |
| 67 | |
Manuel Pégourié-Gonnard | 3134ef0 | 2015-11-25 10:50:27 +0000 | [diff] [blame] | 68 | log "Footprint of standard configurations (minus net.c, timing.c, fs_io)" |
Manuel Pégourié-Gonnard | 4553a6c | 2015-11-25 10:39:00 +0000 | [diff] [blame] | 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 ) |
Manuel Pégourié-Gonnard | 3134ef0 | 2015-11-25 10:50:27 +0000 | [diff] [blame] | 75 | GIT_VERSION=" (git head: $GIT_HEAD)" |
Manuel Pégourié-Gonnard | 4553a6c | 2015-11-25 10:39:00 +0000 | [diff] [blame] | 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 | |
Manuel Pégourié-Gonnard | ac8673c | 2015-10-16 13:03:04 +0200 | [diff] [blame] | 85 | # creates the yotta config |
| 86 | yotta/create-module.sh >/dev/null |
| 87 | |
Manuel Pégourié-Gonnard | 4553a6c | 2015-11-25 10:39:00 +0000 | [diff] [blame] | 88 | doit default include/mbedtls/config.h |
Manuel Pégourié-Gonnard | ac8673c | 2015-10-16 13:03:04 +0200 | [diff] [blame] | 89 | doit yotta yotta/module/mbedtls/config.h |
| 90 | doit thread configs/config-thread.h |
Manuel Pégourié-Gonnard | 4553a6c | 2015-11-25 10:39:00 +0000 | [diff] [blame] | 91 | doit suite-b configs/config-suite-b.h |
Manuel Pégourié-Gonnard | ac8673c | 2015-10-16 13:03:04 +0200 | [diff] [blame] | 92 | doit psk configs/config-ccm-psk-tls1_2.h |
Manuel Pégourié-Gonnard | 4553a6c | 2015-11-25 10:39:00 +0000 | [diff] [blame] | 93 | |
| 94 | zip mbedtls-footprint.zip "$OUTFILE" size-*.txt >/dev/null |