AVR Makefile
از پاپیروس
پرش به ناوبریپرش به جستجو
avr-gcc -Wall -g -Os -mmcu=atmega8 -o am8.bin am8.c
avr-size -C am8.bin
avr-objcopy -j .text -j .data -O ihex am8.bin am8.hex
avrdude -p atmega8 -c usbasp -U flash:w:am8.hex:i -F -P usb
MCU=atmega8
F_CPU=800000
CC=avr-gcc
OBJCOPY=avr-objcopy
SIZE=avr-size
CFLAGS=-Wall -g -Os -mmcu=${MCU} -DF_CPU=${F_CPU} -I.
TARGET=am8
SRCS=am8.c
all:
${CC} ${CFLAGS} -o ${TARGET}.bin ${SRCS}
${SIZE} -C ${TARGET}.bin
${OBJCOPY} -j .text -j .data -O ihex ${TARGET}.bin ${TARGET}.hex
flash:
avrdude -p ${MCU} -c usbasp -U flash:w:${TARGET}.hex:i -F -P usb
clean:
rm -f *.bin *.hex
نسخهی حرفهای تر:
CU=atmega32
F_CPU=16000000UL
CC=avr-gcc
OBJCOPY=avr-objcopy
SIZE=avr-size
#CFLAGS=-Wall -g -Os -mmcu=$(MCU) -DF_CPU=$(F_CPU) -I.
CFLAGS=-Wall -g -Os -mmcu=$(MCU) -I.
SRC ?= blink.c
TARGET := $(basename $(SRC))
all: $(TARGET).elf $(TARGET).hex $(TARGET).bin
$(SIZE) -C $(TARGET).elf
$(TARGET).elf: $(SRC)
$(CC) $(CFLAGS) -o $@ $^
$(TARGET).hex: $(TARGET).elf
$(OBJCOPY) -O ihex -j .text -j .data $< $@
$(TARGET).bin: $(TARGET).elf
$(OBJCOPY) -O binary -j .text -j .data $< $@
flash: $(TARGET).hex
avrdude -p $(MCU) -c usbasp -U flash:w:$(TARGET).hex:i -F -P usb
clean:
rm -f $(TARGET).elf $(TARGET).hex $(TARGET).bin
@ = هدف (Target)
^ = همهچیز (Everything)
< = اولی (First)
دستورهای
make
make flash
make clean
از فایل blink.c استفاده میکنند.
دستورهای
make SRC=test.c
make SRC=test.c flash
make SRC=test.c clean
از فایل test.c استفاده میکنند.