forked from acalatrava/openhaystack_moko
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·49 lines (35 loc) · 1.54 KB
/
build.sh
File metadata and controls
executable file
·49 lines (35 loc) · 1.54 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
# Exit on error
set -e
# Set working directory
WORKSPACE=/spaceinvader
cd $WORKSPACE
# Make directories for hexadecimal files and the final binary
mkdir $WORKSPACE/hex
mkdir $WORKSPACE/dist
# Initialize and update git submodules
git submodule init
git submodule update
# Compile micro-ecc library
make --directory=$WORKSPACE/apps/secure_bootloader/micro-ecc-build
# Set the public key for the secure bootloader
sed -i "s/\/\* PUBLIC_KEY_PLACEHOLDER \*\//$PUBLIC_KEY_HEX/" $WORKSPACE/apps/firmware/dfu_images/public_key.c
# Compile secure bootloader
make --directory=$WORKSPACE/apps/secure_bootloader/build
mv $WORKSPACE/apps/secure_bootloader/build/_build/secure_bootloader_moko.hex $WORKSPACE/hex
# Compile firmware
make --directory=$WORKSPACE/apps/firmware/build
mv $WORKSPACE/apps/firmware/build/_build/nrf52810_xxaa.hex $WORKSPACE/hex
# Make hexadecimal files
cd $WORKSPACE/hex
# Generate DFU settings
nrfutil settings generate --family NRF52810 --application nrf52810_xxaa.hex --application-version 1 --bootloader-version 1 --bl-settings-version 2 bl_settings.hex
# Merge hex files
cp $WORKSPACE/nRF5_SDK_17.0.2_d674dde/components/softdevice/s112/hex/s112_nrf52_7.2.0_softdevice.hex $WORKSPACE/hex
mergehex --merge bl_settings.hex secure_bootloader_moko.hex nrf52810_xxaa.hex s112_nrf52_7.2.0_softdevice.hex --output firmware.hex
# debug
ls -alh firmware.hex
# Convert the HEX file to a BIN file
arm-none-eabi-objcopy --input-target=ihex --output-target=binary firmware.hex $WORKSPACE/dist/firmware.bin
# debug
ls -alh $WORKSPACE/dist/firmware.bin