




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、WinAVR(GCC)新手入門的makefile范例# MCU name # 單片機(jī)類型 參考格式是:atmega8 / at90s2313 / attiny15MCU = atmega16# Processor frequency.# 系統(tǒng)時鐘頻率(Hz),用于生成延時 _delay_us() _delay_ms() 見delay.h # This will define a symbol, F_CPU, in all source code files equal to the # processor frequency. You can then use t
2、his symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done# automatically to create a 32-bit value in your source code.F_CPU = 1000000# Target file name (without extension).# 目標(biāo)文件名(即生成的.hex/.eep/.elf的文件名)TARGET = main# List C source files
3、here. (C dependencies are automatically generated.)# C源文件名(不帶路徑)# 多個文件名間用空格隔開 例如 SRC = file1.c file2.c file3.c# 不需要加上 h頭文件SRC = $(TARGET).c #*后面內(nèi)容基本不需要修改,除非你是老手*# Output format. (can be srec, ihex, binary)# 輸出燒錄文件格式FORMAT = ihex# Optimization level, can be 0, 1, 2, 3, s. # 優(yōu)化級別# 0 = turn o
4、ff optimization. s = optimize for size.# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)OPT = s# Debugging format.# 輸出調(diào)試格式# Native formats for AVR-GCC's -g are dwarf-2 default or stabs.# AVR Studio 4.10 requires dwarf-2.# AVR Extended COFF format requires stabs, plus an av
5、r-objcopy run.DEBUG = dwarf-2# List Assembler source files here.# 匯編源文件名(不帶路徑,但擴(kuò)展名 .sS 需大寫,否則將會被make clean 所誤刪)# 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 up
6、on "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 = # Hey Emacs, this is a -*- makefile -*-#-# WinAVR Makefile Templat
7、e written by Eric B. Weddington, J鰎g Wunsch, et al.# Released to the Public Domain# Additional material for this makefile was written by:# Peter Fleury# Tim Henigan# Colin O'Flynn# Reiner Patommel# Markus Pfaff# Sander Pool# Frederik Rouleau#-# On command line:# make all = Make software.# make c
8、lean = Clean out built project files.# make coff = Convert ELF to AVR COFF.# make extcoff = Convert ELF to AVR Extended COFF.# make program = Download the hex file to the device, using avrdude.# Please customize the avrdude settings below first!# make debug = Start either simulavr or avarice as spec
9、ified for debugging, # with avr-gdb or avr-insight as the front end for debugging.# make filename.s = Just compile filename.c into the assembler code only.# make filename.i = Create a preprocessed source file for use in submitting# bug reports to the GCC project.# To rebuild project do "ma
10、ke clean" then "make all".#-# List any extra directories to look for include files here.# Each directory must be seperated by a space.# Use forward slashes for directory separators.# For a directory that has spaces, enclose it in quotes.EXTRAINCDIRS = # Compiler flag to set the C
11、 Standard level.# c89 = "ANSI" C# gnu89 = c89 plus GCC extensions# c99 = ISO C99 standard (not yet fully implemented)# gnu99 = c99 plus GCC extensionsCSTANDARD = -std=gnu99# Place -D or -U options hereCDEFS = -DF_CPU=$(F_CPU)UL# Place -I options hereCINCS =#- Compiler Options -# -g*: gener
12、ate 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 listingCFLAGS = -g$(DEBUG)CFLAGS += $(CDEFS) $(CINCS)CFLAGS += -O$(OPT)CFLAGS += -funsigned-ch
13、ar -funsigned-bitfields -fpack-struct -fshort-enumsCFLAGS += -Wall -Wstrict-prototypesCFLAGS += -Wa,-adhlns=$(<:.c=.lst)CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)CFLAGS += $(CSTANDARD)#- Assembler Options -# -Wa,.: tell GCC to pass this to the assembler.# -ahlms: create listing# -gstabs: have the
14、 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 thereASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs #- Library O
15、ptions -# Minimalistic printf versionPRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min# Floating point printf version (requires MATH_LIB = -lm below)PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt# If this is left blank, then it will use the Standard printf version.PRINTF_LIB = #PRINTF_LIB = $(PRIN
16、TF_LIB_MIN)#PRINTF_LIB = $(PRINTF_LIB_FLOAT)# Minimalistic scanf versionSCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min# Floating point + % scanf version (requires MATH_LIB = -lm below)SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt# If this is left blank, then it will use the Standard scanf version.SCANF_L
17、IB = #SCANF_LIB = $(SCANF_LIB_MIN)#SCANF_LIB = $(SCANF_LIB_FLOAT)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 o
18、f external RAM, starting after internal RAM (ATmega128!),# only used for heap (malloc().#EXTMEMOPTS = -Wl,-defsym=_heap_start=0x801100,-defsym=_heap_end=0x80ffffEXTMEMOPTS =#- Linker Options -# -Wl,.: tell GCC to pass this to linker.# -Map: create map file# -cref: add cross reference to map fileLDFL
19、AGS = -Wl,-Map=$(TARGET).map,-crefLDFLAGS += $(EXTMEMOPTS)LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)#- Programming Options (avrdude) -# Programming hardware: alf avr910 avrisp bascom bsd # dt006 pavr picoweb pony-stk200 sp12 stk200 stk500# Type: avrdude -c ?# to get a full listing.#AVRDU
20、DE_PROGRAMMER = stk500# com1 = serial port. Use lpt1 to connect to parallel port.AVRDUDE_PORT = com1 # programmer connected to serial deviceAVRDUDE_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 c
21、ounter.# 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
22、submitting bug # to submit bug reports.#AVRDUDE_VERBOSE = -v -vAVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)#- Debugging Options -# For simulavr only - target
23、 MCU frequency.DEBUG_MFREQ = $(F_CPU)# Set the DEBUG_UI to either gdb or insight.# DEBUG_UI = gdbDEBUG_UI = insight# Set the debugging back-end to either avarice, simulavr.DEBUG_BACKEND = avarice#DEBUG_BACKEND = simulavr# GDB Init Filename.GDBINIT_FILE = _avr_gdbinit# When using avarice settings for
24、 the JTAGJTAG_DEV = /dev/com1# Debugging port used to communicate between GDB / avarice / simulavr.DEBUG_PORT = 4242# Debugging host used to communicate between GDB / avarice / simulavr, normally# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a dif
25、ferent computer.DEBUG_HOST = localhost#=# Define programs and commands.SHELL = shCC = avr-gccOBJCOPY = avr-objcopyOBJDUMP = avr-objdumpSIZE = avr-sizeNM = avr-nmAVRDUDE = avrdudeREMOVE = rm -fCOPY = cpWINSHELL = cmd# Define Messages# EnglishMSG_ERRORS_NONE = Errors: noneMSG_BEGIN = - begin -MSG_END
26、= - 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_SYMB
27、OL_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 = $(SRC:.c=.lst) $(ASRC:.S=.lst) # Compiler flags to generate dep
28、endency files.GENDEPFLAGS = -MD -MP -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 b
29、uild sizeafter endbuild: elf hex eep lss symelf: $(TARGET).elfhex: $(TARGET).hexeep: $(TARGET).eeplss: $(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:echoecho $(
30、MSG_BEGIN)end:echo $(MSG_END)echo# Display size of file.HEXSIZE = $(SIZE) -target=$(FORMAT) $(TARGET).hexELFSIZE = $(SIZE) -A $(TARGET).elfAVRMEM = avr-mem.sh $(TARGET).elf $(MCU)sizebefore:if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); $(AVRMEM) 2>/dev/null; echo; fisi
31、zeafter:if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); $(AVRMEM) 2>/dev/null; echo; fi# Display compiler version information.gccversion : $(CC) -version# Program the device. program: $(TARGET).hex $(TARGET).eep$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
32、$(AVRDUDE_WRITE_EEPROM)# Generate avr-gdb config/init file which does the following:# define the reset signal, load the target file, connect to target, and set # a breakpoint at main().gdb-config: $(REMOVE) $(GDBINIT_FILE)echo define reset >> $(GDBINIT_FILE)echo SIGNAL SIGHUP >>
33、; $(GDBINIT_FILE)echo end >> $(GDBINIT_FILE)echo file $(TARGET).elf >> $(GDBINIT_FILE)echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE)ifeq ($(DEBUG_BACKEND),simulavr)echo load >> $(GDBINIT_FILE)endif echo break main >> $(GDBINIT_FILE)debug: gdb-con
34、fig $(TARGET).elfifeq ($(DEBUG_BACKEND), avarice)echo Starting AVaRICE - Press enter when "waiting to connect" message displays.$(WINSHELL) /c start avarice -jtag $(JTAG_DEV) -erase -program -file $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)$(WINSHELL) /c pauseelse$(WINSHELL) /c start simulav
35、r -gdbserver -device $(MCU) -clock-freq $(DEBUG_MFREQ) -port $(DEBUG_PORT)endif$(WINSHELL) /c start avr-$(DEBUG_UI) -command=$(GDBINIT_FILE)# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.COFFCONVERT=$(OBJCOPY) -debugging -change-section-address .data-0x800000 -change-
36、section-address .bss-0x800000 -change-section-address .noinit-0x800000 -change-section-address .eeprom-0x810000coff: $(TARGET).elfechoecho $(MSG_COFF) $(TARGET).cof$(COFFCONVERT) -O coff-avr $< $(TARGET).cofextcoff: $(TARGET).elfechoecho $(MSG_EXTENDED_COFF) $(TARGET).cof$(COFFCONVERT) -O coff-ex
37、t-avr $< $(TARGET).cof# Create final output files (.hex, .eep) from ELF output file.%.hex: %.elfechoecho $(MSG_FLASH) $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $%.eep: %.elfechoecho $(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: %.elfechoecho $(MSG_EXTENDED_LISTING) $(OBJDUMP) -h -S $< > $# Create a symbol table from ELF output file.%.sym: %.elfechoecho $(MSG_SYMBOL_TABLE) $(NM)
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 合伙經(jīng)營退伙協(xié)議書
- 員工激勵股份協(xié)議書
- 占用公路恢復(fù)協(xié)議書
- 商場促銷活動協(xié)議書
- 原拆原建鄰里協(xié)議書
- 化工躉船轉(zhuǎn)讓協(xié)議書
- 員工國際雇傭協(xié)議書
- 廠房加盟合作協(xié)議書
- 初中生預(yù)錄取協(xié)議書
- 廠區(qū)食堂承包協(xié)議書
- 2025年建筑模板制品行業(yè)深度研究報告
- 湖北省荊門市2025年七年級下學(xué)期語文期末考試試卷及答案
- 2025-2030年中國葉黃素行業(yè)市場發(fā)展現(xiàn)狀及競爭格局與投資發(fā)展研究報告
- 2024第41屆全國中學(xué)生物理競賽預(yù)賽試題(含答案)
- 內(nèi)鏡洗消相關(guān)試題及答案
- 高效節(jié)能泵結(jié)構(gòu)優(yōu)化-全面剖析
- 2024-2025湘科版小學(xué)科學(xué)四年級下冊期末考試卷及答案(三套)
- 中國企業(yè)科創(chuàng)力研究報告2024
- 細(xì)胞培養(yǎng)技術(shù)的基礎(chǔ)試題及答案
- (廣東二模)2025年廣東省高三高考模擬測試(二)歷史試卷(含答案)
- GB/T 14601-2025電子特氣氨
評論
0/150
提交評論