Makefile 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. BOARD ?= icebreaker
  2. CROSS ?= riscv-none-elf-
  3. CC = $(CROSS)gcc
  4. OBJCOPY = $(CROSS)objcopy
  5. ICEPROG = iceprog
  6. DFU_UTIL = dfu-util
  7. BOARD_DEFINE=BOARD_$(shell echo $(BOARD) | tr a-z\- A-Z_)
  8. CFLAGS=-Wall -Os -march=rv32i -mabi=ilp32 -ffreestanding -flto -nostartfiles -fomit-frame-pointer -Wl,--gc-section -D$(BOARD_DEFINE) -I.
  9. NO2USB_FW_VERSION=0
  10. include ../../../cores/no2usb/fw/fw.mk
  11. CFLAGS += $(INC_no2usb)
  12. HEADERS_common=\
  13. config.h \
  14. console.h \
  15. led.h \
  16. mini-printf.h \
  17. spi.h \
  18. utils.h \
  19. registers.h \
  20. $(HEADERS_no2usb)
  21. SOURCES_common=\
  22. start.S \
  23. console.c \
  24. led.c \
  25. mini-printf.c \
  26. spi.c \
  27. utils.c \
  28. registers.c \
  29. $(SOURCES_no2usb)
  30. HEADERS_app=\
  31. usb_str_app.gen.h \
  32. $(NULL)
  33. SOURCES_app=\
  34. fw_app.c \
  35. usb_desc_app.c \
  36. $(NULL)
  37. all: boot.hex fw_app.bin
  38. boot.elf: lnk-boot.lds boot.S
  39. $(CC) $(CFLAGS) -Wl,-Bstatic,-T,lnk-boot.lds,--strip-debug -DFLASH_APP_ADDR=0x000a0000 -o $@ boot.S
  40. fw_app.elf: lnk-app.lds $(HEADERS_app) $(SOURCES_app) $(HEADERS_common) $(SOURCES_common)
  41. $(CC) $(CFLAGS) -Wl,-Bstatic,-T,lnk-app.lds,--strip-debug -o $@ $(SOURCES_common) $(SOURCES_app)
  42. %.hex: %.bin
  43. ./bin2hex.py $< $@
  44. %.bin: %.elf
  45. $(OBJCOPY) -O binary $< $@
  46. prog: fw_app.bin
  47. $(ICEPROG) -o 640k $<
  48. dfuprog: fw_app.bin
  49. ifeq ($(DFU_SERIAL),)
  50. $(DFU_UTIL) -R -a 1 -D $<
  51. else
  52. $(DFU_UTIL) -R -S $(DFU_SERIAL) -a 1 -D $<
  53. endif
  54. clean:
  55. rm -f *.bin *.hex *.elf *.o *.gen.h
  56. .PHONY: prog_app clean