搜索
bottom↓
回复: 33

新版WINAVR环境下Demo.c编译及调试具体步骤

[复制链接]

出0入0汤圆

发表于 2004-12-3 22:11:05 | 显示全部楼层 |阅读模式
新版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 于中秋月下
头像被屏蔽

出0入0汤圆

发表于 2004-12-4 02:52:10 | 显示全部楼层
谢谢! 非常好。配合图片,就能成为新手入门的例子了。

出0入0汤圆

 楼主| 发表于 2004-12-4 08:58:03 | 显示全部楼层
这是我在21ic的一个"酷帖",拿来玩玩...当时我对winavr一无所知...



http://www.21icbbs.com/club/bbs/ShowAnnounce.asp?id=1382379

出0入0汤圆

发表于 2004-12-4 17:21:41 | 显示全部楼层
我按上面的步骤生成不了,发现少一个elf文件

昨晚仔细看了一个hotpower贴的makefile文件,发现在完成这一步后



d.Mainfile->C/C++ source file(s)...

   选择C:\WinAvr\examples\demo\demo.c

   点击ok.



加入源文件后,SRC后面跟的不是源文件位置,中间还有其它路径,后用编辑工具手动修改成源文件路径,问题解决。



不知你们碰到过没有,好像是mfile程序的问题,我用的是WIN2000系统。

出0入0汤圆

发表于 2004-12-4 20:55:50 | 显示全部楼层
好贴 支持gccavr

出0入0汤圆

 楼主| 发表于 2004-12-4 22:14:42 | 显示全部楼层
实际上d步骤是可以不要的...



看看我在21IC的灌水实况http://www.21icbbs.com/club/bbs/ShowAnnounce.asp?id=1454568
-----此内容被hotpower于2004-12-04,22:15:59编辑过
头像被屏蔽

出0入0汤圆

发表于 2004-12-4 22:39:50 | 显示全部楼层
有空我会重复这篇文章,然后整理成范例。先谢谢hotpower!
头像被屏蔽

出0入0汤圆

发表于 2004-12-14 09:18:29 | 显示全部楼层
【5楼】 hotpower 说的 “实际上d步骤是可以不要的... 看看我在21IC的灌水实况http://www.21icbbs.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.

出0入0汤圆

发表于 2004-12-20 10:24:55 | 显示全部楼层
哈哈,版主是不明白Hotpower的意思了。我来告诉你吧。

1、“建立一个新项目:New.pnproj”指的是那个给那个项目取名叫"New.pnproj",接下来的你可以在"New.pnproj"上击右键,将"demo.c"加入就可



2、只有你以前做的没错选"Tools->[WinAVR] Make ALL就是编译程序了

出0入0汤圆

发表于 2004-12-20 22:11:59 | 显示全部楼层
d步骤一定不能要,一加就错!

所有函数都定义重复!

出0入0汤圆

 楼主| 发表于 2005-1-22 09:47:10 | 显示全部楼层
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编辑过

出0入0汤圆

 楼主| 发表于 2005-1-22 22:25:49 | 显示全部楼层
【12楼】的makefile确实不行!!!

最简单就是打开makemakefile工具后立即改写所有参数后直接将结果存入所需目录即可...



以下是可以编译通过的...祝楼上加入GCCAVR/WINAVR菜鸟俱乐部...



# Hey Emacs, this is a -*- makefile -*-

#

# WinAVR Sample makefile written by Eric B. Weddington, J鰎g Wunsch, et al.

# Released to the Public Domain

# Please read the make user manual!

#

# Additional material for this makefile was submitted by:

#  Tim Henigan

#  Peter Fleury

#  Reiner Patommel

#  Sander Pool

#  Frederik Rouleau

#  Markus Pfaff

#

# On command line:

#

# make all = Make software.

#

# make clean = Clean out built project files.

#

# make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB).

#

# make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio

#                4.07 or greater).

#

# make program = Download the hex file to the device, using avrdude.  Please

#                customize the avrdude settings below first!

#

# make filename.s = Just compile filename.c into the assembler code only

#

# To rebuild project do "make clean" then "make all".

#





# MCU name

MCU = at90s2313



# Output format. (can be srec, ihex, binary)

FORMAT = ihex



# Target file name (without extension).

TARGET = demo





# List C source files here. (C dependencies are automatically generated.)

SRC = $(TARGET).c





# List Assembler source files here.

# Make them always end in a capital .S.  Files ending in a lowercase .s

# will not be considered source files but generated files (assembler

# output from the compiler), and will be deleted upon "make clean"!

# Even though the DOS/Win* filesystem matches both .s and .S the same,

# it will preserve the spelling of the filenames, and gcc itself does

# care about how the name is spelled on its command-line.

ASRC =







# Optimization level, can be [0, 1, 2, 3, s].

# 0 = turn off optimization. s = optimize for size.

# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)

OPT = s



# Debugging format.

# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.

# AVR (extended) COFF requires stabs, plus an avr-objcopy run.

DEBUG = stabs



# List any extra directories to look for include files here.

#     Each directory must be seperated by a space.

EXTRAINCDIRS =





# Compiler flag to set the C Standard level.

# c89   - "ANSI" C

# gnu89 - c89 plus GCC extensions

# c99   - ISO C99 standard (not yet fully implemented)

# gnu99 - c99 plus GCC extensions

CSTANDARD = -std=gnu99



# Place -D or -U options here

CDEFS =



# Place -I options here

CINCS =





# Compiler flags.

#  -g*:          generate debugging information

#  -O*:          optimization level

#  -f...:        tuning, see GCC manual and avr-libc documentation

#  -Wall...:     warning level

#  -Wa,...:      tell GCC to pass this to the assembler.

#    -adhlns...: create assembler listing

CFLAGS = -g$(DEBUG)

CFLAGS += $(CDEFS) $(CINCS)

CFLAGS += -O$(OPT)

CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums

CFLAGS += -Wall -Wstrict-prototypes

CFLAGS += -Wa,-adhlns=$(<:.c=.lst)

CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))

CFLAGS += $(CSTANDARD)







# Assembler flags.

#  -Wa,...:   tell GCC to pass this to the assembler.

#  -ahlms:    create listing

#  -gstabs:   have the assembler create line number information; note that

#             for use in COFF files, additional information about filenames

#             and function names needs to be present in the assembler source

#             files -- see avr-libc docs [FIXME: not yet described there]

ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs







#Additional libraries.



# Minimalistic printf version

PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min



# Floating point printf version (requires MATH_LIB = -lm below)

PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt



PRINTF_LIB =



# Minimalistic scanf version

SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min



# Floating point + %[ scanf version (requires MATH_LIB = -lm below)

SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt



SCANF_LIB =



MATH_LIB = -lm



# External memory options



# 64 KB of external RAM, starting after internal RAM (ATmega128!),

# used for variables (.data/.bss) and heap (malloc()).

#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff



# 64 KB of external RAM, starting after internal RAM (ATmega128!),

# only used for heap (malloc()).

#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff



EXTMEMOPTS =



# Linker flags.

#  -Wl,...:     tell GCC to pass this to linker.

#    -Map:      create map file

#    --cref:    add cross reference to  map file

LDFLAGS = -Wl,-Map=$(TARGET).map,--cref

LDFLAGS += $(EXTMEMOPTS)

LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)









# Programming support using avrdude. Settings and variables.



# Programming hardware: alf avr910 avrisp bascom bsd

# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500

#

# Type: avrdude -c ?

# to get a full listing.

#

AVRDUDE_PROGRAMMER = stk500



# com1 = serial port. Use lpt1 to connect to parallel port.

AVRDUDE_PORT = com1    # programmer connected to serial device



AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex

#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep





# Uncomment the following if you want avrdude's erase cycle counter.

# Note that this counter needs to be initialized first using -Yn,

# see avrdude manual.

#AVRDUDE_ERASE_COUNTER = -y



# Uncomment the following if you do /not/ wish a verification to be

# performed after programming the device.

#AVRDUDE_NO_VERIFY = -V



# Increase verbosity level.  Please use this when submitting bug

# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>

# to submit bug reports.

#AVRDUDE_VERBOSE = -v -v



AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)

AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)

AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)

AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)







# ---------------------------------------------------------------------------



# Define directories, if needed.

DIRAVR = c:/winavr

DIRAVRBIN = $(DIRAVR)/bin

DIRAVRUTILS = $(DIRAVR)/utils/bin

DIRINC = .

DIRLIB = $(DIRAVR)/avr/lib





# Define programs and commands.

SHELL = sh

CC = avr-gcc

OBJCOPY = avr-objcopy

OBJDUMP = avr-objdump

SIZE = avr-size

NM = avr-nm

AVRDUDE = avrdude

REMOVE = rm -f

COPY = cp









# Define Messages

# English

MSG_ERRORS_NONE = Errors: none

MSG_BEGIN = -------- begin --------

MSG_END = --------  end  --------

MSG_SIZE_BEFORE = Size before:

MSG_SIZE_AFTER = Size after:

MSG_COFF = Converting to AVR COFF:

MSG_EXTENDED_COFF = Converting to AVR Extended COFF:

MSG_FLASH = Creating load file for Flash:

MSG_EEPROM = Creating load file for EEPROM:

MSG_EXTENDED_LISTING = Creating Extended Listing:

MSG_SYMBOL_TABLE = Creating Symbol Table:

MSG_LINKING = Linking:

MSG_COMPILING = Compiling:

MSG_ASSEMBLING = Assembling:

MSG_CLEANING = Cleaning project:









# Define all object files.

OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)



# Define all listing files.

LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)





# Compiler flags to generate dependency files.

GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d





# Combine all necessary flags and optional flags.

# Add target processor to flags.

ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)

ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)











# Default target.

all: begin gccversion sizebefore build sizeafter finished end



build: elf hex eep lss sym extcoff



elf: $(TARGET).elf

hex: $(TARGET).hex

eep: $(TARGET).eep

lss: $(TARGET).lss

sym: $(TARGET).sym







# Eye candy.

# AVR Studio 3.x does not check make's exit code but relies on

# the following magic strings to be generated by the compile job.

begin:

        @echo

        @echo $(MSG_BEGIN)



finished:

        @echo $(MSG_ERRORS_NONE)



end:

        @echo $(MSG_END)

        @echo





# Display size of file.

HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex

ELFSIZE = $(SIZE) -A $(TARGET).elf

sizebefore:

        @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi



sizeafter:

        @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi







# Display compiler version information.

gccversion :

        @$(CC) --version







# Program the device.  

program: $(TARGET).hex $(TARGET).eep

        $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)









# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.

COFFCONVERT=$(OBJCOPY) --debugging \

--change-section-address .data-0x800000 \

--change-section-address .bss-0x800000 \

--change-section-address .noinit-0x800000 \

--change-section-address .eeprom-0x810000





coff: $(TARGET).elf

        @echo

        @echo $(MSG_COFF) $(TARGET).cof

        $(COFFCONVERT) -O coff-avr $< $(TARGET).cof





extcoff: $(TARGET).elf

        @echo

        @echo $(MSG_EXTENDED_COFF) $(TARGET).cof

        $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof







# Create final output files (.hex, .eep) from ELF output file.

%.hex: %.elf

        @echo

        @echo $(MSG_FLASH) $@

        $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@



%.eep: %.elf

        @echo

        @echo $(MSG_EEPROM) $@

        -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \

        --change-section-lma .eeprom=0 -O $(FORMAT) $< $@



# Create extended listing file from ELF output file.

%.lss: %.elf

        @echo

        @echo $(MSG_EXTENDED_LISTING) $@

        $(OBJDUMP) -h -S $< > $@



# Create a symbol table from ELF output file.

%.sym: %.elf

        @echo

        @echo $(MSG_SYMBOL_TABLE) $@

        $(NM) -n $< > $@







# Link: create ELF output file from object files.

.SECONDARY : $(TARGET).elf

.PRECIOUS : $(OBJ)

%.elf: $(OBJ)

        @echo

        @echo $(MSG_LINKING) $@

        $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)





# Compile: create object files from C source files.

%.o : %.c

        @echo

        @echo $(MSG_COMPILING) $<

        $(CC) -c $(ALL_CFLAGS) $< -o $@





# Compile: create assembler files from C source files.

%.s : %.c

        $(CC) -S $(ALL_CFLAGS) $< -o $@





# Assemble: create object files from assembler source files.

%.o : %.S

        @echo

        @echo $(MSG_ASSEMBLING) $<

        $(CC) -c $(ALL_ASFLAGS) $< -o $@







# Target: clean project.

clean: begin clean_list finished end



clean_list :

        @echo

        @echo $(MSG_CLEANING)

        $(REMOVE) $(TARGET).hex

        $(REMOVE) $(TARGET).eep

        $(REMOVE) $(TARGET).obj

        $(REMOVE) $(TARGET).cof

        $(REMOVE) $(TARGET).elf

        $(REMOVE) $(TARGET).map

        $(REMOVE) $(TARGET).obj

        $(REMOVE) $(TARGET).a90

        $(REMOVE) $(TARGET).sym

        $(REMOVE) $(TARGET).lnk

        $(REMOVE) $(TARGET).lss

        $(REMOVE) $(OBJ)

        $(REMOVE) $(LST)

        $(REMOVE) $(SRC:.c=.s)

        $(REMOVE) $(SRC:.c=.d)

        $(REMOVE) .dep/*







# Include the dependency files.

-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)





# Listing of phony targets.

.PHONY : all begin finish end sizebefore sizeafter gccversion \

build elf hex eep lss sym coff extcoff \

clean clean_list program

出0入0汤圆

 楼主| 发表于 2005-1-22 22:34:03 | 显示全部楼层
阿莫站长: 晕【13楼】+【12楼】????



我【13楼】回【12楼】是从"【12楼】的makefile确实不行!!! "开始的...



看来帖子多了,跟帖长后,bug就来了...



哈哈..."防洪"措施简直是"豆腐渣工程"...站长"腐_败"呀!!!

出0入0汤圆

 楼主| 发表于 2005-1-24 01:46:07 | 显示全部楼层
AVR菜鸟俱乐部--------AVR菜鸟成群的地方...

出0入0汤圆

发表于 2005-3-4 20:08:43 | 显示全部楼层
我按步骤进行,完成后却发现OUTPUT这样显示

> "make.exe" all



> Failed to create process: 系统找不到指定的文件。



> Process Exit Code: 0



该如何解决

出0入0汤圆

发表于 2005-3-7 00:44:00 | 显示全部楼层
我试了一下,显示

"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.





Size before:

demo.elf  :

section    size      addr

.text       244         0

.data         0   8388704

.bss          3   8388704

.noinit       0   8388707

.eeprom       0   8454144

.stab       828         0

.stabstr   1437         0

Total      2512









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       828         0

.stabstr   1437         0

Total      2512







Errors: none

-------- end --------





> Process Exit Code: 0

是怎么回事? 另外,demo.c是WinAVR自带的吗?

出0入0汤圆

发表于 2005-3-30 18:00:28 | 显示全部楼层
好不容易啊~~总算编译成功了~~~ 要多谢HOTPOWER~~我从21ic一路“追杀”过来~~^_^!!

猫扑的图片~~晕~~~~~

出0入0汤圆

发表于 2005-4-8 10:50:35 | 显示全部楼层
请问hotpower:

    我按你的步骤调试成功了第一个程序,但我对*.c程序进行了一下修改,保存后直接点[WINAVR] make all后显示:

D:\DOCUME~1\apple\LOCALS~1\Temp\make26127.sh: D:\DOCUME~1\apple\LOCALS~1\Temp\make26127.sh: cannot execute binary file

make.exe: *** [F:/Rcy/AVR程序调试/winavr/lianxi/three.o] Error 126



> Process Exit Code: 2

我将makefile重新设置再导入后也提示上述信息,不知道如果写好的程序需要修改该如何调试?

出0入0汤圆

发表于 2005-4-8 12:07:12 | 显示全部楼层
不用怪make,必定是修改后的 C文件格式错误.

出0入0汤圆

发表于 2005-4-8 14:19:06 | 显示全部楼层
那我在PN中修改C源文件后如何保存呢?

出0入0汤圆

发表于 2005-7-20 17:17:54 | 显示全部楼层
辛苦了!第一次接触AVR这个东东,是个入门的好东西,我按照上面的步骤确实通过了,

只不过感觉我还没有理解为什么要这样做,我只是机械的向上面的方式做了一边,自于里面的因由还需要自己在看看、倒倒!

出0入0汤圆

发表于 2006-1-9 14:32:19 | 显示全部楼层
试过了,不错,能够完成

出0入0汤圆

发表于 2006-3-2 15:46:12 | 显示全部楼层
刚来几天,一直在学习中,网站是TLG代理商告诉我的。昨天Demo.c试过了,今天在试用原装JTAG mkII 仿真器,希望日后能写点东东与大家分享

出0入0汤圆

发表于 2006-4-9 14:24:37 | 显示全部楼层
试了很久,终于成功了,感谢各位的指点,收获很大啊!!!

出0入0汤圆

发表于 2006-8-15 12:40:39 | 显示全部楼层
我对hotpowder的

"单文件也可用d步骤,但必须将include xxx.c坐边的对勾去掉才行...这不更麻烦吗??? "

有问题

通过C/C++ source file所加的文件是除主程序文件外的其他文件

include xxx.c中的xxx.c为主程序文件,一般来说都要加上.对单文件来说,该单文件即为主程序文件,如果把它勾掉,然后再把它通过浏览框加上,该文件岂不是要充当两个角色?

所以,对单文件程序来说,只要把保持include xxx.c左边的对勾,不要再通过浏览框加源文件了

对多程序文件来说,除保持include xxx.c左边的对勾外,还要把其他的源文件加上

出0入0汤圆

 楼主| 发表于 2006-9-1 22:02:17 | 显示全部楼层
实际上WINAVR自带的makefile工具很好用,怎么都能折腾好~~~

出0入0汤圆

发表于 2006-9-20 15:20:41 | 显示全部楼层

出0入0汤圆

发表于 2006-12-27 12:38:56 | 显示全部楼层
把酷帖顶起!把酷帖顶齐!

出0入0汤圆

发表于 2007-1-6 19:11:16 | 显示全部楼层
想问一下如果有多个C源文件要编译,请问在makefile文件里怎么改??

出0入0汤圆

发表于 2007-6-21 11:31:38 | 显示全部楼层
折腾了半天终于有一点明白了,我的问题是在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

出0入0汤圆

发表于 2007-7-16 17:15:32 | 显示全部楼层
走到d.Mainfile->C/C++ source file(s)...

   选择C:\WinAvr\examples\demo\demo.c

   点击ok.

时,出现Oops,SRC not found,是怎么回事?

出0入0汤圆

发表于 2007-7-19 12:25:39 | 显示全部楼层
我按高手的方式配置,

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

出0入0汤圆

发表于 2007-12-21 19:12:18 | 显示全部楼层
我按你们说的做一下,还是有问题,要是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

出0入0汤圆

发表于 2007-12-22 13:08:43 | 显示全部楼层
建议各位看帖的时候注意看一下楼主发帖日期和最后回帖的日期
过于老的帖子看了有负面作用的
开发工具发展变化很大,三年以前的事现在再来看,不一样了
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-3 06:03

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

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