Compiling cross-compilation environments with Crosstool-ng automation (RPM)

Source: Internet
Author: User

Original address: http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi/

A cross compiler are a compiler that runs on one platform/architecture but generates binaries for another Platform/architec Ture. With devices like the Raspberry Pi, where you really don't have much CPU or memory to work with, if you ' re doing any heavy Compiling (like when working on the kernel) a cross compiler is the only-to go. For example, I-Build all my Raspberry Pi kernels on my nice Sandy Bridge Xeon E3 Home Server where they compile in only a Fraction of the time they would on the Pi.

While there was a lot of different methods for building cross-compilers, by far the quickest and easiest was to use Crossto Ol-ng. This was a set of scripts that bring up a menuconfig-like interface to choose your compiler settings, then goes off and Dow Nloads What it needs, patches it, configures it, builds it and installs it all for you. Here's how to get started:

    1. Download Crosstool-ng from the Project Web site. I ' ve used version 1.15.2 as that is the latest when I wrote this.
    2. Unpack cd the tarball and into the unpacked directory, then run ./configure --prefix=/opt/cross . You can pick somewhere else instead of the /opt/cross where I like to keep it.
    3. Run make and sudo make install .
    4. Make sure are in /opt/cross/bin your $PATH .

Right, so the ' s crosstool-ng installed and ready to build a toolchain for you. Next, to actually create your Raspberry Pi toolchain:

  1. Create a directory somewhere in your home directory that crosstool-ng would use as a staging ground. This would contain your toolchain configuration, downloaded files, and intermediary build results. This is not where your final toolchain would end up, and does take up quite a lot of space (3.5GB and up for me). into cd your chosen directory.
  2. Run ct-ng menuconfig . You should see the Ct-ng configuration menu.
  3. Go into Paths and misc options. Enable Try features marked as experimental. This is important.
  4. While you ' re there the want to change your Prefix directory. I like to put all my toolchains in /opt/cross/x-tools/${CT_TARGET} instead of ${HOME}/x-tools/${CT_TARGET} .
  5. Go back to the main menu and select Target options.
  6. Change of the Target architecture to arm. Leave Endianness set to Little endian and bitness set to 32-bit.
  7. Go back to the main menu and select Operating system (Skip toolchain options, the defaults is fine) .
  8. Change Target OS to Linux.
  9. Go back to the main menu and select Binary utilities.
  10. Change binutils version to 2.21.1a or whichever are the latest that isn ' t marked as experimental. Probably unnecessary but I prefer this.
  11. Go back to the main menu and select C compiler.
  12. Enable the Show Linaro versions (experimental) option.
  13. In the GCC version field, choose the linaro-4.6-2012.04 (experimental) compiler. You ' re free to choose a different one but I know the one works well. I do recommend the Linaro versions over the vanilla ones for the RPi.
  14. All the other settings is fine left at their default values. Exit the Configuration tool and save your changes.
  15. Run ct-ng build .
  16. Go away and make a coffee, etc ... This bit would take some time.
  17. You should end to with a freshly baked arm compiler ready for building kernels (and other things) for your Raspberry Pi in Your Prefix directory you chose above.
  18. Just add your compiler directory to your and $PATH start compiling. If you used my preferred prefix directory, you would want to add /opt/cross/x-tools/arm-unknown-linux-gnueabi/bin .

Compiling cross-compilation environments with Crosstool-ng automation (RPM)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.