This repository was archived by the owner on Nov 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
221 lines (190 loc) · 5.7 KB
/
Makefile
File metadata and controls
221 lines (190 loc) · 5.7 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
##
## OpenDMR - Open Source Firmware for DMR Radios
##
##
## Select your radio model among the supported ones: GD77, GD77s, DM1801, MD380
##
RADIO := MD380
##
## List here your source files (both .s, .c and .cpp)
##
SRC := source/testsuites/rtc_test.c
#source/main.c source/io/keyboard.c source/interfaces/pit.c
##
## Selection of MCU platform and baseband
##
ifeq "$(RADIO)" "GD77"
PLATFORM := FSL
BASEBAND := HR_C6000
DEFINES := -DPLATFORM_GD77 -DBSP_FSL
DISPLAY := UC1701
else ifeq "$(RADIO)" "GD77s"
PLATFORM := FSL
BASEBAND := HR_C6000
DEFINES := -DPLATFORM_GD77s -DBSP_FSL
DISPLAY := NONE
else ifeq "$(RADIO)" "DM1801"
PLATFORM := FSL
BASEBAND := HR_C6000
DEFINES := -DPLATFORM_DM1801 -DBSP_FSL
DISPLAY := UC1701
else ifeq "$(RADIO)" "MD380"
PLATFORM := STM32F4XX
BASEBAND := HR_C5000
DEFINES := -DPLATFORM_MD380 -DBSP_STM32F4XX -DENABLE_SWD
DISPLAY := HX83XX
endif
##
## Selection of display controller driver
##
ifeq "$(DISPLAY)" "UC1701"
SRC := $(SRC) source/interfaces/UC1701_graphics.c
else ifeq "$(DISPLAY)" "HX83XX"
SRC := $(SRC) source/interfaces/HX83XX_graphics.c
endif
##
## Drivers' source files and include directories
##
ifeq "$(PLATFORM)" "FSL"
DRIVERS_INC := -Idrivers/fsl
else ifeq "$(PLATFORM)" "STM32F4XX"
DRIVERS_INC := -Idrivers/stm32f4xx -Idrivers/stm32f4xx/usb
DRIVERS_SRC := \
drivers/stm32f4xx/usb/usb_bsp.c \
drivers/stm32f4xx/usb/usb_core.c \
drivers/stm32f4xx/usb/usb_dcd.c \
drivers/stm32f4xx/usb/usb_dcd_int.c \
drivers/stm32f4xx/usb/usbd_desc.c \
drivers/stm32f4xx/usb/usbd_core.c \
drivers/stm32f4xx/usb/usbd_ioreq.c \
drivers/stm32f4xx/usb/usbd_req.c \
drivers/stm32f4xx/usb/usbd_usr.c \
drivers/stm32f4xx/gpio.c \
drivers/stm32f4xx/usb_vcom.c \
drivers/stm32f4xx/delays.c \
drivers/stm32f4xx/adc1.c \
drivers/stm32f4xx/lcd.c \
drivers/stm32f4xx/rtc.c
endif
##
## List here additional static libraries with relative path
##
LIBS :=
##
## List here additional include directories (in the form -Iinclude_dir)
##
INCLUDE_DIRS := -Iinclude/io -Iinclude/interfaces -Iinclude/hardware
##
## List here additional defines
##
DEFINES := $(DEFINES)
##
## Define used to select target processor
##
ifeq "$(PLATFORM)" "FSL"
else ifeq "$(PLATFORM)" "STM32F4XX"
TARGET := -DSTM32F40_41xxx
endif
##
## System clock frequency, in hertz. Must be defined and set to correct value
## in order to make drivers working correctly
##
ifeq "$(PLATFORM)" "FSL"
else ifeq "$(PLATFORM)" "STM32F4XX"
CLK_FREQ := -DHSE_VALUE=8000000
endif
##
## Optimization level
##
OPTLEVEL := -O0
#OPTLEVEL:= -O2
#OPTLEVEL:= -O3
#OPTLEVEL:= -Os
##
## Device-specific source files and include directories, e.g. startup code
##
ifeq "$(PLATFORM)" "FSL"
else ifeq "$(PLATFORM)" "STM32F4XX"
DEVICE_INC := -ICMSIS -Idevice
DEVICE_SRC := \
startup/startup.cpp \
startup/libc_integration.cpp \
device/system_stm32f4xx.c
endif
##
## Operating system's source files and include directories
##
OS_INC := -Ifreertos/portable/GCC/ARM_CM4F -Ifreertos/include
OS_SRC := \
freertos/croutine.c \
freertos/event_groups.c \
freertos/list.c \
freertos/queue.c \
freertos/stream_buffer.c \
freertos/tasks.c \
freertos/timers.c \
freertos/portable/GCC/ARM_CM4F/port.c \
freertos/portable/MemMang/heap_3.c
##
## Exceptions support. Uncomment to disable them and save code size
##
#EXCEPT := -fno-exceptions -fno-rtti -D__NO_EXCEPTIONS
##############################################################################
## You should not need to modify anything below ##
##############################################################################
ALL_INC := -Iinclude $(OS_INC) $(DEVICE_INC) $(DRIVERS_INC) $(INCLUDE_DIRS)
ALL_SRC := $(SRC) $(OS_SRC) $(DEVICE_SRC) $(DRIVERS_SRC)
CONFIGS := $(TARGET) $(CLK_FREQ) $(OPTLEVEL) -DDONT_USE_CMSIS_INIT
ifeq ("$(VERBOSE)","1")
Q :=
ECHO := @true
else
Q := @
ECHO := @echo
endif
## Replaces both "foo.cpp"-->"foo.o" and "foo.c"-->"foo.o"
OBJ := $(addsuffix .o, $(basename $(ALL_SRC)))
CXXFLAGS := $(ALL_INC) -mcpu=cortex-m4 -mthumb -mfloat-abi=hard \
-mfpu=fpv4-sp-d16 $(CONFIGS) $(DEFINES) $(EXCEPT) -c -g -std=c++11
CFLAGS := $(ALL_INC) -mcpu=cortex-m4 -mthumb -mfloat-abi=hard \
-mfpu=fpv4-sp-d16 $(CONFIGS) $(DEFINES) $(EXCEPT) -c -g
AFLAGS := -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16
LFLAGS := -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 \
-Wl,--gc-sections -Wl,-Map,main.map $(OPTLEVEL) -nostdlib \
-Wl,-T./linkerscripts/linker_script.ld
DFLAGS := -MMD -MP
LINK_LIBS := $(LIBS) -Wl,--start-group -lc -lgcc -lm -Wl,--end-group
CC := arm-none-eabi-gcc
CXX := arm-none-eabi-g++
AS := arm-none-eabi-as
CP := arm-none-eabi-objcopy
SZ := arm-none-eabi-size
all: main.bin
main.bin: main.elf
$(ECHO) "[CP ] main.hex"
$(Q)$(CP) -O ihex main.elf main.hex
$(ECHO) "[CP ] main.bin"
$(Q)$(CP) -O binary main.elf main.bin
$(Q)$(SZ) main.elf
main.elf: $(OBJ) #all-recursive
$(ECHO) "[LD ] main.elf"
$(Q)$(CXX) $(LFLAGS) -o main.elf $(OBJ) $(LINK_LIBS)
%.o: %.s
$(ECHO) "[AS ] $<"
$(Q)$(AS) $(AFLAGS) $< -o $@
%.o : %.c
$(ECHO) "[CC ] $<"
$(Q)$(CC) $(DFLAGS) $(CFLAGS) $< -o $@
%.o : %.cpp
$(ECHO) "[CXX ] $<"
$(Q)$(CXX) $(DFLAGS) $(CXXFLAGS) $< -o $@
flash: main_wrapped.bin
$(ECHO) "[DFU ] $<"
$(Q)./scripts/md380_dfu.py upgrade $<
main_wrapped.bin: main.bin
$(ECHO) "[WRAP] $<"
$(Q)./scripts/md380_fw.py --wrap $< $@
clean:
-rm -f $(OBJ) main.elf main.hex main.bin main.map main_wrapped.bin $(OBJ:.o=.d)
#pull in dependecy info for existing .o files
-include $(OBJ:.o=.d)