jw-pkg/make/mcu-flash.mk
Jan Lindemann df6c1ef9a1 make, tmpl/tagged: Add basic microcontroller support
Add support for building the firmware of the Cortex M3 ST-NUCLEO-F103RB
development board with an STM32 microcontroller. This commit add some hooks,
notably support for tagged templates, but adds lots of crap, too, notably
makefiles and variables that should have different names and / or
functionality.

New makefiles are: Mcu-defs.mk  mcu-exe.mk  mcu-flash.mk  mcu-tags.mk
mcu-topdir.mk tagged-tmpl.mk, a new directory is tmpl/tagged.

Signed-off-by: Jan Lindemann <jan@janware.com>
2019-03-06 12:19:42 +00:00

27 lines
969 B
Makefile

.PHONY: flash-fetch flash-push flash-clean-fetch flash-clean-push
all:
flash-fetch: $(MCU_FLASH_FETCH_FILE_HEX)
clean: flash-clean-fetch
flash-clean-fetch:
rm -f $(MCU_FLASH_FETCH_FILE_BIN) $(MCU_FLASH_FETCH_FILE_HEX) *.tmp
flash-clean-push:
rm -f $(MCU_FLASH_PUSH_FILE_BIN) $(MCU_FLASH_PUSH_FILE_HEX) *.tmp
$(MCU_FLASH_FETCH_FILE_BIN):
$(MCU_OPENOCD) -c "init" -c "reset init" -c "flash read_bank $(MCU_FLASH_FETCH_BANK) $@.tmp $(MCU_FLASH_FETCH_OFFSET) $(MCU_FLASH_FETCH_SIZE)" -c "exit"
mv $@.tmp $@
%.hex: %.elf
$(MCU_OBJCOPY) -O ihex $< $@.tmp
mv $@.tmp $@
clean: flash-clean-hex
flash-clean-hex:
rm -rf $(MCU_FLASH_PUSH_FILE_HEX)
%.hex: %.bin
$(MCU_OBJCOPY) $(MCU_OBJCOPY_FETCH_OPTS) -I binary -O ihex $< $@.tmp
mv $@.tmp $@
flash-push:
# see http://openocd.org/doc/html/Flash-Programming.html
$(MCU_OPENOCD) -c "program $(MCU_FLASH_PUSH_FILE_HEX) verify reset exit $(MCU_FLASH_PUSH_OFFSET)"
%-flash-push:
MCU_FLASH_PUSH_FILE_HEX=$* make flash-push