Skip to content

Commit 1854383

Browse files
committed
Do not enable OTP write protect unless ENABLE_OTP_WP=1 is passed during make.
1 parent 463cc32 commit 1854383

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

docs/flash-OTP.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ make keytools
9292
5) Setup the OTP keystore
9393

9494
Flash the OTP keystore primer:
95+
- Run `make otp`
9596
- Flash `./tools/keytools/otp/otp-keystore-primer.bin` to `0x08000000`
9697
- Disconnect the tool and hit reset button
9798
- The primer will run and flash keystore.c to OTP and enable write protection on those blocks

tools/keytools/otp/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ CC=$(CROSS_COMPILE)gcc
3232
OBJCOPY?=$(CROSS_COMPILE)objcopy
3333
SIZE?=$(CROSS_COMPILE)size
3434

35+
ifeq ($(ENABLE_OTP_WP),1)
36+
CFLAGS+=-DENABLE_OTP_WP
37+
endif
38+
3539
all: otp-keystore-primer.bin otp-keystore-gen
3640

3741
otp-keystore-gen: otp-keystore-gen.c
@@ -56,7 +60,7 @@ stm32h5.o: ../../../hal/stm32h5.c
5660
$(Q)$(CC) $(CFLAGS) -c -o $@ $<
5761

5862

59-
63+
6064

6165
clean:
6266
$(Q)rm -rf $(PRI_KS_OBJS) *.bin *.elf

tools/keytools/otp/otp-keystore-primer.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,13 @@ void main(void)
5959
sizeof(struct keystore_slot));
6060
}
6161

62-
/* Protect the OTP area just written */
6362
tot_len = OTP_HDR_SIZE + n_keys * SIZEOF_KEYSTORE_SLOT;
64-
hal_flash_otp_set_readonly(FLASH_OTP_BASE, tot_len);
6563

64+
#ifdef ENABLE_OTP_WP
65+
/* Protect the OTP area just written */
66+
hal_flash_otp_set_readonly(FLASH_OTP_BASE, tot_len);
67+
#endif
68+
(void)tot_len;
6669

6770
/* Done! */
6871
while(1)

0 commit comments

Comments
 (0)