How to build a toolchain for arm cortex-m and cortex-r

From Gentoo Wiki
Jump to:navigation Jump to:search
This article has been flagged for not conforming to the wiki guidelines. Please help Gentoo out by starting fixing things.
This article is a stub. Please help out by expanding it - how to get started.

For up to date information on ARM toolchain building (also for Cortex-R and Cortex-M), please review the main ARM article.

Toolchain installation steps

Crossdev can almost build a functioning toolchain for embedded arm development. The toolchain can be created with the following steps:

Step 1:

root #crossdev --lenv 'USE="nano -nls -threads -unicode"' -s3 -t arm-unknown-eabi

Step 2:

root #crossdev --lenv 'USE="nano -nls -threads -unicode"' --genv 'USE="cxx -nls -nptl -pch -pie -ssp" EXTRA_ECONF="--with-multilib-list=rmprofile --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-shared --disable-threads --disable-tls"' -s4 -t arm-unknown-eabi

Step 3:

root #emerge --ask cross-arm-unknown-eabi/newlib

Step 4:

root #crossdev --lenv 'USE="nano -nls -threads -unicode"' --genv 'USE="cxx -nls -nptl -pch -pie -ssp" EXTRA_ECONF="--with-multilib-list=rmprofile --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-shared --disable-threads --disable-tls"' -s4 --ex-gdb -t arm-unknown-eabi

Now you'll have a functioning multilib / multiarch for embedded arm development with small code output size.

Big thanks to the Gentoo forum user rapsure who posted this instructions here.

Toolchain installation steps with hardware floating point

You may also want the toolchain to contain support for hardware floating point. In that case, use these instructions instead:

Step 1:

root #crossdev --lenv 'USE="nano -nls -threads -unicode"' -s3 -t arm-unknown-eabi

Step 2:

root #crossdev --lenv 'USE="nano -nls -threads -unicode"' --genv 'USE="cxx -nls -nptl -pch -pie -ssp" EXTRA_ECONF="--with-multilib-list=rmprofile --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-shared --disable-threads --disable-tls"' -s4 -t arm-unknown-eabi

Step 3:

root #emerge --ask cross-arm-unknown-eabi/newlib

Step 4:

root #crossdev --lenv 'USE="nano -nls -threads -unicode" EXTRA_ECONF="--enable-newlib-hw-fp"' --genv 'USE="cxx -nls -nptl -pch -pie -ssp" EXTRA_ECONF="--with-multilib-list=rmprofile --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-shared --disable-threads --disable-tls"' -s4 --ex-gdb -t arm-unknown-eabi
Note
I left the toolchain named arm-unknown-eabi because it is what the instructions previously used, but in my experience most IDEs expect the naming convention to be arm-none-eabi. It's perfectly alright to use these instructions with arm-none-eabi instead of arm-unknown-eabi for convenience.