|
|
|
| 论坛首页 -> AVR (原ourAVR.com) 技术论坛 -> 新版WINAVR环境下Demo.c编译及调试具体步骤 (属于论坛:AVR) | 跳转至: | 未登录 |
| ↓↓ 新版WINAVR环境下Demo.c编译及调试具体步骤 | 回复数:36,点击数:17382 |
|
抱歉本贴的回复数太多,为了减轻网络流量,只显示帖子正文的前后各10个回复。本贴的正文内容中间隐藏了16个回复。你需要 点击此处 才能查看全部内容。 对为你带来的访问不便表示歉意。不过我们仍会坚持即使没有登录,仍能共享我们网站的所有资料。你没有 登录后就能消除这个访问上的不便(可增加到显示60个回复)。 如果你是新用户请先 注册。注册是免费的,并且手续简单只需要填写用户名与口令。 ↓↓↓↓↓↓↓↓↓↓↓↓ |
|
【楼主位】 hotpower 菜农 积分:2136 派别: 等级:------ 来自:西安大雁塔村 |
新版WINAVR环境下Demo.c编译及调试具体步骤
hotpower 发表于 9/29/2004 1:06:57 PM AVR 单片机 ←返回版面 新版WINAVR环境下Demo.c编译及调试具体步骤: (HotPower@126.com 2004.9.28) 运行mfile. 运行Programmers Notepad 2. 1. 在Programmers Notepad 2环境下 File->New->Project 建立一个新项目: New.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 d.Mainfile->C/C++ source file(s)... 选择C:\WinAvr\examples\demo\demo.c 点击ok. 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 于中秋月下 |
||
|
|
|
|
【1楼】 armok 阿莫 积分:48830 派别: 等级:------ 来自:ourDEV.cn 站长 |
谢谢! 非常好。配合图片,就能成为新手入门的例子了。 | ||
|
__________________________ There's something good in this world. And it's worth fighting for …… |
|||
|
|
|
|
【2楼】 hotpower 菜农 积分:2136 派别: 等级:------ 来自:西安大雁塔村 |
这是我在***的一个"酷帖",拿来玩玩...当时我对winavr一无所知...
http://www.***bbs.com/club/bbs/ShowAnnounce.asp?id=1382379 |
||
|
|
|
|
【3楼】 tdh03z 积分:128 派别: 等级:------ 来自:江西 |
我按上面的步骤生成不了,发现少一个elf文件
昨晚仔细看了一个hotpower贴的makefile文件,发现在完成这一步后 d.Mainfile->C/C++ source file(s)... 选择C:\WinAvr\examples\demo\demo.c 点击ok. 加入源文件后,SRC后面跟的不是源文件位置,中间还有其它路径,后用编辑工具手动修改成源文件路径,问题解决。 不知你们碰到过没有,好像是mfile程序的问题,我用的是WIN2000系统。 |
||
|
|
|
|
【4楼】 cpu100 积分:386 派别: 等级:------ 来自: |
好贴 支持gccavr | ||
|
|
|
|
【5楼】 hotpower 菜农 积分:2136 派别: 等级:------ 来自:西安大雁塔村 |
实际上d步骤是可以不要的...
看看我在***的灌水实况http://www.***bbs.com/club/bbs/ShowAnnounce.asp?id=1454568 -----此内容被hotpower于2004-12-04,22:15:59编辑过 |
||
|
|
|
|
【6楼】 armok 阿莫 积分:48830 派别: 等级:------ 来自:ourDEV.cn 站长 |
有空我会重复这篇文章,然后整理成范例。先谢谢hotpower! | ||
|
__________________________ There's something good in this world. And it's worth fighting for …… |
|||
|
|
|
|
【7楼】 armok 阿莫 积分:48830 派别: 等级:------ 来自:ourDEV.cn 站长 |
【5楼】 hotpower 说的 “实际上d步骤是可以不要的... 看看我在***的灌水实况http://www.***bbs.com/club/bbs/ShowAnnounce.asp?id=1454568 ”能否直接说明为何不要? 这样指向一个路径,其它人很难找到答案的。
我昨晚重做了一下这个文档,发现以下的问题: 1。“建立一个新项目: New.pnproj ”,应该是新项目 demo.pnproj 吧,否则那来下面的:“在Projects窗口 New Project Group->demo->Add Files ” 2。“Tools->[WINAVR] Make ALL”之前应该双击 demo.c打开C源代码,否则,tools 菜单不会出现 make_all. |
||
|
__________________________ There's something good in this world. And it's worth fighting for …… |
|||
|
|
|
|
【8楼】 jiangbibo 积分:36 派别: 等级:------ 来自: |
哈哈,版主是不明白Hotpower的意思了。我来告诉你吧。
1、“建立一个新项目:New.pnproj”指的是那个给那个项目取名叫"New.pnproj",接下来的你可以在"New.pnproj"上击右键,将"demo.c"加入就可 2、只有你以前做的没错选"Tools->[WinAVR] Make ALL就是编译程序了 |
||
|
|
|
|
【9楼】 jiangbibo 积分:36 派别: 等级:------ 来自: |
d步骤一定不能要,一加就错!
所有函数都定义重复! |
||
|
|
|
|
【10楼】 hotpower 菜农 积分:2136 派别: 等级:------ 来自:西安大雁塔村 |
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有点烦,现在觉得很方便,几乎不费劲... -----此内容被hotpower于2005-01-22,10:00:11编辑过 |
||
|
|
|
|
↑↑↑↑↑↑↑↑↑↑↑↑ 抱歉本贴的回复数太多,为了减轻网络流量,只显示帖子正文的前后各10个回复。本贴的正文内容中间隐藏了16个回复。你需要 点击此处 才能查看全部内容。 对为你带来的访问不便表示歉意。不过我们仍会坚持即使没有登录,仍能共享我们网站的所有资料。你没有 登录后就能消除这个访问上的不便(可增加到显示60个回复)。 如果你是新用户请先 注册。注册是免费的,并且手续简单只需要填写用户名与口令。 ↓↓↓↓↓↓↓↓↓↓↓↓ |
|
【27楼】 mengmeng 积分:2 派别: 等级:------ 来自: |
我对hotpowder的
"单文件也可用d步骤,但必须将include xxx.c坐边的对勾去掉才行...这不更麻烦吗??? " 有问题 通过C/C++ source file所加的文件是除主程序文件外的其他文件 include xxx.c中的xxx.c为主程序文件,一般来说都要加上.对单文件来说,该单文件即为主程序文件,如果把它勾掉,然后再把它通过浏览框加上,该文件岂不是要充当两个角色? 所以,对单文件程序来说,只要把保持include xxx.c左边的对勾,不要再通过浏览框加源文件了 对多程序文件来说,除保持include xxx.c左边的对勾外,还要把其他的源文件加上 |
||
|
|
|
|
【28楼】 hotpower 菜农 积分:2136 派别: 等级:------ 来自:西安大雁塔村 |
实际上WINAVR自带的makefile工具很好用,怎么都能折腾好~~~ | ||
|
|
|
|
【29楼】 zqj750207 积分:120 派别: 等级:------ 来自:甘肃兰州 |
晕 | ||
|
|
|
|
【30楼】 chen 积分:232 派别: 等级:------ 来自:湖北 |
把酷帖顶起!把酷帖顶齐! | ||
|
|
|
|
【31楼】 chenling 积分:89 派别: 等级:------ 来自: |
想问一下如果有多个C源文件要编译,请问在makefile文件里怎么改?? | ||
|
|
|
|
【32楼】 jwc_210 积分:25 派别: 等级:------ 来自:浙江安吉 |
折腾了半天终于有一点明白了,我的问题是在makefile文件里面的
… # List C++ source files here. (C dependencies are automatically generated.) CPPSRC = main.cpp … 处,有一个main.cpp,在C:\WinAVR\mfile下的makefile_template是这样的,拿过来用了之后就出现了问题,把main.cpp去掉之后就好了。 31楼的问题:多个文件名间用空格隔开 例如 SRC = file1.c file2.c file3.c |
||
|
|
|
|
【33楼】 zgfmi 积分:3 派别: 等级:------ 来自: |
走到d.Mainfile->C/C++ source file(s)...
选择C:\WinAvr\examples\demo\demo.c 点击ok. 时,出现Oops,SRC not found,是怎么回事? |
||
|
|
|
|
【34楼】 stoneee 积分:83 派别: 等级:------ 来自: |
我按高手的方式配置,
make all 的结果怎么是这样的?? 这样算不算过? -------- begin -------- avr-gcc (GCC) 4.1.1 (WinAVR 20070122) Copyright (C) 2006 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. Size before: AVR Memory Usage ---------------- Device: Unknown Program: 234 bytes (.text + .data + .bootloader) Data: 3 bytes (.data + .bss + .noinit) Creating load file for EEPROM: demo.eep avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \ --change-section-lma .eeprom=0 --no-change-warnings -O ihex demo.elf demo.eep || exit 0 c:\WinAVR\bin\avr-objcopy.exe: there are no sections to be copied! 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 Warning: no "data" section found in output file Warning: file C:/DOCUME~1/EWEDDI~1/LOCALS~1/Temp/ccMrbaaa.s not found in symbol table, ignoring Warning: ignoring function __vectors() outside any compilation unit Warning: ignoring function __bad_interrupt() outside any compilation unit avr-objcopy: --change-section-vma .eeprom+0xff7f0000 never used avr-objcopy: --change-section-lma .eeprom+0xff7f0000 never used avr-objcopy: --change-section-vma .noinit+0xff800000 never used avr-objcopy: --change-section-lma .noinit+0xff800000 never used avr-objcopy: --change-section-vma .data+0xff800000 never used avr-objcopy: --change-section-lma .data+0xff800000 never used Size after: AVR Memory Usage ---------------- Device: Unknown Program: 234 bytes (.text + .data + .bootloader) Data: 3 bytes (.data + .bss + .noinit) -------- end -------- > Process Exit Code: 0 |
||
|
|
|
|
【35楼】 hustvic 积分:11 派别: 等级:------ 来自: |
我按你们说的做一下,还是有问题,要是SRC:。。。。这里我看路径没问题,则出错make.exe: *** No rule to make target `D:/Program', needed by `demo.elf'. Stop.
若注掉SRC那一行,不知道为什么 Linking: demo.elf avr-gcc -mmcu=at90s2313 -I. -gstabs -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns= -std=gnu99 -MD -MP -MF .dep/demo.elf.d --output demo.elf -Wl,-Map=demo.map,--cref -lm D:/Program Files/bin/../lib/gcc/avr/3.4.3/../../../../avr/lib/crts2313.o(.init9+0x0): undefined reference to `main' make.exe: *** [demo.elf] Error 1 |
||
|
|
|
|
【36楼】 hzn1948 积分:380 派别: 等级:------ 来自: |
建议各位看帖的时候注意看一下楼主发帖日期和最后回帖的日期
过于老的帖子看了有负面作用的 开发工具发展变化很大,三年以前的事现在再来看,不一样了 |
||
|
|
|
|
↑↑↑↑↑↑↑↑↑↑↑↑ 抱歉本贴的回复数太多,为了减轻网络流量,只显示帖子正文的前后各10个回复。本贴的正文内容中间隐藏了16个回复。你需要 点击此处 才能查看全部内容。 对为你带来的访问不便表示歉意。不过我们仍会坚持即使没有登录,仍能共享我们网站的所有资料。你没有 登录后就能消除这个访问上的不便(可增加到显示60个回复)。 如果你是新用户请先 注册。注册是免费的,并且手续简单只需要填写用户名与口令。 |
| ↑↑  快速回复帖子主题:新版WINAVR环境下Demo.c编译及调试具体步骤 |
| 你尚未登录,不能回复以上帖子。 |
| 论坛首页 -> AVR (原ourAVR.com) 技术论坛 -> 新版WINAVR环境下Demo.c编译及调试具体步骤 (属于论坛:AVR) | 跳转至: | 未登录 |
| 任何建议或投诉,欢迎随时与我们联系。 ourDEV.cn 我们的电子开发网,友好交流气氛,乐于开源共享,“这里远比混乱的现实世界美好”。 | ||||
| 网站负责人: | 阿莫(armok),手机:13433056000,电邮:armok ourdev.cn(请将空格改成@) | |||
| 地址与电话: |
东莞市东城八一路同沙工业园内,0769-22298000,传真请按4 阿莫邮购门市与雕刻机展示厅:东莞市莞城区莞太路和生文具礼品批发市场A2018,A2035 杨小姐 13711915767 雕刻机的技术咨询、订单查询、生产进度,可查询:13600266008吴先生(雕刻机设计人员kaif_w) |
|||
| 声明: |
本网站由东莞科士通(Infostone)科技有限公司属下的阿莫电子邮购部提供独家赞助。 有正式的工商注册与网站备案。详情可到东莞工商局查询。 本网站(ourDEV.cn)原名称为ourAVR.com(我们的AVR),自2007-09-01起从专业的AVR网转成综合电子网站。 本网站系统由armok Using Oracle + Java/JSP + WebLogic + Linux 2001/12/20 -- 2007/09/13 本BBS所有代码均为原创,版权归 armok 所有。本网站自:2004-10-03,16:31:17 起开始运行。 |
|||
| 法律顾问: | 本网站尊重知识产权,自2007年08月15日起,魏龙律师担任ourDEV.cn(原ourAVR.com)常年法律顾问。 | |||