From a83742cc3f21c7d8117a7e6dc6d6f9d2a290fe06 Mon Sep 17 00:00:00 2001 From: ryulamp Date: Thu, 12 Feb 2026 14:54:16 +0800 Subject: [PATCH] Refactor secure boot check in otp_is_secure_boot_enabled Refactor otp_is_secure_boot_enabled to check secure boot status before defining BOOTKEY. --- src/fs/otp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/fs/otp.c b/src/fs/otp.c index d16aae1..4825b5b 100644 --- a/src/fs/otp.c +++ b/src/fs/otp.c @@ -261,16 +261,16 @@ typedef esp_err_t otp_ret_t; bool otp_is_secure_boot_enabled(uint8_t *bootkey) { #ifdef PICO_RP2350 - static const uint8_t BOOTKEY[32] = { + const uint8_t *crit1 = otp_buffer(OTP_DATA_CRIT1_ROW); + if ((crit1[0] & (1 << OTP_DATA_CRIT1_SECURE_BOOT_ENABLE_LSB)) == 0) { + return false; + } + alignas(2) uint8_t BOOTKEY[32] = { 0xE1, 0xD1, 0x6B, 0xA7, 0x64, 0xAB, 0xD7, 0x12, 0xD4, 0xEF, 0x6E, 0x3E, 0xDD, 0x74, 0x4E, 0xD5, 0x63, 0x8C, 0x26, 0x0B, 0x77, 0x1C, 0xF9, 0x81, 0x51, 0x11, 0x0B, 0xAF, 0xAC, 0x9B, 0xC8, 0x71 }; - const uint8_t *crit1 = otp_buffer(OTP_DATA_CRIT1_ROW); - if ((crit1[0] & (1 << OTP_DATA_CRIT1_SECURE_BOOT_ENABLE_LSB)) == 0) { - return false; - } uint8_t bootkey_idx = 0; for (; bootkey_idx < 6; bootkey_idx++) { const uint8_t *bootkey_row = otp_buffer(OTP_DATA_BOOTKEY0_0_ROW + 0x10 * bootkey_idx);