linux2.6.14内核移植到2410(一)

     我这里主要是按<<基于S3C2410的Linux全线移植文档.pdf>>文档来做的。
    在 arch/arm/mach­s3c2410/devs.c 文件中:

[arm@localhost linux­2.6.14]$ vi arch/arm/mach­s3c2410/devs.c
添加如下内容:
#include <linux/mtd/partitions.h>
#include <linux/mtd/nand.h>
#include <asm/arch/nand.h>
...
/* NAND Controller */
1.建立 Nand Flash 分区表
/* 一个 Nand Flash 总共 64MB, 按如下大小进行分区 */
static struct mtd_partition partition_info[] ={
    { /* 128k */
        name: "vivi",
        size: 0x00100000,
        offset: 0x0,
    },{ /* 64K */
        name: "param",
        size: 0x00010000,
        offset: 0x00020000,
    }, { /* 2MB */
        name: "kernel",
        size: 0x00220000,
        offset: 0x00030000,
    }, { /* 2M+128k */
        name: "root",
        size: 0x00200000,
        offset: 0x00200000,
    },  { /* 58M */
        name: "user",
        size: 0x03a00000,
        offset: 0x00400000,
    }
}
name: 代表分区名字
size: 代表 flash 分区大小(单位:字节)
offset: 代表 flash 分区的起始地址(相对于 0x0 的偏移)
目标板计划分 4 个区,分别存放 bootloader, kernel, rootfs 以及以便以后扩展使用的用户文件系统空间。
各分区在 Nand flash 中起始地址. 分区大小. 记录如下:
mtdpart info. (5 partitions)
name              offset        size        flag
------------------------------------------------
vivi            : 0x00000000    0x00020000     0  128k
param           : 0x00020000    0x00010000     0   64k
root            : 0x00200000    0x00200000     0    2M
kernel          : 0x00030000    0x00220000     0    2M+128k
user            : 0x00400000    0x03a00000     0   58M

2. 加入 Nand Flash 分区
struct s3c2410_nand_set nandset ={
           nr_partitions: 5,                    /* the number of partitions */
           partitions: partition_info, /* partition table                 */
};
nr_partitions: 指明 partition_info 中定义的分区数目
partitions: 分区信息表
3. 建立 Nand Flash 芯片支持
struct s3c2410_platform_nand superlpplatform={
           tacls:0,
           twrph0:30,
           twrph1:0,
           sets: &nandset,
           nr_sets: 1,
};
tacls, twrph0, twrph1 的意思见 S3C2410 手册的 6­3, 这 3 个值最后会被设置到 NFCONF 中,见 S3C2410 手册 6­6.
sets: 支持的分区集
nr_set:分区集的个数
4. 加入 Nand Flash 芯片支持到 Nand Flash 驱动
另外,还要修改此文件中的 s3c_device_nand 结构体变量,添加对 dev 成员的赋值
struct platform_device s3c_device_nand = {
           .name             = "s3c2410­nand",     /* Device name */
           .id                   = ­1,                           /* Device ID     */
           .num_resources    = ARRAY_SIZE(s3c_nand_resource),
           .resource         = s3c_nand_resource, /* Nand Flash Controller Registers */
           /* Add the Nand Flash device */
           .dev = {
                       .platform_data = &superlpplatform
            }
};
name:  设备名称
id: 有效设备编号,如果只有唯一的一个设备为­1, 有多个设备从 0 开始计数.
num_resource: 有几个寄存器区
resource: 寄存器区数组首地址
dev: 支持的 Nand Flash 设备

5. 为了我们的内核支持 devfs 以及在启动时并在/sbin/init 运行之前能自动挂载/dev 为 devfs 文件系统,修改
fs/Kconfig 文件
[arm@localhost linux­2.6.14]$ 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
6.        配置内核产生.config 文件
[arm@localhost linux­2.6.14]$ cp arch/arm/configs/s3c2410_defconfig  .config
[arm@localhost linux­2.6.14]$ make menuconfig
在 smdk2410_defconfig 基础上,我所增删的内核配置项如下:
Loadable module support  ­­­>
                           [*] Enable loadable module support 
                                      [*] Automatic kernel module loading
System Type  ­­­> [*] S3C2410 DMA support
Boot options  ­­­> Default kernel command string:
         noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0,115200     
         #说明:mtdblock2 代表我的第 4 个 flash 分区,它是我的 rootfs
         #     console=ttySAC0,115200 使 kernel 启动期间的信息全部输出到串口 0 上.
         #     2.6 内核对于串口的命名改为 ttySAC0,但这不影响用户空间的串口编程。
         #     用户空间的串口编程针对的仍是/dev/ttyS0 等
         #     如果你的bootLoader可以向内核传递启动参数,则这一项可以不设置,如果我的就是在VIVI中设置上面的参数的
Floating point emulation  ­­­>
                           [*] NWFPE math emulation
                               This is necessary to run most binaries!!!
#接下来要做的是对内核 MTD 子系统的设置
Device Drivers  ­­­>
         Memory Technology Devices (MTD)  ­­­>
                           [*] MTD partitioning support 
                               #支持 MTD 分区,这样我们在前面设置的分区才有意义
                           [*] Command line partition table parsing
                               #支持从命令行设置 flash 分区信息,灵活
                                      RAM/ROM/Flash chip drivers  ­­­>
                                         <*> Detect flash chips by Common Flash
                                                Interface (CFI) probe
                                         <*> Detect non­CFI AMD/JEDEC­compatible flash chips
                                         <*> Support for Intel/Sharp flash chips
                                         <*> Support for AMD/Fujitsu flash chips
                                         <*> Support for ROM chips in bus mapping
                                      NAND Flash Device Drivers  ­­­>
                                         <*> NAND Device Support
                                         <*> NAND Flash support for S3C2410/S3C2440 SoC
         Character devices  ­­­>
                           [*] Non­standard serial port support
                           [*] S3C2410 RTC Driver
#接下来做的是针对文件系统的设置,本人实验时目标板上要上的文件系统是 cramfs,故做如下配置
File systems  ­­­>
                          <> Second extended fs support   #去除对 ext2 的支持
                  Pseudo filesystems  ­­­>
                          [*] /proc file system support
                          [*] Virtual memory file system support (former shm fs)
                          [*] /dev file system support (OBSOLETE)
                          [*] Automatically mount at boot (NEW)
                              #这里会看到我们前先修改 fs/Kconfig 的成果,devfs 已经被支持上了
                  Miscellaneous filesystems  ­­­>
                          <*> Compressed ROM file system support (cramfs)
                              #支持 cramfs
                  Network File Systems  ­­­>
                          <*> NFS file system support
                            
保存退出,产生.config 文件.
7. 这里还有一个方面要注意的,就是ECC问题,如果不把
    Device Drivers  --->
     Memory Technology Devices (MTD)  --->
        NAND Flash Device Drivers  --->
            [*]   S3C2410 NAND Hardware ECC
    去掉会出现如下的问题:
end_request: I/O error, dev mtdblock3, sector 2
EXT3-fs: unable to read superblock
end_request: I/O error, dev mtdblock3, sector 0
Buffer I/O error on device mtdblock3, logical block 0
end_request: I/O error, dev mtdblock3, sector 0
Buffer I/O error on device mtdblock3, logical block 0
end_request: I/O error, dev mtdblock3, sector 8
Buffer I/O error on device mtdblock3, logical block 1
end_request: I/O error, dev mtdblock3, sector 8
Buffer I/O error on device mtdblock3, logical block 1
end_request: I/O error, dev mtdblock3, sector 16
Buffer I/O error on device mtdblock3, logical block 2
end_request: I/O error, dev mtdblock3, sector 16
Buffer I/O error on device mtdblock3, logical block 2
end_request: I/O error, dev mtdblock3, sector 24
Buffer I/O error on device mtdblock3, logical block 3
end_request: I/O error, dev mtdblock3, sector 24
Buffer I/O error on device mtdblock3, logical block 3
end_request: I/O error, dev mtdblock3, sector 0
FAT: unable to read boot sector
VFS: Cannot open root device "mtdblock3" or unknown-block(31,3)
Please append a correct "root=" boot option
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,3)
 另外,还要在在/linux-2.6.14.1/drivers/mtd/nand/s3c_2410.c中将
chip->eccmode = NAND_ECC_SOFT 改为 chip->eccmode = NAND_ECC_NONE;

8.  关于initrd及RamDisk的问题
       在做2.6.14内核移植之前,我本来是想移植2.6.15的,但是出现了如是的一些问题:就是无法打开根文件系统,        终端显示的信息如下:
        VFS: Cannot open root device "mtdblock3" or unknown-block(31,3)
        Please append a correct "root=" boot option
        Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,3)
       后来改成2.6.14,同样的配置,却不会出现如上的问题。但是在这个过程中我却对RamDisk有了较好的掌握,        包括它也initrd的关系。
                Ramdisk是用来挂载根文件系统而在内存中开辟的地块区域,如果你需要你的内核支持Ramdisk,那么你需要作以下的更改:
   1). 首先,设置vivi的linux_cmd_line为:
    param set linux_cmd_line  "initrd=0x30800000,0x400000 root=/dev/ram0 init=/linuxrc         console=ttySAC0  max=00:0e:3a:aa:bb:cc"
    如果你的bootloader不可以设置启动参数,也可以在
    Boot options  --->   中的第三个选项中按回车进行设置。      
    我通过多次的测试,发现initrd=0x30800000,0x400000的作用就是在RAM中开辟一块始起地址为0x30800000,大小为    4MB的Ramdisk.
   2). 其次还要在配置内核的时候注意以下的选项:
     Device Drivers  --->
         Block devices  --->
            <*> RAM disk support                                     │ │ 
  │ │            (16)  Default number of RAM disks (NEW)                  │ │ 
  │ │            (4096) Default RAM disk size (kbytes) (NEW)              │ │ 
  │ │            [*]   Initial RAM disk (initrd) support
    这样内核就可以支持从Ramdisk启动了。其中4096KB要与上面设置的Ramdisk大小一致,这里为4MB。
    编译内核之后,这样子启动:
    net tftp 192.168.1.100 30008000 zImage
    net tftp 192.168.1.100 30800000 root_china.cramfs
    boot ram 30008000 0x12fee8      
    如果你不想用Ramdisk来挂载文件系统,直接从Flash中打开文件系统,那么在配置内核的时候,可以将RAM     disk support支持去掉。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值