Skip to content

Commit 64bf0f8

Browse files
authored
Merge pull request #1996 from jepler/nrf-reboot-bootloader
[DRAFT] nrf: enable "reboot to bootloader" functionality
2 parents 0871899 + 34e2bab commit 64bf0f8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

ports/nrf/common-hal/microcontroller/__init__.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "shared-bindings/microcontroller/Processor.h"
3838

3939
#include "supervisor/filesystem.h"
40+
#include "supervisor/shared/safe_mode.h"
4041
#include "nrfx_glue.h"
4142

4243
// This routine should work even when interrupts are disabled. Used by OneWire
@@ -52,7 +53,13 @@ void common_hal_mcu_enable_interrupts() {
5253
}
5354

5455
void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) {
55-
// TODO: see atmel-samd for functionality
56+
enum { DFU_MAGIC_UF2_RESET = 0x57 };
57+
if(runmode == RUNMODE_BOOTLOADER)
58+
NRF_POWER->GPREGRET = DFU_MAGIC_UF2_RESET;
59+
else
60+
NRF_POWER->GPREGRET = 0;
61+
if(runmode == RUNMODE_SAFE_MODE)
62+
safe_mode_on_next_reset(PROGRAMMATIC_SAFE_MODE);
5663
}
5764

5865
void common_hal_mcu_reset(void) {

0 commit comments

Comments
 (0)