From f62f4aae84a0fcf2ff4093be41553fca553fd99e Mon Sep 17 00:00:00 2001 From: mwachs5 Date: Wed, 17 May 2017 10:57:03 -0700 Subject: Update Makefile and README with how to use precompiled binaries. --- Makefile | 20 ++++++++++++-------- README.md | 34 +++++++++++++++++++++++++++++----- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 0e785dd..f561668 100644 --- a/Makefile +++ b/Makefile @@ -103,13 +103,15 @@ tools: riscv-gnu-toolchain openocd toolchain_builddir := $(builddir)/riscv-gnu-toolchain/riscv64-unknown-elf toolchain_prefix := $(toolchain_builddir)/prefix -RISCV_GCC := $(abspath $(toolchain_prefix)/bin/riscv64-unknown-elf-gcc) -RISCV_GXX := $(abspath $(toolchain_prefix)/bin/riscv64-unknown-elf-g++) -RISCV_OBJDUMP := $(abspath $(toolchain_prefix)/bin/riscv64-unknown-elf-objdump) -RISCV_GDB := $(abspath $(toolchain_prefix)/bin/riscv64-unknown-elf-gdb) -RISCV_AR := $(abspath $(toolchain_prefix)/bin/riscv64-unknown-elf-ar) +RISCV_PREFIX ?= $(toolchain_prefix) -PATH := $(abspath $(toolchain_prefix)/bin):$(PATH) +RISCV_GCC := $(abspath $(RISCV_PREFIX)/bin/riscv64-unknown-elf-gcc) +RISCV_GXX := $(abspath $(RISCV_PREFIX)/bin/riscv64-unknown-elf-g++) +RISCV_OBJDUMP := $(abspath $(RISCV_PREFIX)/bin/riscv64-unknown-elf-objdump) +RISCV_GDB := $(abspath $(RISCV_PREFIX)/bin/riscv64-unknown-elf-gdb) +RISCV_AR := $(abspath $(RISCV_PREFIX)/bin/riscv64-unknown-elf-ar) + +PATH := $(abspath $(RISCV_PREFIX)/bin):$(PATH) $(RISCV_GCC) $(RISCV_GXX) $(RISCV_OBJDUMP) $(RISCV_GDB) $(RISCV_AR): $(toolchain_builddir)/install.stamp touch -c $@ @@ -148,7 +150,9 @@ toolchain-clean: # initializing the target. openocd_builddir := $(builddir)/openocd openocd_prefix := $(openocd_builddir)/prefix -RISCV_OPENOCD := $(openocd_prefix)/bin/openocd + +RISCV_OPENOCD_PREFIX ?= $(openocd_prefix) +RISCV_OPENOCD ?= $(RISCV_OPENOCD_PREFIX)/bin/openocd .PHONY: openocd openocd: $(RISCV_OPENOCD) @@ -215,7 +219,7 @@ GDB_UPLOAD_CMDS += -ex "quit" upload: $(RISCV_OPENOCD) $(OPENOCDARGS) & \ - $(RISCV_GDB) $(PROGRAM_DIR)/$(PROGRAM) $(GDB_UPLOAD_ARGS) $(GDB_UPLOAD_CMDS);\ + $(RISCV_GDB) $(PROGRAM_DIR)/$(PROGRAM) $(GDB_UPLOAD_ARGS) $(GDB_UPLOAD_CMDS) && \ echo "Successfully uploaded '$(PROGRAM)' to $(BOARD)." ############################################################# diff --git a/README.md b/README.md index 523e754..fe6574f 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,15 @@ First, clone this repository: git clone --recursive https://github.com/sifive/freedom-e-sdk.git ``` +To see Makefile options: + +``` +cd freedom-e-sdk +make help +``` + +#### Building Tools from Source #### + Ubuntu packages needed: $ sudo apt-get install autoconf automake libmpc-dev libmpfr-dev libgmp-dev gawk bison flex texinfo libtool libusb-1.0-0-dev make g++ pkg-config libexpat1-dev zlib1g-dev @@ -25,7 +34,7 @@ Next, build the tools: ``` cd freedom-e-sdk -make tools +make tools [BOARD=freedom-e300-hifive1] ``` If your machine has enough resources, you can speed up the build process by adding `-j n` to `make`, where `n` is the number of processors of your build system. @@ -34,15 +43,30 @@ To compile a bare-metal RISC-V program: ``` cd freedom-e-sdk -make software [PROGRAM=demo_gpio] +make software [PROGRAM=demo_gpio] [BOARD=freedom-e300-hifive1] ``` +#### Using Pre-Built Binary Tools #### + +If you would like to avoid compiling the tools from source, they are +available as pre-built binaries from + +https://sifive.com/products/tools -To see additional options: +For OpenOCD and/or RISC-V GNU Toolchain, +download the .tar.gz for your platform, and unpack it to +your desired location. Then, use the `RISC_PREFIX` and `RISCV_OPENOCD_PREFIX` +variables when attempting to use the tools: ``` -cd freedom-e-sdk -make help +cp openocd--.tar.gz /my/desired/location/ +cp riscv-gnu-toolchain--.tar.gz /my/desired/location +cd /my/desired/location +tar -xvf openocd--.tar.gz +tar -xvf riscv-gnu-toolchain--.tar.gz +export RISCV_OPENOCD_PREFIX /my/desired/location/openocd +export RISCV_PREFIX /my/desired/location/riscv-gnu-toolchain ``` + ### Updating your SDK ### If you'd like to update your SDK to the latest version: -- cgit v1.2.1-18-gbd029 From fdd2423815d27bc20be21f8a4bf7dd4a27fd0320 Mon Sep 17 00:00:00 2001 From: Megan Wachs Date: Wed, 17 May 2017 11:05:09 -0700 Subject: Re-arrange some Makefile instructions --- README.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fe6574f..fe5c25e 100644 --- a/README.md +++ b/README.md @@ -39,12 +39,7 @@ make tools [BOARD=freedom-e300-hifive1] If your machine has enough resources, you can speed up the build process by adding `-j n` to `make`, where `n` is the number of processors of your build system. -To compile a bare-metal RISC-V program: -``` -cd freedom-e-sdk -make software [PROGRAM=demo_gpio] [BOARD=freedom-e300-hifive1] -``` #### Using Pre-Built Binary Tools #### If you would like to avoid compiling the tools from source, they are @@ -83,6 +78,16 @@ If you would like to recompile the entire toolchain after performing the above: make uninstall make tools ``` +### Using the Tools ### + +To compile a bare-metal RISC-V program: + +``` +cd freedom-e-sdk +make software [PROGRAM=demo_gpio] [BOARD=freedom-e300-hifive1] +``` + +Run `make help` for more commands. ### Benchmarking ### -- cgit v1.2.1-18-gbd029 From 05cb35bb1700ce1b93a8502ce2d7e4ca3f22e3fd Mon Sep 17 00:00:00 2001 From: mwachs5 Date: Wed, 17 May 2017 13:42:39 -0700 Subject: rename 'PREFIX' to 'PATH' for more intuitive naming --- Makefile | 18 +++++++++--------- README.md | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index f561668..0e12777 100644 --- a/Makefile +++ b/Makefile @@ -103,15 +103,15 @@ tools: riscv-gnu-toolchain openocd toolchain_builddir := $(builddir)/riscv-gnu-toolchain/riscv64-unknown-elf toolchain_prefix := $(toolchain_builddir)/prefix -RISCV_PREFIX ?= $(toolchain_prefix) +RISCV_PATH ?= $(toolchain_prefix) -RISCV_GCC := $(abspath $(RISCV_PREFIX)/bin/riscv64-unknown-elf-gcc) -RISCV_GXX := $(abspath $(RISCV_PREFIX)/bin/riscv64-unknown-elf-g++) -RISCV_OBJDUMP := $(abspath $(RISCV_PREFIX)/bin/riscv64-unknown-elf-objdump) -RISCV_GDB := $(abspath $(RISCV_PREFIX)/bin/riscv64-unknown-elf-gdb) -RISCV_AR := $(abspath $(RISCV_PREFIX)/bin/riscv64-unknown-elf-ar) +RISCV_GCC := $(abspath $(RISCV_PATH)/bin/riscv64-unknown-elf-gcc) +RISCV_GXX := $(abspath $(RISCV_PATH)/bin/riscv64-unknown-elf-g++) +RISCV_OBJDUMP := $(abspath $(RISCV_PATH)/bin/riscv64-unknown-elf-objdump) +RISCV_GDB := $(abspath $(RISCV_PATH)/bin/riscv64-unknown-elf-gdb) +RISCV_AR := $(abspath $(RISCV_PATH)/bin/riscv64-unknown-elf-ar) -PATH := $(abspath $(RISCV_PREFIX)/bin):$(PATH) +PATH := $(abspath $(RISCV_PATH)/bin):$(PATH) $(RISCV_GCC) $(RISCV_GXX) $(RISCV_OBJDUMP) $(RISCV_GDB) $(RISCV_AR): $(toolchain_builddir)/install.stamp touch -c $@ @@ -151,8 +151,8 @@ toolchain-clean: openocd_builddir := $(builddir)/openocd openocd_prefix := $(openocd_builddir)/prefix -RISCV_OPENOCD_PREFIX ?= $(openocd_prefix) -RISCV_OPENOCD ?= $(RISCV_OPENOCD_PREFIX)/bin/openocd +RISCV_OPENOCD_PATH ?= $(openocd_prefix) +RISCV_OPENOCD ?= $(RISCV_OPENOCD_PATH)/bin/openocd .PHONY: openocd openocd: $(RISCV_OPENOCD) diff --git a/README.md b/README.md index fe5c25e..ad0cf7a 100644 --- a/README.md +++ b/README.md @@ -49,17 +49,17 @@ https://sifive.com/products/tools For OpenOCD and/or RISC-V GNU Toolchain, download the .tar.gz for your platform, and unpack it to -your desired location. Then, use the `RISC_PREFIX` and `RISCV_OPENOCD_PREFIX` +your desired location. Then, use the `RISC_PATH` and `RISCV_OPENOCD_PATH` variables when attempting to use the tools: ``` cp openocd--.tar.gz /my/desired/location/ -cp riscv-gnu-toolchain--.tar.gz /my/desired/location +cp riscv64-unknown-elf-gcc--.tar.gz /my/desired/location cd /my/desired/location tar -xvf openocd--.tar.gz -tar -xvf riscv-gnu-toolchain--.tar.gz -export RISCV_OPENOCD_PREFIX /my/desired/location/openocd -export RISCV_PREFIX /my/desired/location/riscv-gnu-toolchain +tar -xvf riscv64-unknown-elf-gcc--.tar.gz +export RISCV_OPENOCD_PATH=/my/desired/location/openocd +export RISCV_PATH=/my/desired/location/riscv64-unknown-elf-gcc-- ``` ### Updating your SDK ### -- cgit v1.2.1-18-gbd029