Reset a PICO into USB boot drive mode from C++

The Raspberry Pi PICO is lovely. But it does have a few quirks. One of them is that if you want to load new firmware into the device you usually have to hold down the BOOTSEL button during power up to force the PICO to boot into a filestore mode where you can download the new code into it. This works OK, but it becomes a pain if you put your PICO into a nice box which covers the BOOTSEL switch. To get round this I’ve added a command to Connected Little Boxes which causes the PICO to reboot into filestore mode. Below is the function that implements the “upgrade” command:

void doFirmwareUpgradeReset(char *commandLine)
{
    alwaysDisplayMessage("Booting into USB drive mode for firmware update...");
    saveSettings();
    delay(2000);
    reset_usb_boot(1, 0);
}

The interesting thing here is the reset_usb_boot(1,0) function call which causes the PICO to boot into filestore mode. I can now make a call of doFirmwareUpgradeReset when I want to do this.