Alan Green | 9b7a93d | 2021-03-11 14:24:52 +1100 | [diff] [blame^] | 1 | #!/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 | |
| 6 | set -e |
| 7 | PROJECT_ROOT=$(realpath $(dirname ${BASH_SOURCE[0]})/..) |
| 8 | STAGE0="${PROJECT_ROOT}/mcu_rom/stage0/target/thumbv6m-none-eabi/release/stage0.bin" |
| 9 | STAGE1="${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 | ) |
| 26 | echo |
| 27 | STAGE0_SIZE=$(stat --printf='%s' "$STAGE0") |
| 28 | STAGE1_SIZE=$(stat --printf='%s' "$STAGE1") |
| 29 | echo "Stage0: ${STAGE0_SIZE} bytes" |
| 30 | echo "Stage1: ${STAGE1_SIZE} bytes" |