diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 88 |
1 files changed, 81 insertions, 7 deletions
@@ -5,6 +5,36 @@ srcdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) srcdir := $(srcdir:/=) wrkdir := $(CURDIR)/work +############################################################# +# Prints help message +############################################################# + +.PHONY: help +help : + @echo " SiFive Freedom E Software Development Kit " + @echo " Makefile targets:" + @echo "" + @echo " tools:" + @echo " Install compilation & debugging tools" + @echo "" + @echo " fpga [BOOTROM=demo]:" + @echo " Rebuild the image (including Boot SW) to" + @echo " reprogram the FPGA. " + @echo "" + @echo " software [PROGRAM=demo_gpio]:" + @echo " Build a software program to load with the" + @echo " debugger." + @echo "" + @echo " run_debug [PROGRAM=demo_gpio]:" + @echo " Launch the debugging tools to load or" + @echo " debug running programs." + @echo "" + @echo " For more information, visit dev.sifive.com" + +############################################################# +# This section is for tool installation +############################################################# + toolchain_srcdir := $(srcdir)/riscv-gnu-toolchain toolchain32_wrkdir := $(wrkdir)/riscv32-gnu-toolchain toolchain64_wrkdir := $(wrkdir)/riscv64-gnu-toolchain @@ -23,10 +53,11 @@ target32 := riscv32-unknown-linux-gnu .PHONY: all -all: $(hex) +all: tools @echo All done. tools: tools64 tools32 openocd gdb + @echo All Tools Installed tools64: $(toolchain_dest)/bin/$(target64)-gcc tools32: $(toolchain_dest)/bin/$(target32)-gcc @@ -43,7 +74,6 @@ $(toolchain_dest)/bin/$(target32)-gcc: $(toolchain_srcdir) cd $(toolchain32_wrkdir); $(toolchain_srcdir)/configure --prefix=$(toolchain_dest) --with-arch=RV32IMA $(MAKE) -C $(toolchain32_wrkdir) - $(openocd_dest)/bin/openocd: $(openocd_srcdir) mkdir -p $(openocd_wrkdir) cd $(openocd_srcdir); \ @@ -60,11 +90,55 @@ $(gdb_dest)/bin/$(target64)-gdb : $(gdb_srcdir) $(MAKE) -C $(gdb_wrkdir) install +.PHONY: uninstall +uninstall: + rm -rf -- $(toolchain_dest) + +############################################################# +# This Section is for MCS File Generation ( +############################################################# + +BOOTROM ?= demo +BOOTROM_DIR = $(srcdir)/bootrom/$(BOOTROM)/ + +.PHONY: +fpga: + cd $(BOOTROM_DIR);\ + make mcs + +fpga_clean: + cd $(BOOTROM_DIR);\ + make clean + +############################################################# +# This Section is for Software (non-boot) compilation +############################################################# + +PROGRAM ?= demo_gpio +PROGRAM_DIR = $(srcdir)/software/$(PROGRAM) + +.PHONY: software +software: + cd $(PROGRAM_DIR);\ + make + +software_clean: + cd $(PROGRAM_DIR);\ + make clean + +############################################################# +# This Section is for launching the debugger +############################################################# +OPENOCD = $(toolchain_dest)/bin/openocd +OPENOCDARGS += -f $(srcdir)/riscv-tests/debug/targets/m2gl_m2s/openocd.cfg + +GDB = $(toolchain_dest)/bin/riscv64-unknown-elf-gdb +GDBARGS += -ex "target extended-remote localhost:3333" + +run_debug: + $(OPENOCD) $(OPENOCDARGS) & + $(GDB) $(PROGRAM_DIR)/$(PROGRAM) $(GDBARGS) + .PHONY: clean clean: rm -rf -- $(wrkdir) - - -.PHONY: superclean -superclean: - rm -rf -- $(toolchain_dest) |