Advertisement
CATSUPERBERG

STM32Make.make

Feb 21st, 2022
1,677
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 6.56 KB | None | 0 0
  1. ##########################################################################################################################
  2. # File automatically-generated by STM32forVSCode
  3. ##########################################################################################################################
  4.  
  5. # ------------------------------------------------
  6. # Generic Makefile (based on gcc)
  7. #
  8. # ChangeLog :
  9. #   2017-02-10 - Several enhancements + project update mode
  10. #   2015-07-22 - first version
  11. # ------------------------------------------------
  12.  
  13. ######################################
  14. # target
  15. ######################################
  16. TARGET = Simple_lamp
  17.  
  18.  
  19. ######################################
  20. # building variables
  21. ######################################
  22. # debug build?
  23. DEBUG = 1
  24. # optimization
  25. OPT = -Og
  26.  
  27.  
  28. #######################################
  29. # paths
  30. #######################################
  31. # Build path
  32. BUILD_DIR = build
  33.  
  34. ######################################
  35. # source
  36. ######################################
  37. # C sources
  38. C_SOURCES =  \
  39. Core/Src/stm32f1xx_hal_msp.c \
  40. Core/Src/stm32f1xx_it.c \
  41. Core/Src/system_stm32f1xx.c \
  42. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c \
  43. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c \
  44. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c \
  45. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_exti.c \
  46. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c \
  47. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c \
  48. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c \
  49. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c \
  50. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c \
  51. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c \
  52. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c \
  53. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c \
  54. Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c
  55.  
  56.  
  57. CPP_SOURCES = \
  58. Core/Src/hsvConversion.cpp \
  59. Core/Src/incrementCalculator.cpp \
  60. Core/Src/lamp.cpp \
  61. Core/Src/main.cpp
  62.  
  63.  
  64. # ASM sources
  65. ASM_SOURCES =  \
  66. startup_stm32f103xb.s
  67.  
  68.  
  69.  
  70. #######################################
  71. # binaries
  72. #######################################
  73. PREFIX = arm-none-eabi-
  74. POSTFIX = "
  75. # The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
  76. # either it can be added to the PATH environment variable.
  77. GCC_PATH="c:/Users/Mixer/AppData/Roaming/Code/User/globalStorage/bmd.stm32-for-vscode/@xpack-dev-tools/arm-none-eabi-gcc/10.3.1-2.3.1/.content/bin
  78. ifdef GCC_PATH
  79. CXX = $(GCC_PATH)/$(PREFIX)g++$(POSTFIX)
  80. CC = $(GCC_PATH)/$(PREFIX)gcc$(POSTFIX)
  81. AS = $(GCC_PATH)/$(PREFIX)gcc$(POSTFIX) -x assembler-with-cpp
  82. CP = $(GCC_PATH)/$(PREFIX)objcopy$(POSTFIX)
  83. SZ = $(GCC_PATH)/$(PREFIX)size$(POSTFIX)
  84. else
  85. CXX = $(PREFIX)g++
  86. CC = $(PREFIX)gcc
  87. AS = $(PREFIX)gcc -x assembler-with-cpp
  88. CP = $(PREFIX)objcopy
  89. SZ = $(PREFIX)size
  90. endif
  91. HEX = $(CP) -O ihex
  92. BIN = $(CP) -O binary -S
  93.  
  94. #######################################
  95. # CFLAGS
  96. #######################################
  97. # cpu
  98. CPU = -mcpu=cortex-m3
  99.  
  100. # fpu
  101. FPU =
  102.  
  103. # float-abi
  104. FLOAT-ABI =
  105.  
  106. # mcu
  107. MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
  108.  
  109. # macros for gcc
  110. # AS defines
  111. AS_DEFS =
  112.  
  113. # C defines
  114. C_DEFS =  \
  115. -DSTM32F103xB \
  116. -DUSE_HAL_DRIVER
  117.  
  118.  
  119. # AS includes
  120. AS_INCLUDES = \
  121.  
  122. # C includes
  123. C_INCLUDES =  \
  124. -ICore/Inc \
  125. -ICore/Src \
  126. -IDrivers/CMSIS/Device/ST/STM32F1xx/Include \
  127. -IDrivers/CMSIS/Include \
  128. -IDrivers/STM32F1xx_HAL_Driver/Inc \
  129. -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy
  130.  
  131.  
  132.  
  133. # compile gcc flags
  134. ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  135.  
  136. CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
  137.  
  138. ifeq ($(DEBUG), 1)
  139. CFLAGS += -g -gdwarf-2
  140. endif
  141.  
  142. # Add additional flags
  143. CFLAGS +=
  144. ASFLAGS += -specs=nosys.specs
  145. CXXFLAGS =
  146. CXXFLAGS += -feliminate-unused-debug-types
  147.  
  148. # Generate dependency information
  149. CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
  150.  
  151. #######################################
  152. # LDFLAGS
  153. #######################################
  154. # link script
  155. LDSCRIPT = STM32F103C8Tx_FLASH.ld
  156.  
  157. # libraries
  158. LIBS = -lc -lm -lnosys
  159. LIBDIR = \
  160.  
  161.  
  162. # Additional LD Flags from config file
  163. ADDITIONALLDFLAGS = -specs=nosys.specs
  164.  
  165. LDFLAGS = $(MCU) $(ADDITIONALLDFLAGS) -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
  166.  
  167. # default action: build all
  168. all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
  169.  
  170.  
  171. #######################################
  172. # build the application
  173. #######################################
  174. # list of cpp program objects
  175. OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES:.cpp=.o)))
  176. vpath %.cpp $(sort $(dir $(CPP_SOURCES)))
  177. # list of C objects
  178. OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
  179. vpath %.c $(sort $(dir $(C_SOURCES)))
  180. # list of ASM program objects
  181. OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
  182. vpath %.s $(sort $(dir $(ASM_SOURCES)))
  183.  
  184. $(BUILD_DIR)/%.o: %.cpp STM32Make.make | $(BUILD_DIR)
  185.     $(CXX) -c $(CXXFLAGS) $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.cpp=.lst)) $< -o $@
  186.  
  187. $(BUILD_DIR)/%.o: %.c STM32Make.make | $(BUILD_DIR)
  188.     $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
  189.  
  190. $(BUILD_DIR)/%.o: %.s STM32Make.make | $(BUILD_DIR)
  191.     $(AS) -c $(CFLAGS) $< -o $@
  192.  
  193. $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) STM32Make.make
  194.     $(CXX) $(OBJECTS) $(LDFLAGS) -o $@
  195.     $(SZ) $@
  196.  
  197. $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  198.     $(HEX) $< $@
  199.  
  200. $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
  201.     $(BIN) $< $@
  202.  
  203. $(BUILD_DIR):
  204.     mkdir $@
  205.  
  206. #######################################
  207. # flash
  208. #######################################
  209. flash: $(BUILD_DIR)/$(TARGET).elf
  210.     "C:/USERS/MIXER/APPDATA/ROAMING/CODE/USER/GLOBALSTORAGE/BMD.STM32-FOR-VSCODE/@XPACK-DEV-TOOLS/OPENOCD/0.11.0-2.1/.CONTENT/BIN/OPENOCD.EXE" -f ./openocd.cfg -c "program $(BUILD_DIR)/$(TARGET).elf verify reset exit"
  211.  
  212. #######################################
  213. # erase
  214. #######################################
  215. erase: $(BUILD_DIR)/$(TARGET).elf
  216.     "C:/USERS/MIXER/APPDATA/ROAMING/CODE/USER/GLOBALSTORAGE/BMD.STM32-FOR-VSCODE/@XPACK-DEV-TOOLS/OPENOCD/0.11.0-2.1/.CONTENT/BIN/OPENOCD.EXE" -f ./openocd.cfg -c "init; reset halt; stm32f1x mass_erase 0; exit"
  217.  
  218. #######################################
  219. # clean up
  220. #######################################
  221. clean:
  222.     cmd /c rd /s /q $(BUILD_DIR)
  223.    
  224. #######################################
  225. # dependencies
  226. #######################################
  227. -include $(wildcard $(BUILD_DIR)/*.d)
  228.  
  229. # *** EOF ***
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement