CircuitPython version
Adafruit CircuitPython 8.2.1 on 2023-07-25; Adafruit PyPortal Titano with samd51j20
Code/REPL
>>> import microcontroller
>>> microcontroller.on_next_reset(microcontroller.RunMode.UF2)
>>> microcontroller.reset()
Behavior
Reboots to normal running CircuitPython
Description
When I run the provided code, it just goes back to normal user mode.
Additional information
If I use the older RunMode.BOOTLOADER it mounts the PORTALBOOT drive which is what I want.
I think the problem is here https://github.com/adafruit/circuitpython/blob/main/ports/atmel-samd/common-hal/microcontroller/__init__.c#L66
My suggested change is:
diff --git a/ports/atmel-samd/common-hal/microcontroller/__init__.c b/ports/atmel-samd/common-hal/microcontroller/__init__.c
index d1c02b360..054d7ee7f 100644
--- a/ports/atmel-samd/common-hal/microcontroller/__init__.c
+++ b/ports/atmel-samd/common-hal/microcontroller/__init__.c
@@ -63,7 +63,7 @@ void common_hal_mcu_enable_interrupts(void) {
}
void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) {
- if (runmode == RUNMODE_BOOTLOADER) {
+ if ((runmode == RUNMODE_BOOTLOADER) || (runmode == RUNMODE_UF2)) {
if (!bootloader_available()) {
mp_raise_ValueError(translate("Cannot reset into bootloader because no bootloader is present"));
}
But this suggestion could be uninformed, dangerous, or just plain wrong. I don't know if there are some SAMD that have both a bootloader and a UF2 mode for instance.
CircuitPython version
Code/REPL
Behavior
Reboots to normal running CircuitPython
Description
When I run the provided code, it just goes back to normal user mode.
Additional information
If I use the older
RunMode.BOOTLOADERit mounts the PORTALBOOT drive which is what I want.I think the problem is here https://github.com/adafruit/circuitpython/blob/main/ports/atmel-samd/common-hal/microcontroller/__init__.c#L66
My suggested change is:
But this suggestion could be uninformed, dangerous, or just plain wrong. I don't know if there are some SAMD that have both a bootloader and a UF2 mode for instance.