移植2.6.15至HHARM2410-STUDY

來源:互聯網
上載者:User

  移植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。

㈡.製作空的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)

       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

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/

還有很多不完善和不明白的地方,還望大俠多多指點.

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.