NOEL-ARTYA7-EX-QSG
December 2020, Version 1.2
19
www.cobhamaes.com/gaisler
6. Bare-metal cross-compiler
6.1. Overview
The Bare C Cross-Compiler (NCC) is a GNU-based cross-compilation system for NOEL-V processors. It allows
cross-compilation of C and C++ single-threaded applications. This section gives the reader a brief introduction
on how to use NCC together with the NOEL-ARTYA7-EX design. It will be demonstrated how to build an an
example program and run it on the NOEL-ARTYA7-EX using GRMON.
The NCC toolchain includes the GNU C/C++ cross-compiler 10.2.0, GNU Binutils, Newlib embedded C library,
the Bare-C run-time system with NOEL-V support and the GNU debugger (GDB). The toolchain can be down-
loaded from [RD-1] and is available for Linux host.
6.2. Installation
Extract the toolchain and add the
bin
directory to
PATH
. For example:
$ cd /opt
$ tar xf ncc-1.0.0-gcc.tar.bz2
$ PATH="$PATH:/opt/ncc-1.0.0-gcc/bin"
The rest of this chapter assumes that the toolchain has been installed and that riscv-gaisler-elf-gcc is available
in the
PATH
environment variable.
6.3. Compiling with NCC
The following command shows an example of how to compile a typical hello, world program with NCC.
$ cat hello.c
#include <stdio.h>
int main(void)
{
printf("hello, world\n");
return 0;
}
$ riscv-gaisler-elf-gcc -O2 -g hello.c -o hello.elf
It creates a program with the following characteristics:
• RV64IM instruction set
• linked to address
0
.
• UART, TIMER, PLIC is probed using AMBA Plug&Play.
To build the same example targeting a 32-bit NOEL-V processor, use:
$ riscv-gaisler-elf-gcc -march=rv32im -mabi=ilp32 -O2 -g hello.c -o hello.elf
6.4. Compiler options
All GCC options are described in the gcc manual. Some of the most common options are:
Table 6.1. NCC's GCC compiler relevant options
-g
generate debugging information - recommended for debugging with GDB
-march=
Selects instruction set for code generation. See Section 6.5.
-mabi=
Select ABI.
-O2
optimize for speed
-Os
optimize for size
-Og
optimize for debugging experience
6.5. Multilibs
The available multilibs are: