方法1
在魔法棒设置里面找到User选项栏
![](https://img2024.cnblogs.com/blog/1595732/202403/1595732-20240301084647173-1865324262.png)
在红色区域内打勾并输入下面的指令
C:\Keil_v5\ARM\ARMCC\bin\fromelf.exe --bin -o "$L@L.bin" "#L"
就是利用了fromelf.exe命令 --bin 表示输出bin文件 -o 输出目录 源文件
After Build - User command #1: C:\Keil_v5\ARM\ARMCC\bin\fromelf.exe --bin -o "C:\Users\hua\Desktop\App\USER\Objects\app.bin" "C:\Users\hua\Desktop\App\USER\Objects\app.axf"
# keil 官方示例
$K\ARM\ARMCC\bin\fromelf.exe --i32combined --output=@L.hex !L
C:\Keil\ARM\ARMCC\bin\fromelf.exe --i32combined --output=myprog.hex myprog.axf
方法2
使用hex2bin.exe这个命令行工具
hex2bin.exe xxxx.hex
hex2bin.exe下载地址https://www.keil.com/download/docs/7.asp
![](https://img2024.cnblogs.com/blog/1595732/202403/1595732-20240301090126169-608498062.png)