blob: 219362b572f9c0b028e5e4e65368fc5f7a2e1c08 [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
6set -e
7PROJECT_ROOT=$(realpath $(dirname ${BASH_SOURCE[0]})/..)
8STAGE0="${PROJECT_ROOT}/mcu_rom/stage0/target/thumbv6m-none-eabi/release/stage0.bin"
9STAGE1="${PROJECT_ROOT}/mcu_rom/stage1/target/thumbv6m-none-eabi/release/stage1.bin"
10(
11 cd "${PROJECT_ROOT}/mcu_rom/stage0"
12 cargo build --release
13 arm-none-eabi-objcopy \
14 -O binary \
15 target/thumbv6m-none-eabi/release/stage0 \
16 "$STAGE0"
17)
18(
19 cd "${PROJECT_ROOT}/mcu_rom/stage1"
20 cargo build --release
21 arm-none-eabi-objcopy \
22 -O binary \
23 target/thumbv6m-none-eabi/release/stage1 \
24 "$STAGE1"
25)
26echo
27STAGE0_SIZE=$(stat --printf='%s' "$STAGE0")
28STAGE1_SIZE=$(stat --printf='%s' "$STAGE1")
29echo "Stage0: ${STAGE0_SIZE} bytes"
30echo "Stage1: ${STAGE1_SIZE} bytes"