Makefile 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # This file is Copyright (c) 2023 Victor Suarez Rovere <suarezvictor@gmail.com>
  2. # SPDX-License-Identifier: AGPL-3.0-only
  3. #BOARD?=digilent_arty
  4. BOARD?=lambdaconcept_ecpix5
  5. #LATTICETOOLCHAIN=--toolchain diamond
  6. LATTICETOOLCHAIN=--toolchain trellis --nextpnr-seed 0 --nextpnr-timingstrict
  7. SDRAM_BUS_BITS?=32
  8. #SERIAL_PORT?=/dev/ttyUSB0 #for arty
  9. SERIAL_PORT?=/dev/ttyUSB2 #for ecpix5
  10. #AMDTOOLCHAIN?=--toolchain=yosys+nextpnr #FIXME: some glitches
  11. CPU_TYPE?=--cpu-type=vexriscv #only supports vexriscv
  12. SYS_CLK?=--sys-clk-freq 75e6 #ECP5 pass at 96 MHz if just rectangles, but glitches remains
  13. include Makefile.common
  14. include $(BUILD_DIR)/software/include/generated/variables.mak
  15. include $(LITEX_ROOT)/litex/soc/software/common.mak
  16. #INC=-I$(CFLEXROOT)/include #not needed anymore (files incorporated to the project)
  17. CCDEFS=-DSDRAM_BUS_BITS=$(SDRAM_BUS_BITS)
  18. CFLAGS+=$(CCDEFS) $(INC) -Wno-missing-prototypes
  19. CXXFLAGS+=$(CCDEFS) $(INC)
  20. SOCARGS=--pixel-bus-width=$(SDRAM_BUS_BITS) --timer-uptime $(CPU_TYPE)
  21. #FIXME: try crt0 provided by LiteX
  22. %.o: %.S
  23. $(assemble)
  24. %.o: %.c
  25. $(compile)
  26. %.o: %.cpp
  27. $(compilexx)
  28. %.bin: %.elf
  29. $(OBJCOPY) -O binary $< $@
  30. chmod -x $@
  31. prerequisites: LITEX-CONTRIBUTORS
  32. ./build/digilent_arty/software/include/generated/variables.mak: ./digilent_arty.py
  33. $(PYTHON) ./digilent_arty.py $(SOCARGS) --no-compile-gateware
  34. ./build/digilent_arty/gateware/digilent_arty.bit: ./digilent_arty.py c2v
  35. $(PYTHON) ./digilent_arty.py $(SOCARGS) $(AMDTOOLCHAIN)
  36. ./build/lambdaconcept_ecpix5/software/include/generated/variables.mak: ./lambdaconcept_ecpix5.py
  37. $(PYTHON) ./lambdaconcept_ecpix5.py $(SOCARGS) $(SYS_CLK) --no-compile-gateware
  38. ./build/lambdaconcept_ecpix5/gateware/lambdaconcept_ecpix5.bit: ./lambdaconcept_ecpix5.py c2v
  39. $(PYTHON) ./lambdaconcept_ecpix5.py $(SOCARGS) $(SYS_CLK) $(LATTICETOOLCHAIN)
  40. everything: run $(BOARD)
  41. .PHONY: run
  42. run: sim_linux
  43. ./sim_linux
  44. sim_linux: prerequisites sim_linux.c drawing_test.c accel_cores.c sim_fb.c sw_cores.cpp
  45. g++ -O3 -m32 -ggdb $(CCDEFS) $(INC) -o sw_cores.o -c sw_cores.cpp
  46. gcc -O3 -m32 -ggdb $(CCDEFS) $(INC) `sdl2-config --cflags` sim_linux.c sw_cores.o -o $@ `sdl2-config --libs`
  47. rm sw_cores.o
  48. .PHONY: firmware
  49. firmware: main.bin
  50. main.elf: prerequisites main.o accel_cores.o sw_cores.o crt0.o linker.ld
  51. $(CC) crt0.o main.o accel_cores.o sw_cores.o $(LDFLAGS) -T linker.ld -Xlinker -Map=$@.map -N -o $@ \
  52. $(PACKAGES:%=-L$(BUILD_DIR)/software/%) $(LIBS:lib%=-l%)
  53. .PHONY: digilent_arty
  54. digilent_arty: $(BUILD_DIR)/gateware/digilent_arty.bit
  55. openFPGALoader -b arty $(BUILD_DIR)/gateware/digilent_arty.bit
  56. .PHONY: lambdaconcept_ecpix5
  57. lambdaconcept_ecpix5: $(BUILD_DIR)/gateware/lambdaconcept_ecpix5.bit
  58. openFPGALoader -b ecpix5 --cable ft4232 --freq 30e6 $(BUILD_DIR)/gateware/lambdaconcept_ecpix5.bit
  59. #this is only for diamond toolchain:
  60. #PYTHONPATH=/media/vsuarez/elocaldata/SCRATCH/prjtrellis/libtrellis $(PYTHON) ecp5_patch_idcode.py
  61. #openFPGALoader -b ecpix5 --cable ft4232 --freq 30e6 repack.bit #$(BUILD_DIR)/gateware/lambdaconcept_ecpix5.bit
  62. .PHONY: upload
  63. upload: firmware $(BOARD)
  64. $(LITEX_ROOT)/litex/tools/litex_term.py $(SERIAL_PORT) --kernel main.bin
  65. .PHONY: clean
  66. clean:
  67. $(RM) -R build restore
  68. $(RM) *.o *.d *.elf *.elf.map *.bin ellipse_fill32.v rectangle_fill32.v *.v.* sim_linux backup.tar.gz *.orig
  69. LITEX-CONTRIBUTORS:
  70. wget -O $@ https://raw.githubusercontent.com/enjoy-digital/litex/master/CONTRIBUTORS