Introduction
IAP (In-application programming) allows firmware updates over the network without disassembling the device. The firmware of an IAP system typically consists of two parts: the BootLoader Code and the Application Code, stored at different starting addresses:

During system operation, the Bootloader program runs first to check the status and determine whether to execute the application program or upgrade the firmware. In actual development, these two programs are usually written separately, generating two Bin files. To facilitate the download process, these two files can be merged into one, saving a lot of time. This article will explain how to use JFlash to merge two Bin files or two Hex files.
Preparation
-
File to merge 1: bootloader.hex, starting address: 0x8000000
-
File to merge 2: app.hex, starting address: 0x20001000. If it’s a Bin file, ensure the starting address is confirmed.
-
JFlash software
Create Project
Just like downloading a program, first create a new project.
1. Open JFlash

2. Create New Project
Click File -> New Project

3. Select Chip Model
This supports many ARM Cortex core chips. Select the corresponding chip; I will choose the STM32F103RE series.

4. Open the Program File to Merge 1: bootloader.hex
Click File -> Open data file to open the bootloader program.


5. Open the Program File to Merge 2: app.hex
Click File -> Merge data file to open the app program.


Ensure that the starting address of the bootloader program plus the size of the bootloader code does not exceed the starting address of the app program, as shown in the figure below:

6. Save the Merged File
Click File -> Save data file as to save the merged file, and choose the file type as needed.


Note
If the files to be merged are Bin files, they do not carry address information, so you will need to specify addresses without overlapping. It is best to save various files in a format that carries address information, such as hex. For the difference between Hex files and Bin files, you can refer to the article: What Are the Differences Between BIN, HEX, AXF, and ELF File Formats


This article is authorized for publication by the author ‘wcc149’, from the public account ‘Electronic Circuit Development Learning‘.