移植2.6.15至HHARM2410-STUDY

  移植2.6.15至HHARM2410-STUDY
                              By  NKS - freezero
感谢华恒的hn、winter、harry等人的帮助。

下面就以linux 2.6.15的内核作为例子来说明一下:

一、ppcboot
ppcboot 就在华恒的默认安装环境里修改一下就可以了:
# cd /HHARM2410-STUDY/ppcboot-2.0.0/lib_arm
# vi  armlinux.c
修改console为ttySAC0
# make clean
# make
就在当前的目录下生成了ppcboot.bin
# cp ppcboot.bin /tftpboot/

二、制作ramdisk
㈠.下载busybox 1.2.2.1   http://busybox.net/downloads/busybox-1.2.2.1.tar.bz2
将其放在根目录:
# cd /
# tar jxvf busybox-1.2.2.1.tar.bz2
# cd / busybox-1.2.2.1
# make menuconfig
使用busybox制作系统应用程序
下载busybox-1.1.2, 解压
#make defconfig
#make menuconfig (主要修改以下配置)
busybox settings à
build options à
[ * ]build busybox as a static binary(no shared libs)
do you want to build busybox with a cross compiler?
填上你的交叉编译器的路径
/usr/local/arm/3.4.1/arm-linux-
(这里写上交叉编译器的前缀)
     Installation options  à
[*] Don't use /usr  
linux Ext2 FS progs à
将这下面的选项都去掉了,否则编译会出错,不知什么原因。                                                    
#make
# make install
这样就是/ busybox-1.2.2.1/_install目录下有生成的一个linuxrc和2个文件夹:bin和sbin。

<script type="text/javascript"> </script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>

㈡.制作空的ramdisk:
# dd if=/dev/zero of=ramdisk bs=1k count=8000
    在本地目录下出现一个rmdisk的块文件
# losetup /dev/loop2 ramdisk
# mkfs.ext2 /dev/loop2
挂载ramdisk至/mnt下
# mount -t ext2 /dev/loop2 /mnt
㈢.准备lib库文件
# cd /mnt
# mkdir lib
# cd  /usr/local/arm/3.4.1/arm-linux/lib
# for file in libc libcrypt libdl libm libpthread libresolv libutil
> do
> cp $file-*.so /mnt/lib
> cp -d $file.so.[*0-9] /mnt/lib
> done
# cp -d ld*.so* /mnt/lib
㈣.复制busybox文件至ramdisk中:
# cp –rf  /busybox-1.2.2.1/_install/* /mnt/
这样在ramdisk中就有:usr sbin linuxrc lib
㈤.
# umount /dev/loop2
# losetup -d /dev/loop2
# gzip -9 ramdisk

这样ramdisk.gz就制作好了。
# cp ramdisk.gz /tftpboot

三、移植内核
1.首先:
       这里我们使用arm-linux-gcc-3.4.1的交叉编译器:
      ftp://ftp.handhelds.org/projects/toolchain/arm-linux-gcc-3.4.1.tar.bz2
       这个默认是解压到当前目的usr/local/目录下,所以要放在根目录下,让它直接解
       压到系统的/usr目录里以保持统一.
       #cd /
       #tar jxvf arm-linux-gcc-3.4.1.tar.bz2
       等待解压完成。
       
2.下载内核:
       http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.15.tar.gz
       这个内核包随便放在哪个目录,最好放在根目录下,容易查找,然后给它解开
       #tar jxvf  linux-2.6.15.tar.bz2
       等待解压完成。
       
3.修改Makefile:
       这个是必须的,因为要用交叉编译器来编译你这个内核,所以要在Makefile中要
       指定交叉编译的环境:
       # cd linux-2.6.15
       # vi Makefile
       a.在Makefile中找到下面这一行:
        SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ /
                                          -e s/arm.*/arm/ -e s/sa110/arm/ /
                                          -e s/s390x/s390/es/parisc64/parisc/ /
                                          -e s/ppc64/powerpc/ )
       前面加#,将它注销掉。
       b.找到下列行:
       ARCH            ?=$(SUBARCH) <script type="text/javascript"> </script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
       CROSS_COMPILE    ?=
       改成:
       ARCH    = arm
       CROSS_COMPILE =/usr/local/arm/3.4.1/bin/arm-linux-
       (这里的CROSS_COMPILE就是让你指定交叉编译器的路径,也有使用环境变量来指定
            编译器的路径的,我比较喜欢这种方式)
4.配置内核:
这一步比较重要:
a.我们在配置内核的时候总是感到无从下手,因为虽然内核的配置很方便,但是很多配置项我们并不是很明确它的作用,我也一样,既然如此,我们可以先使用内核自己提供的config它的相对路径是:
/linux-2.6.15/arch/arm/configs/smdk2410_defconfig
先依它为蓝本.
# cd  /
#cd  /linux-2.6.15
# cp   arch/arm/configs/smdk2410_defconfig   ./.config
b.# make clean
# make menuconfig
这里的选项很多都是smdk_2410defconfig默认选择的,默认选择的我们不要去掉,
在它的基础上我们稍加修改就可以了。
其中主要修改3项,如下:
①、修改Bootoptions à
(root=1f04 mem=32M)Default kernel command string
改成你的ppcboot里传递给内核的参数:
Initrd=0x30800000 ,0x400000 mem=64M root=/dev/ram init=linuxrc  console=/dev/ttySAC0
②、选上 Float point emulation à
[ * ] NWFE math emnulaiton
③、修改Driver device  à
   Block device à
(4096)Default RAM disk size (kbytes)
改4096为8192
不要问我为什么,我也不知道~我只是试验出来的。
c.就在这个地方,我栽了很多跟头:
实验情况如下:
① 修改Bootoptions à
(root=1f04 mem=32M)Default kernel command string
改成你的ppcboot里传递给内核的参数:
Initrd=0x30800000 ,0x400000 mem=64M root=/dev/ram init=linuxrc  console=/dev/ttySAC0
②修改了Boot options里的启动参数,立即编译成zImage并tftp到ram中go
的话,会出现
Kernel panic - not syncing: VFS: Unable to mount <script type="text/javascript"> </script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script> root fs on unknown-block(1,0)
这样的错误。
③修改了Boot options里的启动参数,另外还选择Float point emulation à
[ * ] NWFE math emnulaiton
照样出现:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(1,0)
④选择了以上项以外还要选上
[ * ]Initial Ramdisk (initrd) support
会出现以下错误:
RAMDISK: incomplete write (-28 != 32768) 4194304
EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended
VFS: Mounted root (ext2 filesystem).
Freeing init memory: 92K
attempt to access beyond end of device
ram0: rw=0, want=8506, limit=8192
attempt to access beyond end of device
ram0: rw=0, want=8506, limit=8192
attempt to access beyond end of device
ram0: rw=0, want=8506, limit=8192
Failed to execute /linuxrc.  Attempting defaults...
Kernel panic - not syncing: No init found.  Try passing init= option to kernel.
⑤选中boot options
NWFE math emulation
Initrd support
改4096为8192
这次行啦,就可以通过啊!
5.# make zImage
等待编译就可以了。
这样在arch/arm/boot/下就有zImage文件了。
# cp arch/arm/boot/zImage /tftpboot/


还有很多不完善和不明白的地方,还望大侠多多指点.

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值