Makefile 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. BOARD ?= icebreaker
  2. CROSS ?= riscv-none-embed-
  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 -Wextra -Wno-unused-parameter -Os -march=rv32i -mabi=ilp32 -ffreestanding -flto -nostartfiles -fomit-frame-pointer -Wl,--gc-section --specs=nano.specs -D$(BOARD_DEFINE) -I.
  9. # Common / Shared
  10. COMMON_PATH=../../riscv_usb/fw/
  11. CFLAGS += -I$(COMMON_PATH)
  12. HEADERS_common=$(addprefix $(COMMON_PATH), \
  13. console.h \
  14. led.h \
  15. mini-printf.h \
  16. spi.h \
  17. utils.h \
  18. )
  19. SOURCES_common=$(addprefix $(COMMON_PATH), \
  20. start.S \
  21. console.c \
  22. led.c \
  23. mini-printf.c \
  24. spi.c \
  25. utils.c \
  26. )
  27. # USB
  28. NO2USB_FW_VERSION=0
  29. include ../../../cores/no2usb/fw/fw.mk
  30. CFLAGS += $(INC_no2usb)
  31. SOURCES_common += $(SOURCES_no2usb)
  32. HEADERS_common += $(HEADERS_no2usb)
  33. # Local
  34. HEADERS_app=\
  35. config.h \
  36. audio.h \
  37. usb_str_app.gen.h \
  38. $(NULL)
  39. SOURCES_app=\
  40. audio.c \
  41. fw_app.c \
  42. usb_desc_app.c \
  43. $(NULL)
  44. all: boot.hex fw_app.bin
  45. boot.elf: $(COMMON_PATH)/lnk-boot.lds $(COMMON_PATH)/boot.S
  46. $(CC) $(CFLAGS) -Wl,-Bstatic,-T,$(COMMON_PATH)/lnk-boot.lds,--strip-debug -DFLASH_APP_ADDR=0x000a0000 -o $@ $(COMMON_PATH)/boot.S
  47. fw_app.elf: $(COMMON_PATH)/lnk-app.lds $(HEADERS_app) $(SOURCES_app) $(HEADERS_common) $(SOURCES_common)
  48. $(CC) $(CFLAGS) -Wl,-Bstatic,-T,$(COMMON_PATH)/lnk-app.lds,--strip-debug -o $@ $(SOURCES_common) $(SOURCES_app)
  49. %.hex: %.bin
  50. $(COMMON_PATH)/bin2hex.py $< $@
  51. %.bin: %.elf
  52. $(OBJCOPY) -O binary $< $@
  53. prog: fw_app.bin
  54. $(ICEPROG) -o 640k $<
  55. dfuprog: fw_app.bin
  56. ifeq ($(DFU_SERIAL),)
  57. $(DFU_UTIL) -R -a 1 -D $<
  58. else
  59. $(DFU_UTIL) -R -S $(DFU_SERIAL) -a 1 -D $<
  60. endif
  61. clean:
  62. rm -f *.bin *.hex *.elf *.o *.gen.h
  63. .PHONY: prog_app clean