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

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [docs/] [userguide/] [sw_toolchain_setup.adoc] - Blame information for rev 71

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 69 zero_gravi
<<<
2
:sectnums:
3
== Software Toolchain Setup
4
 
5
To compile (and debug) executables for the NEORV32 a RISC-V toolchain is required.
6
There are two possibilities to get this:
7
 
8
1. Download and _build_ the official RISC-V GNU toolchain yourself.
9
2. Download and install a prebuilt version of the toolchain; this might also done via the package manager / app store of your OS
10
 
11
[NOTE]
12
The default toolchain prefix (`RISCV_PREFIX` variable) for this project is **`riscv32-unknown-elf-`**. Of course you can use any other RISC-V
13
toolchain (like `riscv64-unknown-elf-`) that is capable to emit code for a `rv32` architecture. Just change `RISCV_PREFIX`
14
according to your needs.
15
 
16
 
17
:sectnums:
18
=== Building the Toolchain from Scratch
19
 
20
To build the toolchain by yourself you can follow the guide from the official https://github.com/riscv-collab/riscv-gnu-toolchain GitHub page.
21
You need to make sure the generated toolchain fits the architecture of the NEORV32 core. To get a toolchain that even supports minimal
22
ISA extension configurations, it is recommend to compile for `rv32i` only. Please note that this minimal ISA also provides further ISA
23
extensions like `m` or `c`. Of course you can use a _multilib_ approach to generate toolchains for several target ISAs at once.
24
 
25
.Configuring GCC build for `rv32i` (minimal ISA)
26
[source,bash]
27
----
28
riscv-gnu-toolchain$ ./configure --prefix=/opt/riscv --with-arch=rv32i --with-abi=ilp32
29
riscv-gnu-toolchain$ make
30
----
31
 
32
[IMPORTANT]
33
Keep in mind that - for instance - a toolchain build with `--with-arch=rv32imc` only provides library code compiled with
34
compressed (`C`) and `mul`/`div` instructions (`M`)! Hence, this code cannot be executed (without
35
emulation) on an architecture without these extensions!
36
 
37
 
38
:sectnums:
39
=== Downloading and Installing a Prebuilt Toolchain
40
 
41
Alternatively, you can download a prebuilt toolchain.
42
 
43
:sectnums:
44
==== Use The Toolchain I have Build
45
 
46
I have compiled a GCC toolchain on a 64-bit x86 Ubuntu (Ubuntu on Windows, actually) and uploaded it to
47
GitHub. You can directly download the according toolchain archive as single _zip-file_ within a packed
48
release from https://github.com/stnolting/riscv-gcc-prebuilt.
49
 
50
Unpack the downloaded toolchain archive and copy the content to a location in your file system (e.g.
51
`/opt/riscv`). More information about downloading and installing my prebuilt toolchains can be found in
52
the repository's README.
53
 
54
 
55
:sectnums:
56
==== Use a Third Party Toolchain
57
 
58
Of course you can also use any other prebuilt version of the toolchain. There are a lot  RISC-V GCC packages out there -
59
even for Windows. On Linux system you might even be able to fetch a toolchain via your distribution's package manager.
60
 
61
[IMPORTANT]
62
Make sure the toolchain can (also) emit code for a `rv32i` architecture, uses the `ilp32` or `ilp32e` ABI and **was not build** using
63
CPU extensions that are not supported by the NEORV32 (like `D`).
64
 
65
 
66
:sectnums:
67
=== Installation
68
 
69
Now you have the toolchain binaries. The last step is to add them to your `PATH` environment variable (if you have not
70
already done so): make sure to add the _binaries_ folder (`bin`) of your toolchain.
71
 
72
[source,bash]
73
----
74 71 zero_gravi
$ export PATH=$PATH:/opt/riscv/bin
75 69 zero_gravi
----
76
 
77
You should add this command to your `.bashrc` (if you are using bash) to automatically add the RISC-V
78
toolchain at every console start.
79
 
80
:sectnums:
81
=== Testing the Installation
82
 
83
To make sure everything works fine, navigate to an example project in the NEORV32 example folder and
84
execute the following command:
85
 
86
[source,bash]
87
----
88
neorv32/sw/example/blink_led$ make check
89
----
90
 
91
This will test all the tools required for generating NEORV32 executables.
92
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.