summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile57
-rw-r--r--README.md20
-rw-r--r--scripts/standalone.mk2
3 files changed, 42 insertions, 37 deletions
diff --git a/Makefile b/Makefile
index 18f3345..994d3d7 100644
--- a/Makefile
+++ b/Makefile
@@ -15,9 +15,14 @@ endif
# Allowed values are 'legacy' and 'mee'
BSP ?= legacy
+# Use BOARD as a synonym for TARGET
+ifneq ($(BOARD),)
+TARGET ?= $(BOARD)
+endif
+
ifeq ($(BSP),legacy)
BSP_SUBDIR ?= env
-BOARD ?= freedom-e300-hifive1
+TARGET ?= freedom-e300-hifive1
PROGRAM ?= demo_gpio
LINK_TARGET ?= flash
GDB_PORT ?= 3333
@@ -26,11 +31,11 @@ else # MEE
BSP = mee
BSP_SUBDIR ?=
PROGRAM ?= hello
-BOARD ?= sifive-hifive1
+TARGET ?= sifive-hifive1
endif # $(BSP)
-BOARD_ROOT ?= $(abspath .)
+TARGET_ROOT ?= $(abspath .)
PROGRAM_ROOT ?= $(abspath .)
SRC_DIR = $(PROGRAM_ROOT)/software/$(PROGRAM)
@@ -44,12 +49,12 @@ PROGRAM_HEX = $(SRC_DIR)/$(PROGRAM).hex
# Finds the directory in which this BSP is located, ensuring that there is
# exactly one.
-BSP_DIR := $(wildcard $(BOARD_ROOT)/bsp/$(BSP_SUBDIR)/$(BOARD))
+BSP_DIR := $(wildcard $(TARGET_ROOT)/bsp/$(BSP_SUBDIR)/$(TARGET))
ifeq ($(words $(BSP_DIR)),0)
-$(error Unable to find BSP for $(BOARD), expected to find either "bsp/$(BOARD)" or "bsp-addons/$(BOARD)")
+$(error Unable to find BSP for $(TARGET), expected to find either "bsp/$(TARGET)" or "bsp-addons/$(TARGET)")
endif
ifneq ($(words $(BSP_DIR)),1)
-$(error Found multiple BSPs for $(BOARD): "$(BSP_DIR)")
+$(error Found multiple BSPs for $(TARGET): "$(BSP_DIR)")
endif
#############################################################
@@ -74,26 +79,26 @@ help:
@echo " SiFive Freedom E Software Development Kit "
@echo " Makefile targets:"
@echo ""
- @echo " software BSP=mee [PROGRAM=$(PROGRAM) BOARD=$(BOARD)]:"
+ @echo " software BSP=mee [PROGRAM=$(PROGRAM) TARGET=$(TARGET)]:"
@echo " Build a software program to load with the"
@echo " debugger."
@echo ""
- @echo " mee BSP=mee [BOARD=$(BOARD)]"
- @echo " Build the MEE library for BOARD"
+ @echo " mee BSP=mee [TARGET=$(TARGET)]"
+ @echo " Build the MEE library for TARGET"
@echo ""
- @echo " clean BSP=mee [PROGRAM=$(PROGRAM) BOARD=$(BOARD)]:"
+ @echo " clean BSP=mee [PROGRAM=$(PROGRAM) TARGET=$(TARGET)]:"
@echo " Clean compiled objects for a specified "
@echo " software program."
@echo ""
- @echo " upload BSP=mee [PROGRAM=$(PROGRAM) BOARD=$(BOARD)]:"
+ @echo " upload BSP=mee [PROGRAM=$(PROGRAM) TARGET=$(TARGET)]:"
@echo " Launch OpenOCD to flash your program to the"
@echo " on-board Flash."
@echo ""
- @echo " debug BSP=mee [PROGRAM=$(PROGRAM) BOARD=$(BOARD)]:"
+ @echo " debug BSP=mee [PROGRAM=$(PROGRAM) TARGET=$(TARGET)]:"
@echo " Launch OpenOCD and attach GDB to the running program."
@echo ""
@echo " standalone BSP=mee STANDALONE_DEST=/path/to/desired/location"
- @echo " [PROGRAM=$(PROGRAM) BOARD=$(BOARD)]:"
+ @echo " [PROGRAM=$(PROGRAM) TARGET=$(TARGET)]:"
@echo " Export a program for a single target into a standalone"
@echo " project directory at STANDALONE_DEST."
@echo ""
@@ -113,20 +118,20 @@ clean:
ifeq ($(BSP),mee)
# MEE boards are any folders that aren't the Legacy BSP or update-targets.sh
-EXCLUDE_BOARD_DIRS = drivers env include libwrap update-targets.sh
-list-boards:
- @echo bsp-list: $(sort $(filter-out $(EXCLUDE_BOARD_DIRS),$(notdir $(wildcard bsp/*))))
+EXCLUDE_TARGET_DIRS = drivers env include libwrap update-targets.sh
+list-targets:
+ @echo bsp-list: $(sort $(filter-out $(EXCLUDE_TARGET_DIRS),$(notdir $(wildcard bsp/*))))
# MEE programs are any submodules in the software folder
list-programs:
@echo program-list: $(shell grep -o '= software/.*$$' .gitmodules | sed 's/.*\///')
-list-options: list-programs list-boards
+list-options: list-programs list-targets
endif
#############################################################
-# Compiles an instance of the MEE targeted at $(BOARD)
+# Compiles an instance of the MEE targeted at $(TARGET)
#############################################################
ifeq ($(BSP),mee)
MEE_SOURCE_PATH ?= freedom-mee
@@ -146,7 +151,7 @@ $(BSP_DIR)/build/Makefile:
--prefix=$(abspath $(BSP_DIR)/install) \
--disable-maintainer-mode \
--with-preconfigured \
- --with-machine-name=$(BOARD) \
+ --with-machine-name=$(TARGET) \
--with-machine-header=$(abspath $(MEE_HEADER)) \
--with-machine-ldscript=$(abspath $(MEE_LDSCRIPT)) \
--with-builtin-libgloss
@@ -158,7 +163,7 @@ $(BSP_DIR)/install/stamp: $(BSP_DIR)/build/Makefile
$(BSP_DIR)/install/lib/libriscv%.a: $(BSP_DIR)/install/stamp ;@:
-$(BSP_DIR)/install/lib/libmee.a: $(BSP_DIR)/install/lib/libriscv__mmachine__$(BOARD).a
+$(BSP_DIR)/install/lib/libmee.a: $(BSP_DIR)/install/lib/libriscv__mmachine__$(TARGET).a
cp $< $@
$(BSP_DIR)/install/lib/libmee-gloss.a: $(BSP_DIR)/install/lib/libriscv__menv__mee.a
@@ -253,11 +258,11 @@ PROGRAM_DIR=$(dir $(PROGRAM_ELF))
.PHONY: software_clean
clean: software_clean
software_clean:
- $(MAKE) -C $(PROGRAM_DIR) CC=$(RISCV_GCC) RISCV_ARCH=$(RISCV_ARCH) RISCV_ABI=$(RISCV_ABI) AR=$(RISCV_AR) BSP_BASE=$(abspath bsp) BOARD=$(BOARD) LINK_TARGET=$(LINK_TARGET) clean
+ $(MAKE) -C $(PROGRAM_DIR) CC=$(RISCV_GCC) RISCV_ARCH=$(RISCV_ARCH) RISCV_ABI=$(RISCV_ABI) AR=$(RISCV_AR) BSP_BASE=$(abspath bsp) TARGET=$(TARGET) LINK_TARGET=$(LINK_TARGET) clean
.PHONY: software
software: software_clean
- $(MAKE) -C $(PROGRAM_DIR) CC=$(RISCV_GCC) RISCV_ARCH=$(RISCV_ARCH) RISCV_ABI=$(RISCV_ABI) AR=$(RISCV_AR) BSP_BASE=$(abspath bsp) BOARD=$(BOARD) LINK_TARGET=$(LINK_TARGET)
+ $(MAKE) -C $(PROGRAM_DIR) CC=$(RISCV_GCC) RISCV_ARCH=$(RISCV_ARCH) RISCV_ABI=$(RISCV_ABI) AR=$(RISCV_AR) BSP_BASE=$(abspath bsp) TARGET=$(TARGET) LINK_TARGET=$(LINK_TARGET)
dasm: software $(RISCV_OBJDUMP)
$(RISCV_OBJDUMP) -D $(PROGRAM_ELF)
@@ -277,14 +282,14 @@ endif
ifeq ($(BSP),mee)
upload: $(PROGRAM_ELF)
- scripts/upload --elf $(PROGRAM_ELF) --openocd $(RISCV_OPENOCD) --gdb $(RISCV_GDB) --openocd-config bsp/$(BOARD)/openocd.cfg
+ scripts/upload --elf $(PROGRAM_ELF) --openocd $(RISCV_OPENOCD) --gdb $(RISCV_GDB) --openocd-config bsp/$(TARGET)/openocd.cfg
debug: $(PROGRAM_ELF)
- scripts/debug --elf $(PROGRAM_ELF) --openocd $(RISCV_OPENOCD) --gdb $(RISCV_GDB) --openocd-config bsp/$(BOARD)/openocd.cfg
+ scripts/debug --elf $(PROGRAM_ELF) --openocd $(RISCV_OPENOCD) --gdb $(RISCV_GDB) --openocd-config bsp/$(TARGET)/openocd.cfg
else # BSP != mee
-OPENOCDCFG ?= bsp/env/$(BOARD)/openocd.cfg
+OPENOCDCFG ?= bsp/env/$(TARGET)/openocd.cfg
OPENOCDARGS += -f $(OPENOCDCFG)
GDB_UPLOAD_ARGS ?= --batch
@@ -301,7 +306,7 @@ GDB_UPLOAD_CMDS += -ex "quit"
upload:
$(RISCV_OPENOCD) $(OPENOCDARGS) & \
$(RISCV_GDB) $(PROGRAM_DIR)/$(PROGRAM) $(GDB_UPLOAD_ARGS) $(GDB_UPLOAD_CMDS) && \
- echo "Successfully uploaded '$(PROGRAM)' to $(BOARD)."
+ echo "Successfully uploaded '$(PROGRAM)' to $(TARGET)."
#############################################################
# This Section is for launching the debugger
diff --git a/README.md b/README.md
index 37b837a..7cce370 100644
--- a/README.md
+++ b/README.md
@@ -196,7 +196,7 @@ example commands.
To compile a bare-metal RISC-V program:
```
-make BSP=mee [PROGRAM=hello] [BOARD=sifive-hifive1] software
+make BSP=mee [PROGRAM=hello] [TARGET=sifive-hifive1] software
```
The square brackets in the above command indicate optional parameters for the
@@ -206,7 +206,7 @@ If, for example, you wished to build the `timer-interrupt` example for the S51
Arty FPGA Evaluation target, you would instead run the command
```
-make BSP=mee PROGRAM=timer-interrupt BOARD=coreip-s51-arty software
+make BSP=mee PROGRAM=timer-interrupt TARGET=coreip-s51-arty software
```
#### Building a Legacy Example ####
@@ -216,38 +216,38 @@ The legacy examples can still be built by omitting `BSP=mee` or by substituting
HiFive 1, run:
```
-make PROGRAM=demo_gpio BOARD=freedom-e300-hifive1 software
+make PROGRAM=demo_gpio TARGET=freedom-e300-hifive1 software
```
#### Uploading to the Target Board ####
```
-make BSP=mee [PROGRAM=hello] [BOARD=sifive-hifive1] upload
+make BSP=mee [PROGRAM=hello] [TARGET=sifive-hifive1] upload
```
#### Debugging a Target Program ####
```
-make BSP=mee [PROGRAM=hello] [BOARD=sifive-hifive1] debug
+make BSP=mee [PROGRAM=hello] [TARGET=sifive-hifive1] debug
```
#### Cleaning a Target Program Build Directory ####
```
-make BSP=mee [PROGRAM=hello] [BOARD=sifive-hifive1] clean
+make BSP=mee [PROGRAM=hello] [TARGET=sifive-hifive1] clean
```
#### Create a Standalone Project ####
You can export a program to a standalone project directory using the `standalone`
-target. The resulting project will be locked to a specific target `BOARD`. Note
+target. The resulting project will be locked to a specific `TARGET`. Note
that this functionality is only supported for Freedom Metal programs, not the
Legacy Freedom E SDK.
`STANDALONE_DEST` is a required argument to provide the desired project location.
```
-make BSP=mee [PROGRAM=hello] [BOARD=sifive-hifive1] STANDALONE_DEST=/path/to/desired/location standalone
+make BSP=mee [PROGRAM=hello] [TARGET=sifive-hifive1] STANDALONE_DEST=/path/to/desired/location standalone
```
Run `make help` for more commands.
@@ -263,8 +263,8 @@ this section to describe the updated build steps.
After setting up the software and debug toolchains, you can build and
execute everyone's favorite benchmark as follows:
-- Compile the benchmark with the command `make software BOARD=freedom-e300-hifive1 PROGRAM=dhrystone LINK_TARGET=dhrystone`. Note that a slightly different linker file is used for Dhrystone which stores read only data in DTIM instead of external flash.
-- Run on the HiFive1 board with the command `make upload BOARD=freedom-e300-hifive1 PROGRAM=dhrystone`.
+- Compile the benchmark with the command `make software TARGET=freedom-e300-hifive1 PROGRAM=dhrystone LINK_TARGET=dhrystone`. Note that a slightly different linker file is used for Dhrystone which stores read only data in DTIM instead of external flash.
+- Run on the HiFive1 board with the command `make upload TARGET=freedom-e300-hifive1 PROGRAM=dhrystone`.
This will take a few minutes. Sample output is provided below.
- Compute DMIPS by dividing the Dhrystones per Second result by 1757, which
was the VAX 11/780's performance. In the example below, 729927 / 1757 =
diff --git a/scripts/standalone.mk b/scripts/standalone.mk
index 244bb7c..a73093f 100644
--- a/scripts/standalone.mk
+++ b/scripts/standalone.mk
@@ -13,7 +13,7 @@ SRC_DIR ?= $(abspath src)
# There must be a settings makefile fragment in the BSP's board directory.
ifeq ($(wildcard $(BSP_DIR)/settings.mk),)
-$(error Unable to find BSP for $(BOARD), expected to find $(BSP_DIR)/settings.mk)
+$(error Unable to find BSP for $(TARGET), expected to find $(BSP_DIR)/settings.mk)
endif
# Include the BSP settings