I'm using precisely this as it is what most smart watches do to enter bootloder, so something like this could work
+++ b/targets/nrf5x_dfu/main.c
@@ -100,13 +100,39 @@ bool dfu_enter_check(void) {
[#else](https://forum.espruino.com/search/?q=%23else)
dfu_start = dfuIsColdBoot; // if no button, enter bootloader if it's a cold boot, then exit after a few seconds
[#endif](https://forum.espruino.com/search/?q=%23endif)
+ if (NRF_POWER->GPREGRET == 1) { NRF_POWER->GPREGRET=0; return true; }
[#ifdef](https://forum.espruino.com/search/?q=%23ifdef) BUTTONPRESS_TO_REBOOT_BOOTLOADER^M
// if DFU looks invalid, go straight to bootloader
if (s_dfu_settings.bank_0.bank_code == NRF_DFU_BANK_INVALID) {
lcd_println("BANK0 INVALID");
and then just poke32(0x4000051c,1) triggers DFU. However as Gordon mentions it is a bit dangerous, anyone can trigger DFU update remotely if you don't set up console password or other protection (like whitelisting/refusing unknown connections)
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I'm using precisely this as it is what most smart watches do to enter bootloder, so something like this could work
so just one line to put here https://github.com/espruino/Espruino/blob/master/targets/nrf5x_dfu/main.c#L103
and then just
poke32(0x4000051c,1)
triggers DFU. However as Gordon mentions it is a bit dangerous, anyone can trigger DFU update remotely if you don't set up console password or other protection (like whitelisting/refusing unknown connections)