I am using Mbed Studio (version 1.4.3). When I started with Mbed OS (version 6.2.1), it would produce both a .bin and a .hex file when I built my project. But when I updated to Mbed OS 6.15.1, I started getting just the .bin file.
I eventually tracked down the target.OUTPUT_EXT setting, which I could set to “hex” to get a .hex file. That’s fine for my development setup (I’m using a j-Link BASE Compact), but for the other prototypes I actually need the .bin file to download via the bootloader.
Currently, I have to edit my mbed_app.json file to change the “hex” to a “bin”, and rebuild everything. Is there anyway to get it to produce both type of output each time I build?
There is a utility program called arm-none-eabi-objcopy in the GCC_ARM package which converts a .bin file to a .hex file.
I use the following Mbed-CLI commds put in one shell script to build both .bin and .hex files:
I think you can make the arm-none-eabi-objcopy utility run also by editing the CMakeLists.txt file located in the root directory of your project. Unfortunately, I’m not a CMake expert. Maybe @ladislas can help you with that.
Thank you, both @hudakz and @lasislas for your quick answers!
I should have mentioned I am running on Windows; but I can certainly create a cmd script to run the
arm-none-eabi-objcopy tool to create a .bin (or .hex) from the elf. But it’s a small pain that I have to go run a separate script after I do a build in Mbed Studio.
I am curious what changed. Since it’s the same version of Studio, it must be something in the build tools in mbed-os. I don’t think Studio uses CMake to run the build (at least, not on Windows). Do you know what Studio does use? I still have both version of mbed-os (6.2.1 and 6.15.1), but when I diff them, there are approximately a million different files. Which one(s) should I look at to see what changed in the build?
Also, is there a way to get Studio to use CMake? Or do you have to build from the command line to do that?
Although I am still curious why it used to produce both (but now it does not), I went ahead created a script I can run to produce the .bin from the .elf when I need it (and I left the build producing the .hex, which is that I mostly need while developing).