2 # Copyright (C) 2015, The LibrePilot Project, http://www.librepilot.org
3 # Copyright (c) 2009-2013, The OpenPilot Team, http://www.openpilot.org
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 ifndef TOP_LEVEL_MAKEFILE
21 $(error Top level Makefile must be used to build this target
)
27 BOARDINC
= $(TOPDIR
)/..
28 OPSYSTEMINC
= $(OPSYSTEM
)/inc
30 PIOSCOMMON
= $(PIOS
)/common
31 FLIGHTLIBINC
= $(FLIGHTLIB
)/inc
34 override USE_DSP_LIB
:= NO
37 ifeq ($(MCU
),cortex-m3
)
38 include $(PIOS
)/stm32f10x
/library.mk
39 else ifeq ($(MCU
),cortex-m4
)
40 include $(PIOS
)/stm32f4xx
/library.mk
41 else ifeq ($(MCU
),cortex-m0
)
42 include $(PIOS
)/stm32f0x
/library.mk
44 $(error Unsupported MCU
: $(MCU
))
47 # List C source files here (C dependencies are automatically generated).
48 # Use file-extension c for "c-only"-files
52 SRC
+= $(OPSYSTEM
)/main.c
53 SRC
+= $(OPSYSTEM
)/pios_board.c
55 ## PIOS Hardware (Common)
56 SRC
+= $(PIOSCOMMON
)/pios_board_info.c
57 SRC
+= $(PIOSCOMMON
)/pios_com_msg.c
58 SRC
+= $(PIOSCOMMON
)/pios_iap.c
59 ifneq ($(PIOS_OMITS_USB
),YES
)
60 SRC
+= ..
/pios_usb_board_data.c
61 SRC
+= $(PIOSCOMMON
)/pios_usb_desc_hid_only.c
62 SRC
+= $(PIOSCOMMON
)/pios_usb_util.c
64 SRC
+= $(PIOSCOMMON
)/pios_led.c
66 ## Misc library functions
67 SRC
+= $(FLIGHTLIB
)/op_dfu.c
68 SRC
+= $(FLIGHTLIB
)/printf-stdarg.c
70 # List C source files here which must be compiled in ARM-Mode (no -mthumb).
71 # Use file-extension c for "c-only"-files
74 # List C++ source files here.
75 # Use file-extension .cpp for C++-files (not .C)
78 # List C++ source files here which must be compiled in ARM-Mode.
79 # Use file-extension .cpp for C++-files (not .C)
82 # List Assembler source files here.
83 # Make them always end in a capital .S. Files ending in a lowercase .s
84 # will not be considered source files but generated files (assembler
85 # output from the compiler), and will be deleted upon "make clean"!
86 # Even though the DOS/Win* filesystem matches both .s and .S the same,
87 # it will preserve the spelling of the filenames, and gcc itself does
88 # care about how the name is spelled on its command-line.
91 # List Assembler source files here which must be assembled in ARM-Mode.
94 # List any extra directories to look for include files here.
95 # Each directory must be seperated by a space.
96 EXTRAINCDIRS
+= $(PIOS
)
97 EXTRAINCDIRS
+= $(PIOSINC
)
98 EXTRAINCDIRS
+= $(BOARDINC
)
99 EXTRAINCDIRS
+= $(FLIGHTLIBINC
)
100 EXTRAINCDIRS
+= $(PIOSCOMMON
)
101 EXTRAINCDIRS
+= $(OPSYSTEMINC
)
103 # List any extra directories to look for library files here.
104 # Also add directories where the linker should search for
105 # includes from linker-script to the list
106 # Each directory must be seperated by a space.
110 # Each library-name must be seperated by a space.
111 # i.e. to link with libxyz.a, libabc.a and libefsl.a:
112 # EXTRA_LIBS = xyz abc efsl
113 # for newlib-lpc (file: libnewlibc-lpc.a):
114 # EXTRA_LIBS = newlib-lpc
119 # enable bootloader specific stuffs
120 CDEFS
+= -DBOOTLOADER
122 # Set linker-script name depending on selected submodel name
123 ifeq ($(MCU
),cortex-m3
)
124 LDFLAGS
+= -T
$(LINKER_SCRIPTS_PATH
)/link_
$(BOARD
)_memory.
ld
125 LDFLAGS
+= -T
$(LINKER_SCRIPTS_PATH
)/link_
$(BOARD
)_BL_sections.
ld
126 else ifeq ($(MCU
),cortex-m4
)
127 LDFLAGS
+= $(addprefix -T
,$(LINKER_SCRIPTS_BL
))
128 else ifeq ($(MCU
),cortex-m0
)
129 LDFLAGS
+= -T
$(LINKER_SCRIPTS_PATH
)/link_
$(BOARD
)_memory.
ld
130 LDFLAGS
+= -T
$(LINKER_SCRIPTS_PATH
)/link_
$(BOARD
)_BL_sections.
ld
133 # Add jtag targets (program and wipe)
134 $(eval
$(call JTAG_TEMPLATE
,$(OUTDIR
)/$(TARGET
).bin
,$(BL_BANK_BASE
),$(BL_BANK_SIZE
),$(OPENOCD_JTAG_CONFIG
),$(OPENOCD_CONFIG
)))