Page 1 of 1

RP2040 stage2 bootloader / allow booting from flash

Posted: Mon Feb 21, 2022 10:51 pm
by electronic_eel
Hi,

the port for the RP2040 is currently not nice to use, because you can't boot from flash, but have to upload the code with a SWD debugger into RAM on each boot. To boot from flash, the RP2040 requires a short bootloader at the beginning of the flash (stage2). This bootloader is included in the Pico-SDK. But to be usable with ChibiOS, building the bootloader must be included in the make build system and the code be linked to the correct addresses.

The attached patches implement this. I have also added a .mk file to create the UF2 files that can be used to flash with the usb bootloader integrated in the RP2040.

I had to add small hooks to the generic ARM GCC makefiles. I have documented this in more detail the individual patch files. If any of my changes there are not acceptable or should be done differently, please explain why and I will try to adapt them.

The linker script patches are based on the work done by forum user szilveszter in this post.

The patches are attached as zip file. Alternatively you can view the whole tree with the patches applied at https://github.com/electroniceel/ChibiOS/tree/RP2040-flash

Please consider applying to ChibiOS.