From: http://blogold.chinaunix.net/u3/104564/showart_2091186.html
1. Install the Cross Compiler
1) the cross compiler uses the Eabi-compliant arm-none-linux-gnueabi-gcc-4.3.3 cross compiler provided by codesourcery ,:
Http://www.codesourcery.com/sgpp/lite/arm/portal/package4571/public/arm-none-linux-gnueabi/arm-2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
2) decompress the package to the/opt/directory:
# Tar jxvf arm-2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2-C/opt/
3) because the executable files in the/opt/arm-2009q1/bin/directory all start with "arm-None-Linux-gnueabi, make several soft links to arm-Linux-xxx for future use:
ln -s arm-none-linux-gnueabi-gdbtui arm-linux-gdbtui
ln -s arm-none-linux-gnueabi-addr2line arm-linux-addr2line
ln -s arm-none-linux-gnueabi-gprof arm-linux-gprof
ln -s arm-none-linux-gnueabi-ar arm-linux-ar
ln -s arm-none-linux-gnueabi-as arm-linux-as
ln -s arm-none-linux-gnueabi-nm arm-linux-nm
ln -s arm-none-linux-gnueabi-ld arm-linux-ld
ln -s arm-none-linux-gnueabi-c++ arm-linux-c++
ln -s arm-none-linux-gnueabi-objcopy arm-linux-objcopy
ln -s arm-none-linux-gnueabi-c++filt arm-linux-c++filt
ln -s arm-none-linux-gnueabi-cpp arm-linux-cpp
ln -s arm-none-linux-gnueabi-ranlib arm-linux-ranlib
ln -s arm-none-linux-gnueabi-objdump arm-linux-objdump
ln -s arm-none-linux-gnueabi-readelf arm-linux-readelf
ln -s arm-none-linux-gnueabi-size arm-linux-size
ln -s arm-none-linux-gnueabi-gcov arm-linux-gcov
ln -s arm-none-linux-gnueabi-strings arm-linux-strings
ln -s arm-none-linux-gnueabi-gdb arm-linux-gdb
ln -s arm-none-linux-gnueabi-strip arm-linux-strip
ln -s arm-none-linux-gnueabi-sprite arm-linux-sprite
4) Create the following three scripts in the/opt/arm-2009q1/bin/directory at the same time:
Script for ARM-Linux-G ++:
#!/bin/sh
arm-none-linux-gnueabi-g++ -march=armv4t $*
Script for ARM-Linux-GCC:
#!/bin/sh
arm-none-linux-gnueabi-gcc -march=armv4t $*
Content of the script arm-linux-gcc-4.3.3:
#!/bin/sh
arm-none-linux-gnueabi-gcc-4.3.3 -march=armv4t $*
5) Add the executable attributes to the preceding three scripts:
# Chmod + x arm-Linux-G ++
# Chmod + x arm-Linux-gcc
# Chmod + x arm-linux-gcc-4.3.3
6) output the path of the Cross-compiler executable file to the PATH environment variable:
# Export Path =/opt/arm-2009q1/bin: $ path
In the future to use the arm-linux-gcc-4.3.3 cross compiler should first execute the above sentence on the terminal!
7) check whether the installation is successful:
# Arm-Linux-gcc-V
If it succeeds, you can see the following information:
Using built-in specs.
Target: arm-none-linux-gnueabi
Configured with: /scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/src/gcc-4.3/configure --build=i686-pc-linux-gnu--host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch--with-gnu-as --with-gnu-ld --with-specs='%{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables}'--enable-languages=c,c++ --enable-shared --enable-symvers=gnu --enable-__cxa_atexit --with-pkgversion='Sourcery G++ Lite 2009q1-203'--with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery--with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc--with-build-sysroot=/scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/lite/install/arm-none-linux-gnueabi/libc--with-gmp=/scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/lite/obj/host-libs-2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr--with-mpfr=/scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/lite/obj/host-libs-2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr--disable-libgomp --enable-poison-system-directories--with-build-time-tools=/scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/lite/install/arm-none-linux-gnueabi/bin--with-build-time-tools=/scratch/mitchell/builds/4.3-arm-none-linux-gnueabi-respin/lite/install/arm-none-linux-gnueabi/bin
Thread model: posix
gcc version 4.3.3 (Sourcery G++ Lite 2009q1-203)
2. Prepare the source code package
1) Linux 2.6.30.4:
Http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.30.4.tar.bz2
2) For the yaffs2 File System:
Http://www.aleph1.co.uk/cgi-bin/viewcvs.cgi/
Click Download GNU tarballto download cvs-root.tar.gz
Put linux-2.6.30.4.tar.bz2and cvs-root.tar.gz in the same directory!
3. porting the kernel
1) decompress the kernel source code package
# Tar jxvf linux-2.6.30.4.tar.bz2
2) enter the kernel directory
# Cd linux-2.6.30.4
3) modify the top-level makefile
# Gedit makefile
In row 193
Arch? = $ (Subarch)
Cross_compile? =
Change
Arch? = Arm
Cross_compile? =/Opt/arm-2009q1/bin/ARM-Linux-
4) modify the machine code
# Gedit ARCH/ARM/tools/Mach-types
In row 379
S3C2440 arch_s3c2440 S3C2440 362
Change
S3C2440 arch_s3c2440 S3C2440 782
This is the same as the machine code parameter passed in by supervivi!
5) modify the clock frequency
# Gedit ARCH/ARM/mach-s3c2440/mach-smdk2440.c
In row 160
Static void _ init smdk2440_map_io (void)
{
S3c24xx_init_io (smdk2440_iodesc, array_size (smdk2440_iodesc ));
// S3c24xx_init_clocks (16934400); // comments this sentence and add the next sentence
2011-0xx_init_clocks (12000000 );
S3c24xx_init_uarts (smdk2440_uartcfgs, array_size (smdk2440_uartcfgs ));
}
6) modify the NAND Flash Partition
# Gedit ARCH/ARM/plat-s3c24xx/common-smdk.c
In row 109
static struct mtd_partition smdk_default_nand_part[] = {
[0] = {
.name = "supervivi",
.size = 0x00030000,
.offset = 0,
},
[1] = {
.name = "Kernel",
.offset = 0x00050000,
.size = 0x00200000,
},
[2] = {
.name = "root",
.offset = 0x00250000,
.size = 0x03dac000,
}
};
4. Configure the kernel
# Cp ARCH/ARM/configs/s3c2410_defconfig. config
# Make menuconfig
Only the following three machine types are selected:
System Type ---> S3C2410 Machines ---> [*] SMDK2410/A9M2410
S3C2440 Machines ---> [*] SMDK2440
[*] SMDK2440 with S3C2440 CPU module
The following two items are added to the kernel features:
Kernel Features ---> [*] Use the ARM EABI to compile the kernel
[*] Allow old ABI binaries to run with this(EXPERIMENTA) kernel
To understand the meaning of each configuration option, click:Introduction to Linux 2.6.19.x kernel compilation configuration options
5. Compile the kernel
# Make zimage
6. Download and download the kernel Image
First, use the yaffs2 root file system image provided by the friendly arm for testing. You can run it here:
FAT: unable to read boot sector
VFS: Cannot open root device "mtdblock2" or unknown-block(31,2)
Please append a correct "root=" boot option; here are the available partitions:
1f00 192 mtdblock0 (driver?)
1f01 2048 mtdblock1 (driver?)
1f02 63152 mtdblock2 (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)
[ ] (unwind_backtrace+0x0/0xdc) from [ ] (panic+0x40/0x110)
[ ] (panic+0x40/0x110) from [ ] (mount_block_root+0x1d0/0x210)
[ ] (mount_block_root+0x1d0/0x210) from [ ] (prepare_namespac)
[ ] (prepare_namespace+0x164/0x1bc) from [ ] (kernel_init+0xb)
[ ] (kernel_init+0xb4/0xe0) from [ ] (do_exit+0x0/0x578)
[ ] (do_exit+0x0/0x578) from [] (0x1)
VII. Add support for the yaffs2 File System
1) return to the parent directory
# CD ..
2) decompress the source code package of the yaffs2 file system.
# Tar zxvf cvs-root.tar.gz
3) Go To The yaffs2 source code directory.
# Cd CVS/yaffs2
4) patch
#./Patch-ker.sh C ../linux-2.6.30.4
Updating.../linux-2.6.30.4/fs/kconfig
Updating.../linux-2.6.30.4/fs/makefile
5) return to the kernel directory
# Cd.../linux-2.6.30.4
6) Reconfigure
# Make menuconfig
Select one of the following items:
File systems ---> [*] Miscellaneous filesystems ---> YAFFS2 file system support
7) recompile the kernel
# Make zimage
8. Download and download the kernel image again
yaffs: dev is 32505858 name is "mtdblock2"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.2, "mtdblock2"
yaffs_read_super: isCheckpointed 0
VFS: Mounted root (yaffs filesystem) on device 31:2.
Freeing init memory: 120K
mount: mounting /dev/sda2 on /opt failed: No such file or directory
mkdir: cannot create directory '/udisk': File exists
mount: mounting /dev/sda1 on /udisk failed: No such file or directory
Please press Enter to activate this console.
[root@jjx /]#
The kernel is successfully transplanted to the console ~~
LCD driver and backlights mounted, RTC for mini2440 & linux2.6.30.4
Add friendly touch screen driver for mini2440 & linux2.6.30.4
Transplant dm9000 driver for mini2440 & linux2.6.30.4
Transplant SD card driver for mini2440 & linux2.6.30.4
Configure USB for mini2440 & linux2.6.30.4
Port the sound card driver for mini2440 & linux2.6.30.4