[{"element_type":"text","content":"\n  \n  \n        \u003cp\u003eUF2 files are an easy way to load firmware on boards with UF2 bootloaders. Normally the UF2 just contains the firmware. However, on RP2040 boards, the \u003cstrong\u003epicotool\u003c/strong\u003e command can be used to produce a UF2 that includes both firmware and the CIRCUITPY filesystem.\u003c/p\u003e\n\u003cp\u003eThe \u003cstrong\u003epicotool\u003c/strong\u003e GitHub repo is \u003ca href=\"https://github.com/raspberrypi/picotool\"\u003ehere\u003c/a\u003e. More complete documentation is in Appendix B in the \u003ca href=\"https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf\"\u003e\u003cem\u003eGetting Started with Raspberry Pi Pico\u003c/em\u003e\u003c/a\u003e document.\u003c/p\u003e\n\u003cp\u003eNote that \u003cstrong\u003epicotool\u003c/strong\u003e is supplied in source format. Pre-built versions are not currently supplied by Raspberry Pi. There are some unofficial builds, but be careful. At least one easily found Windows build does not seem to work properly.\u003c/p\u003e\n      \n\n","metadata":{}},{"element_type":"text","content":"\n        \u003ch2\u003eSaving Flash in a .uf2 or .bin file\u003c/h2\u003e\n\u003cp\u003eTo extract everything in flash storage on your RP2040 board into a UF2, reset the RP2040 into bootloader mode (\u003cstrong\u003eRPI-RP2\u003c/strong\u003e visible) and then do this:\u003c/p\u003e\n      ","metadata":{}},{"element_type":"code","content":"picotool save --all all.uf2","metadata":{"language":"terminal","linenums":false}},{"element_type":"text","content":"\n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n        \u003cp\u003eTo save into a bin file:\u003c/p\u003e\n      \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","metadata":{}},{"element_type":"code","content":"picotool save --all all.bin","metadata":{"language":"terminal","linenums":false}},{"element_type":"text","content":"\n  \n  \n  \n        \u003cp\u003eOn boards with large flash chips, the UF2 file with all of flash will be large, and can take several minutes to load onto the board. You can instead save the \u003cstrong\u003e.bin\u003c/strong\u003e file, and inspect it with a hex editor or similar to find the offset of the last piece of interesting data in the file. If you have \"\u003ca href=\"https://learn.adafruit.com/getting-started-with-raspberry-pi-pico-circuitpython?view=all#flash-resetting-uf2-3083182\"\u003enuked\" (erased)\u003c/a\u003e the flash storage in advance before loading CiruitPython and copying over your files, then unused storage in flash will be all 1's (\u003ccode\u003eFFFF\u003c/code\u003e).\u003c/p\u003e\n\u003cp\u003eOnce you know the offset, you can use \u003cstrong\u003epicotool\u003c/strong\u003e to extract only a range of what is in flash, to create a smaller file. \u003cspan\u003eExtract a range of flash, starting at \u003ccode\u003e0x10000000\u003c/code\u003e, and ending at \u003ccode\u003e0x10000000 + the offset\u003c/code\u003e. For instance, suppose the offset is \u003ccode\u003e0x2cb600\u003c/code\u003e. Use this command:\u003c/span\u003e\u003c/p\u003e\n      \n\n\n","metadata":{}},{"element_type":"code","content":"picotool save --range 0x10000000 0x102cb600 range.uf2","metadata":{"language":"terminal","linenums":false}}]