原创 linux2.6.14内核+yaffs系统移植

2009-3-25 14:33 6010 6 14 分类: MCU/ 嵌入式

rar


----------------------编译内核-----------------
修改 Makefile
主要是以下两项:
1 ) ARCH = arm
2) CROSS_COMPILE = /arm-linux-
选中 load an Alternate Configuration File ,然后键入配置文件的路径。
在我刚编译内核的时候选择的是 linux-2.6.14/arch/arm/configs/smdk2410_defconfig 这个配置文件。
-------------------让内核支持 yaffs 文件系统----------
1. MTD 分区的支持
进入Device Drivers->Memory Technology Devices(MTD)目录,配置界面如下:
Memory Technology Device (MTD) support
[ ]   Debugging                                                          │ │
[ ]   MTD concatenating support                                          │ │

  •    MTD partitioning support                                           │ │
    [ ]     RedBoot partition table parsing                                  │ │
    [ ]     Command line partition table parsing                             │ │
    [ ]     ARM Firmware Suite partition parsing                             │ │
    ---   User Modules And Translation Layers                                │ │
  •    Direct char device access to MTD devices                           │ │
  •    Caching block device access to MTD devices                         │ │
    [ ]   FTL (Flash Translation Layer) support                              │ │
    [ ]   NFTL (NAND Flash Translation Layer) support                        │ │
    [ ]   INFTL (Inverse NAND Flash Translation Layer) support               │ │
    RAM/ROM/Flash chip drivers  --->                                   │ │
    Mapping drivers for chip access  --->                              │ │
    Self-contained MTD device drivers  --->                            │ │
    NAND Flash Device Drivers  --->                                    │ │


    进入NAND Flash Device Drivers目录,配置界面如下:

  • NAND Device Support                                              │ │
    [ ]   Verify NAND page writes                                        │ │
  • NAND Flash support for S3C2410/S3C2440 SoC                       │ │
  •    S3C2410 NAND driver debug                                      │ │
    [ ]   S3C2410 NAND Hardware ECC                                      │ │
    [ ] DiskOnChip 2000, Millennium and Millennium Plus (NAND reimplement│ │
    [ ] Support for NAND Flash Simulator                                 │ │


    其它不用多设,甚至 Direct char device access to MTD devices 选项和Mapping drivers for chip access  ---> 目录下的所有选项都可以去掉(经已试验过) 。因为那些是为 nor flash 服务的,一般文件系统都会放在 nand flash 上吧,不过也不排除例外。那你就干脆让它们留着好了,因为编译出来后实在多不了多少,我把它们去掉的原因只是为了试验 ^_^
    -----------------------添加驱动---------------------
    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[] ={
    [0] = {
    .name = "bootloader",
    .offset = 0x00000000,
    .size = 0x00030000,
    },
    [1] = {
    .name = "kernel",
    .offset = 0x00030000,
    .size = 0x00200000,
    },
    [2] = {
    .name = "root",
    .offset = 0x00230000,
    .size = 0x03dcc000,
    }
    };
    注:分区表信息要参考你自己的内核和文件系统的大小,排布来设置,vivi中的分区信息要和mtd分区信息一致,分多少个区由你自己决定,
    2. 加入Nand Flash分区
    struct s3c2410_nand_set nandset ={
    nr_partitions: 3, /* 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,
    };
    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
     }
    };
    /*----------------------禁止Flash ECC校验(yaffs系统好像不用)---------
    vi drivers/mtd/nand/s3c2410.c
    找到s3c2410_nand_init_chip()函数,在该函数体最后加上一条语句:
    chip>
    eccmode = NAND_ECC_NONE;
    保存,退出。*/
    ----------------------------指定启动时初始化--------------
    kernel启动时依据我们对分区的设置进行初始配置修改arch/arm/mach-s3c2410/mach-smdk2410.
    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,
    };
    --------------------内核加上对yaffs2支持-----------------
    下载yaffs2.tar.gz源码包,解压源码,并进入目录执行
    #./patch-ker.sh /linux-2.6.14.1/
    File systems->Miscellaneous filesystems 目录,配置信息如下:

  • YAFFS2 file system support                                               │ │
    ---   512 byte / page devices                                                │ │
    []     Lets Yaffs do its own ECC                                            │ │
    []       Use the same ecc byte order as Steven Hills nand_ecc.c            │ │
    ---   2048 byte (or larger) / page devices                                   │ │
    []     Autoselect yaffs2 format                                             │ │
    []     Disable lazy loading                                                 │ │
    []   Turn off wide tnodes                                                   │ │
    []   Turn off debug chunk erase check                                       │ │
    []   Cache short names in RAM


    在这里要说明一下以上的配置,在论坛发贴的时候我因为对它不怎么了解,几乎是全部选上的。后来经过自己的理解和摸索,发现:
    1、 ---   2048 byte (or larger) / page devices   目录以下全部不用选,因为这是 yaffs2 文件系统的,如果你是用 yaffs 文件系统的话就不必选择这个了 ( 我到现在还没去研究 yaffs2 比 yaffs 文件系统优越多少,反正 yaffs 文件系统用得好好的 )  
    2、 Lets Yaffs do its own ECC 这一项,网上很多人说 yaffs 文件系统和 mtd 驱程的更新速度问题,导致加上 ecc 检测后,会挂不了 yaffs 文件系统,所以要把 mtd 驱程的 ecc 检测去掉,让 yaffs 自己做 ecc 检测(就是要选上这一项)。不过去掉 mtd 驱程 ecc 检测的后果就是换来烦人的 Reading data from NAND FLASH without ECC is not recommended 的提示,后来发现原来把 mtd 驱程的 ecc 检测加回去,也可以很好的支持 yaffs 文件系统,所以就把这一项去掉了,终于可以不用再看那烦人的提示了 ^_^
    -----------------------devfs-----------------------
    拷贝下面几项到2.6.14的fs/Kconfig中去:
    找到menu "Pseudo filesystems"
    config DEVFS_FS
    bool "/dev file system support (OBSOLETE)"
    depends on EXPERIMENTAL
    help


    config DEVFS_MOUNT
    bool "Automatically mount at boot"
    depends on DEVFS_FS
    help


    config DEVFS_DEBUG
    bool "Debug devfs"
    depends on DEVFS_FS
    help


    重新make menuconfig 在File systems->Pseudo filesystems目录里面可以后到devfs的配置选项如下:

  • /proc file system support                                          │ │
  • /dev file system support (OBSOLETE)                                │ │
  •    Automatically mount at boot                                      │ │
  •    Debug devfs                                                      │ │
  • Virtual memory file system support (former shm fs)                 │ │
    [ ] Relayfs file system support
    顺便说一下,在内核配置的时候经常会看到 debug 选项吧?这是为了调度内核用的,你不需要的话可以去掉。有时还会让你选择 quiet 和 nosy ,选择 nosy 的话输出的调试信息当然会比 quiet 要多了。


     


    保存。


    make zImage。(附上自己的zImage)


     


    启动信息:


    VIVI version 0.1.4 (root@localhost.localdomain) (gcc version 2.95.3 20010315 (release)) #0.1.4 Wed Sep 13 21:06:12 EDT 2006
    MMU table base address = 0x33FBC000
    Succeed memory mapping.
    +---------------------------------------------+
    |  YC2410  USB Downloader ver R2.00  06-12-08 |
    +---------------------------------------------+
    FCLK=200MHz,DMA mode
    USB: IN_ENDPOINT:1 OUT_ENDPOINT:3
    FORMAT: <ADDR(DATA):4>+<SIZE(n+10):4>+<DATA:n>+<CS:2>
    NAND device: Manufacture ID: 0xec, Chip ID: 0x76 (Samsung K9D1208V0M)
    Could not found stored vivi parameters. Use default vivi parameters.
    Press Return to start the LINUX/Wince now, any other key for vivi
    Copy linux kernel from 0x00050000 to 0x30008000, size = 0x00200000 ... done
    zImage magic = 0x016f2818
    Setup linux parameters at 0x30000100
    linux command line is: "noinitrd root="31:2" init="/linuxrc" console="ttySAC0""
    MACH_TYPE = 193
    NOW, Booting Linux......
    Uncompressing Linux................................................................................. done, booting the kernel.
    Linux version 2.6.14 (root@localhost.localdomain) (gcc version 3.4.1) #34 Sat Mar 21 03:29:48 CST 2009
    CPU: ARM920Tid(wb) [41129200] revision 0 (ARMv4T)
    Machine: SMDK2410
    ATAG_INITRD is deprecated; please update your bootloader.
    Memory policy: ECC disabled, Data cache writeback
    CPU S3C2410A (id 0x32410002)
    S3C2410: core 200.000 MHz, memory 100.000 MHz, peripheral 50.000 MHz
    S3C2410 Clocks, (c) 2004 Simtec Electronics
    CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
    USB Control, (c) 2006 s3c2410
    CPU0: D VIVT write-back cache
    CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
    CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
    Built 1 zonelists
    Kernel command line: noinitrd root="31:2" init="/linuxrc" console="ttySAC0"
    irq: clearing subpending status 00000002
    PID hash table entries: 512 (order: 9, 8192 bytes)
    timer tcon="00000000", tcnt a2c1, tcfg 00000200,00000000, usec 00001eb8
    Console: colour dummy device 80x30
    Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
    Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
    Memory: 64MB = 64MB total
    Memory: 62208KB available (1998K code, 475K data, 104K init)
    Mount-cache hash table entries: 512
    CPU: Testing write buffer coherency: ok
    softlockup thread 0 started up.
    NET: Registered protocol family 16
    S3C2410: Initialising architecture
    SCSI subsystem initialized
    usbcore: registered new driver usbfs
    usbcore: registered new driver hub
    devfs: 2004-01-31 Richard Gooch (rgooch@atnf.csiro.au)
    devfs: boot_options: 0x1
    yaffs Mar 20 2009 22:17:07 Installing.
    Console: switching to colour frame buffer device 40x30
    fb0: s3c2410fb frame buffer device
    fb1: Virtual frame buffer device, using 1024K of video memory
    s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2410
    s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2410
    s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2410
    io scheduler noop registered
    io scheduler anticipatory registered
    io scheduler deadline registered
    io scheduler cfq registered
    RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
    usbcore: registered new driver ub
    Cirrus Logic CS8900A driver for Linux (Modified for SMDK2410)
    eth0: CS8900A rev E at 0xe0000300 irq="53", no eeprom , addr: 08: 0:3E:26:0A:5B
    Linux video capture interface: v1.00
    V4L-Driver for Vision CPiA based cameras v1.2.3
    Since in-kernel colorspace conversion is not allowed, it is disabled by default now. Users should fix the applications in case they don't work without conversion reenabled by setting the 'colorspace_conv' module parameter to 1<6>USB driver for Vision CPiA based cameras v1.2.3
    usbcore: registered new driver cpia
    S3C24XX NAND Driver, (c) 2004 Simtec Electronics
    s3c2410-nand: mapped registers at c4980000
    s3c2410-nand: timing: Tacls 10ns, Twrph0 40ns, Twrph1 10ns
    NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit)
    Scanning device for bad blocks
    Creating 3 MTD partitions on "NAND 64MiB 3,3V 8-bit":
    0x00000000-0x00030000 : "bootloader"
    0x00030000-0x00230000 : "kernel"
    0x00230000-0x03ffc000 : "root"
    usbmon: debugfs is not available
    s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
    s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
    s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
    hub 1-0:1.0: USB hub found
    hub 1-0:1.0: 2 ports detected
    Initializing USB Mass Storage driver...
    usb 1-1: new full speed USB device using s3c2410-ohci and address 2
    usbcore: registered new driver usb-storage
    USB Mass Storage support registered.
    usbcore: registered new driver usbhid
    drivers/usb/input/hid-core.c: v2.6:USB HID core driver
    usbcore: registered new driver ov511
    drivers/usb/media/ov511.c: v1.64 for Linux 2.5 : ov511 USB Camera Driver
    drivers/usb/media/spca5xx/spca_core.c: USB SPCA5XX camera found. Type Vimicro Zc301P 0x301b
    usbcore: registered new driver spca5xx
    drivers/usb/media/spca5xx/spca_core.c: spca5xx driver 00.57.06LE registered
    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
    yaffs: dev is 32505858 name is "mtdblock2"
    yaffs: Attempting MTD mount on 31.2, "mtdblock2"
    VFS: Mounted root (yaffs filesystem).
    Mounted devfs on /dev
    Freeing init memory: 104K
    init started: BusyBox v1.9.2 (2009-03-19 21:06:33 CST)
    starting pid 703, tty '': '/etc/init.d/rcS'
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ^     Welcome to YAFFS root filesystem!   ^
    ^                    Qiu                  ^
    ^^^^^^^^^^^^^^^^09-3-18^^^^^^^^^^^^^^^^^^^^
    # mount all...........
    # Starting mdev.........
    starting pid 711, tty '': '/bin/sh'
    [root@Qiu /]#

  • PARTNER CONTENT

    文章评论8条评论)

    登录后参与讨论

    用户377235 2012-6-15 15:22

    thanks

    用户377235 2012-5-2 09:39

    硬件测试还是比较复杂的,有点累呢

    用户603678 2012-4-7 20:02

    多讲讲频谱仪的使用心得

    用户377235 2012-3-31 11:17

    深有同感,本人也做过硬件开发……

    用户1679196 2009-8-27 17:55

    http://www.aleph1.co.uk/cgi-bin/viewcvs.cgi/

    用户1679196 2009-8-14 15:56

    Failed to execute /linuxrc. Attempting default... Kernel panic: No init found. Try passing init= option to kernel. 你的内核在编译的时候启动参数可能有问题。可能不是你的文件系统问题。

    用户44267 2009-8-14 14:12

    能否将您使用的yaffs源码和yaffs根文件目录发给我参考下麽? llclown@163.com 万分感谢 我总是得到这个错误: VFS: Mounted root (yaffs filesystem). Freeing init memory: 116K Warning: unable to open an initial console. Failed to execute /linuxrc. Attempting default... Kernel panic: No init found. Try passing init= option to kernel.

    用户1679196 2009-6-11 11:34

    发过去了

    用户211975 2009-6-9 19:30

    可以给我发一下你的mkyaffsimage吗, gengxinghuan@126.com

    用户1679196 2009-4-22 10:32

    我突然还想不起来yaffs的源码哪下了,mkyaffsimage的源码我是没有啦,用现成的。发给你了。
    相关推荐阅读
    用户1679196 2009-09-04 16:17
    两个linux按键驱动之二 read(定时器去抖动)
    //相比之下poll更为实用,但是这个代码实在太具有代表性了...涉及了下面几个知识。代码很大部分是linux设备驱动开发详解的内容。/*1、阻塞读取,队列概念2、睡眠等待中断产生3、定时器产生及相应...
    用户1679196 2009-09-04 16:08
    两个linux按键驱动之一 poll(未去抖动)
    //驱动//未加去抖动//通过poll判断是否可读来得到中断值#include <linux/module.h> #include <linux/kernel.h>#inclu...
    用户1679196 2009-09-04 09:39
    select 使用
    以下来自网络搜索:Linux下select调用的过程:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:offi...
    用户1679196 2009-09-03 14:52
    Linux设备驱动之定时器
    Linux内核中定义了一个timer_list结构,我们在驱动程序中可以利用之: #include<linux/timer.h> struct timer_list { struct li...
    用户1679196 2009-08-28 17:38
    loff_t *ppos是什么东东
    ssize_t generic_file_read(struct file * filp, char * buf, size_t count, loff_t *ppos) 这是一个文件读函数 我们很容...
    用户1679196 2009-08-12 17:30
    linux 延时函数几个资料
    http://www.cppblog.com/CppExplore/archive/2008/04/02/46111.html一、 基础知识1、时间类型。Linux下常用的时间类型有4个:time_t...
    EE直播间
    更多
    我要评论
    8
    6
    关闭 站长推荐上一条 /3 下一条