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
Flash the OTP keystore primer:
- Run `make otp`
- Flash `./tools/keytools/otp/otp-keystore-primer.bin` to `0x08000000`
- Disconnect the tool and hit reset button
- 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
SIZE?=$(CROSS_COMPILE)size
ifeq ($(ENABLE_OTP_WP),1)
CFLAGS+=-DENABLE_OTP_WP
endif
all: otp-keystore-primer.bin otp-keystore-gen
otp-keystore-gen: otp-keystore-gen.c
@ -56,7 +60,7 @@ stm32h5.o: ../../../hal/stm32h5.c
$(Q)$(CC) $(CFLAGS) -c -o $@ $<
clean:
$(Q)rm -rf $(PRI_KS_OBJS) *.bin *.elf

View File

@ -59,10 +59,13 @@ void main(void)
sizeof(struct keystore_slot));
}
/* Protect the OTP area just written */
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! */
while(1)