jamesmunns

Doing embedded stuff

Be nice, work hard. Build tools, tell stories. Start five year fights. Kein Ort für Nazis.


A list of all the other services I'm on around the internet


Posts with code highlighted with codehost by @wavebeem.


All posts licensed under CC-BY-SA 4.0, unless otherwise stated.


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 bin file with cargo-objcopy
  • Build my "dummy app" image, which uses include_bytes!() to include the bootloader image as a blob of bytes. Turn this into a bin file as above, then turn it into a uf2 image with uf2conv, a Rust CLI app

You must log in to comment.