Compile sketch into bootloader with Atmel Studio or Arduino IDE

Hello,

For production purposes, I am trying to shorten the onboarding process of my Arduino code from uploading bootloader using atmel ICE, and then uploading a sketch...to simply having one binary file that contains both the bootloader and sketch.

I have heard it's possible to compile my sketch into a bootloader using Atmel Studio, but if it's possible with Arduino IDE, that would be preferred.

So, is this possible, and if so can someone explain or link me on how this can be done?

Thanks

In the Arduino IDE, Sketch > Export Compiled Binary will save two binary files to the current sketch folder. One has "witn_bootloader" added into the filename. That binary contains both the compiled sketch and bootloader. So if you upload that binary file to the microcontroller, you will then be able to upload the bootloader. If you use the other binary file, the bootloader is not flashed.

I seem to remember reading somewhere that Export Compiled Binary isn't fully working on all architectures. I just tested it with Arduino AVR Boards (Uno, etc.) and it worked fine.

Let me know if you run into any trouble using it and I'll see if I can help out.

I am using an ARM board, and "Export Compiled Binary" seems to only creates one .bin file, which I think is the sketch only (no with_bootloader in file name).

Googling around, all solutions mainly focus on AVR boards, which use hex files. It's possible to merge bootloader and sketch .hex files into one, but I am not sure if that method will work if I convert my bootloader/sketch from .bin to .hex, merge, then convert back to .bin.

I see. That's a shame. Unfortunately, I don't know how you can do it for an ARM board, but maybe someone else here will be able to help.