OpenCores
Issue List
linux mips-elf toolchain build script .. Success on Fedora 12 64bit Cross Compile #12
Open moodz opened this issue about 14 years ago
moodz commented about 14 years ago

#!/bin/bash GCC_VER="gcc-4.0.2" BINUTILS_VER="binutils-2.16.1" GDB_VER="gdb-6.6" INSIGHT_VER="insight-6.6" TARGET="mips" INSTALL_DIR=$HOME/mips_toolchain

CFLAGS="-g -O2 -mabi=32" ASFLAGS=$CFLAGS

export PATH=$PATH:$INSTALL_DIR rm -fr $INSTALL_DIR/* mkdir $INSTALL_DIR/build mkdir $INSTALL_DIR/src

cd $INSTALL_DIR/src echo Downloading $BINUTILS_VER wget http://ftp.gnu.org/pub/gnu/binutils/$BINUTILS_VER.tar.bz2 echo Uncompressing $BINUTILS_VER tar xvfj $BINUTILS_VER.tar.bz2 > /dev/null mv $BINUTILS_VER $INSTALL_DIR/build/$BINUTILS_VER

cd $INSTALL_DIR/build/$BINUTILS_VER ./configure --prefix=$INSTALL_DIR --target=$TARGET-elf make make install

#the mips binutils now created so export the mips-elf bin path export PATH=$PATH:$INSTALL_DIR/bin

cd $INSTALL_DIR/src echo Downloading $GCC_VER wget http://ftp.gnu.org/pub/gnu/gcc/$GCC_VER/$GCC_VER.tar.bz2

echo Uncompressing $GCC_VER tar xvfj $GCC_VER.tar.bz2 > /dev/null mv $GCC_VER $INSTALL_DIR/build/$GCC_VER

cd $INSTALL_DIR/build ./$GCC_VER/configure --prefix=$INSTALL_DIR --target=$TARGET-elf --enable-languages=c make make install

cd $INSTALL_DIR/src echo Downloading $GDB_VER wget http://ftp.gnu.org/pub/gnu/gdb/$GDB_VER.tar.bz2

echo Uncompressing gdb tar xvfj $GDB_VER.tar.bz2 > /dev/null mv $GDB_VER $INSTALL_DIR/build/$GDB_VER

cd $INSTALL_DIR/build/$GDB_VER ./configure --prefix=$INSTALL_DIR --target=$TARGET-elf make make install

cd $INSTALL_DIR/src echo Downloading $INSIGHT_VER wget http://mirrors.kernel.org/sources.redhat.com/insight/releases/$INSIGHT_VER.tar.bz2

echo Uncompressing insight-gdb tar xvfj $INSIGHT_VER.tar.bz2 > /dev/null mv $INSIGHT_VER $INSTALL_DIR/build/$INSIGHT_VER

cd $INSTALL_DIR/build/$INSIGHT_VER ./configure --prefix=$INSTALL_DIR --target=$TARGET-elf make make install

cd $HOME tar -zcvf mips_toolchain.tgz ./mips_toolchain

moodz commented about 14 years ago

this script puts the tools in $HOME/mips_toolchain/bin so modify the plasma tools Makefile to point at this location.

moodz commented about 14 years ago

moodz@hitmouse tools$ make bootldr /home/moodz/mips_toolchain/bin/mips-elf-as -o boot.o boot.asm /home/moodz/mips_toolchain/bin/mips-elf-gcc -O2 -Wall -c -s bootldr.c /home/moodz/mips_toolchain/bin/mips-elf-gcc -O2 -Wall -c -s no_os.c /home/moodz/mips_toolchain/bin/mips-elf-gcc -O2 -Wall -c -s -DDLL_DISABLE ddr_init.c /home/moodz/mips_toolchain/bin/mips-elf-ld -Ttext 0 -eentry -Map test.map -s -N -o test.axf \ boot.o bootldr.o no_os.o ddr_init.o ./convert_bin.exe test.axf -> code.txt & test.bin Entry=0x0 length=3340=0xd0c cp code.txt ../vhdl Next do make toimage for Xilinx or make tohex for Altera.

<<<<<<<<< got rid of those ld PIC errors ... woohoo !!>>>>>>

moodz commented about 14 years ago

bootldr builds OK .... :-)

Greetings from the bootloader Feb 23 2010 09:57:59:

Waiting for binary image linked at 0x10000000 Other Menu Options: 1. Memory read word 2. Memory write word 3. Memory read byte 4. Memory write byte 5. Jump to address 6. Raw memory read 7. Raw memory write 8. Checksum 9. Dump F. Copy 128KB from DDR to flash

theshadowx commented about 14 years ago

hi Paul thanks for your script, i've tried it in ubuntu 9.04 32bits, but unfortunately it doesn't work, in the folder mips_toolchain/bin/ i don't have mips-elf-gcc

i have just : mips_toolchain/bin/mips-elf-addr2line mips_toolchain/bin/mips-elf-ar mips_toolchain/bin/mips-elf-as mips_toolchain/bin/mips-elf-c++filt mips_toolchain/bin/mips-elf-ld mips_toolchain/bin/mips-elf-nm mips_toolchain/bin/mips-elf-objcopy mips_toolchain/bin/mips-elf-objdump mips_toolchain/bin/mips-elf-ranlib mips_toolchain/bin/mips-elf-readelf mips_toolchain/bin/mips-elf-size mips_toolchain/bin/mips-elf-strings mips_toolchain/bin/mips-elf-strip mips_toolchain/bin/tclsh8.4

during the compilation of the script there was no error

so what should i do?

thanks

moodz commented about 14 years ago

Hi Ali, your gcc may not have built if the gcc you are building with cannot find the path to the elf executables. Put an exit command just after the following lines in the script

cd $INSTALL_DIR/build ./$GCC_VER/configure --prefix=$INSTALL_DIR --target=$TARGET-elf --enable-languages=c make make install exit

This will stop the script just after gcc make and install. Examine the output to see if gcc appears to build and install OK. There could be something wrong with the path. Unfortunately I dont do error checking so the script will continue even if there is an error in one of the stages. Let me know how you go.

theshadowx commented about 14 years ago

thanks Paul for your respond

here what I got at the end off gcc but i dont know what should I do correct it

gcc -g -O2 -DIN_GCC -DCROSS_COMPILE -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long -Wno-variadic-macros -Wold-style-definition -DHAVE_CONFIG_H -I. -I. -I.././gcc-4.0.2/gcc -I.././gcc-4.0.2/gcc/. -I.././gcc-4.0.2/gcc/../include -I.././gcc-4.0.2/gcc/../libcpp/include \ -DTARGET_MACHINE=\"mips-elf\" \ -c .././gcc-4.0.2/gcc/collect2.c -o collect2.o In function ‘open’, inlined from ‘collect_execute’ at .././gcc-4.0.2/gcc/collect2.c:1580: /usr/include/bits/fcntl2.h:51: erreur: call to ‘open_missing_mode’ declared with attribute error: open with O_CREAT in second argument needs 3 arguments make1: collect2.o Erreur 1 make1: quittant le rĂ©pertoire « /home/theshadowx/workspace/mips_toolchain/build/gcc » make: all-gcc Erreur 2 /bin/sh ./gcc-4.0.2/mkinstalldirs /home/theshadowx/workspace/mips_toolchain /home/theshadowx/workspace/mips_toolchain make1: entrant dans le rĂ©pertoire « /home/theshadowx/workspace/mips_toolchain/build/fixincludes » rm -rf /home/theshadowx/workspace/mips_toolchain/libexec/gcc/mips-elf/4.0.2/install-tools /bin/sh .././gcc-4.0.2/fixincludes/../mkinstalldirs /home/theshadowx/workspace/mips_toolchain/libexec/gcc/mips-elf/4.0.2/install-tools mkdir -p -- /home/theshadowx/workspace/mips_toolchain/libexec/gcc/mips-elf/4.0.2/install-tools /bin/sh .././gcc-4.0.2/fixincludes/../mkinstalldirs /home/theshadowx/workspace/mips_toolchain/lib/gcc/mips-elf/4.0.2/install-tools/include mkdir -p -- /home/theshadowx/workspace/mips_toolchain/lib/gcc/mips-elf/4.0.2/install-tools/include /usr/bin/install -c -m 644 .././gcc-4.0.2/fixincludes/README-fixinc \ /home/theshadowx/workspace/mips_toolchain/lib/gcc/mips-elf/4.0.2/install-tools/include/README /usr/bin/install -c fixinc.sh /home/theshadowx/workspace/mips_toolchain/libexec/gcc/mips-elf/4.0.2/install-tools/fixinc.sh /usr/bin/install -c fixincl \ /home/theshadowx/workspace/mips_toolchain/libexec/gcc/mips-elf/4.0.2/install-tools/fixincl /usr/bin/install -c mkheaders /home/theshadowx/workspace/mips_toolchain/libexec/gcc/mips-elf/4.0.2/install-tools/mkheaders make1: quittant le rĂ©pertoire « /home/theshadowx/workspace/mips_toolchain/build/fixincludes » make1: entrant dans le rĂ©pertoire « /home/theshadowx/workspace/mips_toolchain/build/gcc » gcc -g -O2 -DIN_GCC -DCROSS_COMPILE -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long -Wno-variadic-macros -Wold-style-definition -DHAVE_CONFIG_H -I. -I. -I.././gcc-4.0.2/gcc -I.././gcc-4.0.2/gcc/. -I.././gcc-4.0.2/gcc/../include -I.././gcc-4.0.2/gcc/../libcpp/include \ -DTARGET_MACHINE=\"mips-elf\" \ -c .././gcc-4.0.2/gcc/collect2.c -o collect2.o In function ‘open’, inlined from ‘collect_execute’ at .././gcc-4.0.2/gcc/collect2.c:1580: /usr/include/bits/fcntl2.h:51: erreur: call to ‘open_missing_mode’ declared with attribute error: open with O_CREAT in second argument needs 3 arguments make1: collect2.o Erreur 1 make1: quittant le rĂ©pertoire « /home/theshadowx/workspace/mips_toolchain/build/gcc » make: install-gcc Erreur 2

moodz commented about 14 years ago

Your problem is a Ubuntu GCC issue .... see here

https://wiki.kubuntu.org/CompilerFlags

Apparently the solution is to remove the -O2 flags from the CFLAGS options for GCC in the script.

CFLAGS="-g -O2 -mabi=32" ASFLAGS=$CFLAGS

find the part of the script above and remove the -O2

... I dont have ubuntu so you will have to test.

Paul.


Assignee
No one
Labels
Idea