新版WINAVR环境下Demo.c编译及调试具体步骤 | hotpower 发表于 2004-9-29 13:06 AVR 单片机 ←返回版面 举报该贴 |
新版WINAVR环境下Demo.c编译及调试具体步骤: (HotPower@126.com 2004.9.28)
运行mfile. 运行Programmers Notepad 2.
1. 在Programmers Notepad 2环境下 File->New->Project 建立一个新项目: demo.pnproj 在Projects窗口 New Project Group->demo->Add Files 打开C:\WinAvr\examples\demo\demo.c 2. 在mfile环境下 File->Open.. 打开C:\WinAvr\mfile\makefile_template模版文件 另存为C:\WinAvr\examples\demo\makefile 点击ok确认. 3. 在mfile环境下 a.MakeFile->Main file name.. 设置main file为demo b.Mainfile->Mcu type->At90->at90s2313 c.Mainfile->Debug format->Avr-ext-COFF(AVR Studio...) 生成可以在avrstudio中打开进行源码级调试的目标文件 C:\WinAvr\examples\demo\demo.cof 4. 在mfile环境下 File->save保存make文件 5. 在Programmers Notepad 2环境下 在Projects窗口 New Project Group->demo->Add Files 打开C:\WinAvr\examples\demo\makefile Tools->[WINAVR] Make ALL 在Output窗口显示C:\WinAvr\examples\demo\demo.c的编译结果如下:
> "make.exe" all
-------- begin -------- avr-gcc (GCC) 3.4.1 Copyright (C) 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Compiling: demo.c avr-gcc -c -mmcu=at90s2313 -I. -gstabs -Os -funsigned-char -funsigned- bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,- adhlns=demo.lst -std=gnu99 -Wp,-M,-MP,-MT,demo.o,-MF,.dep/demo.o.d demo.c -o demo.o
Linking: demo.elf avr-gcc -mmcu=at90s2313 -I. -gstabs -Os -funsigned-char -funsigned-bitfields - fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=demo.o - std=gnu99 -Wp,-M,-MP,-MT,demo.o,-MF,.dep/demo.elf.d demo.o --output demo.elf -Wl,-Map=demo.map,--cref -lm
Creating load file for Flash: demo.hex avr-objcopy -O ihex -R .eeprom demo.elf demo.hex
Creating load file for EEPROM: demo.eep avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \ --change-section-lma .eeprom=0 -O ihex demo.elf demo.eep
Creating Extended Listing: demo.lss avr-objdump -h -S demo.elf > demo.lss
Creating Symbol Table: demo.sym avr-nm -n demo.elf > demo.sym
Converting to AVR Extended COFF: demo.cof avr-objcopy --debugging --change-section-address .data-0x800000 --change- section-address .bss-0x800000 --change-section-address .noinit-0x800000 -- change-section-address .eeprom-0x810000 -O coff-ext-avr demo.elf demo.cof Discarding local symbol outside any compilation unit: .do_copy_data_start Discarding local symbol outside any compilation unit: .do_copy_data_loop Discarding local symbol outside any compilation unit: .do_clear_bss_start Discarding local symbol outside any compilation unit: .do_clear_bss_loop
Size after: demo.elf : section size addr .text 244 0 .data 0 8388704 .bss 3 8388704 .noinit 0 8388707 .eeprom 0 8454144 .stab 804 0 .stabstr 1234 0 Total 2285
Errors: none -------- end --------
> Process Exit Code: 0
6.运行AVR Studio 4 键入cancel放弃创建或打开AVR Studio的项目文件 选择AVR Simulator ->AT90S2313 键入finish, AVR Studio 4开始创建deno_cof.aps文件 7.在AVR Studio 4环境下Debug Demo.c ............... HotPower@126.com 2004.9.28 于中秋月下
|
|
现在觉得很方便 | hotpower 发表于 2005-1-22 09:38 AVR 单片机 ←返回版面 举报该贴 |
d步骤对单个文件实际就是废话,主要用于多文件系统...
单文件也可用d步骤,但必须将include xxx.c左边的对勾去掉才行...这不更麻烦吗???
实际上,用熟了make工具后,只需3步即可:
1.打开自己已存在的同种MCU的makefile. 2.改写aMakeFile->Main file name.. 设置main file为自己的主文件(不要加文件后缀)
如果想多文件 2.1 Mainfile->C/C++ source file(s)... 选择a1.c a2.c an.c 点击ok. (注意,include xxx.c左边的对勾不能去掉,xxx是主文件)
3.保存在现在的目录中 File->save as...保存make文件
附1.如果想void main(void){}不警告,就直接改写makefile CFLAGS += -ffreestanding
附2.如果想C++编程,也可直接改写makefile(不能用-ffreestanding) 将CC = avr-gcc改为CC = avr-g++
可以看出,实际每次只需改文件名即可... 如果都是main.c那么就直接拷贝makefile到当前目录即可...
刚开始觉得makefile有点烦,现在觉得很方便,几乎不费劲...
|
|
|
文章评论(0条评论)
登录后参与讨论