Rev 78 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 78 | Rev 80 | ||
---|---|---|---|
Line 21... | Line 21... | ||
21 | ###################################### |
21 | ###################################### |
22 | # debug build? |
22 | # debug build? |
23 | DEBUG = 1 |
23 | DEBUG = 1 |
24 | # optimization |
24 | # optimization |
25 | OPT = -Og |
25 | OPT = -Og |
- | 26 | # semihosting |
|
- | 27 | SEMIHOSTING = yes |
|
- | 28 | ||
26 | 29 | ||
27 | 30 | ||
28 | ####################################### |
31 | ####################################### |
29 | # paths |
32 | # paths |
30 | ####################################### |
33 | ####################################### |
Line 56... | Line 59... | ||
56 | Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_tim_ex.c \ |
59 | Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_tim_ex.c \ |
57 | Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_uart.c \ |
60 | Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_uart.c \ |
58 | Src/system_stm32l1xx.c \ |
61 | Src/system_stm32l1xx.c \ |
59 | Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_i2c.c \ |
62 | Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_i2c.c \ |
60 | Src/sysmem.c \ |
63 | Src/sysmem.c \ |
61 | Src/syscalls.c |
64 | # Src/syscalls.c |
62 | 65 | ||
63 | # ASM sources |
66 | # ASM sources |
64 | ASM_SOURCES = \ |
67 | ASM_SOURCES = \ |
65 | startup_stm32l152xe.s |
68 | startup_stm32l152xe.s |
66 | 69 | ||
Line 113... | Line 116... | ||
113 | # C defines |
116 | # C defines |
114 | C_DEFS = \ |
117 | C_DEFS = \ |
115 | -DUSE_HAL_DRIVER \ |
118 | -DUSE_HAL_DRIVER \ |
116 | -DSTM32L152xE |
119 | -DSTM32L152xE |
117 | 120 | ||
- | 121 | ifdef $(SEMIHOSTING) |
|
- | 122 | C_DEFS += -DSEMIHOSTING |
|
- | 123 | endif |
|
118 | 124 | ||
119 | # AS includes |
125 | # AS includes |
120 | AS_INCLUDES = |
126 | AS_INCLUDES = |
121 | 127 | ||
122 | # C includes |
128 | # C includes |
Line 189... | Line 195... | ||
189 | # LDFLAGS |
195 | # LDFLAGS |
190 | ####################################### |
196 | ####################################### |
191 | # link script |
197 | # link script |
192 | LDSCRIPT = STM32L152RETx_FLASH.ld |
198 | LDSCRIPT = STM32L152RETx_FLASH.ld |
193 | 199 | ||
194 | # libraries |
- | |
195 | LIBS = -lc -lm -lnosys |
200 | LIBS = -lc -lm |
196 | LIBDIR = |
201 | LIBDIR = |
197 | LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections |
202 | LDFLAGS = $(MCU) -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections |
- | 203 | ||
- | 204 | # libraries and specs settings |
|
- | 205 | # use -lnosys when not semihosting -lrdimon when semihosting |
|
- | 206 | # use nano.specs when not semihosting -specs=rdimon.specs |
|
- | 207 | ifdef $(SEMIHOSTING) |
|
- | 208 | LDFLAGS += -specs=rdimon.specs |
|
- | 209 | LIBS += -lrdimon |
|
- | 210 | else |
|
- | 211 | LDFLAGS += -specs=nano.specs |
|
- | 212 | LIBS += -lnosys |
|
- | 213 | endif |
|
- | 214 | ||
- | 215 | ||
198 | 216 | ||
199 | # default action: build all |
217 | # default action: build all |
200 | all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin |
218 | all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin |
201 | 219 | ||
202 | 220 | ||
Line 223... | Line 241... | ||
223 | $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ |
241 | $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ |
224 | 242 | ||
225 | $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) |
243 | $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) |
226 | $(AS) -c $(CFLAGS) $< -o $@ |
244 | $(AS) -c $(CFLAGS) $< -o $@ |
227 | 245 | ||
228 | $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile |
246 | $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile $(LDSCRIPT) |
229 | $(CC) $(OBJECTS) $(LDFLAGS) -o $@ |
247 | $(CC) $(OBJECTS) $(LDFLAGS) -o $@ |
230 | $(SZ) $@ |
248 | $(SZ) $@ |
231 | 249 | ||
232 | $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR) |
250 | $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR) |
233 | $(HEX) $< $@ |
251 | $(HEX) $< $@ |
Line 240... | Line 258... | ||
240 | 258 | ||
241 | ####################################### |
259 | ####################################### |
242 | # clean up |
260 | # clean up |
243 | ####################################### |
261 | ####################################### |
244 | clean: |
262 | clean: |
245 | -rm -fR $(BUILD_DIR) |
263 | -rd -r $(BUILD_DIR) |
246 | 264 | ||
247 | ####################################### |
265 | ####################################### |
248 | # dependencies |
266 | # dependencies |
249 | ####################################### |
267 | ####################################### |
250 | -include $(wildcard $(BUILD_DIR)/*.d) |
268 | -include $(wildcard $(BUILD_DIR)/*.d) |