It turns out you CAN read the pico BOOTSEL pin from software.
I became aware of this possibility after pimoroni tweeted that you could use the BOOTSEL button as a MIDI trigger on their upcoming "Tiny2040". We speculated whether there was a small HW circuit to accomplish this, or if it was SW only. Now I have the answer.
I was also heavily informed by the bootloader source, the body of the reading code is taken directly from there with adjusted timings.
The general idea:
- Pressing the button applies a strong pull-down.
- Normally after start-up, this pin is always being driven by the Pico's QSPI peripheral, so the button has no effect