Makefile.stm8l 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. ##########################
  2. # IAR Makefile for STM8L #
  3. ##########################
  4. # Взял из проекта atomthreads и переиначил.
  5. PROJECT=VAPC
  6. # Location of build tools and atomthreads sources
  7. EWSTM8_DIR=C:\IAR\Embedded Workbench 7.3\stm8
  8. EWSTM8_BIN=C:/IAR/Embedded\ Workbench\ 7.3/stm8/bin
  9. CC=$(EWSTM8_BIN)/iccstm8
  10. ASM=$(EWSTM8_BIN)/iasmstm8
  11. LINK=$(EWSTM8_BIN)/ilinkstm8
  12. HEX=$(EWSTM8_BIN)/ielftool
  13. FLASHTOOL=C:/STMicroelectronics/st_toolset/stvp/STVP_CmdLine.exe
  14. FLASHOPT=-Device=STM8L051x3
  15. DEFINES = -D USE_STDPERIPH_DRIVER
  16. DEFINES += -D USE_RTOS
  17. APP_SRC = src
  18. LIB_SRC = lib
  19. # Sources pats
  20. vpath %.c $(APP_SRC)
  21. vpath %.c $(LIB_SRC)
  22. vpath %.c StdPerphDrv/src
  23. # Include paths
  24. INCLUDES = -I inc
  25. INCLUDES += -I lib
  26. INCLUDES += -I StdPerphDrv/inc
  27. # CPU part number
  28. PART = STM8L05X_LD_VL
  29. ICF = lnkstm8l051f3.icf
  30. LIB_MODEL = dlstm8ssn.h
  31. # Directory for built objects
  32. OUT_DIR = Out
  33. OBJ_DIR = $(OUT_DIR)/Obj
  34. LIST_DIR = $(OUT_DIR)/List
  35. # Models
  36. CODE_MODEL = small
  37. DATA_MODEL = small
  38. # Application object files
  39. APP_OBJECTS = $(notdir $(patsubst %.c,%.o,$(wildcard $(APP_SRC)/*.c)))
  40. # Librarys object files
  41. LIB_OBJECTS = $(notdir $(patsubst %.c,%.o,$(wildcard $(LIB_SRC)/*.c)))
  42. # STM8S Peripheral driver object files
  43. PERIPH_OBJECTS = stm8l15x_adc.o
  44. #PERIPH_OBJECTS += stm8l15x_aes.o
  45. #PERIPH_OBJECTS += stm8l15x_beep.o
  46. PERIPH_OBJECTS += stm8l15x_clk.o
  47. #PERIPH_OBJECTS += stm8l15x_comp.o
  48. #PERIPH_OBJECTS += stm8l15x_dac.o
  49. PERIPH_OBJECTS += stm8l15x_dma.o
  50. PERIPH_OBJECTS += stm8l15x_exti.o
  51. #PERIPH_OBJECTS += stm8l15x_flash.o
  52. PERIPH_OBJECTS += stm8l15x_gpio.o
  53. #PERIPH_OBJECTS += stm8l15x_i2c.o
  54. #PERIPH_OBJECTS += stm8l15x_irtim.o
  55. PERIPH_OBJECTS += stm8l15x_itc.o
  56. #PERIPH_OBJECTS += stm8l15x_iwdg.o
  57. #PERIPH_OBJECTS += stm8l15x_lcd.o
  58. #PERIPH_OBJECTS += stm8l15x_pwr.o
  59. #PERIPH_OBJECTS += stm8l15x_rst.o
  60. PERIPH_OBJECTS += stm8l15x_rtc.o
  61. PERIPH_OBJECTS += stm8l15x_spi.o
  62. PERIPH_OBJECTS += stm8l15x_syscfg.o
  63. PERIPH_OBJECTS += stm8l15x_tim1.o
  64. PERIPH_OBJECTS += stm8l15x_tim2.o
  65. PERIPH_OBJECTS += stm8l15x_tim3.o
  66. PERIPH_OBJECTS += stm8l15x_tim4.o
  67. #PERIPH_OBJECTS += stm8l15x_tim5.o
  68. PERIPH_OBJECTS += stm8l15x_usart.o
  69. #PERIPH_OBJECTS += stm8l15x_wfe.o
  70. #PERIPH_OBJECTS += stm8l15x_wwdg.o
  71. # Collection of built objects (excluding test applications)
  72. ALL_OBJECTS = $(APP_OBJECTS) $(LIB_OBJECTS) $(PERIPH_OBJECTS)
  73. BUILT_OBJECTS = $(patsubst %,$(OUT_DIR)/%,$(ALL_OBJECTS))
  74. # Target application filenames (.elf) for each test object
  75. PROJ_ELF = $(PROJECT).elf
  76. PROJ_S19 = $(PROJECT).s19
  77. PROJ_HEX = $(PROJECT).hex
  78. # Search build/output directory for dependencies
  79. vpath %.o .\$(OBJ_DIR)
  80. vpath %.elf .\$(OUT_DIR)
  81. vpath %.hex .\$(OUT_DIR)
  82. # Compiler/Assembler flags
  83. CFLAGS = -e -Oh $(DEFINES)
  84. CFLAGS += --code_model $(CODE_MODEL) --data_model $(DATA_MODEL)
  85. CFLAGS += --dlib_config "$(EWSTM8_DIR)\lib\$(LIB_MODEL)"
  86. CFLAGS += -D NDEBUG -D $(PART)
  87. CFLAGS += -lCN $(LIST_DIR) -lBN $(LIST_DIR)
  88. CFLAGS += --diag_suppress Pa050
  89. DBG_CFLAGS = -e -Ol $(DEFINES) --no_cross_call --debug
  90. DBG_CFLAGS += --no_cse --no_unroll --no_inline --no_code_motion --no_tbaa
  91. DBG_CFLAGS += --code_model $(CODE_MODEL) --data_model $(DATA_MODEL)
  92. DBG_CFLAGS += --dlib_config "$(EWSTM8_DIR)\lib\$(LIB_MODEL)" -D $(PART)
  93. DBG_CFLAGS += -lC $(LIST_DIR) -lB $(LIST_DIR)
  94. DBG_CFLAGS += --diag_suppress Pa050
  95. ASMFLAGS = -M'<>' -ld $(OUT_DIR)\list --diag_suppress Pa050
  96. ASMFLAGS += --code_model $(CODE_MODEL) --data_model $(DATA_MODEL)
  97. DBG_ASMFLAGS = -M'<>' -r -ld $(OUT_DIR)\list --diag_suppress Pa050
  98. DBG_ASMFLAGS += --code_model $(CODE_MODEL) --data_model $(DATA_MODEL)
  99. LINKFLAGS = --redirect _Printf=_PrintfTinyNoMb
  100. LINKFLAGS += --redirect _Scanf=_ScanfSmallNoMb
  101. LINKFLAGS += --config "$(EWSTM8_DIR)\config\$(ICF)"
  102. LINKFLAGS += --config_def _CSTACK_SIZE=0x100
  103. LINKFLAGS += --config_def _HEAP_SIZE=0x100
  104. LINKFLAGS += --map $(OUT_DIR)
  105. LINKFLAGS += --entry __iar_program_start
  106. LINKFLAGS += --merge_duplicate_sections
  107. LINKFLAGS += --strip
  108. LINKFLAGS += -f "$(EWSTM8_DIR)\config\math_small.xcl"
  109. DBG_LINKFLAGS = --redirect _Printf=_PrintfTinyNoMb --redirect _Scanf=_ScanfSmallNoMb
  110. DBG_LINKFLAGS += --config "$(EWSTM8_DIR)\config\$(ICF)" --config_def
  111. DBG_LINKFLAGS += _CSTACK_SIZE=0x100 --config_def _HEAP_SIZE=0x100
  112. DBG_LINKFLAGS += --entry __iar_program_start
  113. #################
  114. # Build targets #
  115. #################
  116. # All
  117. all: $(OUT_DIR) $(PROJ_S19) $(PROJ_HEX)
  118. Release: all
  119. flash: all
  120. # Make build/output directory
  121. $(OUT_DIR):
  122. mkdir $(OUT_DIR)
  123. @mkdir $(OBJ_DIR)
  124. @mkdir $(LIST_DIR)
  125. # Test HEX files (one application build for each test)
  126. $(PROJ_S19): %.s19: $(PROJ_ELF)
  127. @echo
  128. @echo Building $@
  129. @$(HEX) $(OUT_DIR)/$(notdir $<) $(OUT_DIR)/$@ --srec --silent
  130. $(PROJ_HEX): %.hex: $(PROJ_ELF)
  131. @echo Building $@
  132. @$(HEX) $(OUT_DIR)/$(notdir $<) $(OUT_DIR)/$@ --ihex --silent
  133. # Test ELF files (one application build for each test)
  134. $(PROJ_ELF): %.elf: $(ALL_OBJECTS)
  135. @echo
  136. @echo Linking $@
  137. @$(LINK) $(OBJ_DIR)/*.o $(LINKFLAGS) -o $(OUT_DIR)/$@
  138. # All C objects builder
  139. $(ALL_OBJECTS): %.o: %.c
  140. @echo
  141. @echo Compiling $@
  142. @$(CC) $< $(CFLAGS) $(INCLUDES) -o $(OBJ_DIR)
  143. # Clean
  144. clean:
  145. rm -f *.o *.elf *.map *.hex *.bin *.lst *.stm8 *.s19 *.out *.s *.lst
  146. rm -rf $(LIST_DIR)
  147. rm -rf $(OBJ_DIR)
  148. rm -rf $(OUT_DIR)
  149. # Flash
  150. flash:
  151. @$(FLASHTOOL) $(FLASHOPT) -FileProg=$(OUT_DIR)\\$(PROJ_HEX)