星期五, 10月 14, 2005

Build Kernel for ARM - 2nd Trial

Follow : Embedded Linux -- Hardware, Software and Interface.
將script改為手動,一步一步作。

2.6.2以上的kernel source已經將rmk的patch納入,所以已經不用patch了。
但是default還是以native build為主,所以在x86上run make menuconfig時,會自動出現x86的config內容
這是因為2.6 Makefile中 ,ARCH variable的定義是 :
ARCH ?= $SUBARCH
而SUBARCH由uname 取出,所以是host 的cpu type.
的原因。
要作cross-build時,要將Makefile改掉
ARCH ?= arm
CROSS_COMPILE ?= /usr/bin/arm-linux-
之後,run make menuconfig 就會出現以arm為目標的config menu。
在System Type中選SA1100-based,SA11x0 Implementations 就有Compaq iPaq H3600/H3700 可以選。
...
ARM system type選 PXA2xx-based
Intel PXA2xx Implement就有
Select target board 就有 SHARP SL-C7xx Models (Corgi, Shepherd and Husky)
之後就會出現
Enable Sharp SL-700 Support
Enable Sharp SL-750 Support
Enable Sharp SL-760 Support
可以選
..
做config後,將linux src裡的header file copy到PREFIX 中,gcc compile要用`.
開始作gcc的prebuild : 建一個只能用來build libc的gcc.
這個動作叫做libchack (libc hack)
就是修改compile的flag,加入 -Dinhibit_libc,參考http://www.aleph1.co.uk/armlinux/docs/toolchain/toolchHOWTO/x183.html#DIN
的說明。
修改gcc source 中gcc/config/arm/下 t-linux file 的TARET_LIBGCC2_CFLAGS.

make 時出現 找不到stdio.h, tim.h:
In file included from ../../src/gcc/crtstuff.c:64:
../../src/gcc/tsystem.h:90:19: error: stdio.h: No such file or directory
../../src/gcc/tsystem.h:93:23: error: sys/types.h: No such file or
directory
../../src/gcc/tsystem.h:96:19: error: errno.h: No such file or directory
../../src/gcc/tsystem.h:103:20: error: string.h: No such file or
directory
../../src/gcc/tsystem.h:104:20: error: stdlib.h: No such file or
directory
本以為是target platform的include path或是 -Dinhibit_libc的問題,但是確認後還是一樣。
?難道是host 的kernel header ? 要安裝host 的kernel header file ?
#apt-get install kernel-headers-2.4.27-2 (由uname出自己的kernel version決定)
沒效,還是一樣的error,Google一下,看到這一篇:http://lists.debian.org/debian-gcc/2005/06/msg00338.html 說是debian的path 安排和GNU的不一樣(?),follow他的說明(path file內容),把gcc的config file : gcc/config/gnu.h 中
 #undef STANDARD_INCLUDE_DIR
#define STANDARD_INCLUDE_DIR "/include"
改為

#undef STANDARD_INCLUDE_DIR
/* Overriden for Debian GNU/Hurd. */
#define STANDARD_INCLUDE_DIR "/usr/include"
再作一次configure.再make一次..... 一樣的error。
參考另外一個(上次那一個) cross compile script : http://kegel.com/crosstool/crosstool-0.38/doc/crosstool-howto.html#scripts ,發現他的step 不同,在build cross-compiled gcc 之前,還建立glibc header file。
crosstool.sh中有一段:
echo "Install glibc headers needed to build bootstrap compiler -- but only if gcc-3.x"

# Only need to install bootstrap glibc headers for gcc-3.0 and above? Or maybe just gcc-3.3 and above?
# See also http://gcc.gnu.org/PR8180, which complains about the need for this step.
# Don't install them if they're already there (it's really slow)
所以猜想build crosstool的過程在3.0以後有很大的不同,就是在這裡。(所以大多prebuild toolchain都是2.95.3)。

沒有留言:

網誌存檔