Makefile 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 -Os -march=rv32i -mabi=ilp32 -ffreestanding -flto -nostartfiles -fomit-frame-pointer -Wl,--gc-section --specs=nano.specs -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. $(HEADERS_no2usb)
  20. SOURCES_common=\
  21. start.S \
  22. console.c \
  23. led.c \
  24. mini-printf.c \
  25. spi.c \
  26. utils.c \
  27. $(SOURCES_no2usb)
  28. HEADERS_app=\
  29. usb_str_app.gen.h \
  30. $(NULL)
  31. SOURCES_app=\
  32. fw_app.c \
  33. usb_desc_app.c \
  34. $(NULL)
  35. all: boot.hex fw_app.bin
  36. boot.elf: lnk-boot.lds boot.S
  37. $(CC) $(CFLAGS) -Wl,-Bstatic,-T,lnk-boot.lds,--strip-debug -DFLASH_APP_ADDR=0x000a0000 -o $@ boot.S
  38. fw_app.elf: lnk-app.lds $(HEADERS_app) $(SOURCES_app) $(HEADERS_common) $(SOURCES_common)
  39. $(CC) $(CFLAGS) -Wl,-Bstatic,-T,lnk-app.lds,--strip-debug -o $@ $(SOURCES_common) $(SOURCES_app)
  40. %.hex: %.bin
  41. ./bin2hex.py $< $@
  42. %.bin: %.elf
  43. $(OBJCOPY) -O binary $< $@
  44. prog: fw_app.bin
  45. $(ICEPROG) -o 640k $<
  46. dfuprog: fw_app.bin
  47. ifeq ($(DFU_SERIAL),)
  48. $(DFU_UTIL) -R -a 1 -D $<
  49. else
  50. $(DFU_UTIL) -R -S $(DFU_SERIAL) -a 1 -D $<
  51. endif
  52. clean:
  53. rm -f *.bin *.hex *.elf *.o *.gen.h
  54. .PHONY: prog_app clean