Crosstool-NG

From Linux/Xtensa
Revision as of 03:04, 19 November 2015 by Jcmvbkbc (talk | contribs) (update ct-ng status)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Overview

Crosstool-NG provides a system to build a complete toolchain. It supports various C-libraries (newlib, uClibc, glibc, and eglibc), but can also be used to build a toolchain without a C-library. The following paragraphs describe the steps to build a toolchain tailored for an Xtensa configuration.

Configure and build Crosstool-NG

Starting with release 1.22.0 the mainline crosstool-NG repository includes support for Xtensa. Using tip of the cloned git tree for work is not always a good idea, unless you need the latest mainline changes using official releases (marked by tags) would give more predictable results.

git clone https://github.com/crosstool-ng/crosstool-ng.git
git checkout crosstool-ng-1.22.0

Build ct-ng

ct-ng is similar to the command 'make' for other projects, and is used to configure and build the toolchain. Since we cloned it from the repository, its build system is not configured yet, use ./bootstrap script to create it:

./bootstrap

The next step is to configure ct-ng for your system. The default installation path is /usr/local/ but can be overwritten with the --prefix option. It is also possible to configure ct-ng for use without installation with --enable-local configure option:

./configure --enable-local

Finally, run 'make' to build ct-ng (and 'make install' to install it if needed):

make

Xtensa core overlay file

The overlay file includes patches for toolchain tools, such as compiler, assembler, and debugger, that are required to support a specific Xtensa processor configuration. Tensilica provides such an overlay as part of the processor download, however, it needs to be reformatted to match the specific format required by the crosstool-NG. For a script to convert the overlay file, and additional information, please go to Toolchain Overlay File. The current version of crosstool-NG requires that the overlay file name has the format xtensa_<CORE_NAME>.tar, where CORE_NAME can be any user selected name.

Building a 'bare' toolchain without a C-library

Configure the toolchain

The first step is to configure the toolchain:

./ct-ng menuconfig

Make the following changes (---> means to enter the sub-menu). We are assuming that the overlay tar image (xtensa_<CORE_NAME>.tar) has been copied to ABSOLUTE_PATH_TO_OVERLAY.

Target options  --->                                         
Target Architecture (xtensa) 
Target Architecture Variant (Custom Xtensa processor configuration)
(CORE_NAME) Custom Xtensa process configuration file name
(ABSOLUTE_PATH_TO_OVERLAY) Full path to custom Xtensa processor configurations  
C-library  --->                                              
C library (none)

The default directory for the created toolchain is $HOME/x-tools, but can be configured under 'Paths and misc options':

Paths and misc options  --->
(${HOME}/x-tools/${CT_TARGET}) Prefix directory

Build and install the toolchain

Finally, build and install the toolchain.

./ct-ng build

Test it

export PATH=$PATH:$HOME/x-tools/xtensa-unknown-linux-gnu/bin
xtensa-unknown-linux-gnu-gcc t.c

Building uClibc-ng based toolchain

Configure the toolchain

Similar to the 'bare' version above, the first step is to configure crosstool-NG. Simply run

./ct-ng menuconfig

and make the following changes (---> means to enter the sub-menu).

Paths and misc options --->
[*] Try features marked as EXPERIMENTAL
Target options  --->                                         
Target Architecture (xtensa) 
Target Architecture Variant (Custom Xtensa processor configuration)
(CORE_NAME) Custom Xtensa process configuration name
(ABSOLUTE_PATH_TO_OVERLAY) Full path to custom Xtensa processor configurations  
Operating system --->
Target OS (linux)
C-library  --->                                              
C library (uClibc)

Build and install the toolchain

Finally, build and install the toolchain.

./ct-ng build

Building a 'glibc' based toolchain (experimental)

NOTE THAT THE REPOSITORY IS CURRENTLY NOT AVAILABLE.

The glibc port is experimental at the moment and also not part of the main repository yet. A version for Xtensa can be found on linux-xtensa.org, so you can clone it from there:

git clone git://.../git/glibc

Configure the toolchain

Similar to the 'bare' version above, the first step is to configure crosstool-NG. Simply run

./ct-ng menuconfig

and make the following changes (---> means to enter the sub-menu).

Paths and misc options --->
[*] Try features marked as EXPERIMENTAL
Target options  --->                                         
Target Architecture (xtensa) 
Target Architecture Variant (Custom Xtensa processor configuration)
(CORE_NAME) Custom Xtensa process configuration name
(ABSOLUTE_PATH_TO_OVERLAY) Full path to custom Xtensa processor configurations  
C-library  --->                                              
C library (glibc)
glibc version (Custom glibc)
(ABSOLUTE_PATH_TO_glibc-2.17) Full path to custom glibc source
(ports) Extra addons

Build and install the toolchain

Finally, build and install the toolchain.

./ct-ng build