Keil5扩展命令

问题描述

使用keil5有过反汇编及生成bin文件的需求,但是keil5最多只支持两个命令,若在想使用工具对固件进行签名、加密等操作就不够用了。

fromelf  --text  -a -c  --output=bootloader.dis  Objects\bootloader2.axf
fromelf  --bin  --output=bootloader.bin  Objects\bootloader2.axf

使用keil关键字简写如下:

fromelf --text -a -c -o "$L@L.dis" "#L"
fromelf --bin -o "$L@L.bin" "#L"

生成的dis文件和bin文件的路径就是axf文件路径

解决办法

使用bat脚本,脚本里执行多行命令。脚本格式如下:

script.bat "param1" "param2" "..."

为了使命令更为简洁优雅,需要使用关键字给bat脚本传参,同时保证足够的灵活性。keil关键字详见参考资料。

keil定义执行的用户命令

$L\..\script.bat  "$J\..\bin" "#L" "$L@L.dis" "$L@L.bin"

需要注意script.bat脚本的位置,我是与keil工程放在一起,在axf文件外面一层。

脚本内容:

@set compiler_path=%1
@set axf_file=%2
@set dis_file=%3
@set bin_file=%4

:: 反汇编
%compiler_path%\fromelf.exe --text -c -o %dis_file% %axf_file%
:: 生成 bin 文件
%compiler_path%\fromelf.exe --bin -o %bin_file% %axf_file%

| 注:”$J..\bin”表示编译器路径,加入@编译时不回显

参考资料

https://developer.arm.com/documentation/101407/0537/Utilities/Key-Sequence-for-Tool-Parameters

https://www.jianshu.com/p/0cc0429ee9fb

Leave a Reply

Your email address will not be published. Required fields are marked *