Makefile 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. export FW_MAJOR := 1
  2. export FW_MINOR := 4
  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. T=out/$(target)/greaseweazle/target.hex
  53. ocd: FORCE all
  54. $(PYTHON) scripts/telnet.py localhost 4444 \
  55. "reset init ; flash write_image erase `pwd`/$(T) ; reset"
  56. f1_ocd: FORCE all
  57. $(PYTHON) scripts/openocd/flash.py `pwd`/$(T)
  58. flash: FORCE all
  59. $(SUDO) $(STM32FLASH) -b $(BAUD) -w $(T) $(DEV)
  60. start: FORCE
  61. $(SUDO) $(STM32FLASH) -b $(BAUD) -g 0 $(DEV)
  62. serial: FORCE
  63. $(SUDO) miniterm.py $(DEV) 3000000