Why convert UF2 to HEX?
UF2 wraps firmware for drag-and-drop flashing, while .hex (Intel HEX) is an ASCII format that encodes both the data and its memory addresses, used by many flashers and programmers. Since uf2conv.py doesn't emit Intel HEX, you route through a raw .bin and let objcopy (from GNU binutils) add the address records. This is common when a target's programmer or bootloader expects .hex rather than UF2.
How to convert UF2 to HEX
uf2conv.py then objcopy OPEN-SOURCE
Run uf2conv.py firmware.uf2 -c -o firmware.bin, then objcopy -I binary -O ihex --change-addresses 0x2000 firmware.bin firmware.hex to add the flash offset.
objcopy (GNU binutils / arm-none-eabi) FREE
Use the toolchain's arm-none-eabi-objcopy -I binary -O ihex firmware.bin firmware.hex. Add --change-addresses to place the data at the right memory address.
SRecord (srec_cat) OPEN-SOURCE
If objcopy's offset handling misbehaves, run srec_cat firmware.bin -binary -offset 0x2000 -o firmware.hex -intel to build the Intel HEX with a precise address.
About these formats
A UF2 file is a firmware image in Microsoft's USB Flashing Format, used to program microcontroller boards over USB. You do not open it in an app - you put the board into bootloader mode so…
Open .UF2 details →A .hex file is an Intel HEX file: compiled firmware for a microcontroller such as an Arduino, AVR, or PIC chip, stored as plain-text records. You don't run it on a PC - you flash it to the…
Open .HEX details →Quality & what to watch
- There is no one-command UF2-to-HEX; the raw
.binin the middle loses the address, so you must re-supply the flash base offset in the objcopy/srec step. - Get the offset wrong and the
.hexwill place code at the wrong memory address, which can brick or fail to boot the device. - Some objcopy versions had regressions converting binary to ihex; SRecord is the recommended fallback for exact offsets.
Frequently asked questions
Why two steps?
uf2conv.py only outputs raw .bin and C arrays, not Intel HEX. You convert UF2 to .bin, then use objcopy or SRecord to make the .hex.What offset do I use?
--change-addresses or srec -offset.Where do I get objcopy?
arm-none-eabi-objcopy from the GNU Arm Embedded toolchain.What if objcopy gives wrong addresses?
srec_cat with an explicit -offset, which handles binary-to-Intel-HEX address placement reliably.