Makefile 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. ##########################
  2. # IAR Makefile for STM8S #
  3. ##########################
  4. # Âçÿë èç ïðîåêòà atomthreads è ïåðåèíà÷èë.
  5. PROJECT=ChACM
  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=STM8S003x6
  15. DEFINES = -D USE_STDPERIPH_DRIVER
  16. DEFINES += -D STM8S003
  17. #DEFINES += -D USE_RTOS
  18. # Sources paths
  19. APP_SRC = src
  20. LIB_SRC = lib
  21. vpath %.c $(APP_SRC)
  22. #vpath %.c $(LIB_SRC)
  23. vpath %.c StdPerphDrv/src
  24. # Include paths
  25. INCLUDES = -I inc
  26. #INCLUDES += -I lib
  27. INCLUDES += -I StdPerphDrv/inc
  28. # CPU part number
  29. PART=stm8s003f3
  30. ICF=lnkstm8s003f3.icf
  31. LIB_MODEL = dlstm8ssn.h
  32. # Directory for built objects
  33. OUT_DIR = build
  34. OBJ_DIR = $(OUT_DIR)/Obj
  35. LIST_DIR = $(OUT_DIR)/List
  36. # Models
  37. CODE_MODEL = small
  38. DATA_MODEL = small
  39. # Application object files
  40. APP_OBJECTS = main.o
  41. APP_OBJECTS += stm8s_it.o
  42. #APP_OBJECTS += rtos.o
  43. #APP_ASM_OBJECTS = atomport-asm-iar.o
  44. # STM8S Peripheral driver object files
  45. PERIPH_OBJECTS = stm8s_adc1.o
  46. #PERIPH_OBJECTS += stm8s_awu.o
  47. #PERIPH_OBJECTS += stm8s_beep.o
  48. PERIPH_OBJECTS += stm8s_clk.o
  49. PERIPH_OBJECTS += stm8s_exti.o
  50. PERIPH_OBJECTS += stm8s_flash.o
  51. PERIPH_OBJECTS += stm8s_gpio.o
  52. #PERIPH_OBJECTS += stm8s_i2c.o
  53. PERIPH_OBJECTS += stm8s_itc.o
  54. #PERIPH_OBJECTS += stm8s_iwdg.o
  55. #PERIPH_OBJECTS += stm8s_rst.o
  56. #PERIPH_OBJECTS += stm8s_spi.o
  57. PERIPH_OBJECTS += stm8s_tim1.o
  58. PERIPH_OBJECTS += stm8s_tim2.o
  59. PERIPH_OBJECTS += stm8s_tim4.o
  60. #PERIPH_OBJECTS += stm8s_uart1.o
  61. #PERIPH_OBJECTS += stm8s_wwdg.o
  62. # Collection of built objects (excluding test applications)
  63. ALL_OBJECTS = $(APP_OBJECTS) $(PERIPH_OBJECTS)
  64. BUILT_OBJECTS = $(patsubst %,$(OUT_DIR)/%,$(ALL_OBJECTS))
  65. # Target application filenames (.elf) for object
  66. PROJ_ELFS = $(PROJECT).elf
  67. PROJ_S19S = $(PROJECT).s19
  68. PROJ_IHEX = $(PROJECT).hex
  69. # Search build/output directory for dependencies
  70. vpath %.o .\$(OBJ_DIR)
  71. vpath %.elf .\$(OUT_DIR)
  72. vpath %.hex .\$(OUT_DIR)
  73. # Compiler/Assembler flags
  74. CFLAGS = -e -Ohs $(DEFINES) -D NDEBUG
  75. CFLAGS += --code_model $(CODE_MODEL) --data_model $(DATA_MODEL)
  76. CFLAGS += --dlib_config "$(EWSTM8_DIR)\lib\$(LIB_MODEL)"
  77. CFLAGS += -lCN $(LIST_DIR) -lBN $(LIST_DIR)
  78. CFLAGS += --diag_suppress Pa050 --guard_calls --silent
  79. DBG_CFLAGS = -e -Ol $(DEFINES) --no_cse --no_unroll --no_inline --no_code_motion --no_tbaa
  80. DBG_CFLAGS += --no_cross_call --debug --code_model $(CODE_MODEL) --data_model $(DATA_MODEL)
  81. DBG_CFLAGS += --dlib_config "$(EWSTM8_DIR)\lib\$(LIB_MODEL)"
  82. DBG_CFLAGS += -lC $(LIST_DIR) -lB $(LIST_DIR)
  83. DBG_CFLAGS += --diag_suppress Pa050
  84. ASMFLAGS = -M'<>' -ld $(OUT_DIR)\list --diag_suppress Pa050
  85. ASMFLAGS += --code_model $(CODE_MODEL) --data_model $(DATA_MODEL)
  86. DBG_ASMFLAGS = -M'<>' -r -ld $(OUT_DIR)\list --diag_suppress Pa050
  87. DBG_ASMFLAGS += --code_model $(CODE_MODEL) --data_model $(DATA_MODEL)
  88. LINKFLAGS = --redirect _Printf=_PrintfTinyNoMb
  89. LINKFLAGS += --redirect _Scanf=_ScanfSmallNoMb
  90. LINKFLAGS += --config "$(EWSTM8_DIR)\config\lnk$(PART).icf"
  91. LINKFLAGS += --config_def _CSTACK_SIZE=0x100
  92. LINKFLAGS += --config_def _HEAP_SIZE=0x100
  93. LINKFLAGS += --map $(OUT_DIR)
  94. LINKFLAGS += --entry __iar_program_start
  95. LINKFLAGS += --merge_duplicate_sections
  96. LINKFLAGS += --strip
  97. LINKFLAGS += -f "$(EWSTM8_DIR)\config\math_small.xcl"
  98. DBG_LINKFLAGS = --redirect _Printf=_PrintfTinyNoMb --redirect _Scanf=_ScanfSmallNoMb
  99. DBG_LINKFLAGS += --config "$(EWSTM8_DIR)\config\$(ICF)" --config_def
  100. DBG_LINKFLAGS += _CSTACK_SIZE=0x100 --config_def _HEAP_SIZE=0x100
  101. DBG_LINKFLAGS += --entry __iar_program_start
  102. #################
  103. # Build targets #
  104. #################
  105. # All tests
  106. all: $(OUT_DIR) $(PROJ_S19S) $(PROJ_IHEX)
  107. Release: all
  108. flash: all
  109. cleanRelease: clean
  110. # Make build/output directory
  111. $(OUT_DIR):
  112. @mkdir $(OUT_DIR)
  113. @mkdir $(OBJ_DIR)
  114. @mkdir $(LIST_DIR)
  115. # Test HEX files (one application build for each test)
  116. $(PROJ_S19S): %.s19: $(PROJECT).elf
  117. @echo
  118. @echo Building $@
  119. @$(HEX) $(OUT_DIR)/$(notdir $<) $(OUT_DIR)/$@ --srec --silent
  120. $(PROJ_IHEX): %.hex: $(PROJECT).elf
  121. @echo Building $@
  122. @$(HEX) $(OUT_DIR)/$(notdir $<) $(OUT_DIR)/$@ --ihex --silent
  123. # Test ELF files (one application build for each test)
  124. $(PROJ_ELFS): %.elf: $(PERIPH_OBJECTS) $(APP_OBJECTS)
  125. @echo
  126. @echo Linking $@
  127. @$(LINK) $(OBJ_DIR)/*.o $(LINKFLAGS) -o $(OUT_DIR)/$@
  128. # All C objects builder
  129. $(ALL_OBJECTS): %.o: %.c
  130. @echo
  131. @echo Compiling $@
  132. @$(CC) $< $(CFLAGS) $(INCLUDES) -o $(OBJ_DIR)
  133. # Clean
  134. clean:
  135. rm -f *.o *.elf *.map *.hex *.bin *.lst *.stm8 *.s19 *.out *.s *.lst
  136. rm -rf $(LIST_DIR)
  137. rm -rf $(OBJ_DIR)
  138. rm -rf $(OUT_DIR)
  139. # Flash
  140. flash:
  141. @$(FLASHTOOL) $(FLASHOPT) -FileProg=$(OUT_DIR)\\$(PROJ_HEX)