Makefile 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. export FW_MAJOR := 1
  2. export FW_MINOR := 2
  3. PROJ = greaseweazle-firmware
  4. VER := $(FW_MAJOR).$(FW_MINOR)
  5. PYTHON := python3
  6. export ROOT := $(CURDIR)
  7. .PHONY: FORCE
  8. .DEFAULT_GOAL := all
  9. prod-%: FORCE
  10. $(MAKE) target mcu=$* target=bootloader level=prod
  11. $(MAKE) target mcu=$* target=greaseweazle level=prod
  12. debug-%: FORCE
  13. $(MAKE) target mcu=$* target=bootloader level=debug
  14. $(MAKE) target mcu=$* target=greaseweazle level=debug
  15. all-%: FORCE prod-% debug-% ;
  16. all: FORCE all-stm32f1 all-stm32f7 all-at32f4 ;
  17. $(MAKE) target mcu=stm32f1 target=blinky level=debug
  18. clean: FORCE
  19. rm -rf out
  20. out: FORCE
  21. +mkdir -p out/$(mcu)/$(level)/$(target)
  22. target: FORCE out
  23. $(MAKE) -C out/$(mcu)/$(level)/$(target) -f $(ROOT)/Rules.mk target.bin target.hex target.upd $(mcu)=y $(level)=y $(target)=y
  24. dist: level := prod
  25. dist: t := $(ROOT)/out/$(PROJ)-$(VER)
  26. dist: FORCE all
  27. rm -rf out/$(PROJ)-*
  28. mkdir -p $(t)/hex/alt
  29. cd out/stm32f1/$(level)/greaseweazle; \
  30. cp -a target.hex $(t)/hex/$(PROJ)-f1-$(VER).hex; \
  31. cp -a ../bootloader/target.upd $(t)/$(PROJ)-$(VER).upd; \
  32. $(PYTHON) $(ROOT)/scripts/mk_update.py cat $(t)/$(PROJ)-$(VER).upd \
  33. target.upd
  34. cd out/stm32f1/debug/blinky; \
  35. cp -a target.hex $(t)/hex/alt/blinky-test-f1-$(VER).hex
  36. cd out/stm32f7/$(level)/greaseweazle; \
  37. cp -a target.hex $(t)/hex/$(PROJ)-f7-$(VER).hex; \
  38. $(PYTHON) $(ROOT)/scripts/mk_update.py cat $(t)/$(PROJ)-$(VER).upd \
  39. ../bootloader/target.upd target.upd
  40. cd out/at32f4/$(level)/greaseweazle; \
  41. cp -a target.hex $(t)/hex/$(PROJ)-at32f4-$(VER).hex; \
  42. $(PYTHON) $(ROOT)/scripts/mk_update.py cat $(t)/$(PROJ)-$(VER).upd \
  43. ../bootloader/target.upd target.upd
  44. cp -a COPYING $(t)/
  45. cp -a README $(t)/
  46. cp -a RELEASE_NOTES $(t)/
  47. cd out && zip -r $(PROJ)-$(VER).zip $(PROJ)-$(VER)
  48. BAUD=115200
  49. DEV=/dev/ttyUSB0
  50. SUDO=sudo
  51. STM32FLASH=stm32flash
  52. ocd: FORCE all
  53. $(PYTHON) scripts/telnet.py localhost 4444 \
  54. "reset init ; flash write_image erase `pwd`/$(target)/$(target).hex ; reset"
  55. f1_ocd: FORCE all
  56. $(PYTHON) scripts/openocd/flash.py `pwd`/$(target)/$(target).hex
  57. flash: FORCE all
  58. $(SUDO) $(STM32FLASH) -b $(BAUD) -w $(target)/$(target).hex $(DEV)
  59. start: FORCE
  60. $(SUDO) $(STM32FLASH) -b $(BAUD) -g 0 $(DEV)
  61. serial: FORCE
  62. $(SUDO) miniterm.py $(DEV) 3000000