Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to build a toolchain for arm cortex-m and cortex-r
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on ARM
View previous topic :: View next topic  
Author Message
rapsure
Apprentice
Apprentice


Joined: 29 Apr 2004
Posts: 172
Location: Logan, UT USA

PostPosted: Thu Aug 30, 2018 5:01 am    Post subject: How to build a toolchain for arm cortex-m and cortex-r Reply with quote

So crossdev almost can build a functioning toolchain for embedded arm development. I do embedded arm development for my job so this is critical to have a fully functioning toolchain. Here is how to do it.

Step 1:
Code:
crossdev --lenv 'USE="nano -nls -threads -unicode"' -s3 -t arm-unknown-eabi


Step 2:
Code:
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:
Code:
emerge cross-arm-unknown-eabi/newlib


Step 4: to get gdb
Code:
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. Maybe someday these changes can be incorporated into crossdev.

Maybe make this a sticky. I took a lot of time to figure out all of the switches and the process.

With changes to toolchain.eclass as of August 2018 you will need to edit the file to disable --enable-float=soft

Change on line 1116:
Code:
        yes)   confgcc+=( --with-float=soft ) ;;

to
Code:
        yes)    ;;

_________________
:) Hindi ko naintindihan, pakiulit. Sometimes my code works.
Back to top
View user's profile Send private message
eugene-bright
n00b
n00b


Joined: 23 Sep 2018
Posts: 1

PostPosted: Sun Sep 23, 2018 8:26 pm    Post subject: eclass fix Reply with quote

Thanks for your post!
The eclass fix on it's way.
https://bugs.gentoo.org/666896
Back to top
View user's profile Send private message
KAMIKAZE_
Guru
Guru


Joined: 09 Oct 2003
Posts: 309
Location: Riga, Latvia

PostPosted: Wed Oct 03, 2018 1:38 am    Post subject: Reply with quote

After upgrading I've got my micropython firmware build failing with:

Quote:

CC build-PYBV11/pins_PYBV11.c
LINK build-PYBV11/firmware.elf
arm-none-eabi-ld: error: build-PYBV11/firmware.elf uses VFP register arguments, /usr/lib/gcc/arm-none-eabi/8.2.0/libgcc.a(_udivmoddi4.o) does not
arm-none-eabi-ld: failed to merge target specific data of file /usr/lib/gcc/arm-none-eabi/8.2.0/libgcc.a(_udivmoddi4.o)
make: *** [Makefile:528: build-PYBV11/firmware.elf] Error 1

_________________
-=[powered by Gentoo]=-
Back to top
View user's profile Send private message
rapsure
Apprentice
Apprentice


Joined: 29 Apr 2004
Posts: 172
Location: Logan, UT USA

PostPosted: Sat Oct 13, 2018 9:17 pm    Post subject: Reply with quote

Quote:
After upgrading I've got my micropython firmware build failing with:


That is because your comping with hardware fpu support and linking against a soft fpu gcc. The instuctions I gave above gives a multilib build of libc-nano and the smallest code size for a Cortex-M or Cortex-R.
_________________
:) Hindi ko naintindihan, pakiulit. Sometimes my code works.
Back to top
View user's profile Send private message
triffid_hunter
n00b
n00b


Joined: 31 Aug 2013
Posts: 8

PostPosted: Thu Sep 03, 2020 9:55 am    Post subject: Reply with quote

I've found that lots of modern toolchains want arm-none-eabi to have hardfp support, however by default, cross-arm-none-eabi/newlib won't make hardfp libraries but it can be convinced to build them with a configure flag - that means we can make a arm-none-eabi toolchain with -mfloat-abi=soft,softfp,and hard support with this command:

Code:
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-none-eabi


Note the added EXTRA_ECONF="--enable-newlib-hw-fp" under --lenv.
Back to top
View user's profile Send private message
rapsure
Apprentice
Apprentice


Joined: 29 Apr 2004
Posts: 172
Location: Logan, UT USA

PostPosted: Mon Jan 24, 2022 5:26 pm    Post subject: The instructions are functional Reply with quote

So I've use the above process to create binaries for the nrf51, and nrf52 and any Cortex-M... architecture. Never had a problem. I could even find compiler bugs by comparing between several different versions.
_________________
:) Hindi ko naintindihan, pakiulit. Sometimes my code works.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on ARM All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum