forked from feilipu/miniAVRfreeRTOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
103 lines (83 loc) · 2.32 KB
/
makefile
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Make file based on
# https://github.com/peakhunt/freertos_atmega328p/blob/master/Makefile
# and modified by Tiago Lobao
#
#
# make (default) = compile project
#
# make clean = delete all binaries
#
# make program = flash through AVRDUDE
#
# ---------------------------------------
# -------- MAKEFILE USER DEFINES --------
# ---------------------------------------
# ---------------------------------------
# Microcontroller specific
MCU=atmega128
F_CPU=16000000UL
# ---------------------------------------
# Directiory for the freeRTOS
FREERTOS_DIR=./kernel
# ---------------------------------------
# Flashing options
# using standard arduino bootloader
AVRDUDE_PROGRAMMER = arduino
AVRDUDE_PORT = COM3
AVRDUDE_BAUDRATE = 115200
# ---------------------------------------
# Target file name options
TARGET=main
# ---------------------------------------
# compiler / programmer options
CC=avr-gcc
AVRDUDE = avrdude
# ---------------------------------------
# Sources/includes to be used
FREERTOS_SRC := \
$(FREERTOS_DIR)/list.c \
$(FREERTOS_DIR)/timers.c \
$(FREERTOS_DIR)/stream_buffer.c \
$(FREERTOS_DIR)/heap_3.c \
$(FREERTOS_DIR)/event_groups.c \
$(FREERTOS_DIR)/hooks.c \
$(FREERTOS_DIR)/port.c \
$(FREERTOS_DIR)/queue.c \
$(FREERTOS_DIR)/tasks.c
SOURCES := $(FREERTOS_SRC) \
main.c
INC_PATH=-I$(FREERTOS_DIR) -I./
# ---------------------------------------
# ---------- MAKEFILE CODE --------------
# ---------------------------------------
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
AVRDUDE_FLAGS = -p $(MCU) -b $(AVRDUDE_BAUDRATE)
AVRDUDE_FLAGS += -P $(AVRDUDE_PORT)
AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER)
MCUFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU)
CFLAGS = $(MCUFLAGS) $(INC_PATH) -c $(SOURCES)
LFLAGS = $(MCUFLAGS) -o $(TARGET).elf *.o
# ---------------------------------------
# Optimization choice
# This will avoid not used code and guarantee proper delays
CFLAGS += -ffunction-sections -O2
LFLAGS += -Wl,--gc-sections
all: $(TARGET)
$(TARGET):
$(CC) $(CFLAGS)
$(CC) $(LFLAGS)
avr-objcopy -O ihex $(TARGET).elf $(TARGET).hex
program:
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
clean:
@echo "Cleaning $(TARGET)"
rm -f $(BINARY)
rm -f $(MAPFILE)
rm -f $(SYMFILE)
rm -f $(LSSFILE)
@echo "Cleaning Objects"
rm -f *.o
rm -f $(TARGET)*.hex
rm -f $(TARGET)*.elf
rm -rf obj
rm -rf .dep