Advertisement
Guest User

Untitled

a guest
Jun 17th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 2.22 KB | None | 0 0
  1. BUILD_BASE  = build
  2. FW_DIR      = firmware
  3.  
  4. TARGET = app
  5.  
  6. STARTUP = startup_stm32f10x_ld_vl.S
  7.  
  8. TARGET_OUT = $(addprefix $(BUILD_BASE)/,$(TARGET).elf)
  9. FW_OUT = $(addprefix $(FW_DIR)/,$(TARGET).hex)
  10.  
  11. STLINK_FLASH = "C:\Program Files (x86)\STMicroelectronics\STM32 ST-LINK Utility\ST-LINK Utility\ST-LINK_CLI.exe"
  12. STLINK_FLAGS = -c SWD -p $(FW_OUT) -Rst -Run
  13.  
  14. MODULES   = user SPL SPL/src SPL/inc CoreSupport
  15. SRC_DIR   = $(MODULES)
  16. BUILD_DIR = $(addprefix build/,$(MODULES))
  17.  
  18. SRC       = $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c))
  19. OBJ       = $(patsubst %.c,build/%.o,$(SRC))
  20. INCLUDES  = $(addprefix -I ,$(SRC_DIR))
  21.  
  22. LD_SCRIPT   = stm32f103c8_flash.ld
  23. LDFLAGS = -T$(LD_SCRIPT) -Wl,--gc-sections,-Map=$@.map,-cref,-u,Reset_Handler $(INCLUDES)  
  24.  
  25. CFLAGS  =   -specs=nano.specs -ffunction-sections -fdata-sections -mcpu=cortex-m3 -mthumb -Wall -g -O2 \
  26.             -fomit-frame-pointer -fverbose-asm -mfloat-abi=soft -D__STACK_SIZE=0x0100 -D__HEAP_SIZE=0x0000 \
  27.             -DSTM32F103C8 -DSTM32F10X_MD -DUSE_STDPERIPH_DRIVER -DRUN_FROM_FLASH=1
  28.  
  29. ASFLAGS = -Wa,-adhlns=$@.lst -c -fmessage-length=0 -mcpu=cortex-m3 -mfloat-abi=soft
  30.  
  31. OBJCPFLAGS = -O ihex
  32. OBJSIZEFLAGS = --format=berkeley
  33.  
  34. CC=arm-none-eabi-gcc.exe
  35. LD=arm-none-eabi-gcc.exe
  36. AR=arm-none-eabi-ar.exe
  37. AS=arm-none-eabi-as.exe
  38. OBJCP=arm-none-eabi-objcopy.exe
  39. OBJDP=arm-none-eabi-objdump.exe
  40. OBJSIZE=arm-none-eabi-size.exe
  41.  
  42. V ?= $(VERBOSE)
  43. ifeq ("$(V)","1")
  44. Q :=
  45. vecho := @true
  46. else
  47. Q := @
  48. vecho := @echo
  49. endif
  50.  
  51. vpath %.c $(SRC_DIR)
  52.  
  53. define compile-objects
  54. build/%.o: %.c
  55.     $(vecho) $(CC) $(INCLUDES) $(CFLAGS)  -c $$< -o $$@
  56.     $(Q) $(CC) $(INCLUDES) $(CFLAGS)  -c $$< -o $$@
  57. endef
  58.  
  59. .PHONY: all checkdirs clean flash
  60.  
  61. all: checkdirs $(TARGET_OUT) $(FW_OUT)
  62.  
  63. checkdirs: $(BUILD_DIR) $(FW_DIR)
  64.  
  65. $(TARGET_OUT):$(OBJ)
  66.     $(vecho) $(LD) $(LDFLAGS) $(OBJ) -o $@
  67.     $(Q) $(LD) $(LDFLAGS) $(OBJ) -o $@
  68.  
  69. $(FW_OUT):$(TARGET_OUT)
  70.     $(OBJCP) $(OBJCPFLAGS) $< $@
  71.     $(OBJSIZE) $(OBJSIZEFLAGS) $< $@
  72.  
  73. $(BUILD_DIR):
  74.     $(Q) md $(subst /,\,$@)
  75.  
  76. $(FW_DIR):
  77.     $(Q) md $(subst /,\,$@)
  78.  
  79. $(foreach bdir,$(BUILD_DIR),$(eval $(call compile-objects,$(bdir))))
  80.  
  81. flash: all
  82.     $(STLINK_FLASH) $(STLINK_FLAGS)
  83.    
  84. clean:
  85.     $(Q) rm -rf $(BUILD_DIR)
  86.     $(Q) rm -rf $(BUILD_BASE)
  87.     $(Q) rm -rf $(FW_DIR)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement