OpenCores
URL https://opencores.org/ocsvn/neorv32/neorv32/trunk

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [docs/] [userguide/] [sw_toolchain_setup.adoc] - Diff between revs 71 and 72

Only display areas with differences | Details | Blame | View Log

Rev 71 Rev 72
<<<
<<<
:sectnums:
:sectnums:
== Software Toolchain Setup
== Software Toolchain Setup
To compile (and debug) executables for the NEORV32 a RISC-V toolchain is required.
To compile (and debug) executables for the NEORV32 a RISC-V toolchain is required.
There are two possibilities to get this:
There are two possibilities to get this:
1. Download and _build_ the official RISC-V GNU toolchain yourself.
1. Download and _build_ the official RISC-V GNU toolchain yourself.
2. Download and install a prebuilt version of the toolchain; this might also done via the package manager / app store of your OS
2. Download and install a prebuilt version of the toolchain; this might also done via the package manager / app store of your OS
[NOTE]
[NOTE]
The default toolchain prefix (`RISCV_PREFIX` variable) for this project is **`riscv32-unknown-elf-`**. Of course you can use any other RISC-V
The default toolchain prefix (`RISCV_PREFIX` variable) for this project is **`riscv32-unknown-elf-`**. Of course you can use any other RISC-V
toolchain (like `riscv64-unknown-elf-`) that is capable to emit code for a `rv32` architecture. Just change `RISCV_PREFIX`
toolchain (like `riscv64-unknown-elf-`) that is capable to emit code for a `rv32` architecture. Just change `RISCV_PREFIX`
according to your needs.
according to your needs.
:sectnums:
:sectnums:
=== Building the Toolchain from Scratch
=== Building the Toolchain from Scratch
To build the toolchain by yourself you can follow the guide from the official https://github.com/riscv-collab/riscv-gnu-toolchain GitHub page.
To build the toolchain by yourself you can follow the guide from the official https://github.com/riscv-collab/riscv-gnu-toolchain GitHub page.
You need to make sure the generated toolchain fits the architecture of the NEORV32 core. To get a toolchain that even supports minimal
You need to make sure the generated toolchain fits the architecture of the NEORV32 core. To get a toolchain that even supports minimal
ISA extension configurations, it is recommend to compile for `rv32i` only. Please note that this minimal ISA also provides further ISA
ISA extension configurations, it is recommend to compile for `rv32i` only. Please note that this minimal ISA also provides further ISA
extensions like `m` or `c`. Of course you can use a _multilib_ approach to generate toolchains for several target ISAs at once.
extensions like `m` or `c`. Of course you can use a _multilib_ approach to generate toolchains for several target ISAs at once.
.Configuring GCC build for `rv32i` (minimal ISA)
.Configuring GCC build for `rv32i` (minimal ISA)
[source,bash]
[source,bash]
----
----
riscv-gnu-toolchain$ ./configure --prefix=/opt/riscv --with-arch=rv32i --with-abi=ilp32
riscv-gnu-toolchain$ ./configure --prefix=/opt/riscv --with-arch=rv32i --with-abi=ilp32
riscv-gnu-toolchain$ make
riscv-gnu-toolchain$ make
----
----
[IMPORTANT]
[IMPORTANT]
Keep in mind that - for instance - a toolchain build with `--with-arch=rv32imc` only provides library code compiled with
Keep in mind that - for instance - a toolchain build with `--with-arch=rv32imc` only provides library code compiled with
compressed (`C`) and `mul`/`div` instructions (`M`)! Hence, this code cannot be executed (without
compressed (`C`) and `mul`/`div` instructions (`M`)! Hence, this code cannot be executed (without
emulation) on an architecture without these extensions!
emulation) on an architecture without these extensions!
 
 
 
[IMPORTANT]
 
Make sure to use "newlib" as C standard library as the NEORV32 has no native support for Linus-like operating systems.
 
 
 
 
:sectnums:
:sectnums:
=== Downloading and Installing a Prebuilt Toolchain
=== Downloading and Installing a Prebuilt Toolchain
Alternatively, you can download a prebuilt toolchain.
Alternatively, you can download a prebuilt toolchain.
:sectnums:
:sectnums:
==== Use The Toolchain I have Build
==== Use The Toolchain I have Build
I have compiled a GCC toolchain on a 64-bit x86 Ubuntu (Ubuntu on Windows, actually) and uploaded it to
I have compiled a GCC toolchain on a 64-bit x86 Ubuntu (Ubuntu on Windows, actually) and uploaded it to
GitHub. You can directly download the according toolchain archive as single _zip-file_ within a packed
GitHub. You can directly download the according toolchain archive as single _zip-file_ within a packed
release from https://github.com/stnolting/riscv-gcc-prebuilt.
release from https://github.com/stnolting/riscv-gcc-prebuilt.
Unpack the downloaded toolchain archive and copy the content to a location in your file system (e.g.
Unpack the downloaded toolchain archive and copy the content to a location in your file system (e.g.
`/opt/riscv`). More information about downloading and installing my prebuilt toolchains can be found in
`/opt/riscv`). More information about downloading and installing my prebuilt toolchains can be found in
the repository's README.
the repository's README.
:sectnums:
:sectnums:
==== Use a Third Party Toolchain
==== Use a Third Party Toolchain
Of course you can also use any other prebuilt version of the toolchain. There are a lot  RISC-V GCC packages out there -
Of course you can also use any other prebuilt version of the toolchain. There are a lot  RISC-V GCC packages out there -
even for Windows. On Linux system you might even be able to fetch a toolchain via your distribution's package manager.
even for Windows. On Linux system you might even be able to fetch a toolchain via your distribution's package manager.
[IMPORTANT]
[IMPORTANT]
Make sure the toolchain can (also) emit code for a `rv32i` architecture, uses the `ilp32` or `ilp32e` ABI and **was not build** using
Make sure the toolchain can (also) emit code for a `rv32i` architecture, uses the `ilp32` or `ilp32e` ABI and **was not build** using
CPU extensions that are not supported by the NEORV32 (like `D`).
CPU extensions that are not supported by the NEORV32 (like `D`).
:sectnums:
:sectnums:
=== Installation
=== Installation
Now you have the toolchain binaries. The last step is to add them to your `PATH` environment variable (if you have not
Now you have the toolchain binaries. The last step is to add them to your `PATH` environment variable (if you have not
already done so): make sure to add the _binaries_ folder (`bin`) of your toolchain.
already done so): make sure to add the _binaries_ folder (`bin`) of your toolchain.
[source,bash]
[source,bash]
----
----
$ export PATH=$PATH:/opt/riscv/bin
$ export PATH=$PATH:/opt/riscv/bin
----
----
You should add this command to your `.bashrc` (if you are using bash) to automatically add the RISC-V
You should add this command to your `.bashrc` (if you are using bash) to automatically add the RISC-V
toolchain at every console start.
toolchain at every console start.
:sectnums:
:sectnums:
=== Testing the Installation
=== Testing the Installation
To make sure everything works fine, navigate to an example project in the NEORV32 example folder and
To make sure everything works fine, navigate to an example project in the NEORV32 example folder and
execute the following command:
execute the following command:
[source,bash]
[source,bash]
----
----
neorv32/sw/example/blink_led$ make check
neorv32/sw/example/blink_led$ make check
----
----
This will test all the tools required for generating NEORV32 executables.
This will test all the tools required for generating NEORV32 executables.
Everything is working fine if `Toolchain check OK` appears at the end.
Everything is working fine if `Toolchain check OK` appears at the end.
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.