⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 makefile

📁 AVR USB 下载线, 全套的开发资料,想做板子的可以参考下/
💻
字号:
# Project configuration:

OBJS  = main.o usb.o
ASMS  = main.s usb.s
BIN   = main

#Hardware
MCU     = atmega8
ROM_START = 0x1C00

#Compiler flags
CCFLAGS = -g  -Os -Wall -Wstrict-prototypes -mmcu=$(MCU) -mcall-prologues -fomit-frame-pointer 

#Linker flags
LDFLAGS = -Wl,-Map=$(BIN).map,--cref,--section-start=.text=$(ROM_START),--defsym=app_start=0 -mmcu=$(MCU) -gstabs,-ahlms=$(<:.c=.lst)

# Assembler config
#ASTFLAG = 

# Compiler configuration:
CC      = avr-gcc
LD      = avr-gcc
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump.exe
UPLOAD  = avrdude.exe

# 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 

#Do all
all: image extcoff
#extcoff

#create ROM-Image
image: $(BIN)
	avr-size $(BIN).elf
	
#Upload
upload: $(BIN).hex
	$(UPLOAD) -p$(MCU) -cstk200 -e -U flash:w:$(BIN).hex

#asm
asm: $(ASMS)

#clean source directory
.phony:	clean
clean:
	rm -f *.o *.s *.bak *.hex *.cof *.elf *.map *.lst

#create docs
doc:
	doxygen doxy.dxy

# Build rules:
%.o: %.c
	$(CC) $(CCFLAGS) $(ASTFLAG) -c $<
	
%.s: %.c
	$(CC) $(CCFLAGS) -S $(ASTFLAG) -c $<
		
$(BIN): $(OBJS)
	$(LD) $(LDFLAGS) -o$(BIN).elf $^
	$(OBJCOPY) -O ihex -R .eeprom $(BIN).elf $(BIN).hex
	$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex $(BIN).elf $(BIN)_eeprom.hex
	$(OBJDUMP) -t -h -S $(BIN).elf >$(BIN).lst
	
coff: $(BIN).elf
	$(COFFCONVERT) -O coff-avr $< $(BIN).cof

extcoff: $(BIN).elf
	$(COFFCONVERT) -O coff-ext-avr $< $(BIN).cof

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -