ESP32 native bootloader mode

This commit is contained in:
Ben Meadors 2025-01-25 12:02:34 -06:00
parent 4c97351187
commit 96a119cdd8
2 changed files with 11 additions and 2 deletions

View File

@ -352,7 +352,7 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta
}
case meshtastic_AdminMessage_enter_dfu_mode_request_tag: {
LOG_INFO("Client requesting to enter DFU mode");
#if defined(ARCH_NRF52) || defined(ARCH_RP2040)
#if defined(ARCH_NRF52) || defined(ARCH_RP2040) || defined(ARDUINO_USB_CDC_ON_BOOT)
enterDfuMode();
#endif
break;
@ -1160,4 +1160,4 @@ void disableBluetooth()
nrf52Bluetooth->shutdown();
#endif
#endif
}
}

View File

@ -248,3 +248,12 @@ void cpuDeepSleep(uint32_t msecToWake)
esp_sleep_enable_timer_wakeup(msecToWake * 1000ULL); // call expects usecs
esp_deep_sleep_start(); // TBD mA sleep current (battery)
}
void enterDfuMode()
{
#if defined(ARDUINO_USB_CDC_ON_BOOT)
// This is a no-op on the ESP32 normally, but on the ESP32-S3/C3 it will reboot to USB/JTAG mode
REG_WRITE(RTC_CNTL_OPTION1_REG, RTC_CNTL_FORCE_DOWNLOAD_BOOT);
esp_restart();
#endif
}