Creating .bin file for marlin built through PlatformIO and VScode

I am using PlatfromIO via “auto build marlin” on VS code (windows 10) to compile Marlin, I have had no issues previously, by either updating directly via USB, or using the .hex file via cura.

Now I need the .bin file to upgrade a 3d printer remotely. However, whenever I build Marlin, the last few lines are about building firmware.hex and firmware.elf , but nothing about the firmware.bin file and it doesn’t exist in the .pio folder unlike the .hex and .elf files which do.

I have searched the web and found a suggestion re. additional script .py, but this does not work (won’t even build).

I am using both the marlin v 2.0.x and marlin-bugfix 2.0.x available from github and even with a straight download of the code (no changes) although it builds, it doesn’t produce .bin files. (Marlin mega2560)

Are you 100% sure about that? When previously the .hex file was enough? Needing a file for Marlin that is not generated by Marlin sounds weird.

If you have the .hex file, just objcopy it into a .bin file. In a VSCode Terminal, and assuming the .hex file is located in a relative path .pio\build\ATmega2560\firmware.hex, and a Windows username of Max you can execute

C:\Users\Max.platformio\packages\toolchain-atmelavr\bin\avr-objcopy.exe -O binary -I ihex .pio\build\ATmega2560\firmware.hex firmware.bin

And that will convert from .hex (Intel Hex) to .bin (binary).

As can be adapted from this code, that can also be automated in an extra_script.

You need the .hex if you are loading it through a loader such as cura etc, without the loader you can insert a microSD card and if there is a .bin file it will install this upon booting up. it does not recognise a .hex as a bootable image.

Thanks for your reply, I will try this later or tomorrow.

The odjcopy worked, had to be slightly different - needed an extra “/” from your example, and unfortunately my path to the .hex and .bin files did not work - perhaps too long or incompatible characters, so copied the .hex to c:/marlin and used explicit paths as:

C:\Users\username\ .platformio\packages\toolchain-atmelavr\avr\bin\objcopy.exe -O binary -I ihex C:\Marlin\firmware.hex C:\Marlin\firmware.bin

Which worked fine, the .bin worked without needing to move a computer to the printer - just recognised the file upon boot up and updated the firmware no issue.

1 Like

Max, thank you. (I copied the program to the mega2560 folder and ran it, but it worked. No idea why VSC didn’t produce a bin file by itself, it always has in the past, but I’m too busy to find out. I’ll use your method if I need it in the future. [I normally get close on the first compile, but there are some details I missed - especially when it comes to Marlin (although I’ve been compiling code for decades)].)

Can someone spell this out in lame terms? I am not the best with computers an have this exact problem.

If you are able to compile the firmware you will find the bin file by navigating to the project folder in the Windows explorer and opening the .pio folder and searching therein.