Revert "Revert "Merge remote-tracking branch 'origin/parched/OP-1324_fix_build_when_p...
[librepilot.git] / make / boot-defs.mk
blob1ebf53d96d40eb561130f6980607bf196c8bb5a8
2 # Copyright (c) 2009-2013, The OpenPilot Team, http://www.openpilot.org
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 # for more details.
14 # You should have received a copy of the GNU General Public License along
15 # with this program; if not, write to the Free Software Foundation, Inc.,
16 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ifndef OPENPILOT_IS_COOL
20 $(error Top level Makefile must be used to build this target)
21 endif
23 # Paths
24 TOPDIR = .
25 OPSYSTEM = $(TOPDIR)
26 BOARDINC = $(TOPDIR)/..
27 OPSYSTEMINC = $(OPSYSTEM)/inc
28 PIOSINC = $(PIOS)/inc
29 PIOSCOMMON = $(PIOS)/common
30 FLIGHTLIBINC = $(FLIGHTLIB)/inc
32 # ARM DSP library
33 override USE_DSP_LIB := NO
35 ## PIOS Hardware
36 ifeq ($(MCU),cortex-m3)
37 include $(PIOS)/stm32f10x/library.mk
38 else ifeq ($(MCU),cortex-m4)
39 include $(PIOS)/stm32f4xx/library.mk
40 else
41 $(error Unsupported MCU: $(MCU))
42 endif
44 # List C source files here (C dependencies are automatically generated).
45 # Use file-extension c for "c-only"-files
47 ## Bootloader Core
48 SRC += ../pios_usb_board_data.c
49 SRC += $(OPSYSTEM)/main.c
50 SRC += $(OPSYSTEM)/pios_board.c
52 ## PIOS Hardware (Common)
53 SRC += $(PIOSCOMMON)/pios_board_info.c
54 SRC += $(PIOSCOMMON)/pios_com_msg.c
55 SRC += $(PIOSCOMMON)/pios_iap.c
56 SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c
57 SRC += $(PIOSCOMMON)/pios_usb_util.c
58 SRC += $(PIOSCOMMON)/pios_led.c
60 ## Misc library functions
61 SRC += $(FLIGHTLIB)/op_dfu.c
62 SRC += $(FLIGHTLIB)/printf-stdarg.c
64 # List C source files here which must be compiled in ARM-Mode (no -mthumb).
65 # Use file-extension c for "c-only"-files
66 SRCARM +=
68 # List C++ source files here.
69 # Use file-extension .cpp for C++-files (not .C)
70 CPPSRC +=
72 # List C++ source files here which must be compiled in ARM-Mode.
73 # Use file-extension .cpp for C++-files (not .C)
74 CPPSRCARM +=
76 # List Assembler source files here.
77 # Make them always end in a capital .S. Files ending in a lowercase .s
78 # will not be considered source files but generated files (assembler
79 # output from the compiler), and will be deleted upon "make clean"!
80 # Even though the DOS/Win* filesystem matches both .s and .S the same,
81 # it will preserve the spelling of the filenames, and gcc itself does
82 # care about how the name is spelled on its command-line.
83 ASRC +=
85 # List Assembler source files here which must be assembled in ARM-Mode.
86 ASRCARM +=
88 # List any extra directories to look for include files here.
89 # Each directory must be seperated by a space.
90 EXTRAINCDIRS += $(PIOS)
91 EXTRAINCDIRS += $(PIOSINC)
92 EXTRAINCDIRS += $(BOARDINC)
93 EXTRAINCDIRS += $(FLIGHTLIBINC)
94 EXTRAINCDIRS += $(PIOSCOMMON)
95 EXTRAINCDIRS += $(OPSYSTEMINC)
97 # List any extra directories to look for library files here.
98 # Also add directories where the linker should search for
99 # includes from linker-script to the list
100 # Each directory must be seperated by a space.
101 EXTRA_LIBDIRS +=
103 # Extra Libraries
104 # Each library-name must be seperated by a space.
105 # i.e. to link with libxyz.a, libabc.a and libefsl.a:
106 # EXTRA_LIBS = xyz abc efsl
107 # for newlib-lpc (file: libnewlibc-lpc.a):
108 # EXTRA_LIBS = newlib-lpc
109 EXTRA_LIBS +=
111 # Compiler flags
112 CDEFS +=
114 # Set linker-script name depending on selected submodel name
115 ifeq ($(MCU),cortex-m3)
116 LDFLAGS += -T$(LINKER_SCRIPTS_PATH)/link_$(BOARD)_memory.ld
117 LDFLAGS += -T$(LINKER_SCRIPTS_PATH)/link_$(BOARD)_BL_sections.ld
118 else ifeq ($(MCU),cortex-m4)
119 LDFLAGS += $(addprefix -T,$(LINKER_SCRIPTS_BL))
120 endif
122 # Add jtag targets (program and wipe)
123 $(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BL_BANK_BASE),$(BL_BANK_SIZE),$(OPENOCD_JTAG_CONFIG),$(OPENOCD_CONFIG)))