Chinaunix首页 | 论坛 | 博客
  • 博客访问: 416977
  • 博文数量: 131
  • 博客积分: 1990
  • 博客等级: 上尉
  • 技术积分: 996
  • 用 户 组: 普通用户
  • 注册时间: 2009-09-24 12:15
文章分类
文章存档

2011年(4)

2010年(19)

2009年(108)

我的朋友

分类: LINUX

2009-09-29 14:41:08

2.4内核由于本身并不支持2410,移植起来较为烦琐,所以直接上2.6的版本.
1.准备工作

下载解压交叉编译工具,2.6的内核编译要用3.4.1版本的(arm-linux-gcc-3.4.1).
    下载解压2.6.14.1内核.
    之前文章已经说明不再赘述.
2.Flash分区管理
    启动开发板,进入vivi,查看vivi的分区信息.
    分区信息如下所示:
分区
起始地址
分区大小
分区作用
Part0
0x0
0x00020000 (128k)
bootloader
Part1
0x00020000
0x00010000 (64k)
bootloader params
Part2
0x00030000
0x001c0000 (1m+768k)
linux kernel
Part3
0x00200000
0x00400000 (4m)
root filesystem
Part4
0x00600000
0x03a00000 (58m)
usr filesystem
    根据实际需要也可相应的更改分区表.
3.修改Makefile
       #vi Makefile
       找到ARCH与CROSS_COMPILE,修改为
       ARCH ?= arm
       CROSS_COMPILE ?= /usr/local/arm/3.4.1/bin/arm-linux-
4.将Flash分区信息加入内核
#vi arch/arm/mach-s3c2410/devs.c
添加头文件:
        #include
#include
#include
添加分区结构:
        static struct mtd_partition partition_info[]={
                {name:"bootloader",
                offset:0,
                size: 0x00020000,},

                {name:"param",
                offset:0x00020000,
                size:0x00010000,},

                {name:"kernel",
                offset:0x00030000,
                size:0x001c0000,},

                {name:"root",
                offset:0x00200000,
                size:0x00400000,},

                {name:"usr",
                offset:0x00600000,
                size:0x03a00000,}
        };

struct s3c2410_nand_set nandset={
                     nr_partitions: 5,                          //分区数量
                     partitions: partition_info,             //分区表
};
struct s3c2410_platform_nand superlpplatform={
       //NAND Flash芯片支持
       //参数意义可参考S3C2410手册
                     tacls: 0,
                     twrph0: 30,
                     twrph1: 0,
                     sets: &nandset,
                     nr_sets: 1,
};

  修改s3c_device_nand,以加入NAND Flash驱动:
              struct platform_device s3c_device_nand = {
                     .name = "s3c2410-nand",      //设备名称
                     .id = -1, //有效设备编号,-1表示唯一设备
                     .num_resources = ARRAY_SIZE(s3c_nand_resource),   //寄存器区的个数
                     .resource = s3c_nand_resource,     //寄存器区的首地址
                     //添加如下信息,表示NAND Flash设备
       .dev={
                            .platform_data=&superlpplatform
                     }
};
5.指定启动时的设备初始化
       #vi arch/arm/mach-s3c2410/mach-smdk2410.c
       修改:
       static struct platform_device *smdk2410_devices[] __initdata = {
              &s3c_device_usb,
              &s3c_device_lcd,
              &s3c_device_wdt,
              &s3c_device_i2c,
              &s3c_device_iis,
              //添加如下信息
              &s3c_device_nand,
};
6.禁止Flash ECC效验
内核通过vivi把数据写入NAND Flash,而vivi的ECC效验算法和内核的不同,内核的效验码是由NAND Flash控制器产生的,所以在此必须禁用NAND Flash ECC。
#vi drivers/mtd/nand/s3c2410.c
找到s3c2410_nand_init_chip函数,加入chip->eccmode的值为:
NAND_ECC_NONE

7.内核配置与编译
为了我们的内核支持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
配置内核:
#cp arch/arm/configs/smdk2410_defconfig .config
#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代表我的第3个flash分区,它是我的rootfs
# console=ttySAC0,115200使kernel启动期间的信息全部输出到串口0上.
# 2.6内核对于串口的命名改为ttySAC0,但这不影响用户空间的串口编程。
# 用户空间的串口编程针对的仍是/dev/ttyS0等
Floating point emulation >
[*] NWFPE math emulation
This is necessary to run most binaries!!!
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 nonCFI AMD/JEDECcompatible 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 >
[*] Nonstandard serial port support
[*] S3C2410 RTC Driver
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


编译内核:
#make zImage

8.加载内核
vivi>load flash kernel t
修改vivi启动参数:
vivi>param set linux_cmd_line “noinitrd root=/dev/mtdblock/3 init=/linuxrc console=ttySAC0,115200”
vivi>param save
但是我自己的还没移植成功
mice: PS/2 mouse device common for all mice
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 2, 16384 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
TCP bic registered
NET: Registered protocol family 1
Reading data from NAND FLASH without ECC is not recommended
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)
每次到这就停,郁闷中.........
阅读(940) | 评论(0) | 转发(0) |
0

上一篇:买票

下一篇:s3c2410 bootloader 阅读笔记

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