Today I wrote a firmware image that contained a bootloader. When I flashed it onto a board with an existing bootloader, it erased the existing bootloader, and replaced it with the bootloader image baked into the firmware image.
This seems like a silly thing to do, but it means that I can replace the off-the-shelf uf2 bootloader in the seeed studio xiao nrf52 with my fancy bootloader, without having to use an SWD debugger. The set up process for switching over to my environment is:
- Plug in USB cable
- Drag this uf2 file to the usb drive.
- The usb flash drive will disconnect, and it will come back up as a usb serial port you can use with my cli tool instead.
And you are now done.
I don't really recommend you do this (unless you are looking for adventure), as my bootloader is pretty limited and opinionated. But it's really neat that I did this and it worked on the first try.
Basically the steps for me doing this was:
- Build my bootloader image, turn it into a
binfile withcargo-objcopy - Build my "dummy app" image, which uses
include_bytes!()to include the bootloader image as a blob of bytes. Turn this into abinfile as above, then turn it into a uf2 image withuf2conv, a Rust CLI app
