Hermann Stamm-Wilbrandt Gives the Raspberry Pi Pico a Software Reset, No-Button Boot Flash Script
With one small change to the SDK, the Raspberry Pi Pico can be flashed without physical interaction — entirely in software.
Developer Hermann Stamm-Wilbrandt offers an alternative to having to hold down the BOOTSEL button to put the Raspberry Pi Pico into programming mode, offering a "No-Button-Boot (NBB)" alternative that triggers on changing the boad rate of the serial connection.
The Raspberry Pi Pico, launched earlier this year as the first microcontroller board from Raspberry Pi and the first outing for its in-house RP2040 silicon, is a popular board — but having to pull the USB cable, hold down the BOOTSEL button, and reinsert the cable gets old fast. Fitting an after-market reset switch helps, but Stamm-Wilbrandt's approach is different: It's entirely software-based.
"Without changing your code," Stamm-Wilbrandt explains, "flashing the Pico without pressing [the BOOTSEL] switch is possible now! [Triggering on] baud rate changes convinced me, with Python as easy as sending '\0'."
Stamm-Wilbrandt's approach has resulted in a smart tool, written as a Bash script, dubbed "flash": "Running 'flash' command just reboots the Pico as can be seen," he writes. "'flash' with .uf2 argument brings Pico into BOOTSEL mode and then flashes the .uf2. [The] Minicom session does not know about baud rate change, but does not need to. The reboot/start in BOOTSEL mode bring[s] the Pico to 115200 default baud rate again."
More information on the approach, which requires a small change to the Pico Software Development Kit (SDK) source code so the microcontroller becomes aware of the baud rate reset trigger, can be found on the Raspberry Pi forum, along with a link to the source code of the flash script.