summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitmodules6
-rw-r--r--Makefile45
-rw-r--r--README.md5
-rw-r--r--bsp/coreip-e20-arty/metal.ramrodata.lds14
-rwxr-xr-xbsp/update-targets.sh9
-rw-r--r--doc/sphinx/contents.rst4
m---------freedom-devicetree-tools0
m---------freedom-metal0
-rwxr-xr-xscripts/fixup-dts107
-rwxr-xr-xscripts/open-docs20
-rw-r--r--scripts/standalone.mk18
-rwxr-xr-xscripts/submodules-use-ssh.sh2
m---------software/coremark0
13 files changed, 131 insertions, 99 deletions
diff --git a/.gitmodules b/.gitmodules
index 40b88d9..fd90c58 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -52,3 +52,9 @@
[submodule "software/example-user-syscall"]
path = software/example-user-syscall
url = https://github.com/sifive/example-user-syscall.git
+[submodule "software/coremark"]
+ path = software/coremark
+ url = https://github.com/sifive/benchmark-coremark.git
+[submodule "freedom-devicetree-tools"]
+ path = freedom-devicetree-tools
+ url = https://github.com/sifive/freedom-devicetree-tools.git
diff --git a/Makefile b/Makefile
index c19045b..2be82e1 100644
--- a/Makefile
+++ b/Makefile
@@ -20,6 +20,26 @@ endif
PROGRAM ?= hello
TARGET ?= sifive-hifive1
+# Setup differences between host platforms
+ifeq ($(OS),Windows_NT)
+ SED_RE_FLAG = -r
+else
+ UNAME_S := $(shell uname -s)
+ ifeq ($(UNAME_S),Linux)
+ SED_RE_FLAG = -r
+ endif
+ ifeq ($(UNAME_S),Darwin)
+ SED_RE_FLAG = -E
+ endif
+endif
+
+# Coremark require PORT_DIR set for different OS, freedom-metal for us!
+ifeq ($(PROGRAM),coremark)
+ifeq ($(PORT_DIR),)
+PORT_DIR = freedom-metal
+endif
+endif
+
TARGET_ROOT ?= $(abspath .)
PROGRAM_ROOT ?= $(abspath .)
@@ -93,8 +113,15 @@ help:
@echo " Exports a program for a single target into a standalone"
@echo " project directory at STANDALONE_DEST."
@echo ""
- @echo " For more information, view the Freedom E SDK Documentation at"
- @echo " https://sifive.github.io/freedom-e-sdk-docs/index.html"
+ @echo " open-docs"
+ @echo " Opens the Freedom E SDK documentation in your HTML"
+ @echo " viewer of choice. The documentation can also be found"
+ @echo " online at"
+ @echo " https://sifive.github.io/freedom-e-sdk-docs/index.html"
+
+.PHONY: open-docs
+open-docs: scripts/open-docs
+ $^
.PHONY: clean
clean:
@@ -102,9 +129,9 @@ clean:
#############################################################
# Enumerate BSPs and Programs
#
-# List all available boards and programs in a form that
-# Freedom Studio knows how to parse. Do not change the
-# format or fixed text of the output without consulting the
+# List all available boards and programs in a form that
+# Freedom Studio knows how to parse. Do not change the
+# format or fixed text of the output without consulting the
# Freedom Studio dev team.
#############################################################
@@ -131,7 +158,7 @@ list-targets:
list-target-tags:
@echo target-tags: $(shell find $(TARGET_ROOT)/bsp -name settings.mk | \
xargs grep -he "TARGET_TAGS" | \
- sed -r 's/TARGET_TAGS.*=(.*)/\1/' | \
+ sed $(SED_RE_FLAG) 's/TARGET_TAGS.*=(.*)/\1/' | \
tr ' ' '\n' | \
sort | \
uniq)
@@ -194,6 +221,9 @@ standalone: \
cp release.mk $</release.mk
echo "PROGRAM = $(PROGRAM)" > $</Makefile
+ifneq ($(PORT_DIR),)
+ echo "PORT_DIR = $(PORT_DIR)" > $</Makefile
+endif
cat scripts/standalone.mk >> $</Makefile
cat scripts/libmetal.mk >> $</Makefile
else # "rtl" not in TARGET_TAGS
@@ -220,6 +250,9 @@ standalone: \
cp release.mk $</release.mk
echo "PROGRAM = $(PROGRAM)" > $</Makefile
+ifneq ($(PORT_DIR),)
+ echo "PORT_DIR = $(PORT_DIR)" > $</Makefile
+endif
cat scripts/standalone.mk >> $</Makefile
cat scripts/libmetal.mk >> $</Makefile
endif # rtl in TARGET_TAGS
diff --git a/README.md b/README.md
index 922e588..65ba13b 100644
--- a/README.md
+++ b/README.md
@@ -95,9 +95,12 @@ operating systems to RISC-V.
- example-pmp
- Demonstrates how to configure a Physical Memory Protection (PMP) region
- sifive-welcome
- - Prints the SiFive banner and blinks LEDs
+ - Prints the SiFive banner and blinks LEDs
- dhrystone
- "Dhrystone" Benchmark Program by Reinhold P. Weicker
+ - coremark
+ - "CoreMark" Benchmark Program that measures the performance of embedded
+ microcrontrollers (MCU) Please use SiFive GNU Embedded Toolchain >= v2019.05
### Setting up the SDK ###
diff --git a/bsp/coreip-e20-arty/metal.ramrodata.lds b/bsp/coreip-e20-arty/metal.ramrodata.lds
index 513e567..0c6fffa 100644
--- a/bsp/coreip-e20-arty/metal.ramrodata.lds
+++ b/bsp/coreip-e20-arty/metal.ramrodata.lds
@@ -9,8 +9,9 @@ ENTRY(_enter)
MEMORY
{
- ram (wxa!ri) : ORIGIN = 0x80000000, LENGTH = 0x10000
+ ram (wxa!ri) : ORIGIN = 0x80000000, LENGTH = 0x8000
flash (rxai!w) : ORIGIN = 0x40400000, LENGTH = 0x1fc00000
+ itim (wx!rai) : ORIGIN = 0x80008000, LENGTH = 0x8000
}
PHDRS
@@ -127,13 +128,17 @@ SECTIONS
{
. = ALIGN(4);
PROVIDE( metal_segment_itim_target_start = . );
- } >ram AT>flash :ram_init
+ } >itim AT>flash :itim_init
.itim :
{
*(.itim .itim.*)
- } >flash AT>flash :flash
+ *(.text.unlikely .text.unlikely.*)
+ *(.text.startup .text.startup.*)
+ *(.text .text.*)
+ *(.gnu.linkonce.t.*)
+ } >itim AT>flash :itim_init
. = ALIGN(8);
@@ -144,8 +149,7 @@ SECTIONS
*(.text.startup .text.startup.*)
*(.text .text.*)
*(.gnu.linkonce.t.*)
- *(.itim .itim.*)
- } >flash AT>flash :flash
+ } >itim AT>flash :flash
.lalign :
diff --git a/bsp/update-targets.sh b/bsp/update-targets.sh
index e3b2496..198cd5a 100755
--- a/bsp/update-targets.sh
+++ b/bsp/update-targets.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env sh
+#!/bin/bash
help() {
cat >&2 <<EOF
@@ -45,9 +45,10 @@ then
TARGET_LIST="$(ls -d coreip*) "
TARGET_LIST+="sifive-hifive1 sifive-hifive1-revb freedom-e310-arty sifive-hifive-unleashed "
else
- if [ ! -f "$DTSFILE" -a "$DTSFILE" != "*.dts" ]
+ file "$DTSFILE"
+ if [ ! -f "$DTSFILE" ]
then
- echo "[ERROR] $0: $DTSFILE must be a dts file" >&2
+ echo "[ERROR] $0: $DTSFILE must be a file" >&2
help "$0"
exit 1
fi
@@ -70,7 +71,7 @@ else
echo "[INFO] $0: "$CUSTOM_TARGET" not found! Creating one" >&2
mkdir -p $CUSTOM_TARGET
fi
- cp $DTSFILE $CUSTOM_TARGET
+ cp $DTSFILE "$CUSTOM_TARGET/design.dts"
TARGET_LIST="$CUSTOM_TARGET "
fi
diff --git a/doc/sphinx/contents.rst b/doc/sphinx/contents.rst
index cad7f78..3a20bad 100644
--- a/doc/sphinx/contents.rst
+++ b/doc/sphinx/contents.rst
@@ -153,3 +153,7 @@ The example programs can be found under the ``software/`` directory.
- "Dhrystone" Benchmark Program by Reinhold P. Weicker
+- coremark
+
+ - "CoreMark" Benchmark Program that measures the performance of embedded
+ microcrontrollers (MCU)
diff --git a/freedom-devicetree-tools b/freedom-devicetree-tools
new file mode 160000
+Subproject aa23e2880d81a655f7150e459b9c3b0d938b11f
diff --git a/freedom-metal b/freedom-metal
-Subproject 7eb6be9e76019ab6c20c78c529b747bf6bc2b16
+Subproject 2c101d05a09afaf8f00469e5b0565069055d6a2
diff --git a/scripts/fixup-dts b/scripts/fixup-dts
index 278b835..8b2457f 100755
--- a/scripts/fixup-dts
+++ b/scripts/fixup-dts
@@ -38,10 +38,10 @@ if [ `grep -c 'riscv,pmp' ${dts}` -eq 0 ]; then
# Check for targets without PMP support
TARGET=`echo ${dts} | cut -d '/' -f 1`
- if [ $TARGET != "freedom-e310-arty" -a \
- $TARGET != "sifive-hifive1" -a \
- $TARGET != "coreip-e20-rtl" -a \
- $TARGET != "coreip-e20-arty" ]; then
+ if [ "$TARGET" != "freedom-e310-arty" -a \
+ "$TARGET" != "sifive-hifive1" -a \
+ "$TARGET" != "coreip-e20-rtl" -a \
+ "$TARGET" != "coreip-e20-arty" ]; then
${SED} -i '/riscv,isa/a riscv,pmpregions = <1>;' ${dts}
@@ -105,84 +105,27 @@ if [ `grep -c 'stdout-path' ${dts}` -eq 0 ]; then
fi
-# Add a test memory node if one doesn't exist
-
-if [ `grep -c 'sifive,testram0' ${dts}` -eq 0 ]; then
-
- # bullet and U cores have a memory defined already
- if [ `grep -c 'sifive,bullet0' ${dts}` -eq 0 -a `grep -c 'SiFive,FU' ${dts}` -eq 0 ]; then
-
- echo "$0: Test memory node not found in ${dts}."
-
- # The heuristic for determining which memory address contains the
- # program code loaded by the RTL testbench is determined by taking
- # the design ports and sorting them in order of (periph, sys, mem),
- # and then lexicographically by protocol.
-
- port_types="periph sys mem"
- protocols="ahb axi4 tl"
-
- for port_type in ${port_types}; do
- for protocol in ${protocols}; do
-
- # Check if the port exists
- if [ `grep -c "${protocol}-${port_type}-port" ${dts}` -ne 0 ]; then
-
- # Build the node name
- port_node_name=`egrep -o "${protocol}-${port_type}-port@[a-fA-F0-9]+" ${dts}`
- echo -e "$0: \tUsing node \t${port_node_name}"
-
- # Get the address and size cells
- address_cells=`cat ${dts} | tr -d '\n\t' | grep -oP "${port_node_name}.*?address-cells = <\K(\d+)"`
- echo -e "$0: \tAddress cells \t${address_cells}"
- size_cells=`cat ${dts} | tr -d '\n\t' | grep -oP "${port_node_name}.*?size-cells = <\K(\d+)"`
- echo -e "$0: \tSize cells \t${size_cells}"
-
- # Get the base address and size
- if [ ${address_cells} -eq 1 -a ${size_cells} -eq 1 ]; then
- address_and_size=(`cat ${dts} | tr -d '\n\t' | grep -oP "${port_node_name}.*?ranges = <0x\d+ \K(0x\d+ 0x\d+)"`)
- base_address=${address_and_size[0]}
- size=${address_and_size[1]}
- elif [ ${address_cells} -eq 1 -a ${size_cells} -eq 2 ]; then
- address_and_size=(`cat ${dts} | tr -d '\n\t' | grep -oP "${port_node_name}.*?ranges = <0x\d+ \K(0x\d+ 0x\d+ 0x\d+)"`)
- base_address=${address_and_size[0]}
- size="${address_and_size[1]} ${address_and_size[2]}"
- elif [ ${address_cells} -eq 2 -a ${size_cells} -eq 1 ]; then
- address_and_size=(`cat ${dts} | tr -d '\n\t' | grep -oP "${port_node_name}.*?ranges = <0x\d+ 0x\d+ \K(0x\d+ 0x\d+ 0x\d+)"`)
- base_address="${address_and_size[0]} ${address_and_size[1]}"
- size=${address_and_size[2]}
- elif [ ${address_cells} -eq 2 -a ${size_cells} -eq 2 ]; then
- address_and_size=(`cat ${dts} | tr -d '\n\t' | grep -oP "${port_node_name}.*?ranges = <0x\d+ 0x\d+ \K(0x\d+ 0x\d+ 0x\d+ 0x\d+)"`)
- base_address="${address_and_size[0]} ${address_and_size[1]}"
- size="${address_and_size[2]} ${address_and_size[3]}"
- fi
- echo -e "$0: \tBase addr \t${base_address}"
- echo -e "$0: \tSize \t\t${size}"
-
- # Build the name of the testram node
- if [ "${address_and_size[0]}" == "0x0" ]; then
- node_name_addr=`echo ${address_and_size[1]} | cut -c 3-`
- else
- node_name_addr=`echo ${address_and_size[0]} | cut -c 3-`
- fi
-
- # Determine word size from ISA bitness
- if [ `grep -c 'riscv,isa = "rv32' ${dts}` -ne 0 ]; then
- word_size=4
- else
- word_size=8
- fi
- echo -e "$0: \tWord size \t${word_size}"
-
- # Create the test memory
- ${SED} -i "s/ranges;/ranges;\n\t\ttest_memory: testram@${node_name_addr} {\n\t\t\tcompatible = \"sifive,testram0\";\n\t\t\treg = <${base_address} ${size}>;\n\t\t\treg-names = \"mem\";\n\t\t\tword-size-bytes = <${word_size}>;\n\t\t};/" ${dts}
- echo -e "$0: \tAdded testram@${node_name_addr}"
-
- # Break out of both loops
- break 2
- fi
- done
- done
+# FPGA targets need a 0x400000 byte offset into their SPI flash
+
+# Is the target an FPGA?
+if [ `echo ${dts} | grep -c 'arty'` -ne 0 -o `echo ${dts} | grep -c 'fpga'` -ne 0 ] ; then
+ # Is there a metal,entry property in the chosen node?
+ if [ `grep -c 'metal,entry' ${dts}` -eq 0 ] ; then
+ echo "$0: FPGA target needs metal,entry property to set boot offset."
+
+ # Find the SPI device with the lowest base address
+ first_spi_node=`grep -oE "spi@[[:xdigit:]]+?" ${dts} | sort | head -n 1`
+
+ # Get the DTS node label of that SPI device
+ spi_entry_label=`grep -oE "[^[:space:]]+?:\s+?${first_spi_node}" ${dts} | cut -d ':' -f 1`
+
+ if [ `grep -c 'chosen' ${dts}` -eq 0 ]; then
+ ${SED} -i "/cpus/i chosen {\n};" ${dts}
+ fi
+
+ ${SED} -i "/chosen/a metal,entry = <&${spi_entry_label} 0x400000>;" ${dts}
+
+ echo -e "$0: \tAdded metal,entry for SPI node ${first_spi_node} with label ${spi_entry_label}"
fi
fi
diff --git a/scripts/open-docs b/scripts/open-docs
new file mode 100755
index 0000000..8ad5299
--- /dev/null
+++ b/scripts/open-docs
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+SDK_PATH="$( cd "$(dirname "$0")/.." ; pwd -P )"
+DOCS_PATH=$SDK_PATH/doc/html/index.html
+
+XDG_OPEN=`which xdg-open`
+OPEN=`which open`
+
+if [ "$XDG_OPEN" != "" ]; then
+ echo "Opening $DOCS_PATH"
+ $XDG_OPEN $DOCS_PATH
+
+elif [ "$OPEN" != "" ]; then
+ echo "Opening $DOCS_PATH"
+ $OPEN $DOCS_PATH
+
+else
+ echo "Please open $DOCS_PATH in your preferred HTML viewer"
+fi
+
diff --git a/scripts/standalone.mk b/scripts/standalone.mk
index 6f87950..d0740cd 100644
--- a/scripts/standalone.mk
+++ b/scripts/standalone.mk
@@ -49,6 +49,14 @@ ifeq ($(LINK_TARGET),)
endif
endif
+ifeq ($(PROGRAM),coremark)
+ifeq ($(CONFIGURATION),release)
+ifeq ($(LINK_TARGET),)
+LINK_TARGET = ramrodata
+endif
+endif
+endif
+
ifeq ($(LINK_TARGET),)
LINK_TARGET = default
endif
@@ -127,6 +135,15 @@ endif
RISCV_XCFLAGS += -DDHRY_ITERS=$(TARGET_DHRY_ITERS)
endif
+ifeq ($(PROGRAM),coremark)
+ifeq ($(RISCV_SERIES),sifive-7-series)
+RISCV_XCFLAGS += -O2 -fno-common -funroll-loops -finline-functions -funroll-all-loops --param max-inline-insns-auto=20 -falign-functions=8 -falign-jumps=8 -falign-loops=8 --param inline-min-speedup=10 -mtune=sifive-7-series -ffast-math
+else
+RISCV_XCFLAGS += -O2 -fno-common -funroll-loops -finline-functions --param max-inline-insns-auto=20 -falign-functions=4 -falign-jumps=4 -falign-loops=4 --param inline-min-speedup=10
+endif
+RISCV_XCFLAGS += -DITERATIONS=$(TARGET_CORE_ITERS)
+endif
+
# Turn on garbage collection for unused sections
RISCV_LDFLAGS += -Wl,--gc-sections
# Turn on linker map file generation
@@ -171,6 +188,7 @@ $(PROGRAM_ELF): \
$(BSP_DIR)/metal.$(LINK_TARGET).lds
mkdir -p $(dir $@)
$(MAKE) -C $(SRC_DIR) $(basename $(notdir $@)) \
+ PORT_DIR=$(PORT_DIR) \
AR=$(RISCV_AR) \
CC=$(RISCV_GCC) \
CXX=$(RISCV_GXX) \
diff --git a/scripts/submodules-use-ssh.sh b/scripts/submodules-use-ssh.sh
index 25a270d..106af2b 100755
--- a/scripts/submodules-use-ssh.sh
+++ b/scripts/submodules-use-ssh.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env sh
+#!/bin/bash
# By default, when you clone Freedom E SDK, submodules are instantiated with their
# origin URLs pointing to GitHub's HTTPS URL for the repository.
diff --git a/software/coremark b/software/coremark
new file mode 160000
+Subproject 2a15fbb3ecae618f978a1c6f9eaa1fb469aa688