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

Subversion Repositories neorv32

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

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 72 zero_gravi
[IMPORTANT]
38
Make sure to use "newlib" as C standard library as the NEORV32 has no native support for Linus-like operating systems.
39 69 zero_gravi
 
40 72 zero_gravi
 
41 69 zero_gravi
:sectnums:
42
=== Downloading and Installing a Prebuilt Toolchain
43
 
44
Alternatively, you can download a prebuilt toolchain.
45
 
46
:sectnums:
47
==== Use The Toolchain I have Build
48
 
49
I have compiled a GCC toolchain on a 64-bit x86 Ubuntu (Ubuntu on Windows, actually) and uploaded it to
50
GitHub. You can directly download the according toolchain archive as single _zip-file_ within a packed
51
release from https://github.com/stnolting/riscv-gcc-prebuilt.
52
 
53
Unpack the downloaded toolchain archive and copy the content to a location in your file system (e.g.
54
`/opt/riscv`). More information about downloading and installing my prebuilt toolchains can be found in
55
the repository's README.
56
 
57
 
58
:sectnums:
59
==== Use a Third Party Toolchain
60
 
61
Of course you can also use any other prebuilt version of the toolchain. There are a lot  RISC-V GCC packages out there -
62
even for Windows. On Linux system you might even be able to fetch a toolchain via your distribution's package manager.
63
 
64
[IMPORTANT]
65
Make sure the toolchain can (also) emit code for a `rv32i` architecture, uses the `ilp32` or `ilp32e` ABI and **was not build** using
66
CPU extensions that are not supported by the NEORV32 (like `D`).
67
 
68
 
69
:sectnums:
70
=== Installation
71
 
72
Now you have the toolchain binaries. The last step is to add them to your `PATH` environment variable (if you have not
73
already done so): make sure to add the _binaries_ folder (`bin`) of your toolchain.
74
 
75
[source,bash]
76
----
77 71 zero_gravi
$ export PATH=$PATH:/opt/riscv/bin
78 69 zero_gravi
----
79
 
80
You should add this command to your `.bashrc` (if you are using bash) to automatically add the RISC-V
81
toolchain at every console start.
82
 
83
:sectnums:
84
=== Testing the Installation
85
 
86
To make sure everything works fine, navigate to an example project in the NEORV32 example folder and
87
execute the following command:
88
 
89
[source,bash]
90
----
91
neorv32/sw/example/blink_led$ make check
92
----
93
 
94
This will test all the tools required for generating NEORV32 executables.
95
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.