问题描述
大家都有过 反汇编 及 生成 bin
文件 的需求。
但是 keil
最多只支持两个命令,若再想使用工具对固件进行 签名、加密等操作就显然不够用了。
fromelf.exe --text -c -o "$L@L.asm" "#L"
fromelf.exe --bin -o "$L@L.bin" "#L"

问题分析
能自动化的东西绝不手动。Keil
调用 bat
脚本,脚本里执行多命令。
解决方法
为使命令更为简洁优雅,需要使用 keil
关键字给 bat
脚本传参,同时保证足够的灵活性。 keil
关键字详见参考资料。
keil 定义执行的用户命令
..\firmware.bat "$J\..\bin" "#L" "$L@L.asm" "$L@L.bin"

脚本内容
set compiler_path=%1
set axf_file=%2
set asm_file=%3
set bin_file=%4
:: 反汇编
%compiler_path%\fromelf.exe --text -c -o %asm_file% %axf_file%
:: 生成 bin 文件
%compiler_path%\fromelf.exe --bin -o %bin_file% %axf_file%
注:
keil
没有提供编译器bin
路径的关键字,只有编译器include
路径,所以使用"$J\..\bin"
代替,一点小瑕疵,强迫症表示极其难受。
网友评论