Skip to content

Commit 08d4060

Browse files
mathewb64timg236
authored andcommitted
tools: Sign bootsys in the AB partition
1 parent 86a3922 commit 08d4060

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

tools/update-pieeprom.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@ sign_firmware_blob() {
156156
fi
157157
}
158158

159+
isABCapableImage() {
160+
image="$1"
161+
offset=0x10008
162+
count=8
163+
bootsys="bootsys"
164+
filename=$(dd if="${image}" bs=1 skip=$((offset)) count=$((count)) status=none | strings)
165+
if [ "${filename}" = "${bootsys}" ]; then
166+
return 0
167+
fi
168+
return 1
169+
}
170+
159171
sign_firmware() {
160172
if [ "${SIGN_FIRMWARE}" = 1 ]; then
161173
echo "SIGN_RECOVERY: ${SIGN_RECOVERY}"
@@ -185,7 +197,13 @@ sign_firmware() {
185197
rpi-eeprom-config -x "${pieeprom_src}"
186198
)
187199
sign_firmware_blob "${TMP_DIR}/bootcode.bin" "${TMP_DIR}/bootcode.bin.signed"
188-
rpi-eeprom-config --bootcode "${TMP_DIR}/bootcode.bin.signed" -o "${pieeprom_dst}" "${pieeprom_src}"
200+
if isABCapableImage "${pieeprom_src}"; then
201+
sign_firmware_blob "${TMP_DIR}/bootsys" "${TMP_DIR}/bootsys.signed"
202+
rpi-eeprom-config --bootcode "${TMP_DIR}/bootcode.bin.signed" --bootsys "${TMP_DIR}/bootsys.signed" -o "${pieeprom_dst}" "${pieeprom_src}"
203+
else
204+
rpi-eeprom-config --bootcode "${TMP_DIR}/bootcode.bin.signed" -o "${pieeprom_dst}" "${pieeprom_src}"
205+
206+
fi
189207
SRC_IMAGE="${pieeprom_dst}"
190208
fi
191209
fi

0 commit comments

Comments
 (0)