8000 esp32: Minor bug fix for Secure Boot · pycom/pycom-micropython-sigfox@0650a29 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 0650a29

Browse files
author
iwahdan88
committed
esp32: Minor bug fix for Secure Boot
1 parent d8769fd commit 0650a29

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

esp32/application.mk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ PART_CSV = lib/partitions.csv
421421
PART_BIN = $(BUILD)/lib/partitions.bin
422422
PART_BIN_ENCRYPT = $(PART_BIN)_enc
423423
APP_BIN_ENCRYPT = $(APP_BIN)_enc_0x10000
424-
APP_BIN_ENCRYPT_2 = $(APP_BIN)_enc_0x1A0000
424+
APP_BIN_ENCRYPT_2 = $(APP_BIN)_enc_0x1C0000
425425

426426
ESPPORT ?= /dev/ttyUSB0
427427
ESPBAUD ?= 921600
@@ -452,7 +452,7 @@ SIGN_BINARY = $(ESPSECUREPY) sign_data --keyfile $(SECURE_KEY)
452452
# $(ENCRYPT_BINARY) $(ENCRYPT_0x10000) -o image_encrypt.bin image.bin
453453
ENCRYPT_BINARY = $(ESPSECUREPY) encrypt_flash_data --keyfile $(ENCRYPT_KEY)
454454
ENCRYPT_0x10000 = --address 0x10000
455-
ENCRYPT_0x1A0000 = --address 0x1A0000
455+
ENCRYPT_0x1C0000 = --address 0x1C0000
456456

457457
GEN_ESP32PART := $(PYTHON) $(ESP_IDF_COMP_PATH)/partition_table/gen_esp32part.py -q
458458

@@ -627,9 +627,9 @@ ifeq ($(SECURE), on)
627627
$(ECHO) "Signing $@"
628628
$(Q) $(SIGN_BINARY) $@
629629
$(ECHO) $(SEPARATOR)
630-
$(ECHO) "Encrypt image into $(APP_BIN_ENCRYPT) (0x10000 offset) and $(APP_BIN_ENCRYPT_2) (0x1A0000 offset)"
630+
$(ECHO) "Encrypt image into $(APP_BIN_ENCRYPT) (0x10000 offset) and $(APP_BIN_ENCRYPT_2) (0x1C0000 offset)"
631631
$(Q) $(ENCRYPT_BINARY) $(ENCRYPT_0x10000) -o $(APP_BIN_ENCRYPT) $@
632-
$(Q) $(ENCRYPT_BINARY) $(ENCRYPT_0x1A0000) -o $(APP_BIN_ENCRYPT_2) $@
632+
$(Q) $(ENCRYPT_BINARY) $(ENCRYPT_0x1C0000) -o $(APP_BIN_ENCRYPT_2) $@
633633
$(ECHO) "Overwrite $(APP_BIN) with $(APP_BIN_ENCRYPT)"
634634
$(CP) -f $(APP_BIN_ENCRYPT) $(APP_BIN)
635635
$(ECHO) $(SEPARATOR)

esp32/bootloader/bootloader.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ bool load_partition_table(bootloader_state_t* bs)
176176
#ifdef CONFIG_SECURE_BOOT_ENABLED
177177
if(esp_secure_boot_enabled()) {
178178
ESP_LOGI(TAG, "Verifying partition table signature...");
179-
err = esp_secure_boot_verify_signature(ESP_PARTITION_TABLE_ADDR, ESP_PARTITION_TABLE_DATA_LEN);
179+
err = esp_secure_boot_verify_signature(CONFIG_PARTITION_TABLE_OFFSET, ESP_PARTITION_TABLE_DATA_LEN);
180180
if (err != ESP_OK) {
181181
ESP_LOGE(TAG, "Failed to verify partition table signature.");
182182
return false;

esp32/tools/mpy-build-check.sh

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,27 @@ if [ "${BOARD}" != "WIPY" -a "${BOARD}" != "SIPY" -a "${BOARD}" != "LOPY" -a "${
2424
exit 1
2525
fi
2626

27-
MPY_PATH=./"${BUILD_DIR}"/"${BOARD}"/"${RELEASE_TYP}"/frozen_mpy
28-
29-
if ! [ -d ${MPY_PATH} ] ; then
30-
#Build Directory not created yet
31-
exit 0
32-
fi
33-
3427
BUILD_TIMESTAMP=./"${BUILD_DIR}"/${BOARD}"/"${RELEASE_TYP}"/"mpy_last_build_timestamp.TS
3528

3629
#If Last mpy Build Timestamp Not avialable create it
3730
if [ ! -f ${BUILD_TIMESTAMP} ] ; then
3831
$(touch ${BUILD_TIMESTAMP})
3932
fi
4033

41-
LAST_BUILD=$(<${BUILD_TIMESTAMP})
4234
#Get Current Timestamp
4335
CURR_TS="$(date +"%s")"
4436

37+
MPY_PATH=./"${BUILD_DIR}"/"${BOARD}"/"${RELEASE_TYP}"/frozen_mpy
38+
39+
if ! [ -d ${MPY_PATH} ] ; then
40+
#Build Directory not created yet
41+
#Update Last Build Timestamp
42+
$(echo ${CURR_TS} > ${BUILD_TIMESTAMP})
43+
exit 0
44+
fi
45+
46+
LAST_BUILD=$(<${BUILD_TIMESTAMP})
47+
4548
#Check if any of Frozen Directorys has been updated.. Rebuild out Mpy files
4649
for dir in ${PY_DIRS}
4750
do

0 commit comments

Comments
 (0)
0