How to: 🥸 Export Compiled Binary...Create a single BIN file for Production and Test

Hi there
So this may be useful to some of the makers and want-a-be programmers out there.
If you ever had a need to produce a finished project Production BIN file. A single file that is flashable to the Xiao ESP32x line of MCU’s without giving up the Source code or Sketch it’s derived from.

This is NOT for security (as no encryption is employed in this info) More over it’s ONLY meant for Flashing a single BIN file to speed production or Trouble-shoot the Compiler environment.

i.e. I compile a specific sketch and download the code that RUNS , AOK.
(Joe Third-Grader) Takes My Sketch and It fails to run but compiles ok? :face_with_peeking_eye:
What do you do? How can you troubleshoot that scenario?
with tools and ingenuity. This method allows you to freeze the compiler environment and build a BIN that will work no matter what (less defective Hardware)…

You ever see this Menu selection under “Sketch” in the IDE? " Export Compiled Binary"

It does exactly that, Outputs the necessary Binary files to Build a Flashable BIN file.
When you click it, You’ll get the 3 files of your sketch, (the main.ino.bin, the bootloader.bin, the partitions.bin) these three files and the Arduino boot_app0.bin (generated by IDE upload process)
all get combined to make a single production BIN file you can flash serially to 8*or so units at a time(Factory-Multi-Download Tab) production style.

You get the offsets of each file from the IDE upload process (by not selecting a com port or disconnecting the device) The Xiao ESP32C3 is on Com3 ( I pick com10 to avoid port not open problem with ESP RF test Tool, open at the same time and to get the offsets from IDE compiler output.
Cut and paste the highlighted line to notepad and word wrap it at the “bin” line. (pic 3)

Clear the error box and cut and paste the Highlighted line…

paste it in Notepad to get the offset Hex locations and file paths to paste into flash tool.

Lots of info on this line, It’s all about the Flash chip inside , (size matters) useful for Reading!
offsets are 0x0, 0x8000, 0xe000, 0x10000. we’ll use them to combine the bins into ONE production Flashable BIN file.
next we open the Tool to Flash ESP chips.
open it and you’ll see this.
select USB for load mode , hit ok,
You get to the Good Stuff. (also should be noted the PDF for this file is included in the download) all the steps listed and more are in there if you want to Stretch your reach with this stuff. Watch what I do in the next video with this tool set. but I digress…
You should see this screen

I will add the paths, file names, offsets and check

then press start, as long as the com port is not open on any other app it will Flash the chip and the progress bar will move across the bottom.
Press reset on the Xiao it will run.

To make the single Production BIN file after you verified the Bins run AOK , then you can press the “CombineBin” button, you’ll get this.

The “target.bin” and the success text… Now you can ZIP the file or Flash it to any new hardware.
just by selecting the single BIN. like this;

Here’s the example Drop it on a ESP32C3 Xiao on a Round Display with a SD card with a gif folder in it containing the Winking Chimp.gif file.

Hope that Helps
Ask me anything.
GL :slight_smile: PJ :v:

You can also use the esptool just as the IDE does. You just don’t see it easy. the command is like this: “esptool.exe” --chip esp32c3 --port “COM10” --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x0 “C:\Users\Dude\target.bin”
and worth Noting the Flashing of the four files is precisely what the IDE does under the hood with those offsets and esptool. :+1:
Bonus, Flashing the Target.bin file is the same as Flashing the Factory.bin as in the Getting Started WiKi for the Xiao ESP32C3 Here: using the EspRFTestTool_
same tech, different file. :vulcan_salute:

Thank you for this documentation. I use PlatformIO for compiling and flashing, which also generates binary files. I have utilized GitHub Actions on my GitHub repository to automatically generate these binary files with each new release. This allows anyone to flash a working version for a supported microcontroller without needing to build the project locally. You can find more information on this repository:

Hi there,
Yes this is more geared to a local control, No network required.
Nice feeder project though for sure, great doc’s. No schematic or PDF of it?

This was meant to demonstrate the usage of that menu item under “Sketch” in Arduino,
“Export Compiled Binary” just connecting the DOTs :smile: :+1:

Seeed would do better IMO with New User’s Along with the Wiki examples that go out of date and don’t work anymore to Provide the compiled binary in a Uf2 or HEX form also so “third graders” can drop it on the Xiao and GO!
The vast , Plethora a veritable cornucopia of Libraries and Board files is NUTZ and a huge barrier to entry for newbies and non tech types…just saying :wink: :v:
GL :slight_smile: PJ
Here is the Link to make the uf2 file in the ZIP