Makefile 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. cdc-dlm.h \
  38. mc97.h \
  39. usb_str_app.gen.h \
  40. $(NULL)
  41. SOURCES_app=\
  42. audio.c \
  43. cdc-dlm.c \
  44. mc97.c \
  45. fw_app.c \
  46. usb_desc_app.c \
  47. $(NULL)
  48. all: boot.hex fw_app.bin
  49. boot.elf: $(COMMON_PATH)/lnk-boot.lds $(COMMON_PATH)/boot.S
  50. $(CC) $(CFLAGS) -Wl,-Bstatic,-T,$(COMMON_PATH)/lnk-boot.lds,--strip-debug -DFLASH_APP_ADDR=0x000a0000 -o $@ $(COMMON_PATH)/boot.S
  51. fw_app.elf: $(COMMON_PATH)/lnk-app.lds $(HEADERS_app) $(SOURCES_app) $(HEADERS_common) $(SOURCES_common)
  52. $(CC) $(CFLAGS) -Wl,-Bstatic,-T,$(COMMON_PATH)/lnk-app.lds,--strip-debug -o $@ $(SOURCES_common) $(SOURCES_app)
  53. %.hex: %.bin
  54. $(COMMON_PATH)/bin2hex.py $< $@
  55. %.bin: %.elf
  56. $(OBJCOPY) -O binary $< $@
  57. prog: fw_app.bin
  58. $(ICEPROG) -o 640k $<
  59. dfuprog: fw_app.bin
  60. ifeq ($(DFU_SERIAL),)
  61. $(DFU_UTIL) -R -a 1 -D $<
  62. else
  63. $(DFU_UTIL) -R -S $(DFU_SERIAL) -a 1 -D $<
  64. endif
  65. clean:
  66. rm -f *.bin *.hex *.elf *.o *.gen.h
  67. .PHONY: prog_app clean