1. 程式人生 > >linux 2.6.24.4在S3C2410上的移植(核心配置)(基於GEC2410)

linux 2.6.24.4在S3C2410上的移植(核心配置)(基於GEC2410)

移植完u-boot後,接下來就是linux核心了.以下記錄我移植的步驟,如有問題,歡迎指正.
1.下載linux kernel原始碼
http://www.kernel.org/下載linux核心原始碼,這裡我們使用2.6.24.4的核心.
解壓linux-2.6.24.4.tar.bz2
[[email protected] GEC2410]$ tar -xvjf linux-2.6.24.4.tar.bz2
[[email protected] GEC2410]$ cd linux-2.6.24.4

2.修改頂層Makefile,設定交叉編譯器
ARCH  ?= arm
CROSS_COMPILE ?= /home/GEC2410/toolchain/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-

3. 複製編譯配置檔案到linux-2.6.24.4下為預設配置檔案.config,移植過程以sdmk2410開發板為模板.
同時將複製一個新的配置檔案gec2410.defconfig放到configs目錄下,最近的配置都儲存到這個這個檔案,這樣就可以直接用make gec2410_defconfig進行配置了.
[

[email protected]]$cp arch/arm/configs/s3c2410_defconfig arch/arm/configs/gec2410.defconfig
[[email protected]]$cp arch/arm/configs/s3c2410_defconfig .config

3.設定Nand分割槽
我們將nand(64M)分成4個區,分別為u-boot 1MB, Linux Kernel 3MB, Root 40MB, User 20MB.
修改arch/arm/plat-s3c24xx/common-smdk.c中108行的smdk_default_nand_part[]如下:
[
[email protected]
linux-2.6.24.4]$ vim arch/arm/plat-s3c24xx/common-smdk.c


4. 禁止Flash ECC校驗
由於uboot通過軟體ECC,而核心是硬體ECC,所以這裡將核心ECC禁止.
修改drivers/mtd/nand/s3c2410.c中的s3c2410_nand_init_chip()函式,在該函式體最後加上一句:
chip->eccmode = NAND_ECC_NONE;

5 配置核心
(1) 支援啟動時掛載devfs
為了我們的核心支援devfs以及在啟動時並在/sbin/init執行之前能自動掛載/dev為devfs檔案系統,修改fs/Kconfig檔案
vi fs/Kconfig
找到menu "Pseudo filesystems"
新增如下語句:
config DEVFS_FS
bool "/dev file system support (OBSOLETE)"
default y
config DEVFS_MOUNT
bool "Automatically mount at boot"
default y
depends on DEVFS_FS
(2)核心配置
首先載入SMDK2410的核心配置
[[email protected] linux-2.6.24.4]$make smdk2410_defconfig
[[email protected] linux-2.6.24.4]$ make menuconfig
增加MTD,Nand支援,選中
Device Drivers-Memory Technology Device (MTD) support
選中使用預設配置即可,其中包括以下等支援:
<*>MTD partitioning support
<*>Command line partition table parsing
<*>Direct char device access to MTD devices
<*>Caching block device access to MTD devices
<*>NAND Device Support
      <*>NAND Flash support for S3C2410/S3C2440 SoC
增加FS支援(NFS,cramfs):
File System:
<*>Network File Systems
       Miscellaneous filesystems -->
          <*>Compressed ROM file system support (cramfs)  
      Pseudo filesystems -->
          <*>/dev file system support (OBSOLETE)
可以看到上面設定的devfs已經被支援了.
儲存配置檔案,下次就可以用make gec2410_defconfig來載入配置資訊了.
[[email protected]]$cp .config arch/arm/configs/gec2410_defconfig

6.製作uImage
zImage是ARM Linux常用的一種壓縮映像檔案,uImage是U-boot專用的映像檔案,它是在zImage之前加上一個長度為0x40的“頭”,說明這個映像檔案的型別、載入位置、生成時間、大小等資訊。
可以使用mkimage來生成uImage,該工具位於u-boot下的tools目錄,編譯完u-boot就可以找到這個工具.我們拷到/linux2.6.24/arm/arm/boot/,用來將zImage生成uImage.
其引數含義為
         -A ==> set architecture to 'arch'   //用於指定CPU型別,比如ARM
          -O ==> set operating system to 'os'  //用於指定作業系統,比如Linux
          -T ==> set image type to 'type'      //用於指定image型別,比如Kernel
          -C ==> set compression type 'comp'   //指定壓縮型別
          -a ==> set load address to 'addr' (hex)  //指定image的載入地址
          -e ==> set entry point to 'ep' (hex)     //核心的入口地址,一般是:image的載入地址+0x40(資訊頭的大小)
          -n ==> set image name to 'name'          //image在頭結構中的命名
          -d ==> use image data from 'datafile'    //無頭資訊的image檔名
          -x ==> set XIP (execute in place)        //設定執行位置

[[email protected] boot]$ ./mkimage -A arm -O linux -T kernel -C none -a 30008000 -e 30008040 -n linux-2.6.24 -d zImage uImage
為了方便起見,我們將這個命令寫入到一個mkuimage.sh的批處理檔案中,這樣只要執行這個檔案就不必輸入這麼長的命令了.
mkuimage.sh:
echo "making uImage..."

./mkimage -A arm -O linux -T kernel -C none -a 30008000 -e 30008040 -n linux-2.6.24 -d zImage uImage

echo "making uImage finished..."
然後執行:
[[email protected] linux-2.6.24.4]$ cd arch/arm/boot
[[email protected] boot]$ chmod 777 mkuImage.sh
[[email protected] boot]$ sh mkuImage.sh(或者./mkuImage.sh)
making uImage...
Image Name:   linux-2.6.24
Created:      Mon May 24 10:06:09 2010
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    1567656 Bytes = 1530.91 kB = 1.50 MB
Load Address: 0x30008000
Entry Point:  0x30008040
making uImage finished...
就可以看到uImage生成了.

使用u-boot燒寫uImage到nand,設定啟動引數讓u-boot自動載入uImage執行核心.
GEC2410#tftp 30008000 uImage
GEC2410#nand erase 100000 200000
GEC2410#nand write 30008000 100000 200000
GEC2410#setenv bootcmd nand read 30008000 100000 200000/;bootm

GEC2410#saveenv
GEC2410#bootm

## Booting image at 30008000 ...
   Image Name:   linux-2.6.24
   Created:      2010-05-21   8:35:34 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    1567720 Bytes =  1.5 MB
   Load Address: 30008000
   Entry Point:  30008040
   Verifying Checksum ... OK
   XIP Kernel Image ... OK

Starting kernel ...

Uncompressing Linux.............................................................
......................................... done, booting the kernel.
......
這時linux就啟動了,但這時cs8900網絡卡驅動還沒有,根檔案系統還沒有.系統會停在.
No filesystem could mount root, tried:  ext3 ext2 cramfs msdos vfat romfs
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)
下一步先移植cs8900網絡卡驅動,然後是根檔案系統.