Establishment of MIPS-ELF-GCC cross-compilation environment

Source: Internet
Author: User
Tags bz2 mkdir

/**************************************************************************************

Mips-elf's cross compilation environment originates from an article in the network, but I can't find the source. At the same time, after my

Some modifications, and finally I successfully configured this cross compilation environment in Slackware 12.0 Linux. As for

Other versions of Linux I believe should be able to compile successfully, but I will be in other Linux as soon as possible

Verified, so as to facilitate everyone's reference. Please correct me for the deficiencies.

**************************************************************************************/

The following is steps to build cross compilers. So far, I tried a for PowerPC and MIPS.

Basically, all your have to do are to follow the following 9 steps. Download sources Set Environment variables build binutils builds bootstrap gcc build newlib builds gcc again with newlib GDB With PSIM Compile your code Run 1. What do you need?

Have to obtain the following source codes binutils Http://www.gnu.org/software/binutils/GCC http://www.gnu.org /software/gcc/gcc.html newlib Http://sources.redhat.com/newlib/GDB http://www.gnu.org/software/gdb/gdb.html 2. Set Environment Variables

Choose your taget such as Powerpc-eabi, Powerpc-elf, mips-elf, and so on

For bash simply type

% Export Target=powerpc-eabi
% Export prefix=/usr/local/$TARGET
% Export path= $PATH: $PREFIX/bin
3. Build Binutils
% tar xjfv binutils-2.17.tar.bz2
% mkdir build-binutils
% CD Build-binutils
% .. /binutils-2.17/configure--target= $TARGET--prefix= $PREFIX
% make all
% make Install
4. Build Bootstrap GCC
% tar xjfv gcc-4.1.1.tar.bz2
% mkdir BUILD-GCC
% CD BUILD-GCC
% .. /gcc-4.1.1/configure--target= $TARGET--prefix= $PREFIX--without-headers--with-newlib --with-gnu-as-- With-gnu-ld
% make ALL-GCC
% make INSTALL-GCC

--with-gnu-as--with-gnu-ld prevents native assembler on certain architectures. (For others, this does not have any effects) 5. Build Newlib

Newlib provides standard C library for embedded systems


% mkdir Build-newlib
% CD Build-newlib
% .. /newlib-1.14.0/configure--target= $TARGET--prefix= $PREFIX
% make all
% make Install
6. Build GCC again with Newlib
% CD BUILD-GCC
% .. /gcc-4.1.1/configure--target= $TARGET--prefix= $PREFIX--with-newlib--with-gnu-as--with-gnu-ld--disable-shared- Disable-libssp
% make all
% make Install
7. GDB with PSIM
% tar xjfv gdb-6.3.tar.bz2  
% mkdir Build-gdb
% CD Build-gdb
% .. /gdb-6.3/configure--target= $TARGET--prefix= $PREFIX--enable-sim-powerpc
--enable-sim-stdio
% make all
% make Install

congratulations! Build your tool chain 8. Compile Your code

Now, the IT ' s time to compile your code.

% powerpc-eabi-gcc-mcpu=405 Hello.c-o Hello-msim
% MIPS-ELF-GCC-TIDT.LD-MIPS4 Hello.c-o Hello

-T option specifies libraries that include start code.

To Compile with specific Memory map

% powerpc-eabi-gcc-wl,-ttext,0x4000,-tdata,0xf000 Hello.c-msim
(-wl,-ttext,0x4000,-tdata,0x10000)
9. Run
% Powerpc-eabi-run Hello
% Mips-elf-run Hello

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.