노무현 대통령 배너


2006. 3. 28. 10:48

[본문스크랩] Arm Cross Toolchains 만들기

Arm cross toolchain을 만드는 무수한 방법이 존재하는데..

그중에서 저도 가장 빠른시간에 편한 방법으로 하는 방법이 아래의 방법입니다.

몇개의 크로스 툴체인을 만들 필요가 있어서 작업해 보았는데..

잘 되네요...

==============================================

cross toolchain만드는 법(gcc 3.3.2 glib 2.3.2)

Last modification:2006-01-20

출처 : http://kernelproject.org/viewtopic.php?t=1267
kernelproject && Embedded System Project 게시판 인덱스 -> bucks+klinux

원저자 : 고도리님.


1. crosstool-0.27.tar.gz
www.kegel.com/crosstool에서 받아온다.

2. 압축을 푼다.

3. 해당디렉토리로 옮겨간다.

4. ghc-arm-softfloat.sh을 만든다.

#!/bin/sh
set -ex
TARBALLS_DIR=/root/crosstool/aaa
RESULT_TOP=/opt/crosstool
export TARBALLS_DIR RESULT_TOP
GCC_LANGUAGES="c,c++"
export GCC_LANGUAGES

# Really, you should do the mkdir before running this,
# and chown /opt/crosstool to yourself so you don't need to run as root.
mkdir -p $RESULT_TOP


# Build the toolchain. Takes a couple hours and a couple gigabytes.

eval `cat arm-softfloat.dat gcc-3.3.2-glibc-2.3.2.dat` sh all.sh --notest

echo Done.


5. vi getandpatch.sh

ftp의 passive mode때문에 방화벽 밑에서 설치할 경우는 이 파일을 수정해야 한다.

getandpatch.sh 에서 wget -P 라는 넘을 wget --passive-ftp -P 로 바꿀 것.

6. sh ghc-arm-softfloat.sh

이럼 대략 한 세시간 걸려서 된다....ㅎㅎ

7. 다 된후에 경로 추가
$HOME/.bashrc에 다음과 같은넘 추가

PATH=$PATH:/opt/crosstool/arm-softfloat-linux-gnu/gcc-3.3.4-glibc-2.3.3/bin
export PATH

그 다음에 source .bashrc 해주면 된다.

==========================================================================

수정 : kingseft


C:Vmware/Fedora4 에서 실험을 해보자.

1. crosstool-0.27.tar.gz 을 www.kegel.com/crosstool에서 받아온다.
지금 실험을 하는 시점에서는 버전업이 되었다. 아래 파일을 다운 받았다.

http://kegel.com/crosstool/crosstool-0.38.tar.gz (tarball)

2.디렉토리를 만들어 주었다.

[root@TechwinLinux /]# mkdir -p /home/kingseft/crosstool/aaa
[root@TechwinLinux /]# chmod -c 777 -R /home/kingseft/crosstool/aaa
[root@TechwinLinux /]# mkdir -p /opt/crosstool/


3.해당디렉토리에서 압축을 풀고 이동한다.

cd/home/kingseft/crosstool/aaa
tar zxvf crosstool-0.38.tar.gz

아래와 같은 디렉토리가 생성된다.

[root@TechwinLinux aaa]# ls -al
total 3764
drwxrwxrwx 3 root root 4096 Oct 21 22:56 .
drwxrwxrwx 3 root root 4096 Oct 21 22:52 ..
drwxr-x--- 7 kingseft kingseft 12288 Aug 2 02:34 crosstool-0.38
-rwxrwxrwx 1 kingseft kingseft 3828943 Aug 1 17:46 crosstool-0.38.tar.gz
[root@TechwinLinux aaa]#


해당 디렉토리로 이동한다.
cd crosstool-0.38


4.쉘 스크립트를 하나 만든다. 이건 현철님 스크립트를 그냥 배꼈다. ^^
디렉토리 수정과 gcc, glibc 버젼을 원하는 것으로 바꾸어주었다. (당근 해당 버젼이 있는지 디렉토리에서 스크립트 찾아보자)

kingseft-arm-softfloat.sh을 만든다.


#!/bin/sh
set -ex
TARBALLS_DIR=/home/kingseft/crosstool/aaa
RESULT_TOP=/opt/crosstool
export TARBALLS_DIR RESULT_TOP
GCC_LANGUAGES="c,c++"
export GCC_LANGUAGES

# Really, you should do the mkdir before running this,
# and chown /opt/crosstool to yourself so you don't need to run as root.
mkdir -p $RESULT_TOP


# Build the toolchain. Takes a couple hours and a couple gigabytes.

eval `cat arm-softfloat.dat gcc-3.3.4-glibc-2.3.3.dat` sh all.sh --notest

echo Done.

5.vi getandpatch.sh

ftp의 passive mode때문에 방화벽 밑에서 설치할 경우는 이 파일을 수정해야 한다.
getandpatch.sh 에서 wget -P 라는 넘을 wget --passive-ftp -P 로 바꿀 것.

^^ 어라. 살펴보니 이미 이제는 아래와 같이 바뀌어 있다.

wget --tries=5 -P ${TARBALLS_DIR} -c $1 || wget --tries=5 --passive-ftp -P ${TARBALLS_DIR} -c $1


6.chmod -c 777 -R /root/
root로 로그인 하지 말고, 일반 유저로 로그인한다음에...

sh kingseft-arm-softfloat.sh

자. 무엇인가 진행된다. 기다려 보자. 어휴. 회사에서 받으려니 미치겠다. ㅠ.ㅠ

binutil을 다운받는데.. 너무 느려서 그 주소를 보고 flashget으로받으니 금방 받았다. 이 파일을 현재 디렉토리에 넣어두었다.


다시 해보자.

sh kingseft-arm-softfloat.sh


7.주의할점은 root로 작업하면 안된다는 점이다. ^^


8.잘 하다가 에러가 난다.
arm-softfloat.dat gcc-3.3.4-glibc-2.3.3.dat 파일을 살펴보고 커널의 이름을 수정하였다.
기존 2.4 커널에서 우리가 사용하는 2.6.13 커널로 바꾸어주었다.


BINUTILS_DIR=binutils-2.15
GCC_DIR=gcc-3.3.4
GLIBC_DIR=glibc-2.3.3
GLIBCTHREADS_FILENAME=glibc-linuxthreads-2.3.3
LINUX_DIR=linux-2.6.13<==== 이 부분을 바꾸어 보자.

9.vi all.sh 해서

shtesthello.sh 를 막자.이상하게 "PATH_MAX" 가 정의되지 않았다고 나온다.

##shtesthello.sh


10.다된후에 /root/.bash_profile 에 다음을 추가한다.

PATH=$PATH:/opt/crosstool/gcc-3.3.4-glibc-2.3.3/arm-softfloat-linux-gnu/bin
export PATH


그런 다음에 source.bash_profile을 실행한다.

11.일단 확인을 해보면..

[root@TechwinLinux ~]# arm-softfloat-linux-gnu-gcc --version
arm-softfloat-linux-gnu-gcc (GCC) 3.3.4
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@TechwinLinux ~]#

12.U-boot 을 컴파일 테스트 해보자. 잘되는 것 같다.

Makefile 에서 아래를 수정해 주었다. ^^

ifeq ($(ARCH),arm)
## kingseft
##CROSS_COMPILE = arm-linux-
CROSS_COMPILE = arm-softfloat-linux-gnu-
endif

13.이솝커널을 Kernel Compile을 해보자.

잘된다. ^^
역시 Makefile 에서

CROSS_COMPILE = arm-softfloat-linux-gnu-

수정한다.

에이 귀찮다.


14.나중에 /opt/crosstool/gcc-3.3.4-glibc-2.3.3/arm-softfloat-linux-gnu/bin 디렉토리 아래의 실행파일 이름들을 바꾸어 줄까 ^^
arm-softfloat-linux-gnu- 이렇게 된 놈들을 arm-linux- 이런식으로 ^^

다 바꾸어주자.

15.크로스 툴체인 설치 끝.


16.크로스 툴체인 설치방법이야.. 워낙이 다양하고 많은 방법이 있지만, 난 crosstool 이 녀석이 제이 맘에든다.
실패할 확률도 적고... 스크립트가 잘 작성이 되어있기에.. 큰 문제없이 구동할 수 있다.

=========================================================================================

[현철님 코멘트]

arm-softfloat.dat 파일에서

TARGET=arm-softfloat-linux-gnu

부분을

TARGET=arm-linux

로 해주시면 arm-linux-gcc가 생성될겁니다. 이렇게 안하면 나중에 app들 크로스 컴팔할때 귀찮아지겠지요.


--------------------------------------------------------------------------------------------