ubifs文件系统制作

时间:2022-03-23 00:09:53

ubifs文件系统:

  无排序区块图像文件系统(Unsorted Block Image File System, UBIFS)是用于固态硬盘存储设备上,并与LogFS相互竞争,作为JFFS2的后继文件系统之一。真正开始开发于2007年,并于200810月第一次加入稳定版本于Linux核心2.6.27版。UBIFS最早在2006年由IBMNokia的工程师Thomas GleixnerArtem Bityutskiy所设计,专门为了解决MTDMemory Technology Device)设备所遇到的瓶颈。由于Nand Flash容量的暴涨,YAFFS等皆无法再去控制Nand Flash的空间。UBIFS通过子系统UBI处理与MTD device之间的动作。与JFFS2一样,UBIFS建构于MTD device之上,因而与一般的block device不兼容。

UBIFS文件系统目录存储在flash上,UBIFS 挂载时不需要扫描整个存储器来重新创建文件目录。支持实时压缩,而且可选择性压缩部份文件。另外UBIFS使用日志(journal),可减少对flash index的更新频率UBIFS 目前是 Nokia N900 智能手机上的默认文件系统。

1.1修改根文件系统目录

将etc/mdev.conf文件中的下面两行注释掉。

 

[zoulei2@localhost etc]$ vim mdev.conf                                                                                                                

sd[a-z][0-9]      0:0 0777        @(mount /dev/$MDEV /mnt/usb)

sd[a-z]           0:0 0777        $(umount /mnt/usb)

#ub[a-z][0-9]      0:0 0777        @(mount /dev/$MDEV /mnt/usb)#第一处需要注释的地方

#ub[a-z]           0:0 0777        $(umount /mnt/usb)#第二处需要注释的地方

mmcblk[0-9]p[0-9] 0:0 0777        @(mount /dev/$MDEV /mnt/sdc)

mmcblk[0-9]       0:0 0777        $(umount /mnt/sdc)

 ******************************************************************************************************************

将etc/inittab文件中的下面两行注释掉。

 ******************************************************************************************************************

[zoulei@localhost rootfs]$ cd etc/

[zoulei@localhost etc]$ ls

dropbear  init.d

[zoulei@localhost etc]$ vim inittab

# /etc/inittab                                                                                                                     

#

# Copyright (C) 2011 fulinux <fulinux@gmail.com>

#

# Note: BusyBox init doesn't support runlevels.  The runlevels field is

# completely ignored by BusyBox init. If you want runlevels, use sysvinit.

#

# Format for each entry: <id>:<runlevels>:<action>:<process>

#

# id        == tty to run on, or empty for /dev/console.

#              If specified, then /dev/$id device must exist

# runlevels == ignored, busybox doesn't support it

# action    == one of sysinit, respawn, askfirst, wait, and once

# process   == program to run

# Startup the system

# mount all the file systems specified in /etc/fstab

::sysinit:/bin/mount -a

#Use mdev as hotplug to auto mount USB storage or SD card

::sysinit:/bin/echo /sbin/mdev > /proc/sys/kernel/hotplug

#Use mdev to auto generate the device node in /dev path

::sysinit:/sbin/mdev -s

#make shm, pts support

::sysinit:/bin/mkdir -p /dev/pts

::sysinit:/bin/mkdir -p /dev/shm

::sysinit:/bin/mount -t devpts devpts /dev/pts

#Mount our apps/info partition

#null::wait:/bin/mount -o sync,noatime,ro -t jffs2 /dev/mtdblock6 /apps#第一处需要注释的地方

#null::wait:/bin/mount -o sync,noatime,ro -t jffs2 /dev/mtdblock7 /info#第二处需要注释的地方

#Set hostname

null::sysinit:/bin/hostname -F /etc/hostname

#Enable console logon

null::respawn:/sbin/getty -L ttyS0 115200 vt100

# now run any rc scripts

null::wait:/etc/init.d/rcS

# system daemon

null::respawn:/sbin/syslogd -n

null::respawn:/sbin/klogd -n

# Stuff to do before rebooting

null::shutdown:/bin/umount /apps

null::shutdown:/bin/umount /info

null::shutdown:/bin/killall klogd

null::shutdown:/bin/killall syslogd

null::shutdown:/bin/umount -a -r

#null::shutdown:/sbin/swapoff -a

1.2添加内核对ubifs的支持

[zoulei@localhost linux-3.0]$ make menuconfig

Device Drivers  --->

       <*> Memory Technology Device (MTD) support  --->

             <*>   Enable UBI - Unsorted block images  --->

                  --- Enable UBI - Unsorted block images                                     

                  (4096) UBI wear-leveling threshold (NEW)                                   

                  (1)   Percentage of reserved eraseblocks for bad eraseblocks handling (NEW)

                  < >   MTD devices emulation driver (gluebi) (NEW)                          

                  [ ]   UBI debugging (NEW)       

 Device Drivers  --->  

        <*> Memory Technology Device (MTD) support  ---> 

              <*>   NAND Device Support  --->  

                       [ ]   Verify NAND page writes //不要选这个

              

       

   File systems  --->

       [*] Miscellaneous filesystems  --->

  

             <*>   UBIFS file system support          

             [*]     Extended attributes support      

             [*]     Advanced compression options     

             [*]       LZO compression support (NEW)  

             [*]       ZLIB compression support (NEW)

             [ ]     Enable debugging support (NEW)       

[zoulei@localhost linux-3.0]$ make

1.3mkfs.ubifs工具

[zoulei@localhost opt]$ mkdir mtd-utiles

 [zoulei@localhost opt]$ cd mtd-utiles/

[zoulei@localhost mtd-utiles]$ vim build.sh

#!/bin/sh

#+--------------------------------------------------------------------------------------------
#|Description: This shell script used to download lzo,zlib,mtd-utils source code
#| and cross compile it for ARM Linux, all is static cross compile.
#| Author: GuoWenxue <guowenxue@gmail.com>
#| ChangeLog:
#| 1, Initialize 1.0.0 on 2011.04.12
#+--------------------------------------------------------------------------------------------

PRJ_PATH=`pwd`

LZO="lzo-2.04"
ZLIB="zlib-1.2.5"
e2fsprogs_ver=1.42
mtd="mtd-utils-1.4.9"

function decompress_packet()
(
echo "+---------------------------------------------+"
echo "| Decompress $1 now"
echo "+---------------------------------------------+"

ftype=`file "$1"`
case "$ftype" in
"$1: Zip archive"*)
unzip "$1" ;;
"$1: gzip compressed"*)
if [ `expr "$1" : ".*.tar.*" ` ] ; then
tar -xzf $1
else
gzip -d "$1"
fi ;;
"$1: bzip2 compressed"*)
if [ `expr "$1" : ".*.tar.*" ` ] ; then
tar -xjf $1
else
bunzip2 "$1"
fi ;;
"$1: POSIX tar archive"*)
tar -xf "$1" ;;
*)
echo "$1 is unknow compress format";;
esac
)

# Download lzo source code packet
if [ ! -s $LZO.tar.gz ] ; then
wget http://www.oberhumer.com/opensource/lzo/download/$LZO.tar.gz
fi

# Decompress lzo source code packet
if [ ! -d $LZO ] ; then
decompress_packet $LZO.tar.*
fi

# Cross compile lzo

cd $LZO
if [ ! -s src/.libs/liblzo*.a ] ; then
unset LDFLAGS
./configure --enable-static --disable-shared
make
fi
cd -


echo "+----------------------------------------+"
echo "| Cross compile $ZLIB now "
echo "| Crosstool: $CROSS"
echo "+----------------------------------------+"

# Download zlib source code packet
if [ ! -s $ZLIB.tar* ] ; then
#wget http://www.zlib.net/$ZLIB.tar.gz
#wget http://www.imagemagick.org/download/delegates/$ZLIB.tar.bz2
#wget http://down1.chinaunix.net/distfiles/$ZLIB.tar.bz2
wget http://pkgs.fedoraproject.org/repo/pkgs/zlib/zlib-1.2.5.tar.bz2/be1e89810e66150f5b0327984d8625a0/$ZLIB.tar.bz2
fi

# Decompress zlib source code packet
if [ ! -d $ZLIB ] ; then
decompress_packet $ZLIB.tar.*
fi

#Cross compile zlib

cd $ZLIB
if [ ! -s libz.a ] ; then
unset LDFLAGS
./configure --static
make
fi
cd -


echo "+----------------------------------------+"
echo "| Cross compile e2fsprogsV$e2fsprogs_ver now "
echo "| Crosstool: $CROSS"
echo "+----------------------------------------+"
#e2fsprogs is for UBIFS, download e2fsprogs source code packet
if [ ! -s e2fsprogs-$e2fsprogs_ver.tar.gz ] ; then
wget http://nchc.dl.sourceforge.net/project/e2fsprogs/e2fsprogs/$e2fsprogs_ver/e2fsprogs-$e2fsprogs_ver.tar.gz
fi

# Decompress e2fsprogs source code packet
if [ ! -d e2fsprogs-$e2fsprogs_ver ] ; then
decompress_packet e2fsprogs-$e2fsprogs_ver.tar.*
fi

cd e2fsprogs-$e2fsprogs_ver
if [ ! -s lib/libuuid.a ] ; then
./configure --enable-elf-shlibs
make
fi
cd -

echo "+----------------------------------------+"
echo "| Cross compile mtd-utils now "
echo "| Crosstool: $CROSS"
echo "+----------------------------------------+"

if [ ! -s ${mtd}.tar.bz2 ] ; then
wget ftp://ftp.infradead.org/pub/mtd-utils/${mtd}.tar.bz2
fi
decompress_packet ${mtd}.tar.bz2

# download mtd-utils source code
#if [ ! -d mtd-utils* ] ; then
#git clone git://git.infradead.org/mtd-utils.git

#fi

cd ${mtd}
#Add the CROSS tool in file common.mk

line=`sed -n '/CFLAGS ?= -O2 -g/=' common.mk `
if [ ! -z $line ] ; then
sed -i -e ${line}s"|.*|CFLAGS ?= -O2 -g --static|" common.mk
fi

unset LDFLAGS
unset CFLAGS

set -x
export CFLAGS="-DWITHOUT_XATTR -I$PRJ_PATH/$ZLIB -I$PRJ_PATH/$LZO/include -I$PRJ_PATH/e2fsprogs-$e2fsprogs_ver/lib"
export ZLIBLDFLAGS=-L$PRJ_PATH/$ZLIB
export LZOLDFLAGS=-L$PRJ_PATH/$LZO/src/.libs/
export LDFLAGS="-static -L $PRJ_PATH/e2fsprogs-$e2fsprogs_ver/lib $ZLIBLDFLAGS $LZOLDFLAGS"
make

set -x
#strip nandwrite flash_erase nanddump
#sudo cp nandwrite $INST_PATH/.nandwrite
#sudo cp flash_erase $INST_PATH/.flash_erase
#sudo cp nanddump $INST_PATH/.nanddump

 *************************************************************************************************************

   说明:由于这是一个shell脚本文件,所以我们运行这个脚本时,还会产生一个mkfs.jffs2的工具,这个工具是用来制作jffs2映像文件的。

****************************************************************************************************************************

[zoulei@localhost mtd-utiles]$ ls

build.sh

[zoulei@localhost mtd-utiles]$ sh build.sh 


ubifs文件系统制作

[zoulei@localhost mtd-utiles]$ cd mtd-utils-1.4.9

[zoulei@localhost mtd-utils-1.4.9]$ ls

common.mk         docfdisk.o                    flash_lock.c       ftl_check.c    load_nandsim.sh    nanddump       nftl_format.o  serve_image.c

compr.c           doc_loadbios                  flash_lock.o       ftl_check.o    make_a_release.sh  nanddump.c     rbtree.c       serve_image.o

compr.h           doc_loadbios.c                flash_otp_dump     ftl_format     MAKEDEV            nanddump.o     rbtree.h       summary.h

compr_lzo.c       doc_loadbios.o                flash_otp_dump.c   ftl_format.c   Makefile           nandtest       rbtree.o       sumtool

compr_lzo.o       feature-removal-schedule.txt  flash_otp_dump.o   ftl_format.o   mcast_image.h      nandtest.c     recv_image     sumtool.c

compr.o           fectest.c                     flash_otp_info     include        mkfs.jffs2         nandtest.o     recv_image.c   sumtool.o

compr_rtime.c     flashcp                       flash_otp_info.c   jffs2dump      mkfs.jffs2.1       nandwrite      recv_image.o   tests

compr_rtime.o     flashcp.c                     flash_otp_info.o   jffs2dump.c    mkfs.jffs2.c       nandwrite.c    rfddump        ubi-utils

compr_zlib.c      flashcp.o                     flash_otp_lock.c   jffs2dump.o

compr_zlib.o      flash_erase                   flash_otp_write.c  jffs2reader

COPYING           flash_eraseall                flash_unlock       jffs2reader.c

device_table.txt  flash_erase.c                 flash_unlock.c     jffs2reader.o

docfdisk          flash_erase.o                 flash_unlock.o     jffs-dump.c

docfdisk.c        flash_lock                    ftl_check          lib

 

[zoulei@localhost mtd-utils-1.4.9]$ cd mkfs.ubifs/

[zoulei@localhost mkfs.ubifs]$ ls

compr.c  compr.o  crc16.c  crc16.o  devtable.c  hashtable  lpt.c  lpt.o       mkfs.ubifs.c  mkfs.ubifs.o  ubifs.h

compr.h  COPYING  crc16.h  defs.h   devtable.o  key.h      lpt.h  mkfs.ubifs  mkfs.ubifs.h  README        ubifs-media.h

[zoulei@localhost mkfs.ubifs]$

 

1.4制作映像文件

 

[zoulei@localhost mkfs.ubifs]$ sudo cp mkfs.ubifs /usr/bin/

 ****************************************************************************************************************************************************************************************

说明:因为mkfs.ubifs工具制作的文件系统映像,在uboot中烧录这种映像文件的方式过于复杂,既要使uboot支持nandflash分区,又要在uboot中激活这个分区,再通过ubi write命令烧录这个映像。所以我们换一种比较容易的方式来移植这个文件系统

在制作mkfs.jffs2mkfs.ubifs工具时,其实还有一个ubinize工具是同时生成的,它的作用是将mkfs.ubifs制作的映像转换为可以直接用nand write命令烧录的映像文件。

 ****************************************************************************************************************************************************************************************

[zoulei@localhost mkfs.ubifs]$ cd ..

[zoulei@localhost mtd-utils-1.4.9]$ cd ubi-utils/

[zoulei@localhost ubi-utils]$ ls

dictionary.c    libscan.c    libubi_int.h          ubiattach.c  ubidetach.o  ubinfo     ubirename.c  ubirsvol.o

dictionary.o    libscan.o    libubi.o              ubiattach.o  ubiformat    ubinfo.c   ubirename.o  ubiupdatevol

include         libubi.a     LICENSE.libiniparser  ubicrc32     ubiformat.c  ubinfo.o   ubirmvol     ubiupdatevol.c

libiniparser.a  libubi.c     mtdinfo               ubicrc32.c   ubiformat.o  ubinize    ubirmvol.c   ubiupdatevol.o

libiniparser.c  libubigen.a  mtdinfo.c             ubicrc32.o   ubimkvol     ubinize.c  ubirmvol.o   ubiutils-common.c

libiniparser.o  libubigen.c  mtdinfo.o             ubidetach    ubimkvol.c   ubinize.o  ubirsvol     ubiutils-common.o

libscan.a       libubigen.o  ubiattach             ubidetach.c  ubimkvol.o   ubirename  ubirsvol.c

[zoulei@localhost ubi-utils]$ sudo cp ubinize /usr/bin/

[zoulei@localhost ubi-utils]$ cd /opt

[zoulei@localhost opt]$


1.5制作root.ubifs文件

rootfs.ubifs的制作过程是通过下面的shell脚本完成的:

[zoulei@localhost opt]$ vim build_ubifs.sh

#!/bin/sh
#+--------------------------------------------------------------------------------------------
#|Description: This shell script is used to generate a UBIFS rootfs for K9F2G08 nandflash
#| Author: GuoWenxue <guowenxue@gmail.com> QQ: 281143292
#| ChangeLog:
#| 1, Initialize 1.0.0 on 2012.04.18
#| Reference:
#| http://www.linux-mtd.infradead.org/faq/ubifs.html
#| http://blog.sina.com.cn/s/blog_5b9ea9840100apqc.html
#+--------------------------------------------------------------------------------------------

VERSION=1.0.0
ROOTFS_DIR=rootfs
INSTALL_PATH=../../../bin/

#===================================================================
# Linux kenrel mount rootfs partition information for reference +
#===================================================================
# ~ >: cat /proc/mtd
# dev: size erasesize name
# mtd0: 00100000 00020000 "mtdblock0 u-boot 1MB"
# mtd1: 00f00000 00020000 "mtdblock1 kernel 15MB"
# mtd2: 04000000 00020000 "mtdblock2 rootfs 64MB"
# mtd3: 05000000 00020000 "mtdblock3 apps 80MB"
# mtd4: 03000000 00020000 "mtdblock4 data 48MB"
# mtd5: 03000000 00020000 "mtdblock5 info 48MB"

#UBI: attaching mtd2 to ubi2
#UBI: physical eraseblock size: 131072 bytes (128 KiB)
#UBI: logical eraseblock size: 129024 bytes
#UBI: smallest flash I/O unit: 2048
#UBI: sub-page size: 512
#UBI: VID header offset: 512 (aligned 512)
#UBI: data offset: 2048
#UBI: max. sequence number: 2
#UBI: attached mtd2 to ubi2
#UBI: MTD device name: "mtdblock2 rootfs 64MB"
#UBI: MTD device size: 64 MiB
#UBI: number of good PEBs: 510
#UBI: number of bad PEBs: 2
#UBI: number of corrupted PEBs: 0
#UBI: max. allowed volumes: 128
#UBI: wear-leveling threshold: 4096
#UBI: number of internal volumes: 1
#UBI: number of user volumes: 0
#UBI: available PEBs: 501
#UBI: total number of reserved PEBs: 9
#UBI: number of PEBs reserved for bad PEB handling: 5
#UBI: max/mean erase counter: 1/1
#UBI: image sequence number: 558504080
#UBI: background thread "ubi_bgt2d" started, PID 1200
#ubiattach -m 2 -d 2 /dev/ubi_ctrl
#mount -t ubifs -o rw,sync ubi2:rootfs /rootfs
#UBIFS: default file-system created
#UBIFS: mounted UBI device 2, volume 0, name "rootfs"
#UBIFS: file system size: 63479808 bytes (61992 KiB, 60 MiB, 492 LEBs)
#UBIFS: journal size: 3225600 bytes (3150 KiB, 3 MiB, 25 LEBs)
#UBIFS: media format: w4/r0 (latest is w4/r0)
#UBIFS: default compressor: lzo
#UBIFS: reserved for root: 2998307 bytes (2928 KiB)


#===========================================
# u-boot setup bootargs env +
#===========================================
# set bubifs 'tftp 30800000 rootfs-ubifs.bin;nand erase 1000000 4000000;nand write 30800000 1000000 $filesize'
# set bootargs 'console=ttyS0,115200 mem=64M ubi.mtd=2 root=ubi0:rootfs rootwait rootfstype=ubifs rw'

#===========================================
# Shell script body start here +
#===========================================

IMAGE_NAME=rootfs-ubifs
config_file=rootfs_ubinize.cfg

#UBI: physical eraseblock size: 131072 bytes (128 KiB)
#UBI: logical eraseblock size: 129024 bytes
PEB_SIZE=128KiB
LEB_SIZE=129024

#UBIFS: file system size: 63479808 bytes (61992 KiB, 60 MiB, 492 LEBs)
#80MiB value
LEB_COUNT=490

VOL_SIZE=`expr $LEB_COUNT \* $LEB_SIZE`

# ubi2: min./max. I/O unit sizes: 2048/2048, sub-page size 2048

#UBI: smallest flash I/O unit: 2048
#UBI: sub-page size: 512
#UBI: VID header offset: 512 (aligned 512)
MIN_IO_SIZE=2048
SUB_PAGE_SIZE=512
VID_HDR_OFFSET=512


echo "Decompress rootfs packet and update rootfs version..."
SVNVER=`svn up rootfs.tar.bz2 | grep "At revision" | awk '{print $3}' | cut -d. -f1`
echo "version=V${VERSION} r$SVNVER `date +"%Y-%m-%d"`" > fs.conf

if [ ! -d $ROOTFS_DIR ] ; then
sudo tar -xjf $ROOTFS_DIR.tar.bz2
fi
sudo mv fs.conf $ROOTFS_DIR/etc/fs.conf
sudo chown root.root $ROOTFS_DIR/etc/fs.conf

echo ""
echo "Generating $IMAGE_NAME.bin file by mkfs.ubifs..."
set -x
sudo mkfs.ubifs -x lzo -m $MIN_IO_SIZE -e $LEB_SIZE -c $LEB_COUNT -r $ROOTFS_DIR -o $IMAGE_NAME.img
set +x

echo
echo "Generating configuration file..."
echo "[ubifs-volume]" > $config_file
echo "mode=ubi" >> $config_file
echo "image=$IMAGE_NAME.img" >> $config_file
echo "vol_id=0" >> $config_file
echo "vol_size=$VOL_SIZE" >> $config_file
echo "vol_type=dynamic" >> $config_file
echo "vol_name=rootfs" >> $config_file
echo "vol_flags=autoresize" >> $config_file
echo "vol_alignment=1" >> $config_file
echo

set -x
sudo ubinize -o $IMAGE_NAME.bin -m $MIN_IO_SIZE -p $PEB_SIZE -s $SUB_PAGE_SIZE -O $VID_HDR_OFFSET $config_file
sudo chmod a+x $IMAGE_NAME.bin
cp $IMAGE_NAME.bin $INSTALL_PATH
set +x
sudo rm -f $IMAGE_NAME.img $config_file

[zoulei@localhost opt]$ sh build_ubifs.sh
Generating rootfs_ubifs.img file by mkfs.ubifs...
+ sudo mkfs.ubifs -x lzo -m 2048 -e 129024 -c 140 -r rootfs -o rootfs_ubifs.img
+ set +x

Generating configuration file...

+ sudo ubinize -o rootfs.ubifs -m 2048 -p 131072 -s 512 -O 512 rootfs_ubinize.cfg
+ set +x


[zoulei@localhost opt]$ ls

buildroot-2012.02          buildroot-2012.08                 buildroot-install.sh   busybox-1.20.2          mtd-utiles  rootfs.jffs2

buildroot-2012.02.tar.bz2  buildroot-2012.08-arm920t.config  build_ubifs.sh        busybox-1.20.2.tar.bz2  rootfs      rootfs-ubifs.bin

[zoulei@localhost opt]$ du -h rootfs-ubifs.bin

5.5M    rootfs-ubifs.bin

1.6添加ubootubifs支持

uboot环境变量设置:

[fl2440@zoulei]# set bootargs_ubifs 'console=ttyS0,115200 mem=64M ubi.mtd=2 root=ubi0:rootfs rootwait rootfstype=ubifs rw'

[fl2440@zoulei]# set bootargs 'console=ttyS0,115200 mem=64M ubi.mtd=2 root=ubi0:rootfs rootwait rootfstype=ubifs rw'

[fl2440@zoulei]# set bubifs ‘tftp 30008000 rootfs1-ubifs.bin;nand erase 1000000 4000000;nand write 30008000 1000000 900000’

[fl2440@zoulei]# set bkr ‘tftp 30008000 linuxrom2-s3c2440.bin;nand erase 100000 f00000;nand write 30008000 100000 900000’

[fl2440@zoulei]# set bootcmd_rootfs 'nand read 30008000 100000 400000;bootm 30008000'

 **************************************************************************************************************************************************************************************

参数说明:console=ttyS0:表示控制终端为串口,115200:表示串口波特率,mem64:文件系统分区大小,这里也可以不用设置。Ubi.mtd:表示文件系统的mtdblock分区位于什么位置,而我的是mtdblock[2],所以这里设置为2rootstype:文件系统类型。

 **************************************************************************************************************************************************************************************

[fl2440@zoulei]# save

Saving Environment to NAND...

Erasing Nand...

Erasing at 0x60000 -- 100% complete.

Writing to Nand... Done

1.7下载内核和rootfs.ubifs

[fl2440@zoulei]#run bkr

......

中间的信息省略

......

[fl2440@zoulei]#run bubifs

......

中间的信息省略

......

1.8 启动引导

[fl2440@zoulei]#boot

中间信息省略......

ubifs文件系统制作


效果图出来了,说明ubifs文件系统就制作移植成功了......

********************************************************************************************************************************************************************

移植过程中遇到的问题及解决办法:

1.出现如下错误:

问题1:

UBI error: ubi_io_write: error -5 while writing 512 bytes to PEB 71:512, written 0 bytes

UBI warning: ubi_eba_write_leb: failed to write VID header to LEB 2147479551:0, PEB 71

UBI: try another PEB

UBI error: ubi_io_write: error -5 while writing 512 bytes to PEB 70:512, written 0 bytes

UBI warning: ubi_eba_write_leb: failed to write VID header to LEB 2147479551:0, PEB 70

UBI: try another PEB

UBI error: ubi_io_write: error -5 while writing 512 bytes to PEB 69:512, written 0 bytes

UBI warning: ubi_eba_write_leb: failed to write VID header to LEB 2147479551:0, PEB 69

UBI: try another PEB

UBI error: ubi_io_write: error -5 while writing 512 bytes to PEB 68:512, written 0 bytes

UBI warning: ubi_eba_write_leb: failed to write VID header to LEB 2147479551:0, PEB 68

UBI warning: ubi_ro_mode: switch to read-only mode

UBI error: autoresize: cannot auto-resize volume 0

UBI error: ubi_init: cannot attach mtd2

 

问题2:

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

[<c002d670>] (unwind_backtrace+0x0/0xf0) from [<c036966c>] (panic+0x58/0x18c)

[<c036966c>] (panic+0x58/0x18c) from [<c0008c90>] (mount_block_root+0x15c/0x210)

[<c0008c90>] (mount_block_root+0x15c/0x210) from [<c0008f98>] (prepare_namespace+0x8c/0x1b0)

[<c0008f98>] (prepare_namespace+0x8c/0x1b0) from [<c000894c>] (kernel_init+0xdc/0x110)

[<c000894c>] (kernel_init+0xdc/0x110) from [<c0028e80>] (kernel_thread_exit+0x0/0x8)

问题3:

VFS: Cannot open root device "ubi0:rootfs" or unknown-block(0,0)

Please append a correct "root=" boot option; here are the available partitions:

1f00            1024 mtdblock0  (driver?)

1f01           15360 mtdblock1  (driver?)

1f02           65536 mtdblock2  (driver?)

1f03           81920 mtdblock3  (driver?)

1f04           81920 mtdblock4  (driver?)

1f05           16384 mtdblock5  (driver?)

 

解决:问题1,3的解决方法是

linux内核中make menuconfig

 Device Drivers  --->  

        <*> Memory Technology Device (MTD) support  ---> 

              <*>   NAND Device Support  --->  

                       [ ]   Verify NAND page writes //不要选这个即可解决~

问题2的解决方法是:

由于nandflash中有坏块,之前设置命令nand write 100000 600000 中写的文件大小600000偏小,所以将写的大小设置大一点即可解决

 

注意:在擦除nandflash时,一定要是擦除整个分区的大小,我的内核分区大小是15M,所以应该是nand erase 100000  f00000 ,那个100000 表示内核分区的起始位置。(15M=1024x1024x15换算成十六进制是f00000)

***********************************************************************************************************************************************************************************