ARM AArch64

Guide for users with ARM computers

Linux VM Setup

This guide assumes that you have already setup your Linux environment and are already in it. If you haven't set it up already, we recommend using UTM to do so.

Get UTM

Compiling the entire toolchain yourself might take a long time, as well as a large amount of space, so we have prepared a precompiled version of it here.

Step 1: Download the zipped toolchain

Download Compiled RISC-V GNU-Toolchain for Linux-AArch64

You can either download this on your host OS (macOS) and SCP it to your guest OS (Linux), or directly download it from inside the guest OS which is more convenient.

Running this command in your terminal will download the file to the directory that you are currently in. By default, the terminal will open in your home directory, which is where the rest of this guide assumes you will place the downloaded file.

Invoking the cd command without any arguments will bring you to your user's home directory if you are not in it.

Step 2: Unzip toolchain

Step 3: Add binaries to PATH

After exporting the PATH to the binaries, you will be able to use all the tools inside the riscv64-unknown-elf/bin folder. To use the cross-compiler, simply call riscv64-unknown-elf-gcc.

Note that without completing step 4, you will need to export the PATH (step 3) every time you start a new terminal session.

Step 4: Place PATH in ~/.bashrc (Optional)

  1. Adding the PATH to your ~/.<shell>rc file automatically invokes the command for you on every startup.

As there are many shells in use, you may need to change the <shell> to the one you are using. In this guide, we assume that you are using bash as it is the default for most Linux Distributions.

  1. To edit the ~/.bashrc you can use any editor you want, but terminal editors like nano or vi are the most convenient.

  1. After invoking the command above, simply add the export command shown in step 3 to a new line in the .bashrc file.

2. Compiling Your Own Toolchain (Advanced)

Step 1: Clone the RISC-V GNU Toolchain

Step 2: Install prerequisites

You will need to install some prerequisites for the build process. Different Linux distros have different package managers, so we will provide separate commands. You only need to run the one for your distro.

Debian/Ubuntu

Fedora/CentOS/RHEL

Arch

Step 3: Build Toolchain

Step 4: Add binaries to PATH

Step 5: Place PATH in ~/.<shell>rc (Optional)

You can follow the same steps as in the Precompiled Toolchain Step 4

3. Using your cross-compiler

You can invoke this command to compile for RISC-V

Last updated

Was this helpful?