Skip to content

Commit a9c02cd

Browse files
committed
patches to improve resistance to fault injection
1 parent 9b8c023 commit a9c02cd

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

Diff for: targets/stm32l432/src/device.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,12 @@ void device_init()
304304

305305
hw_init(LOW_FREQUENCY);
306306

307+
#if BOOT_TO_DFU
308+
flash_option_bytes_init(1);
309+
#else
310+
flash_option_bytes_init(0);
311+
#endif
312+
307313
if (! tsc_sensor_exists())
308314
{
309315
_NFC_status = nfc_init();
@@ -329,12 +335,6 @@ void device_init()
329335

330336
device_migrate();
331337

332-
#if BOOT_TO_DFU
333-
flash_option_bytes_init(1);
334-
#else
335-
flash_option_bytes_init(0);
336-
#endif
337-
338338

339339
}
340340

Diff for: targets/stm32l432/src/flash.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ void flash_option_bytes_init(int boot_from_dfu)
7070

7171
flash_lock();
7272

73-
__enable_irq();
73+
74+
/* Perform option byte loading which triggers a device reset. */
75+
FLASH->CR |= FLASH_CR_OBL_LAUNCH;
76+
77+
while (true);
7478
}
7579

7680
void flash_erase_page(uint8_t page)

0 commit comments

Comments
 (0)