-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
44 lines (32 loc) · 831 Bytes
/
makefile
File metadata and controls
44 lines (32 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
TARGET=main
MCU=atmega328p
SOURCES=main.c ds3231.c i2cMaster.c
PROGRAMMER=usbasp
#PORT=-P/dev/ttyACM0
PORT=-PCOM4
BAUD=-B115200
OBJECTS=$(SOURCES:.c=.o)
CFLAGS=-c -Os
LDFLAGS=
all: hex eeprom
hex: $(TARGET).hex
eeprom: $(TARGET)_eeprom.hex
$(TARGET).hex: $(TARGET).elf
avr-objcopy -O ihex -j .data -j .text $(TARGET).elf $(TARGET).hex
$(TARGET)_eeprom.hex: $(TARGET).elf
avr-objcopy -O ihex -j .eeprom --change-section-lma .eeprom=1 $(TARGET).elf $(TARGET)_eeprom.hex
$(TARGET).elf: $(OBJECTS)
avr-gcc $(LDFLAGS) -mmcu=$(MCU) $(OBJECTS) -o $(TARGET).elf
.c.o:
avr-gcc $(CFLAGS) -mmcu=$(MCU) $< -o $@
size:
avr-size --mcu=$(MCU) -C $(TARGET).elf
program:
avrdude -p$(MCU) $(PORT) $(BAUD) -c$(PROGRAMMER) -Uflash:w:$(TARGET).hex:a
clean_tmp:
rm -rf *.o
rm -rf *.elf
clean:
rm -rf *.o
rm -rf *.elf
rm -rf *.hex