Make uf2reset available across nRF52 CLI roles

This commit is contained in:
mikecarper committed 2026-09-04 02:01:40 -07:00
1 parent e36b092aa3
commit 65a53285d9
14 files changed
+154 -34

No files matched your search

+21
View File
@@ -33,6 +33,10 @@ static bool ota_ble_started = false;
#define NRF52_WATCHDOG_TIMEOUT_SECONDS 60UL
#endif
#ifndef DFU_MAGIC_UF2_RESET
#define DFU_MAGIC_UF2_RESET 0x57
#endif
#if NRF52_WATCHDOG_TIMEOUT_SECONDS > 131071UL
#error "NRF52_WATCHDOG_TIMEOUT_SECONDS exceeds the nRF52 WDT counter range"
#endif
@@ -96,6 +100,23 @@ bool NRF52Board::isUserGpioAvailable(uint8_t pin) const {
#endif
}
bool NRF52Board::rebootToUf2Bootloader() {
uint8_t sd_enabled = 0;
if (sd_softdevice_is_enabled(&sd_enabled) != NRF_SUCCESS) return false;
if (sd_enabled) {
if (sd_power_gpregret_clr(0, 0xFF) != NRF_SUCCESS
|| sd_power_gpregret_set(0, DFU_MAGIC_UF2_RESET) != NRF_SUCCESS) {
return false;
}
} else {
NRF_POWER->GPREGRET = DFU_MAGIC_UF2_RESET;
}
NVIC_SystemReset();
return true;
}
static void connect_callback(uint16_t conn_handle) {
ota_conn_handle = conn_handle;
MESH_DEBUG_PRINTLN("BLE client connected");