forked from trezor/trezor-mcu
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbuild-current-bootloader.sh
More file actions
executable file
·32 lines (27 loc) · 1021 Bytes
/
build-current-bootloader.sh
File metadata and controls
executable file
·32 lines (27 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
set -e
MODEL=$(echo ${DEVICE_MODEL} | awk -F'_' '{print $2}' | tr '[:upper:]' '[:lower:]')
IMAGE=trezor-mcu-build
TAG=${1:-current}
BINFILE=build/bootloader-$MODEL-$TAG.bin
ELFFILE=build/bootloader-$MODEL-$TAG.elf
echo "Build bootloader for device $MODEL"
docker build -t $IMAGE .
docker run -e DEVICE_MODEL=${DEVICE_MODEL} -e BOOTLOADER=1 -e MEMORY_PROTECT=$MEMORY_PROTECT -t -v "$(pwd)/build:/build:z" -v "$(pwd):/bithd-mcu" $IMAGE /bin/sh -c "\
cd /bithd-mcu && \
make -C vendor/libopencm3 && \
rm -f gen/*.o && make clean && make && \
make -C bootloader align && \
cp bootloader/bootloader.bin /$BINFILE && \
cp bootloader/bootloader.elf /$ELFFILE"
/usr/bin/env python3 -c "
from __future__ import print_function
import hashlib
import sys
fn = sys.argv[1]
data = open(fn, 'rb').read()
print('\n\n')
print('Filename :', fn)
print('Fingerprint :', hashlib.sha256(hashlib.sha256(data).digest()).hexdigest())
print('Size : %d bytes (out of %d maximum)' % (len(data), 32768))
" "$BINFILE"