common.mk 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. GPSIM_FLAGS = -L .
  2. GPSIM = gpsim
  3. GPASM_FLAGS = --debug-info
  4. GPASM = gpasm
  5. # Use ICSP port
  6. MINIPRO_FLAGS += -i
  7. MINIPRO = minipro
  8. %.hex: %.asm
  9. $(GPASM) $(GPASM_FLAGS) $^
  10. %.bin: %.hex
  11. srec_cat $^ --intel --crop 0x0 $(SIZE) --fill 0x00 0x0 $(SIZE) -o $@ --binary
  12. all: $(NAME).bin
  13. # Run in simulator
  14. run: $(NAME).hex
  15. $(GPSIM) $(GPSIM_FLAGS) -s $(NAME).cod $(NAME).hex
  16. # Program
  17. upload: $(NAME).bin $(NAME)-fuses.conf
  18. # Program memory
  19. $(MINIPRO) $(MINIPRO_FLAGS) -w $(NAME).bin
  20. # Config memory
  21. $(MINIPRO) $(MINIPRO_FLAGS) -e -c config -w $(NAME)-fuses.conf
  22. # Get the program
  23. download:
  24. # Program memory
  25. $(MINIPRO) $(MINIPRO_FLAGS) -r $(NAME).bin
  26. # Read out the config word from chip
  27. fuses.conf:
  28. $(MINIPRO) $(MINIPRO_FLAGS) -c config -r fuses.conf
  29. -grep 'conf_word = 0x0000' fuses.conf && rm fuses.conf
  30. # Replace config word with our one
  31. $(NAME)-fuses.conf: fuses.conf $(NAME).hex
  32. sed "s/\(conf_word = 0x..\).*/\1$$(srec_cat $(NAME).hex --intel --exclude 0x0 $(CONFIG) -offset -$(CONFIG) -o - --hex-dump |sed 's/.*: \(..\).*/\1/')/" <fuses.conf >$@
  33. # Chuck mess
  34. clean:
  35. rm -f *.cod *.hex *.lst *.bin *.conf