After digging a bit into the RP2040 datasheet, it seems like we might also need to take a look at the bootrom. Fortunately, the full source code is available on GitHub.
There's no documentation how to build it, but it turns out it's pretty straightforward. Here are the complete instructions for building the RP2040 bootrom from source:
- Install dependencies:
sudo apt install cmake gcc-arm-none-eabi
Checkout the repository:
git clone https://github.com/raspberrypi/pico-bootrom
cd pico-bootrom git submodule update --init mkdir build cd build cmake .. make -j4