Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Architectures & Platforms Gentoo on ARM
  • Search

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

Gentoo on all things ARM. Both 32 bit and 64 bit.
Tell about your hardware and CHOST.
Problems with crossdev targeting ARM hardware go here too.
Post Reply
  • Print view
Advanced search
6 posts • Page 1 of 1
Author
Message
rapsure
Apprentice
Apprentice
User avatar
Posts: 172
Joined: Thu Apr 29, 2004 9:59 pm
Location: Logan, UT USA
Contact:
Contact rapsure
Website

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

  • Quote

Post by rapsure » Thu Aug 30, 2018 5:01 am

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: Select all

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

Code: Select all

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: Select all

emerge cross-arm-unknown-eabi/newlib
Step 4: to get gdb

Code: Select all

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: Select all

        yes)   confgcc+=( --with-float=soft ) ;;
to

Code: Select all

        yes)    ;;
:) Hindi ko naintindihan, pakiulit. Sometimes my code works.
Top
eugene-bright
n00b
n00b
Posts: 2
Joined: Sun Sep 23, 2018 6:34 pm

eclass fix

  • Quote

Post by eugene-bright » Sun Sep 23, 2018 8:26 pm

Thanks for your post!
The eclass fix on it's way.
https://bugs.gentoo.org/666896
Top
KAMIKAZE_
Guru
Guru
Posts: 309
Joined: Thu Oct 09, 2003 3:56 pm
Location: Riga, Latvia
Contact:
Contact KAMIKAZE_
Website

  • Quote

Post by KAMIKAZE_ » Wed Oct 03, 2018 1:38 am

After upgrading I've got my micropython firmware build failing with:
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]=-
Top
rapsure
Apprentice
Apprentice
User avatar
Posts: 172
Joined: Thu Apr 29, 2004 9:59 pm
Location: Logan, UT USA
Contact:
Contact rapsure
Website

  • Quote

Post by rapsure » Sat Oct 13, 2018 9:17 pm

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.
Top
triffid_hunter
n00b
n00b
Posts: 8
Joined: Sat Aug 31, 2013 8:38 am

  • Quote

Post by triffid_hunter » Thu Sep 03, 2020 9:55 am

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: Select all

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.
Top
rapsure
Apprentice
Apprentice
User avatar
Posts: 172
Joined: Thu Apr 29, 2004 9:59 pm
Location: Logan, UT USA
Contact:
Contact rapsure
Website

The instructions are functional

  • Quote

Post by rapsure » Mon Jan 24, 2022 5:26 pm

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.
Top
Post Reply
  • Print view

6 posts • Page 1 of 1

Return to “Gentoo on ARM”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic