Cross Compiler build process preparation to download the source package: you can download the source package binutils-2.17.tar.gz ftp://ftp.gnu.org gcc-3.4.6.tar.gz glibc-2.3.6.tar.gz or to ftp://sourceware.org/pub/download. Put the source code package in the/home/zht/cross-compiler/build-tools/directory. You can. Put the patch file in the/home/zht/cross-compiler/build-tools/patch directory. Prepare the kernel source code package: linux-2.4.27.tar.gz patch-2.4.27-vrs1 2.4.27vrs1-at91-17032005.patch prepare the source code for the target kernel in the/home/zht/cross-compiler/kernel directory and configure the compilation. 1 prepare the kernel header file # cd/home/zht/cross-compiler/# mkdir-P/usr/loca/ARM-Linux/include # cp-r kernel/linux-2.4.27/include /Linux // usr/local/ARM-Linux/include/# cp-r kernel/linux-2.4.27/include/ASM-arm // usr/local/ARM-Linux /include/ASM # cp-r kernel/linux-2.4.27/include/ASM-generic // usr/local/ARM-Linux/include2 binutils setting # cd build-tools /# mkdir build-binutils # tar zxvf binutils-2.17.tar.gz # cd build-binutils /#.. /binutils-2.17/configure -- target = arm-Linux -- prefix =/usr/local/arm # Make # make install View: # ls/usr/local/ARM/bin/set Environment Variables
# Export Path = $ path:/usr/local/ARM/bin 2 boot compiler settings ① prepare the glibc header file for the boot Compiler (see 2 p130) # cd/home/zht/cross-compiler/build-tools/# tar zxvf glibc-2.3.6.tar.gz # tar zxvf glibc-linuxthreads-2.3.6.tar.gz -- directory = glibc-2.3.6 # mkdir build-glibc-headers # cd build-glibc -headers #.. /glibc-2.3.6/configure -- Host = arm-Linux -- prefix = "/usr" -- enable-add-ons = linuxthreads -- With-headers =/usr/local/ARM-Linux /INC Lude/# make cross-compiling = Yes install_root =/usr/local/ARM-Linux/prefix = "" Install-headers # Touch/usr/local/ARM- linux/include/GNU/stubs. h # Touch/usr/local/ARM-Linux/include/bits/stdio_lim.h ② build the GCC compiler in sequence # CD/home/zht/cross-compiler/build- tools/# tar zxvf gcc-3.4.6.tar.gz # patch-P1-D gcc-3.4.6 <patch/gcc-3.4.6-patches-1.2/patch/33_all_pr15068-fix.patch (why? You can find the cause on the Internet, which is also described in 33_all_pr15068-fix.patch. If you do not install this patch and then compile glibc, an error will occur ). # Mkdir build-boot-GCC # cd build-boot-GCC #.. /gcc-3.4.6/configure -- target = arm-Linux -- prefix =/usr/local/ARM/-- disable-shared -- With-headers =/usr/local/ARM-Linux/ include/-- With-newlib -- enable-Language = C # Make all-GCC # make install-GCC view: # ls/usr/local/ARM/bin 3 C link library glibc settings # cd/home/zht/cross-compiler/build-tools/# mkdir build-glibc # cd build -glibc # cc = arm-Linux-GCC .. /glibc-2.3.6/config Ure -- Host = arm-Linux -- Build = i686-pc-linux -- prefix = "/usr" -- enable-add-ons = linuxthreads -- With-headers =/usr/local/ARM- linux/include/The following are the required patch files, for more information, see Appendix 1. Compile the glibc solution or refer to reference 1. You can download the patch file at http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets. # Patch-P0-D glibc-2.3.6 <patch/glibc-patches/5090_all_divdi3-asm-fix.patch # patch-P1-D glibc-2.3.6 <patch/glibc-patches/patches # patch-P1-D glibc-2.3.6 <patch/ glibc-patches/patches # patch-P1-D glibc-2.3.6 <patch/glibc-patches/gcc_eh.patch.cross start compilation # Make install_root =/usr/local/ARM-Linux prefix = "" Install configure libc. so file # vi/usr/local/ARM-Linux/lib/libc. so group (/lib/libc. so.6/lib/libc_nonshared.a) to: group (libc. so.6 libc_nonshared.a) Configure libpthread. so file # vi/usr/local/ARM-Linux/lib/libpthread. so group (/lib/libpthread. so.0/lib/libpthread_nonshared.a) to: group (libpthread. so.0 libpthread_nonshared.a) 4 complete compiler settings # cd/home/zht/cross-compiler/build-tools/# mkdir build-GCC # cd build-GCC if you require GCC to support multiple programming languages: #.. /gcc-3.4.6/configure -- target = arm-Linux -- Host = i686-pc-linux -- prefix =/usr/local/arm -- enable-threads = POSIX if required GCC only supports C and C ++ Programming the language configuration is as follows: #.. /gcc-3.4.6/configure -- target = arm-Linux -- Host = i686-pc-linux -- prefix =/usr/local/arm -- enable-threads = POSIX -- enable-versions ages = C, c ++ # Make all # make install 5 Repeat 3 Re-compile glibc 6 according to reference 2, make the following settings
# Cd/usr/local/ARM-Linux/bin # mv as ar gcc ld nm ranlib strip/usr/local/ARM/lib/GCC/ARM-Linux/3.4.6 # for file in as ar gcc ld nm ranlib strip> do> ln-S/usr/local/ARM/lib/GCC/ARM-Linux/3.4.6/$ file.> done 7 uses the established cross compiler to compile the kernel (compile the linux-2.4.27-vrs1) error and handle 1.: Error: Invalid option 'short-load-bytes: set cflags_boot :=$ (APCS-y) $ (arch-y) $ (tune-y) in arch/ARM/makefile) -mshort-load-bytes-msoft-float-uarmcflags + =$ (APCS-y) $ (arch-y) $ (tune-y) -Change mshort-load-bytes-msoft-float-uarm to cflags_boot :=$ (APCS-y) $ (arch-y) $ (tune-y) -malignment-traps-msoft-float-uarmcflags + =$ (APCS-y) $ (arch-y) $ (tune-y) -malignment-traps-msoft-float-uarm 2 Environment: In function 'at91 _ register_uart ': at91_serial.c: 654: Error: syntax error before "_ function _" at91_serial.c: 691: Error: syntax error before "_ function _" processing: Convert printk (kern_err _ function _ "in drivers/at91/serial/at91_serial.c __": bad Index Number % d/N ", idx); changed to: printk (kern_err" % s: Bad Index Number % d/N ",__ function _, idx ); change printk (kern_err _ function _ ": Bad Port Number % d/N", Port) to: printk (kern_err "% s: bad Port Number % d/N ",__ function _, Port); 3 keyboard. c: In function 'kbd _ processkeycode': keyboard. c: 413: Error: Label at end of compound statementkeyboard. c: In function 'do _ FN ': handle the following: Drivers/Char/keyboard. in C, the # endif }}rep = 0; out :}is changed to: # endif }}rep = 0; Out: rep = rep ;} 4/home/zht/sources/mykernel/kernel2.4.27/linux-2.4.27/include/Linux/sched. h: 766: Sorry, unimplemented: inlining failed in call to '_ mmdrop': function body not availablesched. c: 771: Sorry, unimplemented: called from here for processing: Include/Linux/sched. in H, line766extern inline void fastcall (_ mmdrop (struct mm_struct *); changed to extern void fastcall (_ mmdrop (struct mm_struct *)); 5/home/zht/sources/mykernel/kernel2.4.27/linux-2.4.27/include/Linux/blkdev. h: 236: Sorry, unimplemented: inlining failed in call to 'blk _ get_queue ': function body not availableblkpg. c: 264: Sorry, unimplemented: called from here/home/zht/sources/mykernel/kernel2.4.27/linux-2.4.27/include/Linux/blkdev. h: 236: Sorry, unimplemented: inlining failed in call to 'blk _ get_queue ': function body not availableblkpg. c: 267: Sorry, unimplemented: called from here for processing: Include/Linux/blkdev. in H, line236extern inline request_queue_t * blk_get_queue (kdev_t Dev); changed to extern request_queue_t * blk_get_queue (kdev_t Dev ); 6/home/zht/sources/mykernel/kernel2.4.27/linux-2.4.27/include/NET/IP. h: 140: Sorry, unimplemented: inlining failed in call to 'IP _ finish_output ': function body not availableip_forward.c: 165: Sorry, unimplemented: called from here processing is as follows: include/NET/IP. in H, line140 extern _ inline _ int ip_finish_output (struct sk_buff * SKB); changed to extern int ip_finish_output (struct sk_buff * SKB ); appendix 1 errors during cross-compiler establishment and solutions 1 compiling glibc
①/Tmp/ccqizhcq. s: assembler messages:/tmp/ccqizhcq. s: 2243: Error: Symbol definition loop encountered at '_ divdi3_internal'/tmp/ccqizhcq. s: 2243: Error: Symbol definition loop encountered at '_ udivdi3_internal'/tmp/ccqizhcq. s: 2243: Error: Symbol definition loop encountered at '_ moddi3_internal'/tmp/ccqizhcq. s: 2243: Error: Symbol definition loop encountered at '_ umoddi3_internal' make [2]: *** [/Ho Me/zht/cross-compiler/build-tools/build-glibc/CSU/divdi3. OS] Error 1 learn to find the patch 5090_all_divdi3-asm-fix.patch on the Internet and enter glibc. ② Make [2]: *** [/home/zht/cross-compiler/build-tools/build-glibc/MISC/ioperm. o] Error 1 make [2]: Leaving directory '/home/zht/cross-compiler/build-tools/glibc-2.3.6/misc' make [1]: * ** [MISC/subdir_lib] Error 2 make [1]: Leaving directory '/home/zht/cross-compiler/build-tools/glibc-2.3.6' make: * ** [all] Error 2 go online and learn to find the patch 6200_all_arm-glibc-2.3.4-ioperm.patch and enter glibc. ③ .. /Sysdeps/Unix/sysv/Linux/bind. s: assembler messages :.. /sysdeps/Unix/sysv/Linux/bind. s: 5: Error: symbol' _ bind 'is already definedmake [2]: * ** [/home/zht/cross-compiler/build-tools/build-glibc/socket/bind. o] Error 1 make [2]: Leaving directory '/home/zht/cross-compiler/build-tools/glibc-2.3.6/socket' make [1]: * ** [socket/subdir_lib] Error 2 go to the Internet and find the patch 6230_all_arm-glibc-2.3.6-socket-no-weak-alias.patc. H and enter glibc. ④/Usr/local/ARM/bin /.. /lib/GCC/ARM-Linux/3.4.6 /.. /.. /.. /.. /ARM-Linux/bin/ld: cannot find-lgcc_ehcollect2: LD returned 1 exit statusmake [2]: * ** [/home/zht/cross-compiler/build-tools/build-glibc/iconv/iconvconfig] Error 1 make [2]: leaving directory '/home/zht/cross-compiler/build-tools/glibc-2.3.6/iconv 'make [1]: *** [iconv/others] Error 2 make [1]: leaving directory '/home/zht/cross-compiler/build- OLS/glibc-2.3.6 'make: *** [all] Error 2 go online to learn to find the patch gcc_eh.patch.cross and break into glibc. For more information, see reference 1:
1. Custom toolchain for ARMHttp://blog.csdn.net/zht_sir/archive/2007/03/27/1542379.aspx2 build embedded Linux system Karim yaghmour