Do not enable OTP write protect unless `ENABLE_OTP_WP=1` is passed during make.

pull/455/head
David Garske 2024-07-09 16:18:08 -07:00
parent 463cc32b7d
commit 1854383462
3 changed files with 11 additions and 3 deletions

View File

@ -92,6 +92,7 @@ make keytools
5) Setup the OTP keystore 5) Setup the OTP keystore
Flash the OTP keystore primer: Flash the OTP keystore primer:
- Run `make otp`
- Flash `./tools/keytools/otp/otp-keystore-primer.bin` to `0x08000000` - Flash `./tools/keytools/otp/otp-keystore-primer.bin` to `0x08000000`
- Disconnect the tool and hit reset button - Disconnect the tool and hit reset button
- The primer will run and flash keystore.c to OTP and enable write protection on those blocks - The primer will run and flash keystore.c to OTP and enable write protection on those blocks

View File

@ -32,6 +32,10 @@ CC=$(CROSS_COMPILE)gcc
OBJCOPY?=$(CROSS_COMPILE)objcopy OBJCOPY?=$(CROSS_COMPILE)objcopy
SIZE?=$(CROSS_COMPILE)size SIZE?=$(CROSS_COMPILE)size
ifeq ($(ENABLE_OTP_WP),1)
CFLAGS+=-DENABLE_OTP_WP
endif
all: otp-keystore-primer.bin otp-keystore-gen all: otp-keystore-primer.bin otp-keystore-gen
otp-keystore-gen: otp-keystore-gen.c otp-keystore-gen: otp-keystore-gen.c

View File

@ -59,10 +59,13 @@ void main(void)
sizeof(struct keystore_slot)); sizeof(struct keystore_slot));
} }
/* Protect the OTP area just written */
tot_len = OTP_HDR_SIZE + n_keys * SIZEOF_KEYSTORE_SLOT; tot_len = OTP_HDR_SIZE + n_keys * SIZEOF_KEYSTORE_SLOT;
hal_flash_otp_set_readonly(FLASH_OTP_BASE, tot_len);
#ifdef ENABLE_OTP_WP
/* Protect the OTP area just written */
hal_flash_otp_set_readonly(FLASH_OTP_BASE, tot_len);
#endif
(void)tot_len;
/* Done! */ /* Done! */
while(1) while(1)