Skip to content

Instantly share code, notes, and snippets.

@jonahgraham
Last active September 10, 2019 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonahgraham/549d953838f760812a89153bfe78ddf0 to your computer and use it in GitHub Desktop.
Save jonahgraham/549d953838f760812a89153bfe78ddf0 to your computer and use it in GitHub Desktop.
Install the tools needed for open-isa getting started on Linux as documented here: https://open-isa.org/get-started/
#!/bin/bash
# This script can be used to download and install the tools as specified on https://open-isa.org/get-started/.
# Running this scipt will result in all the tools being added as sub-folders:
# - Eclipse: ./eclipse/eclipse
# - SDK: ./vega
# - Toolchain: ./toolchain
# - Toolchain OCD: ./toolchain/openocd
# - Toolchain bin dir: ./toolchain/riscv32-unknown-elf-gcc/bin/
# - OVPsim: ./riscv-ovpsim
# These are the modifications compared to the website:
# - Uses GNU MCU Eclipse pacakged Eclipse with the required plug-ins already installed
# - The licsense for the SDK is implicitly accepted, please review it in LICESE.txt
# - The OVP Simulator for RISC-V is included
# - Additional tools and prerequistes may be needed, such as a make and Java
# Show commands being used and error out on unexpected situations
set -eux
# Download Eclipse with MCU Plug-ins, SDK and toolchain
curl -L https://github.com/gnu-mcu-eclipse/org.eclipse.epp.packages/releases/download/v4.5.1-20190101-2018-12/20190101-2023-gnumcueclipse-4.5.1-2018-12-R-linux.gtk.x86_64.tar.gz > 20190101-2023-gnumcueclipse-4.5.1-2018-12-R-linux.gtk.x86_64.tar.gz
curl -L https://github.com/open-isa-org/open-isa.org/releases/download/1.0.0/rv32m1_sdk_riscv_installer.sh > rv32m1_sdk_riscv_installer.sh
curl -L https://github.com/open-isa-org/open-isa.org/releases/download/1.0.0/Toolchain_Linux.tar.gz > Toolchain_Linux.tar.gz
curl -L https://github.com/riscv/riscv-ovpsim/archive/master.zip > riscv-ovpsim-master.zip
# Convert SDK shell script into the tar file -- this implictly accepts the license and extract to ./vega
ARCHIVE=$(awk '/^__ARCHIVE__/ {print NR + 1; exit 0; }' "rv32m1_sdk_riscv_installer.sh")
tail -n+${ARCHIVE} "rv32m1_sdk_riscv_installer.sh" | tar -xz > /dev/null 2>&1 || true
mkdir vega
(cd vega && tar xf ../rv32m1_sdk_riscv.tar.gz)
# Extract toolchain, takes two steps as there are archives in Toolchain_Linux.tar.gz)
mkdir toolchain
pushd toolchain
tar xf ../Toolchain_Linux.tar.gz # this makes tar files for next lines
tar xf riscv32-unknown-elf-gcc.tar.gz
rm riscv32-unknown-elf-gcc.tar.gz
tar xf openocd.tar.gz
rm openocd.tar.gz
popd
# Extract eclipse that includes GNU MCU plugins, eclipse executable will be ./eclipse/eclipse
tar xf 20190101-2023-gnumcueclipse-4.5.1-2018-12-R-linux.gtk.x86_64.tar.gz
# Set the toolchain defaults for GNU MCU plug-ins to what we just "installed"
mkdir -p eclipse/configuration/.settings/
# openocd location
echo "eclipse.preferences.version=1" > eclipse/configuration/.settings/ilg.gnumcueclipse.debug.gdbjtag.openocd.prefs
echo "install.folder=$PWD/toolchain" >> eclipse/configuration/.settings/ilg.gnumcueclipse.debug.gdbjtag.openocd.prefs
# gcc & friends location
echo "eclipse.preferences.version=1" > eclipse/configuration/.settings/ilg.gnumcueclipse.managedbuild.cross.riscv.prefs
# (magic number comes from https://github.com/gnu-mcu-eclipse/eclipse-plugins/blob/ce601cf2ec20cba90d9f2c2fbdb236b5fd7a6385/bundles/ilg.gnumcueclipse.managedbuild.cross.riscv/src/ilg/gnumcueclipse/managedbuild/cross/riscv/ToolchainDefinition.java#L30)
echo "toolchain.path.512258282=$PWD/pulp/riscv32-unknown-elf/bin" >> eclipse/configuration/.settings/ilg.gnumcueclipse.managedbuild.cross.riscv.prefs
# Setup RISC-V OVP Simulator
unzip riscv-ovpsim-master.zip
mv riscv-ovpsim-master riscv-ovpsim
# Optional, comment to preserve downloads
rm rv32m1_sdk_riscv.tar.gz 20190101-2023-gnumcueclipse-4.5.1-2018-12-R-linux.gtk.x86_64.tar.gz rv32m1_sdk_riscv_installer.sh Toolchain_Linux.tar.gz riscv-ovpsim-master.zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment