Chinaunix首页 | 论坛 | 博客
  • 博客访问: 14796
  • 博文数量: 4
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 45
  • 用 户 组: 普通用户
  • 注册时间: 2012-12-15 12:37
文章分类

全部博文(4)

文章存档

2013年(3)

2012年(1)

我的朋友

分类:

2012-12-15 12:38:53

一、安装交叉编译器
1)交叉编译器使用CodeSourcery提供的符合EABI标准的arm-none-linux-gnueabi-gcc-4.3.3交叉编译器,下载地址:


2)下载后,解压到/opt/目录:
# tar jxvf arm-2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2 -C /opt/

3)因为/opt/arm-2009q1/bin/目录中的可执行文件均以不常用的" arm-none-linux-gnueabi- "开头,做几个arm-linux-xxx软链接以方便日后使用:

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)同时在/opt/arm-2009q1/bin/目录建立如下三个脚本:
脚本arm-linux-g++的内容:

#!/bin/sh
arm-none-linux-gnueabi-g++ -march=armv4t $*


脚本arm-linux-gcc的内容:

#!/bin/sh
arm-none-linux-gnueabi-gcc -march=armv4t $*


脚本arm-linux-gcc-4.3.3的内容:

#!/bin/sh
arm-none-linux-gnueabi-gcc-4.3.3 -march=armv4t $*


5)为以上三个脚本加上可执行属性:
# chmod +x arm-linux-g++
# chmod +x arm-linux-gcc
# chmod +x arm-linux-gcc-4.3.3


6)输出交叉编译器的可执行文件的路径到PATH环境变量:
# export PATH=/opt/arm-2009q1/bin:$PATH

以后要用到arm-linux-gcc-4.3.3交叉编译器时都应该先在终端上执行上面一句!

7)查看是否安装成功:
# arm-linux-gcc -v
如果成功的话,可以看到如下信息:

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)



二、准备源码包
1)Linux 2.6.30.4的下载地址:


2)yaffs2文件系统的下载地址:

点击Download GNU tarball,下载cvs-root.tar.gz

请把linux-2.6.30.4.tar.bz2和cvs-root.tar.gz放在同一目录内!



三、移植内核
1)解压内核源码包
# tar jxvf linux-2.6.30.4.tar.bz2

2)进入内核目录
# cd linux-2.6.30.4

3)修改顶层Makefile
# gedit Makefile
在193行
ARCH  ?= $(SUBARCH)
CROSS_COMPILE  ?=
修改为
ARCH  ?= arm
CROSS_COMPILE  ?= /opt/arm-2009q1/bin/arm-linux-


4)修改机器码
# gedit arch/arm/tools/mach-types
在379行
s3c2440            ARCH_S3C2440        S3C2440            362
修改为
s3c2440            ARCH_S3C2440        S3C2440            782
与supervivi传入的机器码参数一致即可!

5)修改时钟频率
# gedit arch/arm/mach-s3c2440/mach-smdk2440.c
在160行

static void __init smdk2440_map_io(void)
{
    s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc));
    //s3c24xx_init_clocks(16934400); //注释这句,加入下一句
    s3c24xx_init_clocks(12000000);
    s3c24xx_init_uarts(smdk2440_uartcfgs, ARRAY_SIZE(smdk2440_uartcfgs));
}


6)修改Nand Flash分区
# gedit arch/arm/plat-s3c24xx/common-smdk.c
在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,
    }
};



四、配置内核
# cp arch/arm/configs/s3c2410_defconfig .config
# make menuconfig
机器类型只选以下三项:

System Type ---> S3C2410 Machines ---> [*] SMDK2410/A9M2410
                 S3C2440 Machines ---> [*] SMDK2440
                                       [*] SMDK2440 with S3C2440 CPU module


内核特性加上以下两项:

Kernel Features ---> [*] Use the ARM EABI to compile the kernel
                     [*] Allow old ABI binaries to run with this(EXPERIMENTA) kernel


如果你想了解每个配置选项的意义,请点击:
Linux 2.6.19.x 内核编译配置选项简介

五、编译内核
# make zImage


六、下载、烧写内核镜像
先使用友善之臂公司提供的yaffs2根文件系统镜像做测试,可以运行到这里:

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)
[<c002c700>] (unwind_backtrace+0x0/0xdc) from [<c02a7d2c>] (panic+0x40/0x110)
[<c02a7d2c>] (panic+0x40/0x110) from [<c0008fcc>] (mount_block_root+0x1d0/0x210)
[<c0008fcc>] (mount_block_root+0x1d0/0x210) from [<c0009264>] (prepare_namespac)
[<c0009264>] (prepare_namespace+0x164/0x1bc) from [<c0008598>] (kernel_init+0xb)
[<c0008598>] (kernel_init+0xb4/0xe0) from [<c004812c>] (do_exit+0x0/0x578)
[<c004812c>] (do_exit+0x0/0x578) from [<00000001>] (0x1)



七、加入对yaffs2文件系统的支持
1)回到上级目录
# cd ..

2)解压yaffs2文件系统源码包
# tar zxvf cvs-root.tar.gz

3)进入yaffs2
源码目录
# cd cvs/yaffs2

4)打补丁
# ./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)回到内核目录
# cd ../../linux-2.6.30.4

6)重新配置
# make menuconfig
选上以下一项:

File systems ---> [*] Miscellaneous filesystems ---> <*> YAFFS2 file system support


7)重新编译内核
# make zImage



八、重新下载、烧写内核镜像

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 /]#


成功进入控制台,内核算是移植成功了~~

移植LCD驱动与加入背光、RTC for mini2440 & Linux2.6.30.4

加入友善的触摸屏驱动 for mini2440 & Linux2.6.30.4

移植DM9000驱动 for mini2440 & Linux2.6.30.4

移植SD卡驱动 for mini2440 & Linux2.6.30.4

配置USB for mini2440 & Linux2.6.30.4

移植声卡驱动 for mini2440 & Linux2.6.30.4


阅读(583) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:linux ps 命令查看进程状态

给主人留下些什么吧!~~