搜索
bottom↓
回复: 13

[翻译]无聊的时候,翻译一下Iccavr关于命令行编译的部分……

[复制链接]

出0入296汤圆

发表于 2006-4-27 23:35:41 | 显示全部楼层 |阅读模式
Compiler Arguments

编译命令行



The IDE controls the behaviors of the compiler by passing command line arguments to the compiler Driver. Normally you do not need to know what these command line arguments do, but you can see them in the generated makefile and in the Status Window when you perform a build. Nevertheless, this page documents the options as used by the AVR IDE in case you want to drive the compiler using your own editor/IDE such as Codewright. All arguments are passed to the driver and the driver in turn passes the appropriate arguments down to different passes.



IDE编程环境通过给编译器传送命令行来控制编译器的动作。当我们构建工程项目的时候,你可以在状态窗口中看见makefile的内容,通常,你并不需要去知道那些命令行参数具体是做什么的。然而,这篇文章告诉我们,在你想通过自己的编辑器来驱动编译器的时候,你同样可以像在 AVR 集成编译环境中一样使用那些设置。所有的命令参数都被传送给编译器,然后,编译器按照适当的顺序处理不同的编译流程。

出0入296汤圆

 楼主| 发表于 2006-4-27 23:47:18 | 显示全部楼层
The general format of a command is

通用的命令格式是:



iccavr [ command line arguments ] <file1> <file2> ... [ <lib1> ... ]

iccavr [命令行参数] <文件一> <文件二> ... [<lib库一> ...]



where iccavr is the name of the compiler driver. As you can see, you can invoke the driver with multiple files and the driver will perform the operations on all of the files. By default, the driver then links all the object files together to create the output file.

"iccavr"是编译驱动器的名称。就像你看到的那样,你可以调用编译器处理多文档的情况,这时,编译器会按照设定处理所有的文件。默认情况下,编译器会将所有的目标文件连接在一起来构建一个输出文件。



For most of the common options, the driver knows which arguments are destined for which compiler passes. You can also specify which pass an argument applies to by using a -W<c> prefix. For example:

在大多数情形下,编译器知道每一个参数是针对哪一项编译设定的。你也可以通过使用一个 -W<c> 来自己详细的指定参数应用的环境。例如:



-Wp        is the preprocessor. e.g -Wp-e

-Wp      说明这是预处理程序   例如:-Wp-e



-Wf        is the compiler proper. e.g. -Wf-atmega

-Wf      说明编译的硬件对象是什么 比方说 -Wf-atmega



-Wa        is the assembler

-Wa      说明这是一个汇编程序



-Wl        (letter el) is the linker

-Wl      (W后面的是字母L) 说明这是一个连接器

出0入296汤圆

 楼主| 发表于 2006-4-27 23:54:09 | 显示全部楼层
Arguments Affecting the Driver itself

命令行影响着编译器本身



-c        Compile the file to the object file level only (does not invoke the linker.)

-c       仅仅将源文件转换为目标文件(并不调用连接器)



-o <name>        Name the output file. By default, the output file name is the same as the input file name, or the same as the first input file if you supply a list of files

-o <名称>给输出文件命名。默认情况下,输出文件的名称和输入文件的名称相同,或者和你提供的文件列表中第一个输入文件名称相同。



-v        Verbose mode. Print out each compiler pass as it is being executed.

-v       冗长模式(?)  打印出编译器编译的动作记录。

出0入296汤圆

 楼主| 发表于 2006-4-28 00:00:29 | 显示全部楼层
Preprocessor Arguments

预处理设定



-D<name>[=value]        Define a macro. See Compiler Options: Macro Define(s). Note that you should define ATMEGA if the target is a ATMega device since there are some definitions in the header file avr.h which depend on this being defined.

-D<名称>[=设定值] 定义一个宏。参见编译设定的相应内容:宏定义。注意:在你编译ATMega器件程序的时候,你需要定义一个名为ATMEGA的宏。因为在头文件avr.h中有许多重要的宏定义依赖于这个宏的存在(ATMEGA)。



-U<name>        Undefine a macro. See Compiler Options: Macro Undefine(s).

-U<名称> 为定义的宏。参见编译设定的相关内容:为定义宏。



-e                Accept C++ comments.

-e                兼容C++的注释模式



-I<dir>        (Capital letter i) Specify the location(s) to look for header files.

Multiple -I flags can be supplied.

-I<目录>  (这里是大写字母I) 设定查找头文件的路径。编译器支持多个I参数的存在。

出0入296汤圆

 楼主| 发表于 2006-4-28 18:55:05 | 显示全部楼层
Assembler Argument

汇编程序设定



-n        Generally only use for assembling a Startup File. Normally the assembler inserts an implicit ".area text" at the beginning of a file it is processing. This allows the common case of omitting an area directive in the beginning of a code module to be assembled correct. However, the startup file has special requirements that this implicit insertion should not be done.

-n       通常,这个参数被用作说明使用汇编程序作为启动文件的情况。一般,汇编程序会在他处理的文件开头处插入一个段“.area test”。这样就能保证在通常省略一个指向汇编代码起始位置的区段时,代码能被正确的编译。但是,汇编程序作为启动文件时却要求省略这一区段。(-n就是用来完成这一特殊的说明工作的,即在汇编语言程序中省略这一区段的插入工作)

出0入296汤圆

 楼主| 发表于 2006-4-28 19:03:04 | 显示全部楼层
Compiler Arguments

编译设定



-e        Accept extensions including 0b???? binary constants.

-e       兼容扩展的二进制数值表示模式 0b????



-l        (letter el) Generate a listing file.

-l       (这里是字母L) 编译时生成一个列表文件



-A -A        (two -As) Turn on strict ANSI checking. Single -A turns on some ANSI checking.

-A -A    (两个 -A) 启用严格的ANSI标准检测。单个 -A将打开部分ANSI检测功能。



-g        Generate debug information.

-g       在编译时产生调试信息。

出0入296汤圆

 楼主| 发表于 2006-4-28 19:14:57 | 显示全部楼层
When using with the driver, the options below must be used with the -Wf- prefix. e.g. -Wf-str_in_flash.

下面的参数在作用于编译器的时候,一定要加上-Wf作为说明,例如:-Wf-str_in_flash



-Mavr_mega        Generate ATMega instructions such as call and jmp instead of rcall and rjmp.

-Mavr_mega        编译时为ATMega中call和jmp生成指令来代替rcall 和 rjmp。



-Mavr_enhanced        Generate enhanced core instructions and call and jmp

-Mavr_enhanced    编译时生成带call和jmp的核心增强代码。



-Mavr_enhanced_short        Generate enhanced core instructions but not call and jmp

-Mavr_enhanced_short       编译时生成不带call和jmp的核心增强代码



-str_in_flash        Allocate literal strings in FLASH only

-str_in_flash     将字符串常量全部放在Flash存储器里面。



-use_elpm                Generate ELPM instead of LPM for accessing Flash memory. This is useful for bootloader program for devices with greater than 64K bytes of flash.

-use_elpm         编译时使用ELPM代替LPM来处理Flash存储器。当使用bootloader程序为大于64Kflash的器件编程的时候,这是一个非常有用的参数。

出0入296汤圆

 楼主| 发表于 2006-4-28 19:40:34 | 显示全部楼层
Assembler Arguments

汇编程序设定



-W        Turn on relocation wrapping. See Relative Jump/Call Wrapping. When using the driver, you must use -Wa-W.

-W       允许在编译时对程序结构进行重新布局。请参见 Jump/Call区别于联系的相关内容。使用的时候,注意格式是:-Wa-W.



Linker Arguments

连接设定



-L<dir>        Specify the library directory. Only one library directory (the last specified) will be used.

-L<目录> 指定Lib库文件的目录。但是只能有一个Lib库文件的目录有效(以最后一个设定为算)。



-O        Invoke the Code Compressor (operative only for the PROFESSIONAL version).

-O       启用代码压缩器。(这一操作仅仅在ICC专业版中有效)。



-m        Generate a map file.

-m       编译时,生成map文件。



-g        Generate debug information.

-g       编译时生成调试信息。



-u<crt>        Use <crt> instead of the default startup file. If the file is just a name without path information, then it must be located in the library directory.

-u<crt>  使用<ctr>指定的文件来代替默认的启动文件。如果指定的只是一个不含路径信息的文件名称,那么编译器将在lib库指定的位置查找。



-W        Turn on relocation wrapping. See Relative Jump/Call Wrapping. Note that you need to use the -Wl prefix since the driver does not know of this option directly (i.e. -Wl-W).

-W       允许在编译时对程序结构进行重新布局。请参见 Jump/Call区别于联系的相关内容。注意:因为编译器并不知道这个参数使用的目的对象具体是什么,所以在使用的时候你需要增加一个-Wl前缀。



-fihx_coff        Output format is both COFF and Intel HEX.

-fihx_coff        设定输出格式为COFF格式和Intel HEX格式同时存在。



-fcoff        Output format is COFF. Note that if you have EEPROM data, it is always written as Intel HEX format in the <output>.eep file.

-fcoff   设定输出格式为COFF格式。注意,如果你的工程中存在需要存储于EEPROM的数据,系统会一直使用Intel HEX格式作为输出到EEPROM中的文件的格式。



-fintelhex        Output format is Intel HEX

-fintelhex        设定输出格式为Intel HEX格式。



-fmots19        Output format is Motorola S19 (not used on AVR - you can ignore this).

-fmots19 设定输出格式为Motorola S19格式(如果不是编译AVR项目,你可以忽略这个选项)

出0入296汤圆

 楼主| 发表于 2006-4-28 20:11:47 | 显示全部楼层
-bfunc_lit:<address ranges>        Assign the address ranges for the area named "func_lit." The format is <start address>[.<end address>] where addresses are byte addresses. Any memory not used by this area will be consumed by areas that follow it, so this effectively declares the size of the FLASH memory. For example, some typical values are:

-bfunc_lit:<地址序列>按照指定的地址序列为"func_lic"区段编址。地址序列的格式是:<起始地址>[.<中指地址>]。这里是按照字节来编址的。这一区段声明的地址空间将受到保护不会被其他相邻的区段占用,所以,这是一个有效的声明Flash存储器大小的方法。例如,一些典型的设定值为:



-bfunc_lit:0x60.0x10000        for ATMega

-bfunc_lit:0x60.0x10000    当使用ATMega系列的时候



-bfunc_lit:0x1a.0x800         for 23xx

-bfunc_lit:0x1a.0x800      当使用23系列的时候



-bfunc_lit:0x1a.0x2000         for 85xx

-bfunc_lit:0x1a.0x2000     当使用85系列的时候



-bdata:<address ranges>        Assign the address ranges for the area or section named "data," which is the data memory on the AVR. For example, some typical values are:

-bdata:<地址序列>          按照指定的地址序列为data区段或者块编址。其中,data区段是AVR的数据存储区。例如,一些典型的设定值为:



-bdata:0x60.0x800                for ATMega

-bdata:0x60.0x800          当使用ATMega系列的时候



-bdata:0x60.0x80                for 23xx

-bdata:0x60.0x80           当使用23系列的时候



-bdata:0x60.0x200                for 85xx

-bdata:0x60.0x200          当使用85系列的时候



-beeprom:<address ranges>        Assign the address ranges for the EEPROM. EEPROM data is written to <output file>.eep as an Intel HEX file regardless of the output file format.

-beeprom:<地址序列>        按照指定的地址序列为EEPROM编址。EEPROM数据将被强制按照Intel HEX格式输出到<输出文件名>.eep文件中。



-b<area>:<address ranges>        Assigns the address ranges for the area. You can use this to create your own areas with its own address. See Program Areas. The range format is <start>.<end>[:<start>.<end>]*. For example:

-b<区域名称>:<地址序列>    按照指定的地址序列为指定的区域编址。你可以使用这个参数来建立你自己的区域并为之分配自己的地址。具体参照编程区域的相关内容。编址的格式是<起始地址>.<结束地址>[:<起始地址>.<终止地址>]



-bmyarea:0x1000.0x2000:0x3000.0x4000



specifies that "myarea" goes from locations 0x1000 to 0x2000, and 0x3000 to 0x4000.

设定"myarea"为从的0x1000到0x2000以及从0x3000到0x4000的地址空间。



-dram_end:<address>        Define the end of the internal RAM area. This is used by the startup file to initialize the value of the hardware stack. For the classic non-Mega devices, "ram_end" is the size of the SRAM plus 96 bytes of IO and CPU registers minus one. For the Mega devices, it is the size of the SRAM minus one. External SRAM does not affect this value since the hardware stack is always allocated in the internal RAM for faster execution speed.

-dram_end:<地址>           定义内部RAM区段的终止地址。这一设定被启动文件用来初始化硬件堆栈的大小。对于非Mega系列的器件来说,"ram_end"指定的是SRAM的大小加上96个字节的IO、CPU寄存器大小再减一以后的数值。对于Mega系列芯片来说,这一设定值是SRAM的大小减一以后的值。外部的SRAM大小不会影响到这一设定值,因为硬件堆栈总是被定位在内部的RAM空间中用以获得最快的执行速度。

出0入296汤圆

 楼主| 发表于 2006-4-28 20:32:21 | 显示全部楼层
-dhwstk_size:<size>        Define the size of the hardware stack. The hardware is allocated at the top of SRAM, then the software stack follows it. See Stacks.

-dhwstk_size:<大小>        定义硬件堆栈的大小。硬件堆栈总是被定为在SRAM的顶端,而软件堆栈就随其后。详情参见堆栈的相关内容。





-l<lib name>        Link in the specific library files in addition to the default libcavr.a. This can be used to change the behavior of a function in libcavr.a since libcavr.a is always linked in last. The "libname" is the library file name without the "lib" prefix and without the ".a" suffix. For example:

-l<lib库名称>     在默认的libcavr.a库之外连接指定的lib库文件。这个设定可以被用来改变libcavr.a中的函数实体,因为libcavr.a总是被最后连接的。lib库名称是lib文件的名称除去了lib前缀和.a扩展名以后的部分。例如:



-lstudio        "libstudio.a"        using with AVR Studio IO

-lstudio "libstudio.a"     使用AVR Studio的虚拟输入输出设备



-llpavr        "liblpavr.a"        using full printf

-llpavr  "liblpavr.a"      使用完整的printf函数



-lfpavr        "libfpavr.a"        using floating point printf

-lfpavr  "libfpavr.a"      使用可变指针的printf函数(通过修改指针来指定输出的显示缓冲地址)



-F<pat>        Fill unused ROM locations with "pat."

-F<字符>  在未使用的ROM空间中填充指定的字符



-R        Do not link in the startup file or the default library file. This is useful if you are writing an assembly only application.

-R       不连接启动文件和默认的lib库文件。这一选项在你编写一个纯汇编语言程序的时候非常有用。





---------------------------------------------------

That`s all.

And I want to say have a good night whatever you are.HaHaHaHa~~~~~~~~~
-----此内容被Gorgon Meducer于2006-04-28,20:32:43编辑过

出0入0汤圆

发表于 2006-4-29 07:59:24 | 显示全部楼层
期待楼主能把在Source Insight中使用ICC编译的方法写出来,ICC的编辑环境太差了。不过看到这么多参数,估计做出来也不容易。

出0入0汤圆

发表于 2011-3-4 10:46:15 | 显示全部楼层
请教,如何不开始iccavr软件,利用其命令行方式实现编译和链接,使其生成HEX文件呢?

出0入296汤圆

 楼主| 发表于 2011-3-4 16:42:35 | 显示全部楼层
答案是根据上面的说明用命令行模式来……
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-5-4 23:17

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表