From 3da1e2e24fb713e87984bc18d7c1c4c44a97fa47 Mon Sep 17 00:00:00 2001 From: Nathaniel Graff Date: Fri, 8 Mar 2019 10:24:33 -0800 Subject: Support Debug/Release configurations - Puts shared flags in scripts/standalone and adds "build configurations" for debug and release which customize the build flags for specific purposes. - Documents CONFIGURATION in Sphinx docs and makefile help Signed-off-by: Nathaniel Graff --- Makefile | 46 +++++++++++++++++++++---------- debug.mk | 12 ++++++++ doc/sphinx/userguide/buildingcoreip.rst | 13 +++++---- doc/sphinx/userguide/buildingdevboard.rst | 17 ++++++------ doc/sphinx/userguide/standalone.rst | 2 +- release.mk | 7 +++++ scripts/libmetal.mk | 2 +- scripts/standalone.mk | 46 ++++++++++++++++++++++++++++--- 8 files changed, 110 insertions(+), 35 deletions(-) create mode 100644 debug.mk create mode 100644 release.mk diff --git a/Makefile b/Makefile index 355524e..319903a 100644 --- a/Makefile +++ b/Makefile @@ -64,31 +64,37 @@ help: @echo " SiFive Freedom E Software Development Kit " @echo " Makefile targets:" @echo "" - @echo " software [PROGRAM=$(PROGRAM) TARGET=$(TARGET)]:" - @echo " Build a software program to load with the" - @echo " debugger." + @echo " software [PROGRAM=$(PROGRAM)] [TARGET=$(TARGET)]" + @echo " [CONFIGURATION=$(CONFIGURATION)]:" + @echo " Builds the requested PROGRAM for the TARGET using the" + @echo " specified build CONFIGURATION." @echo "" - @echo " metal [TARGET=$(TARGET)]" - @echo " Build the Freedom Metal library for TARGET" + @echo " metal [TARGET=$(TARGET)] [CONFIGURATION=$(CONFIGURATION)]" + @echo " Builds the Freedom Metal library for TARGET." @echo "" - @echo " clean [PROGRAM=$(PROGRAM) TARGET=$(TARGET)]:" - @echo " Clean compiled objects for a specified " + @echo " clean [PROGRAM=$(PROGRAM)] [TARGET=$(TARGET)]" + @echo " [CONFIGURATION=$(CONFIGURATION)]:" + @echo " Cleans compiled objects for a specified " @echo " software program." @echo "" - @echo " upload [PROGRAM=$(PROGRAM) TARGET=$(TARGET)]:" - @echo " Launch OpenOCD to flash your program to the" - @echo " on-board Flash." + @echo " upload [PROGRAM=$(PROGRAM)] [TARGET=$(TARGET)]" + @echo " [CONFIGURATION=$(CONFIGURATION)]:" + @echo " For board and FPGA TARGETs, uploads the program to the" + @echo " on-board flash." @echo "" - @echo " debug [PROGRAM=$(PROGRAM) TARGET=$(TARGET)]:" - @echo " Launch OpenOCD and attach GDB to the running program." + @echo " debug [PROGRAM=$(PROGRAM)] [TARGET=$(TARGET)]" + @echo " [CONFIGURATION=$(CONFIGURATION)]:" + @echo " For board and FPGA TARGETs, attaches GDB to the" + @echo " running program." @echo "" @echo " standalone STANDALONE_DEST=/path/to/desired/location" @echo " [INCLUDE_METAL_SOURCES=1] [PROGRAM=$(PROGRAM)]" - @echo " [TARGET=$(TARGET)]:" - @echo " Export a program for a single target into a standalone" + @echo " [TARGET=$(TARGET)] [CONFIGURATION=$(CONFIGURATION)]:" + @echo " Exports a program for a single target into a standalone" @echo " project directory at STANDALONE_DEST." @echo "" - @echo " For more information, read the accompanying README.md" + @echo " For more information, view the Freedom E SDK Documentation at" + @echo " https://sifive.github.io/freedom-e-sdk-docs/index.html" .PHONY: clean clean: @@ -160,6 +166,8 @@ standalone: \ $(STANDALONE_DEST)/src \ $(SRC_DIR) \ freedom-metal \ + debug.mk \ + release.mk \ scripts/standalone.mk \ scripts/libmetal.mk cp -r $(addprefix $(BSP_DIR)/,$(filter-out build,$(shell ls $(BSP_DIR)))) $ $> $> $ $> $ Date: Tue, 12 Mar 2019 09:58:13 -0700 Subject: ELF output has .elf extension Signed-off-by: Nathaniel Graff --- Makefile | 2 +- scripts/standalone.mk | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 319903a..ee3b396 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ PROGRAM_ROOT ?= $(abspath .) SRC_DIR = $(PROGRAM_ROOT)/software/$(PROGRAM) -PROGRAM_ELF = $(SRC_DIR)/$(PROGRAM) +PROGRAM_ELF = $(SRC_DIR)/$(PROGRAM).elf PROGRAM_HEX = $(SRC_DIR)/$(PROGRAM).hex ############################################################# diff --git a/scripts/standalone.mk b/scripts/standalone.mk index 6fa3da4..ac5635f 100644 --- a/scripts/standalone.mk +++ b/scripts/standalone.mk @@ -112,7 +112,7 @@ include $(CONFIGURATION).mk # Software ############################################################# -PROGRAM_ELF ?= $(SRC_DIR)/$(PROGRAM) +PROGRAM_ELF ?= $(SRC_DIR)/$(PROGRAM).elf PROGRAM_HEX ?= $(SRC_DIR)/$(PROGRAM).hex .PHONY: all @@ -135,7 +135,7 @@ $(PROGRAM_ELF): \ $(BSP_DIR)/install/lib/libmetal.a \ $(BSP_DIR)/install/lib/libmetal-gloss.a \ $(BSP_DIR)/metal.lds - $(MAKE) -C $(dir $@) $(notdir $@) \ + $(MAKE) -C $(dir $@) $(basename $(notdir $@)) \ AR=$(RISCV_AR) \ CC=$(RISCV_GCC) \ CXX=$(RISCV_GXX) \ -- cgit v1.2.3 From 1b72ca73835d6064b467a126a392f4539fa2f10a Mon Sep 17 00:00:00 2001 From: Nathaniel Graff Date: Tue, 12 Mar 2019 10:09:10 -0700 Subject: Build metal libs into install/lib/CONFIGURATION Removes the INCLUDE_METAL_SOURCES option. If we want to be able to support multiple build configurations for standalone projects, the Metal library must be rebuilt to take into account those options. An alternative is to put back the prebuilt library option and just remove the configuration option from standalone projects without the Metal library sources. Signed-off-by: Nathaniel Graff --- Makefile | 27 +-------------------------- doc/sphinx/userguide/standalone.rst | 7 +------ scripts/libmetal.mk | 23 ++++++++++++++--------- scripts/standalone.mk | 4 ++-- 4 files changed, 18 insertions(+), 43 deletions(-) diff --git a/Makefile b/Makefile index ee3b396..96e8fd5 100644 --- a/Makefile +++ b/Makefile @@ -88,8 +88,7 @@ help: @echo " running program." @echo "" @echo " standalone STANDALONE_DEST=/path/to/desired/location" - @echo " [INCLUDE_METAL_SOURCES=1] [PROGRAM=$(PROGRAM)]" - @echo " [TARGET=$(TARGET)] [CONFIGURATION=$(CONFIGURATION)]:" + @echo " [PROGRAM=$(PROGRAM)] [TARGET=$(TARGET)]:" @echo " Exports a program for a single target into a standalone" @echo " project directory at STANDALONE_DEST." @echo "" @@ -158,8 +157,6 @@ $(STANDALONE_DEST): $(STANDALONE_DEST)/%: mkdir -p $@ -ifneq ($(INCLUDE_METAL_SOURCES),) - standalone: \ $(STANDALONE_DEST) \ $(STANDALONE_DEST)/bsp \ @@ -186,28 +183,6 @@ standalone: \ cat scripts/standalone.mk >> $> $ $> $ $@ -$(BSP_DIR)/install/lib/libriscv%.a: $(BSP_DIR)/install/stamp ;@: +$(METAL_LIB_DIR)/libriscv%.a: $(METAL_LIB_DIR)/stamp ;@: -$(BSP_DIR)/install/lib/libmetal.a: $(BSP_DIR)/install/lib/libriscv__mmachine__$(TARGET).a +$(METAL_LIB_DIR)/libmetal.a: $(METAL_LIB_DIR)/libriscv__mmachine__$(TARGET).a cp $< $@ -$(BSP_DIR)/install/lib/libmetal-gloss.a: $(BSP_DIR)/install/lib/libriscv__menv__metal.a +$(METAL_LIB_DIR)/libmetal-gloss.a: $(METAL_LIB_DIR)/libriscv__menv__metal.a cp $< $@ .PHONY: clean-metal clean-metal: - rm -rf $(BSP_DIR)/install + rm -rf $(METAL_PREFIX) rm -rf $(BSP_DIR)/build clean: clean-metal diff --git a/scripts/standalone.mk b/scripts/standalone.mk index ac5635f..73b9776 100644 --- a/scripts/standalone.mk +++ b/scripts/standalone.mk @@ -132,8 +132,8 @@ PROGRAM_SRCS = $(wildcard $(SRC_DIR)/*.c) $(wildcard $(SRC_DIR)/*.h) $(wildcard $(PROGRAM_ELF): \ $(PROGRAM_SRCS) \ - $(BSP_DIR)/install/lib/libmetal.a \ - $(BSP_DIR)/install/lib/libmetal-gloss.a \ + $(BSP_DIR)/install/lib/$(CONFIGURATION)/libmetal.a \ + $(BSP_DIR)/install/lib/$(CONFIGURATION)/libmetal-gloss.a \ $(BSP_DIR)/metal.lds $(MAKE) -C $(dir $@) $(basename $(notdir $@)) \ AR=$(RISCV_AR) \ -- cgit v1.2.3 From e106e9e51e8c8e9aca053f1cdc3d49c85df98212 Mon Sep 17 00:00:00 2001 From: Nathaniel Graff Date: Tue, 12 Mar 2019 10:22:46 -0700 Subject: Build program into SRC_DIR/CONFIGURATION/PROGRAM Signed-off-by: Nathaniel Graff --- Makefile | 4 ++-- scripts/standalone.mk | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 96e8fd5..3853c53 100644 --- a/Makefile +++ b/Makefile @@ -25,8 +25,8 @@ PROGRAM_ROOT ?= $(abspath .) SRC_DIR = $(PROGRAM_ROOT)/software/$(PROGRAM) -PROGRAM_ELF = $(SRC_DIR)/$(PROGRAM).elf -PROGRAM_HEX = $(SRC_DIR)/$(PROGRAM).hex +PROGRAM_ELF = $(SRC_DIR)/$(CONFIGURATION)/$(PROGRAM).elf +PROGRAM_HEX = $(SRC_DIR)/$(CONFIGURATION)/$(PROGRAM).hex ############################################################# # BSP Loading diff --git a/scripts/standalone.mk b/scripts/standalone.mk index 73b9776..17fec17 100644 --- a/scripts/standalone.mk +++ b/scripts/standalone.mk @@ -112,8 +112,8 @@ include $(CONFIGURATION).mk # Software ############################################################# -PROGRAM_ELF ?= $(SRC_DIR)/$(PROGRAM).elf -PROGRAM_HEX ?= $(SRC_DIR)/$(PROGRAM).hex +PROGRAM_ELF ?= $(SRC_DIR)/$(CONFIGURATION)/$(PROGRAM).elf +PROGRAM_HEX ?= $(SRC_DIR)/$(CONFIGURATION)/$(PROGRAM).hex .PHONY: all all: software @@ -135,7 +135,8 @@ $(PROGRAM_ELF): \ $(BSP_DIR)/install/lib/$(CONFIGURATION)/libmetal.a \ $(BSP_DIR)/install/lib/$(CONFIGURATION)/libmetal-gloss.a \ $(BSP_DIR)/metal.lds - $(MAKE) -C $(dir $@) $(basename $(notdir $@)) \ + mkdir -p $(dir $@) + $(MAKE) -C $(SRC_DIR) $(basename $(notdir $@)) \ AR=$(RISCV_AR) \ CC=$(RISCV_GCC) \ CXX=$(RISCV_GXX) \ @@ -143,6 +144,7 @@ $(PROGRAM_ELF): \ CXXFLAGS="$(RISCV_CXXFLAGS)" \ LDFLAGS="$(RISCV_LDFLAGS)" \ LDLIBS="$(RISCV_LDLIBS)" + mv $(SRC_DIR)/$(basename $(notdir $@)) $@ touch -c $@ $(RISCV_SIZE) $@ @@ -158,6 +160,7 @@ endif .PHONY: clean-software clean-software: $(MAKE) -C $(SRC_DIR) clean + rm -rf $(SRC_DIR)/$(CONFIGURATION) .PHONY: clean clean: clean-software -- cgit v1.2.3 From d971028e328b99867322ad38f540f76e2b83e100 Mon Sep 17 00:00:00 2001 From: Nathaniel Graff Date: Wed, 13 Mar 2019 08:37:07 -0700 Subject: Clean a single Metal configuration at a time Signed-off-by: Nathaniel Graff --- scripts/libmetal.mk | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/libmetal.mk b/scripts/libmetal.mk index b443ca7..b50c599 100644 --- a/scripts/libmetal.mk +++ b/scripts/libmetal.mk @@ -42,10 +42,19 @@ $(METAL_LIB_DIR)/libmetal.a: $(METAL_LIB_DIR)/libriscv__mmachine__$(TARGET).a $(METAL_LIB_DIR)/libmetal-gloss.a: $(METAL_LIB_DIR)/libriscv__menv__metal.a cp $< $@ +# If we're cleaning the last Metal library for a TARGET, then remove +# the install directory, otherwise just remove the built libs for that +# CONFIGURATION. +ifeq ($(words $(wildcard $(METAL_PREFIX)/lib/*)),1) +METAL_CLEAN = $(METAL_PREFIX) +else +METAL_CLEAN = $(METAL_LIB_DIR) +endif + .PHONY: clean-metal clean-metal: - rm -rf $(METAL_PREFIX) - rm -rf $(BSP_DIR)/build + rm -rf $(METAL_CLEAN) + rm -rf $(METAL_BUILD_DIR) clean: clean-metal metal_install: metal -- cgit v1.2.3 From 74fa7c2f23d7639781cf23101488d797cd06aec6 Mon Sep 17 00:00:00 2001 From: Nathaniel Graff Date: Wed, 13 Mar 2019 09:55:09 -0700 Subject: Update docs Signed-off-by: Nathaniel Graff --- doc/html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/html b/doc/html index c4ace9c..de252ca 160000 --- a/doc/html +++ b/doc/html @@ -1 +1 @@ -Subproject commit c4ace9ccd13fb0dfbbb5c1d742dfc909f1811462 +Subproject commit de252ca314eb39ec6095d86881ce6f1dd34562ea -- cgit v1.2.3