在KEIL中生成bin文件的方法
生成hex文件
KEIL中默認(rèn)生成的是axf文件。
如果想要生成hex文件,則只需要簡單地勾一下:
?
生成bin文件
要生成bin文件,則需要用到fromelf。
Keil自帶了一個小工具,可以通過執(zhí)行指令來將AXF文件轉(zhuǎn)換為BIN文件這就需要調(diào)用一個外部程序fromelf.exe來將AXF文件轉(zhuǎn)換為BIN格式文件。
fromelf.exe文件的位置在安裝目錄?Keil_v5\ARM\ARMCC\bin?或者?Keil_v5\ARM\ARMCLANG\bin?目錄下。
在Options -> User -> After Build/Rebuild -> Run#1中輸入:
C:\Keil_v5\ARM\ARMCLANG\bin\fromelf.exe --bin -o ./Objects/Demo.bin ./Objects/Demo.axf其中-o后面的要輸出目標(biāo)bin文件的路徑和文件名;最后面的是生成的axf文件的路徑及文件名。
這個方法網(wǎng)上有很多例子可以參考。
?
fromelf詳解
首先參考KEIL官網(wǎng)的手冊:
fromelf Command-line Options
http://www.keil.com/support/man/docs/armutil/armutil_pge1362128884798.htm
?
主要內(nèi)容如下:
ARM 映像轉(zhuǎn)換工具
fromelf [options] input_file
選項(xiàng):
--help 顯示幫助信息
--vsn 顯示版本信息
--output file 輸出文件名. (默認(rèn)輸出 -text 格式)
--nodebug 不要輸出調(diào)試信息到映像文件中
--nolinkview 不要輸出段信息到映像文件中
二進(jìn)制輸出格式:
--bin 普通二進(jìn)制
--m32 摩托羅拉32位Hex碼
--i32 英特爾32位Hex碼
--vhx 定向字節(jié)的 Hex 格式
--base addr 為 m32,i32設(shè)置基地址(可選的)
輸出格式要求的調(diào)試信息
--fieldoffsets Structures/Classes的匯編描述
--expandarrays Arrays inside and outside structures are expanded
其他輸出格式:
--elf ELF格式
--text 文本信息
文本信息的標(biāo)志
-v 詳細(xì)信息
-a 打印數(shù)據(jù)的地址信息 (得到的.axf映像文件)
-c 匯編碼
-d 打印數(shù)據(jù)的段內(nèi)容
-e 打印例表
-g 打印調(diào)試表
-r 打印重定位信息
-s 打印符號表
-t 打印字符表
-y 打印段內(nèi)容分析
-z 打印代碼與數(shù)據(jù)的大小信息
?
可移植的方法
上述方法有一個不好的問題,就是在一個項(xiàng)目組里面多人同時開發(fā)一個項(xiàng)目時,如果大家安裝KEIL開發(fā)環(huán)境時的路徑不一樣,則無法共享同一個配置。另外,當(dāng)完成一個項(xiàng)目的開發(fā)后,再開始一個新的項(xiàng)目時,生成的axf文件的文件名也需要重新配置。為了解決這個問題,可以使用以下的命令行:
fromelf --bin -o "$L@L.bin" "#L"或者
$K\ARM\ARMCC\bin\fromelf.exe --bincombined --output=@L.bin !L自動生成跟工程名稱相同的bin文件。
?
說明:
| 符號代號(Key Code) | |
| $ | 擴(kuò)展為 指定文件的路徑名 |
| @ | 表示 Output -> Name of Exectable:定義的工程名,比如test1 build工程后,最終生成的bin文件名稱將是test1.bin |
| !? | 當(dāng)前目錄下的擴(kuò)展路徑 !L 編譯(Build)后,就是?.\obj\xx.axf文件 |
| 文件代號(File Code) | |
| K | ?keil develop chaintool 工具鏈(fromelf.exe) |
| L | Linker output file L.bin 編譯后,生成的就是最終的xx.bin文件 |
參考:
Key Sequence for Tool Parameters
http://www.keil.com/support/man/docs/uv4/uv4_ut_keysequence.htm
Use?Key Sequences?to pass arguments from μVision to external user programs. Key Sequences are combinations of a?Key Code?and a?File Code. Key sequences can be used, for example, in the dialogsTools,?SVCS,?Options for Target — User, or from the command line. The following rules apply:
- Certain Key Codes have to be duplicated when used from the command line.
To use the symbols?$, #, %, @, ~, ^
escape them with?$$, ##, %%, @@, ~~, ^^. - Enclose Key Sequences within quotes (" ") when using folder names that might contain special characters (space,?~, or?#).
Key Codes and File Codes are listed in the tables below:
| % | File name with extension (PROJECT1.UVPROJ) |
| # | File name with extension and complete path specification (C:\MYPROJECT\PROJECT1.UVPROJ) |
| @ | File name without extension or path specification (PROJECT1) |
| $ | Path name of a file. Path names get extended with a backslash. For example,?$P?could generate?C:\MYPROJECT\. |
| ! | File name with extension and relative path specification to the current folder (.\SRC\TEST.C) |
| ~?1 | Line number of the current cursor position |
| ^?1 | Column number of the current cursor position |
| $D | Device name as selected from the Device Database. |
| E | Editor file name currently in focus. |
| F | Depending on the context, this File Code returns:
|
| H | Application HEX file name (PROJECT1.H86). |
| $J | Absolute compiler system include folder. Compiler base folders are listed in the fieldProject — Manage — Project Items — Folder/Extensions - ARMCC Folder. The include path depends on the compiler selected in?Options for Target - Code Generation - ARM Compiler. |
| K | Absolute root folder of the development toolchain, regardless of the Key Code used. |
| L | Linker output file. Typically the executable file used for debugging (PROJECT1). |
| $M | CPU mask revision number. |
| P | Current project file name. |
| X | μVision executable program file (..\UV4\UV4.EXE). Works for For Key Code %, # @. |
| $X | XTAL clock frequency in MHz as specified in?Options for Target — Target — XTAL. |
| ^X | XTAL clock frequency in kHz as specified in?Options for Target — Target — XTAL. |
?
?
?
?
?
?
總結(jié)
以上是生活随笔為你收集整理的在KEIL中生成bin文件的方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android 设置全屏样式主题的总结
- 下一篇: eureka 自我保护机制