Skip to content
This repository was archived by the owner on Feb 25, 2023. It is now read-only.

Commit 60ffdee

Browse files
committed
add HSM version file / Redis key
Because: * To check if the HSM firmware should be updated, the Base image needs to know the firmware version that it contains. * From the firmware file, only the versioning counter can be read directly, but to get this information from the HSM it would need to boot into the bootloader first, which is cumbersome. * Getting the semantic version from the HSM firmware (not bootloader) and decide whether to update is less complex. * The downgrade protection using the monotonic counter is still in place when actually updating the HSM firmware. This commit: * adds the file `config/version_hsm`, containing the semantiv version * renames the file `config/version` to `config/version_bbb` for consistency * stores the HSM firmware version in Redis key `hsm:firmware:version` during build * resets this Redis key from the file on every boot
1 parent d279ef4 commit 60ffdee

File tree

6 files changed

+18
-6
lines changed

6 files changed

+18
-6
lines changed

armbian/base/config/redis/factorysettings.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ SET base:setup 0
1616
ZADD base:descriptionCode 0 0
1717
SET base:stateCode 0
1818

19+
SET hsm:firmware:version xxx
20+
1921
SET middleware:passwordSetup 0
2022
SET middleware:datadir /data/bbbmiddleware
2123
SET middleware:hsmserialport /dev/ttyS2
File renamed without changes.

armbian/base/config/version_hsm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4.4.0

armbian/base/customize-armbian-rockpro64.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ set -e
3434
# CONFIG
3535
# ------------------------------------------------------------------------------
3636

37+
# BitBoxBase and HSM version are set here:
38+
# armbian/base/config/version_bbb
39+
# armbian/base/config/version_hsm
40+
3741
BITCOIN_VERSION="0.18.1"
3842
LIGHTNING_VERSION="0.7.3"
3943
ELECTRS_VERSION="0.7.0"
4044
BIN_DEPS_TAG='0.0.5'
4145

42-
HSM_VERSION='4.3.0'
43-
4446
PROMETHEUS_VERSION="2.11.1"
4547
PROMETHEUS_CHKSUM="33b4763032e7934870721ca3155a8ae0be6ed590af5e91bf4d2d4133a79e4548"
4648
NODE_EXPORTER_VERSION="0.18.1"
@@ -60,6 +62,7 @@ PRODUCTION IMAGE: ${BASE_PRODUCTION_IMAGE}
6062
================================================================================
6163
VERSIONS:
6264
BASE IMAGE ${BASE_VERSION}
65+
HSM ${HSM_VERSION}
6366
BINARY DEPS ${BIN_DEPS_TAG}
6467
BITCOIN ${BITCOIN_VERSION}
6568
LIGHTNING ${LIGHTNING_VERSION}
@@ -151,7 +154,9 @@ source /etc/os-release
151154
BASE_DISTRIBUTION=${VERSION_CODENAME}
152155
BASE_DISTRIBUTION=${BASE_DISTRIBUTION:-"bionic"}
153156

154-
BASE_VERSION=$(head -n1 /opt/shift/config/version)
157+
BASE_VERSION=$(head -n1 /opt/shift/config/version_bbb)
158+
HSM_VERSION=$(head -n1 /opt/shift/config/version_hsm)
159+
155160
BASE_BUILDMODE=${1:-"armbian-build"}
156161

157162
# Source configuration to read BASE_PRODUCTION_IMAGE
@@ -370,6 +375,7 @@ fi
370375

371376
< /opt/shift/config/redis/factorysettings.txt sh /opt/shift/scripts/redis-pipe.sh | redis-cli --pipe
372377
redis-cli SET base:version "${BASE_VERSION}"
378+
redis-cli SET hsm:firmware:version "${HSM_VERSION}"
373379
redis-cli SET build:date "$(date +%Y-%m-%d)"
374380
redis-cli SET build:time "$(date +%H:%M)"
375381
redis-cli SET build:commit "$(cat /opt/shift/config/latest_commit)"

armbian/base/scripts/systemd-startup-after-redis.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ source /opt/shift/scripts/include/updateTorOnions.sh.inc
3131
redis_require
3232

3333
# update hardcoded Base image version
34-
VERSION=$(head -n1 /opt/shift/config/version)
35-
redis_set "base:version" "${VERSION}"
34+
VERSION_BBB=$(head -n1 /opt/shift/config/version_bbb)
35+
redis_set "base:version" "${VERSION_BBB}"
36+
37+
VERSION_HSM=$(head -n1 /opt/shift/config/version_hsm)
38+
redis_set "base:version" "${VERSION_HSM}"
3639

3740

3841
# check for reset triggers on flashdrive

armbian/mender-convert.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fi
1818

1919
ACTION=${1:-"build"}
2020
SOURCE_NAME="BitBoxBase_Armbian_RockPro64"
21-
VERSION="$(head -n1 base/config/version)"
21+
VERSION="$(head -n1 base/config/version_bbb)"
2222
TEMP_NAME="BitBoxBase"
2323
TARGET_NAME="BitBoxBase-v${VERSION}-RockPro64"
2424

0 commit comments

Comments
 (0)