blob: 26f3e4a1997f6b69ac470de8180696cc44bb6fc7 [file] [log] [blame]
Alan Green9b7a93d2021-03-11 14:24:52 +11001#!/bin/bash
2
3# Builds code and prints binary sizes. For now, this only reports sizes of MCU
4# binaries as that is by far the most space-constrained.
5
Alan Green9b7a93d2021-03-11 14:24:52 +11006PROJECT_ROOT=$(realpath $(dirname ${BASH_SOURCE[0]})/..)
David Lattimorebcc2d842021-03-19 14:28:26 +11007
8source $PROJECT_ROOT/environment
9
10set -e
Alan Green9b7a93d2021-03-11 14:24:52 +110011STAGE0="${PROJECT_ROOT}/mcu_rom/stage0/target/thumbv6m-none-eabi/release/stage0.bin"
12STAGE1="${PROJECT_ROOT}/mcu_rom/stage1/target/thumbv6m-none-eabi/release/stage1.bin"
David Lattimorebcc2d842021-03-19 14:28:26 +110013APPLICATION="${PROJECT_ROOT}/mcu_rom/application/target/thumbv6m-none-eabi/release/application.bin"
Alan Green9b7a93d2021-03-11 14:24:52 +110014(
15 cd "${PROJECT_ROOT}/mcu_rom/stage0"
David Lattimorebcc2d842021-03-19 14:28:26 +110016 cargo +$RUST_VERSION build --release
Alan Green9b7a93d2021-03-11 14:24:52 +110017 arm-none-eabi-objcopy \
18 -O binary \
19 target/thumbv6m-none-eabi/release/stage0 \
20 "$STAGE0"
21)
22(
23 cd "${PROJECT_ROOT}/mcu_rom/stage1"
David Lattimorebcc2d842021-03-19 14:28:26 +110024 cargo +$RUST_VERSION build --release
Alan Green9b7a93d2021-03-11 14:24:52 +110025 arm-none-eabi-objcopy \
26 -O binary \
27 target/thumbv6m-none-eabi/release/stage1 \
28 "$STAGE1"
29)
David Lattimorebcc2d842021-03-19 14:28:26 +110030(
31 cd "${PROJECT_ROOT}/mcu_rom/application"
32 cargo +$RUST_VERSION build --release
33 arm-none-eabi-objcopy \
34 -O binary \
35 target/thumbv6m-none-eabi/release/application \
36 "$APPLICATION"
37)
Alan Green9b7a93d2021-03-11 14:24:52 +110038echo
39STAGE0_SIZE=$(stat --printf='%s' "$STAGE0")
40STAGE1_SIZE=$(stat --printf='%s' "$STAGE1")
David Lattimorebcc2d842021-03-19 14:28:26 +110041APPLICATION_SIZE=$(stat --printf='%s' "$APPLICATION")
Alan Green9b7a93d2021-03-11 14:24:52 +110042echo "Stage0: ${STAGE0_SIZE} bytes"
43echo "Stage1: ${STAGE1_SIZE} bytes"
David Lattimorebcc2d842021-03-19 14:28:26 +110044echo "Application: ${APPLICATION_SIZE} bytes"