zoukankan      html  css  js  c++  java
  • nand中间出现坏块,无法正常启动内…

    我板子的启动过程如下:

    ..showlogo..
    Flash:   1 MB
    NAND:    SLC detected.256 MB
    In:      serial
    Out:     serial
    Err:     serial
    *************show logo***************Hit any key to stop autoboot:  0

    NAND read: device 0 offset 0x900000, size 0x300000
    s3c-nand: ECC uncorrectable error detected
    s3c-nand: ECC uncorrectable error detected
    s3c-nand: ECC uncorrectable error detected
    s3c-nand: ECC uncorrectable error detected
    s3c-nand: ECC uncorrectable error detected
    s3c-nand: ECC uncorrectable error detected
    s3c-nand: ECC uncorrectable error detected
                      .....
    s3c-nand: ECC uncorrectable error detected
    s3c-nand: ECC uncorrectable error detected
    s3c-nand: ECC uncorrectable error detected
    s3c-nand: ECC uncorrectable error detected
    s3c-nand: ECC uncorrectable error detected
    s3c-nand: ECC uncorrectable error detected
    s3c-nand: ECC uncorrectable error detected
    s3c-nand: ECC uncorrectable error detected
     3145728 bytes read: ERROR
    get_format
    -------- 0 --------
    Wrong Image Format for bootm command
    ERROR: can't get kernel image!

    分析:uboot能够正常启动,但是从这句“NAND read: device 0 offset 0x900000, size 0x300000
    ”可以看出在nand中0x900000出开始读kernel到内存时,出错,问题应该出在这段nand中,幸亏uboot能正常启动,那就好说了,直接重新给nand分区,然后修改uboot启动后设置启动参数,就可以搞定了。

    值得注意的是:nand分区在linux内核中修改,/arch/arm/plat-s3c24xx/common-smdk.c

                                            struct mtd_partition s3c_partition_info[]

    板子原来的分区如下:

    struct mtd_partition s3c_partition_info[] = {
            {
                    .name  = "Bootloader",
                    .offset  = 0,
                    .size  = (1024*SZ_1K),
                 //   .mask_flags = MTD_CAP_NANDFLASH,
      
            },
      {
                    .name  = "Logo",
                    .offset  = MTDPART_OFS_APPEND,
                    .size  = (8*SZ_1M),
                   
                   // .mask_flags = MTD_CAP_NANDFLASH,
            },
            {
                    .name  = "Kernel",
                    .offset  = MTDPART_OFS_APPEND,
                    .size  = (3*SZ_1M),
                   // .mask_flags = MTD_CAP_NANDFLASH,
            },
    #ifdef CONFIG_SPLIT_ROOT_FILESYSTEM
            {
                    .name  = "Root - Cramfs",
                    .offset  = MTDPART_OFS_APPEND,
                    .size  = (48*SZ_1M),
            },
    #endif
            {
                    .name  = "File System",
                    .offset  = MTDPART_OFS_APPEND,
                    .size  = MTDPART_SIZ_FULL,
            }
    };

    #endif

    从上可以看出我板子的nand分区是:Bootloader --1M           0x0000 0000--0x0010 0000

                                    Logo       --8M           0x0001 0000--0x0090 0000

                                    Kernel     --3M           0x0009 0000--0x00c0 0000

                                    Root - Cramfs  --48M      0x000c 0000--0x03c0 0000

                                    File System    --剩余都是 0x03c0 0000--末尾

    从上面可以看出,我们内核那部分空间会有部分坏块可能,所以我们要把内核空间往后移动2M空间就足够解决问题了,由于变量MTDPART_OFS_APPEND的使用,我们很好改变分区的位置和大小,我们只需要把Bootloader的空间增加2M就可以了,后面的分区就依次向后弄懂2M位置(uboot一般都很小,一般500多kb,所以后面的大部分空间就浪费了,由于nand一般都比较大,我们也就不必担心浪费的问题)。

    修改后的分区应该是

                                    Bootloader --1M           0x0000 0000--0x0030 0000

                                    Logo       --8M           0x0003 0000--0x00b0 0000

                                    Kernel     --3M           0x000b 0000--0x00e0 0000

                                    Root - Cramfs  --48M      0x000e 0000--0x03e0 0000

                                    File System    --剩余都是 0x03e0 0000--末尾

    uboot再重新启动时,还要修改bootcmd

    SMDK2416 # setenv bootcmd nand read c0008000 b00000 300000;bootm c0008000
    SMDK2416 # saveenv

     

    重新修改nand分区后,如何再进行sd卡一键烧写:

    uboot分两种:一个是从sd卡启动的uboot,另一个是从nand启动的uboot;把修改过分区后的内核及其他相应文件制作一键烧写的sd卡,从sd卡启动进入uboot(此为sd的uboot),敲空格进入命令行

    Helper2416 # print
    bootargs=set bootargs root=/dev/mtdblock2 console=ttySAC0,115200  mem=128m
    bootcmd=sleep 1;nand scrub ;sleep 1;nand erase;sleep 1;movi read 3800000# 40000 c0000000 ;sleep 1;nand write c0000000 0 40000;sleep 1;movi read kernel c0000000;sleep 1;nand write c0000000 900000 200000;sleep 1;movi read 3600000# 1800000 c0000000;sleep 1;nand write.yaffs c0000000 c00000 17ffac0
    bootdelay=3
    baudrate=115200
    ethaddr=00:40:5c:26:0a:5b
    ipaddr=192.168.0.20
    serverip=192.168.0.100
    gatewayip=192.168.0.1
    netmask=255.255.255.0
    nfspath=/opt/target
    nfsargs=set bootargs console=ttySAC0,115200 root=/dev/nfs nfsroot=$serverip:/opt/target,tcp rw ip=$ipaddr init=/linuxrc
    updateu=nfs c0000000 $serverip:$nfspath/u-boot.bin;nand erase 0 40000;nand write c0000000 0 40000
    updatek=nfs c0000000 $serverip:$nfspath/zImage;nand erase 40000 200000;nand write c0000000 40000 200000
    bootnand=nand read c2000000 40000 200000;bootm c2000000
    stdin=serial
    stdout=serial
    stderr=serial

    Environment size: 950/16380 bytes
    就是上面那红色部分bootcmd完成了,把sd卡上的uboot、kernel、文件系统依次copy到内存中,然后再copy到nand中保存的。因为我们修改了kernel的nand分区,所以我们也要修改这部分往nand中回写部分的地址。要和内核中的nand分区对应。我的修改如下:

    setenv bootcmd 'nand scrub ;sleep 1;nand erase;movi read 3800000# 40000 c0000000 ;nand write c0000000 0 40000;movi read kernel c0000000;nand write c0000000 b00000 300000;movi read 3600000# 1800000 c0000000;nand write.yaffs c0000000 e00000 17ffac0'

    saveenv  保存(这些环境参数保存到哪去了呢?注意我们此时是从sd卡启动的,当然保存到sd中的uboot中了)

    然后就可以用这个sd卡进行一键烧写了。

     

    还有就是要注意了,烧写完成后,启动还要报错:说是找不到zImage,那是因为你的nand中的uboot参数bootcmd没有修改成和内核nand分区对应的地址。

     

  • 相关阅读:
    我对管理信息系统定位的理解
    正斜杠和反斜杠-windows、web、c语言大讨论
    java异常处理的两种方法
    使用throws抛出异常
    课后作业
    每日自学
    《梦断代码》读后感
    每日自学
    每日自学
    每日自学
  • 原文地址:https://www.cnblogs.com/songfeixiang/p/3733770.html
Copyright © 2011-2022 走看看