方法
整理很久之前帮客户写的一个项目,在做CI/CD的时候发现每次打包固件使用python脚本比较麻烦,直接使用Jlink提供的JFlash更加的高效快捷
JFlash.exe -openprj"AT32F415CBxx.jflash" -open"E:\work\AT32F415\project\new_version_boot\Debug\rtthread.bin",0x08000000 -merge"E:\work\AT32F415\project\master\Debug\rtthread.bin",0x08008000 -saveas"Merged.hex" -auto
参考
《UM08003_JFlash》
Programming multiple data files at once
For some production environments, the firmware image to program may consist of multiple data files, e.g.
- Bootloader
- Firmware
- Unit-specific data
- MAC address
- Calibration data
- Signature
- etc…
J-Flash can only program one data file to a target at a time.
Programming the data files separately could cause a series of issues, e.g.
- One of the data files enables a flash write protection, causing following flash programming attempts to fail
- Multiple programming operations decrease the flash memory’s lifespan
- Multiple programming operations increase the time required to produce a single unit
Instead, J-Flash can be used to merge multiple data files into a single data file which can then be programmed in one go. Example:
JFlash.exe -openprj"Path\To\Proj.jflash" -open"Path\To\Data1.bin",0x08000000 -merge"Path\To\Data2.bin",0x08000200 -merge"Path\To\Data3.bin",0x08000400 -saveas"Path\To\Merged.hex" -auto
The command line above does the following:
- Starts J-Flash
- Opens the project file
Proj.jflash
- Opens the data file
Data1.bin
- Merges
Data2.bin
intoData1.bin
- Merges
Data3.bin
into the merged data - Saves the resulting data file to
Merged.hex
- Starts production programming of the merged data
Note:
The contents of the data files Data1.bin
, Data2.bin
and Data3.bin
are not changed by J-Flash using the command line above.
Furthermore, saving the resulting merged data before programming is not necessary and that step may be omitted.