File tree Expand file tree Collapse file tree 2 files changed +16
-13
lines changed
Expand file tree Collapse file tree 2 files changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -304,12 +304,6 @@ 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-
313307 if (! tsc_sensor_exists ())
314308 {
315309 _NFC_status = nfc_init ();
@@ -329,13 +323,18 @@ void device_init()
329323 device_init_button ();
330324 }
331325
326+ device_migrate ();
327+
328+ #if BOOT_TO_DFU
329+ flash_option_bytes_init (1 );
330+ #else
331+ flash_option_bytes_init (0 );
332+ #endif
333+
332334 usbhid_init ();
333335 ctaphid_init ();
334336 ctap_init ();
335337
336- device_migrate ();
337-
338-
339338}
340339
341340int device_is_nfc (void )
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ void flash_option_bytes_init(int boot_from_dfu)
4747 val &= ~(1 <<25 ); // SRAM2_RST = 1 (erase sram on reset)
4848 val &= ~(1 <<24 ); // SRAM2_PE = 1 (parity check en)
4949
50- if (FLASH -> OPTR == val )
50+ if (( FLASH -> OPTR & 0xb3f77ff ) == ( val & 0xb3f77ff ) )
5151 {
5252 return ;
5353 }
@@ -68,13 +68,17 @@ void flash_option_bytes_init(int boot_from_dfu)
6868 while (FLASH -> SR & (1 <<16 ))
6969 ;
7070
71- flash_lock ();
72-
71+ if (FLASH -> CR & (1 <<30 ))
72+ {
73+ FLASH -> OPTKEYR = 0x08192A3B ;
74+ FLASH -> OPTKEYR = 0x4C5D6E7F ;
75+ }
7376
7477 /* Perform option byte loading which triggers a device reset. */
7578 FLASH -> CR |= FLASH_CR_OBL_LAUNCH ;
7679
77- while (true);
80+ while (true)
81+ ;
7882}
7983
8084void flash_erase_page (uint8_t page )
You can’t perform that action at this time.
0 commit comments