amiro-os / modules / NUCLEO-L476RG / Makefile @ 39e164a2
History | View | Annotate | Download (9.659 KB)
| 1 | 27d0378b | Simon Welzel | ################################################################################  | 
      
|---|---|---|---|
| 2 | # AMiRo-OS is an operating system designed for the Autonomous Mini Robot #  | 
      ||
| 3 | # (AMiRo) platform. #  | 
      ||
| 4 | 1678f270 | Simon Welzel | # Copyright (C) 2016..2019 Thomas Schöpping et al. #  | 
      
| 5 | 27d0378b | Simon Welzel | # #  | 
      
| 6 | # This program is free software: you can redistribute it and/or modify #  | 
      ||
| 7 | # it under the terms of the GNU General Public License as published by #  | 
      ||
| 8 | # the Free Software Foundation, either version 3 of the License, or #  | 
      ||
| 9 | # (at your option) any later version. #  | 
      ||
| 10 | # #  | 
      ||
| 11 | # This program is distributed in the hope that it will be useful, #  | 
      ||
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of #  | 
      ||
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #  | 
      ||
| 14 | # GNU General Public License for more details. #  | 
      ||
| 15 | # #  | 
      ||
| 16 | # You should have received a copy of the GNU General Public License #  | 
      ||
| 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. #  | 
      ||
| 18 | # #  | 
      ||
| 19 | # This research/work was supported by the Cluster of Excellence Cognitive #  | 
      ||
| 20 | # Interaction Technology 'CITEC' (EXC 277) at Bielefeld University, which is #  | 
      ||
| 21 | # funded by the German Research Foundation (DFG). #  | 
      ||
| 22 | ################################################################################  | 
      ||
| 23 | |||
| 24 | |||
| 25 | |||
| 26 | ################################################################################  | 
      ||
| 27 | # Build global options #  | 
      ||
| 28 | # NOTE: Can be overridden externally. #  | 
      ||
| 29 | # #  | 
      ||
| 30 | |||
| 31 | # Compiler options here.  | 
      ||
| 32 | ifeq ($(USE_OPT),)  | 
      ||
| 33 | 00843891 | Thomas Schöpping | USE_OPT = -O2 -fstack-usage  | 
      
| 34 | 27d0378b | Simon Welzel | endif  | 
      
| 35 | |||
| 36 | # C specific options here (added to USE_OPT).  | 
      ||
| 37 | ifeq ($(USE_COPT),)  | 
      ||
| 38 | 691a0632 | Thomas Schöpping | USE_COPT = -std=c17  | 
      
| 39 | 27d0378b | Simon Welzel | endif  | 
      
| 40 | |||
| 41 | # C++ specific options here (added to USE_OPT).  | 
      ||
| 42 | ifeq ($(USE_CPPOPT),)  | 
      ||
| 43 | USE_CPPOPT = -fno-rtti -std=c++17  | 
      ||
| 44 | endif  | 
      ||
| 45 | |||
| 46 | 732a4657 | Thomas Schöpping | # Enable this if you want the linker to remove unused code and data.  | 
      
| 47 | 27d0378b | Simon Welzel | ifeq ($(USE_LINK_GC),)  | 
      
| 48 | USE_LINK_GC = yes  | 
      ||
| 49 | endif  | 
      ||
| 50 | |||
| 51 | # Linker extra options here.  | 
      ||
| 52 | ifeq ($(USE_LDOPT),)  | 
      ||
| 53 | USE_LDOPT =  | 
      ||
| 54 | endif  | 
      ||
| 55 | |||
| 56 | 732a4657 | Thomas Schöpping | # Enable this if you want link time optimizations (LTO).  | 
      
| 57 | 27d0378b | Simon Welzel | ifeq ($(USE_LTO),)  | 
      
| 58 | USE_LTO = yes  | 
      ||
| 59 | endif  | 
      ||
| 60 | |||
| 61 | # Enable this if you want to see the full log while compiling.  | 
      ||
| 62 | ifeq ($(USE_VERBOSE_COMPILE),)  | 
      ||
| 63 | USE_VERBOSE_COMPILE = no  | 
      ||
| 64 | endif  | 
      ||
| 65 | |||
| 66 | # If enabled, this option makes the build process faster by not compiling  | 
      ||
| 67 | # modules not used in the current configuration.  | 
      ||
| 68 | ifeq ($(USE_SMART_BUILD),)  | 
      ||
| 69 | USE_SMART_BUILD = no  | 
      ||
| 70 | endif  | 
      ||
| 71 | |||
| 72 | # #  | 
      ||
| 73 | # Build global options #  | 
      ||
| 74 | ################################################################################  | 
      ||
| 75 | |||
| 76 | ################################################################################  | 
      ||
| 77 | # Architecture or project specific options #  | 
      ||
| 78 | # #  | 
      ||
| 79 | |||
| 80 | # Stack size to be allocated to the Cortex-M process stack. This stack is  | 
      ||
| 81 | # the stack used by the main() thread.  | 
      ||
| 82 | ifeq ($(USE_PROCESS_STACKSIZE),)  | 
      ||
| 83 | USE_PROCESS_STACKSIZE = 0x400  | 
      ||
| 84 | endif  | 
      ||
| 85 | |||
| 86 | # Stack size to the allocated to the Cortex-M main/exceptions stack. This  | 
      ||
| 87 | # stack is used for processing interrupts and exceptions.  | 
      ||
| 88 | ifeq ($(USE_EXCEPTIONS_STACKSIZE),)  | 
      ||
| 89 | USE_EXCEPTIONS_STACKSIZE = 0x400  | 
      ||
| 90 | endif  | 
      ||
| 91 | |||
| 92 | 732a4657 | Thomas Schöpping | # Enables the use of FPU.  | 
      
| 93 | 27d0378b | Simon Welzel | # Possible selections are:  | 
      
| 94 | # no - no FPU is used (probably equals 'soft')  | 
      ||
| 95 | # soft - does not use the FPU, thus all floating point operations are emulated  | 
      ||
| 96 | # softfp - uses the FPU, but uses the integer registers only  | 
      ||
| 97 | # hard - uses the FPU and passes data via the FPU registers  | 
      ||
| 98 | ifeq ($(USE_FPU),)  | 
      ||
| 99 | USE_FPU = softfp  | 
      ||
| 100 | endif  | 
      ||
| 101 | |||
| 102 | 732a4657 | Thomas Schöpping | # FPU-related options.  | 
      
| 103 | ifeq ($(USE_FPU_OPT),)  | 
      ||
| 104 | USE_FPU_OPT = -mfloat-abi=$(USE_FPU) -mfpu=fpv4-sp-d16  | 
      ||
| 105 | endif  | 
      ||
| 106 | |||
| 107 | 27d0378b | Simon Welzel | # #  | 
      
| 108 | # Architecture or project specific options #  | 
      ||
| 109 | ################################################################################  | 
      ||
| 110 | |||
| 111 | ################################################################################  | 
      ||
| 112 | 732a4657 | Thomas Schöpping | # Project, target, sources and paths #  | 
      
| 113 | 27d0378b | Simon Welzel | # #  | 
      
| 114 | |||
| 115 | 2f5f6722 | Thomas Schöpping | # Absolute path to the project  | 
      
| 116 | PROJECT_PATH := $(abspath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))  | 
      ||
| 117 | |||
| 118 | 27d0378b | Simon Welzel | # Define project name here  | 
      
| 119 | 2f5f6722 | Thomas Schöpping | PROJECT := $(patsubst $(abspath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))..)/%,%,$(PROJECT_PATH))  | 
      
| 120 | 27d0378b | Simon Welzel | |
| 121 | 732a4657 | Thomas Schöpping | # Target settings.  | 
      
| 122 | MCU = cortex-m4  | 
      ||
| 123 | |||
| 124 | # Imported source files and paths.  | 
      ||
| 125 | 27d0378b | Simon Welzel | include ../../kernel/kernel.mk  | 
      
| 126 | 732a4657 | Thomas Schöpping | CHIBIOS := $(AMIROOS_KERNEL)  | 
      
| 127 | CONFDIR := .  | 
      ||
| 128 | ifeq ($(BUILDDIR),)  | 
      ||
| 129 | 2f5f6722 | Thomas Schöpping | BUILDDIR := $(PROJECT_PATH)/build  | 
      
| 130 | 732a4657 | Thomas Schöpping | endif  | 
      
| 131 | DEPDIR := $(dir $(BUILDDIR)).dep  | 
      ||
| 132 | AMIROOS := ../..  | 
      ||
| 133 | # Licensing files.  | 
      ||
| 134 | 1678f270 | Simon Welzel | include $(CHIBIOS)/os/license/license.mk  | 
      
| 135 | 732a4657 | Thomas Schöpping | # Startup files.  | 
      
| 136 | 27d0378b | Simon Welzel | include $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32l4xx.mk  | 
      
| 137 | 732a4657 | Thomas Schöpping | # HAL-OSAL files (optional).  | 
      
| 138 | 27d0378b | Simon Welzel | include $(CHIBIOS)/os/hal/hal.mk  | 
      
| 139 | include $(CHIBIOS)/os/hal/ports/STM32/STM32L4xx/platform.mk  | 
      ||
| 140 | include $(CHIBIOS)/os/hal/osal/rt/osal.mk  | 
      ||
| 141 | 2a9f9ad7 | Thomas Schöpping | include $(CHIBIOS)/os/hal/lib/streams/streams.mk  | 
      
| 142 | 732a4657 | Thomas Schöpping | # RTOS files (optional).  | 
      
| 143 | 27d0378b | Simon Welzel | include $(CHIBIOS)/os/rt/rt.mk  | 
      
| 144 | include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk  | 
      ||
| 145 | 732a4657 | Thomas Schöpping | # Auto-build files in ./source recursively.  | 
      
| 146 | include $(CHIBIOS)/tools/mk/autobuild.mk  | 
      ||
| 147 | 27d0378b | Simon Welzel | # Other files (optional).  | 
      
| 148 | include $(CHIBIOS)/test/lib/test.mk  | 
      ||
| 149 | include $(CHIBIOS)/test/rt/rt_test.mk  | 
      ||
| 150 | 1678f270 | Simon Welzel | include $(CHIBIOS)/test/oslib/oslib_test.mk  | 
      
| 151 | 27d0378b | Simon Welzel | # AMiRo-BLT files  | 
      
| 152 | include ../../bootloader/bootloader.mk  | 
      ||
| 153 | # AMiRo-LLD files  | 
      ||
| 154 | include ../../periphery-lld/periphery-lld.mk  | 
      ||
| 155 | # AMiRo-OS files  | 
      ||
| 156 | include ../modules.mk  | 
      ||
| 157 | include $(AMIROOS)/core/core.mk  | 
      ||
| 158 | include $(AMIROOS)/unittests/unittests.mk  | 
      ||
| 159 | |||
| 160 | # Define linker script file here  | 
      ||
| 161 | 1678f270 | Simon Welzel | LDSCRIPT= STM32L476xG.ld  | 
      
| 162 | 27d0378b | Simon Welzel | |
| 163 | # C sources that can be compiled in ARM or THUMB mode depending on the global  | 
      ||
| 164 | # setting.  | 
      ||
| 165 | 732a4657 | Thomas Schöpping | CSRC = $(ALLCSRC) \  | 
      
| 166 | 27d0378b | Simon Welzel | $(CHIBIOS)/os/various/syscalls.c \  | 
      
| 167 | 2a9f9ad7 | Thomas Schöpping | $(CHIBIOS)/os/various/evtimer.c \  | 
      
| 168 | $(TESTSRC) \  | 
      ||
| 169 | 1678f270 | Simon Welzel | board.c \  | 
      
| 170 | 732a4657 | Thomas Schöpping | $(PERIPHERYLLDCSRC) \  | 
      
| 171 | $(UNITTESTSCSRC) \  | 
      ||
| 172 | $(AMIROOSCORECSRC) \  | 
      ||
| 173 | $(MODULESCSRC) \  | 
      ||
| 174 | 27d0378b | Simon Welzel | module.c \  | 
      
| 175 | $(APPSCSRC)  | 
      ||
| 176 | |||
| 177 | # C++ sources that can be compiled in ARM or THUMB mode depending on the global  | 
      ||
| 178 | # setting.  | 
      ||
| 179 | 732a4657 | Thomas Schöpping | CPPSRC = $(ALLCPPSRC) \  | 
      
| 180 | 1678f270 | Simon Welzel | $(CHIBIOS)/os/various/cpp_wrappers/syscalls_cpp.cpp \  | 
      
| 181 | 732a4657 | Thomas Schöpping | $(AMIROOSCORECPPSRC) \  | 
      
| 182 | 27d0378b | Simon Welzel | $(APPSCPPSRC)  | 
      
| 183 | |||
| 184 | 732a4657 | Thomas Schöpping | # List ASM source files here.  | 
      
| 185 | ASMSRC = $(ALLASMSRC) \  | 
      ||
| 186 | $(APPSASMSRC)  | 
      ||
| 187 | |||
| 188 | # List ASM with preprocessor source files here.  | 
      ||
| 189 | ASMXSRC = $(ALLXASMSRC) \  | 
      ||
| 190 | 27d0378b | Simon Welzel | $(APPSASMXSRC)  | 
      
| 191 | |||
| 192 | 732a4657 | Thomas Schöpping | # Inclusion directories.  | 
      
| 193 | INCDIR = $(CONFDIR) \  | 
      ||
| 194 | $(ALLINC) \  | 
      ||
| 195 | 27d0378b | Simon Welzel | $(TESTINC) \  | 
      
| 196 | $(CHIBIOS)/os/hal/lib/streams \  | 
      ||
| 197 | 732a4657 | Thomas Schöpping | $(BOOTLOADERINC) \  | 
      
| 198 | 27d0378b | Simon Welzel | $(PERIPHERYLLDINC) \  | 
      
| 199 | $(AMIROOS) \  | 
      ||
| 200 | $(UNITTESTSINC) \  | 
      ||
| 201 | 732a4657 | Thomas Schöpping | $(AMIROOSCOREINC) \  | 
      
| 202 | $(MODULESINC) \  | 
      ||
| 203 | 27d0378b | Simon Welzel | $(APPSINC)  | 
      
| 204 | |||
| 205 | 732a4657 | Thomas Schöpping | # Define C warning options here.  | 
      
| 206 | CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes  | 
      ||
| 207 | 27d0378b | Simon Welzel | |
| 208 | 732a4657 | Thomas Schöpping | # Define C++ warning options here.  | 
      
| 209 | CPPWARN = -Wall -Wextra -Wundef  | 
      ||
| 210 | 27d0378b | Simon Welzel | |
| 211 | # #  | 
      ||
| 212 | 732a4657 | Thomas Schöpping | # Project, target, sources and paths #  | 
      
| 213 | 27d0378b | Simon Welzel | ################################################################################  | 
      
| 214 | |||
| 215 | ################################################################################  | 
      ||
| 216 | # Start of user section #  | 
      ||
| 217 | # #  | 
      ||
| 218 | |||
| 219 | # List all user C define here, like -D_DEBUG=1  | 
      ||
| 220 | UDEFS +=  | 
      ||
| 221 | |||
| 222 | # Define ASM defines here  | 
      ||
| 223 | UADEFS +=  | 
      ||
| 224 | |||
| 225 | # List all user directories here  | 
      ||
| 226 | UINCDIR +=  | 
      ||
| 227 | |||
| 228 | # List the user directory to look for the libraries here  | 
      ||
| 229 | ULIBDIR +=  | 
      ||
| 230 | |||
| 231 | # List all user libraries here  | 
      ||
| 232 | ULIBS +=  | 
      ||
| 233 | |||
| 234 | # #  | 
      ||
| 235 | 732a4657 | Thomas Schöpping | # End of user section #  | 
      
| 236 | 27d0378b | Simon Welzel | ################################################################################  | 
      
| 237 | |||
| 238 | 1678f270 | Simon Welzel | ################################################################################  | 
      
| 239 | 732a4657 | Thomas Schöpping | # Common rules #  | 
      
| 240 | 1678f270 | Simon Welzel | # #  | 
      
| 241 | 27d0378b | Simon Welzel | |
| 242 | 732a4657 | Thomas Schöpping | RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk  | 
      
| 243 | include $(RULESPATH)/arm-none-eabi.mk  | 
      ||
| 244 | 27d0378b | Simon Welzel | include $(RULESPATH)/rules.mk  | 
      
| 245 | |||
| 246 | 732a4657 | Thomas Schöpping | # #  | 
      
| 247 | # Common rules #  | 
      ||
| 248 | ################################################################################  | 
      ||
| 249 | |||
| 250 | ################################################################################  | 
      ||
| 251 | # Custom rules #  | 
      ||
| 252 | # #  | 
      ||
| 253 | 83e94d4b | Thomas Schöpping | |
| 254 | flash: $(BUILDDIR)/$(PROJECT).elf  | 
      ||
| 255 | eeb84bf1 | Thomas Schöpping | openocd -f interface/stlink-v2-1.cfg -c "set WORKAREASIZE 0x2000" -f target/stm32l4x.cfg -c "program $(BUILDDIR)/$(PROJECT).elf verify reset exit"  | 
      
| 256 | 83e94d4b | Thomas Schöpping | |
| 257 | 1678f270 | Simon Welzel | # #  | 
      
| 258 | 732a4657 | Thomas Schöpping | # Custom rules #  | 
      
| 259 | 1678f270 | Simon Welzel | ################################################################################  |