ubifs文件系统制作与移植

时间:2021-11-30 09:04:49

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

装载声明:点击打开链接

作       者:fulinux

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

UBIFS文件系统使用



1, UBIFS简介

linux-2.6.27以前,谈到Flash文件系统,大家很多时候多会想到cramfsjffs2yaffs2等文件系统。它们也都是基于文件系统+mtd+flash设备的架构。linux-2.6.27后,内核加入了一种新型的flash文件系统UBIFS(Unsorted Block Image File Systems)

UBIFS最早在2006年由IBMNokia的工程师Thomas GleixnerArtem Bityutskiy所设计,专门为了解决MTDMemory Technology Device)设备所遇到的瓶颈。由于NandFlash容量的暴涨,YAFFS等皆无法再去控制Nand Flash的空间。UBIFS通过子系统UBI 处理与MTD device之间的动作。与JFFS2 一样,UBIFS 建构于MTD device 之上,而与一般的block device不兼容。它在设计与性能上均较YAFFS2JFFS2更能适用于MLC NAND FLASH上面。

   UBIFS 支持 write-back, 其写入的数据会被cache, 直到有必要写入时才写到flash, 大大地降低分散小区块数量及I/O效率。UBIFS UBIFS文件系统目录存储在flash上,UBIFS mount时不需要scan整个flash的数据来重新创建文件目录。支持on-the-flight压缩文件数据,而且可选择性压缩部份文件。另外UBIFS使用日志(journal),可减少对flash index的更新频率。

  下面是UBIFS与其它文件系统的一些比较:

ubifs文件系统制作与移植

  关于UBIFS与其它文件系统更详细的比较,可以参考TOSHIBA的两个文档:

  Evaluation of Flash File Systems for Large NAND Flash Memory 

     Evaluation of UBI and UBIFS 

     http://wenku.baidu.com/view/eebeacd9a58da0116c174991.html

UBIFS的官方站点为: http://www.linux-mtd.infradead.org/doc/ubifs.html

2, 内核支持UBIFS

在配置Linux内核(make menuconfig)时,选择下面选项来支持UBIFS

   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)                     

       

   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)       


3, 测试的板子上Nandflash K9F2G08及在Linux内核中的分区信息:

 K9F2G08相关硬件信息:

1 Page= (2K+64)Bytes

 1 Block= 64Pages =(128K+4K) Bytes

 1 Device = 2048 Blocks = (2K+64) * 64Pages * 2048 Blocks = 2112 Mbits = 256MiB

 

下面是以256M的nandflash进行移植,内核中nandflash的分区表信息是这样的

Creating 11 MTD partitions on "NAND":
0x000000000000-0x000000100000 : "mtdblock0 u-boot 1MB"
0x000000100000-0x000000500000 : "mtdblock1 kernel 4MB"
0x000000500000-0x000000f00000 : "mtdblock2 ramdisk 10MB"
0x000000f00000-0x000001e00000 : "mtdblock3 cramfs 15MB"
0x000001e00000-0x000004600000 : "mtdblock4 jffs2 40MB"
0x000004600000-0x000006e00000 : "mtdblock5 yaffs2 40MB"
0x000006e00000-0x000009600000 : "mtdblock6 ubifs 40MB"
0x000009600000-0x000009700000 : "mtdblock7 info 1MB"
0x000009700000-0x00000bf00000 : "mtdblock8 apps 40MB"
0x00000bf00000-0x00000e700000 : "mtdblock9 data 40MB"
0x00000e700000-0x000010000000 : "mtdblock10 backup 25MB"

4、制作mkfs.ubifs和ubinize工具

对于ubifs文件系统要想烧到对应的nandflash分区中去(对应上面的“mtdblock5”)有两种方式,第一种是用ubi write,前提是在uboot中创建ubifs的分区同时必须用ubi part命令激活这个分区,但是我这个uboot中ubi part命令无法执行,有很多错误,我找不到解决方法。因此第一种在我这里不行。第二种时用ubinize工具将mkfs.ubifs制作的镜像转换为可以直接用nand write来烧录多nandflash中去。下面介绍第二种方法:

[lingyun@localhost rootfs]$ clear
[lingyun@localhost rootfs]$ mkdir mtd-utils
[lingyun@localhost rootfs]$ cd mtd-utils/
[lingyun@localhost mtd-utils]$ 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
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

[lingyun@localhost mtd-utils]$sh build.sh

编译过程。。。。。。。。。

[lingyun@localhost mtd-utils]$ ls
build.sh        e2fsprogs-1.42.tar.gz  lzo-2.04.tar.gz  mtd-utils-1.4.9.tar.bz2  zlib-1.2.5.tar.bz2
e2fsprogs-1.42  lzo-2.04               mtd-utils-1.4.9  zlib-1.2.5
[lingyun@localhost mtd-utils]$ cd mtd-utils-1.4.9
[lingyun@localhost mtd-utils-1.4.9]$ ls
common.mk         feature-removal-schedule.txt  flash_otp_lock.c   jffs-dump.c        nanddump.o     recv_image.o
compr.c           fectest.c                     flash_otp_write.c  lib                nandtest       rfddump
compr.h           flashcp                       flash_unlock       load_nandsim.sh    nandtest.c     rfddump.c
compr_lzo.c       flashcp.c                     flash_unlock.c     make_a_release.sh  nandtest.o     rfddump.o
compr_lzo.o       flashcp.o                     flash_unlock.o     MAKEDEV            nandwrite      rfdformat
compr.o           flash_erase                   ftl_check          Makefile           nandwrite.c    rfdformat.c
compr_rtime.c     flash_eraseall                ftl_check.c        mcast_image.h      nandwrite.o    rfdformat.o
compr_rtime.o     flash_erase.c                 ftl_check.o        mkfs.jffs2         nftldump       serve_image
compr_zlib.c      flash_erase.o                 ftl_format         mkfs.jffs2.1       nftldump.c     serve_image.c
compr_zlib.o      flash_lock                    ftl_format.c       mkfs.jffs2.c       nftldump.o     serve_image.o
COPYING           flash_lock.c                  ftl_format.o       mkfs.jffs2.o       nftl_format    summary.h
device_table.txt  flash_lock.o                  include            mkfs.ubifs         nftl_format.c  sumtool
docfdisk          flash_otp_dump                jffs2dump          mtd_debug          nftl_format.o  sumtool.c
docfdisk.c        flash_otp_dump.c              jffs2dump.c        mtd_debug.c        rbtree.c       sumtool.o
docfdisk.o        flash_otp_dump.o              jffs2dump.o        mtd_debug.o        rbtree.h       tests
doc_loadbios      flash_otp_info                jffs2reader        mtd-utils.spec     rbtree.o       ubi-utils
doc_loadbios.c    flash_otp_info.c              jffs2reader.c      nanddump           recv_image
doc_loadbios.o    flash_otp_info.o              jffs2reader.o      nanddump.c         recv_image.c
[lingyun@localhost mtd-utils-1.4.9]$ cd mkfs.ubifs/
[lingyun@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
[lingyun@localhost mkfs.ubifs]$ sudo cp mkfs.ubifs /usr/bin/
[lingyun@localhost mkfs.ubifs]$ cd ..

[lingyun@localhost mtd-utils-1.4.9]$ cd ubi-utils/
[lingyun@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
[lingyun@localhost ubi-utils]$ 


5、制作rootfs.ubifs镜像文件

 注1:mkfs.ubifs中的选项说明

-r, -d, --root=DIR       build file system from directory DIR

-m, --min-io-size=SIZE   minimum I/O unit size, 参考上面手动挂载一个分区时的信息

-e, --leb-size=SIZE      logical erase block size  参考上面手动挂载一个分区时的信息

-c, --max-leb-cnt=COUNT  maximum logical erase block count 依赖分区大小,调整测试出来

-o, --output=FILE        output to FILE

-x, --compr=TYPE         compression type - "lzo", "favor_lzo", "zlib" or

                         "none" (default: "lzo")

注2: ubinize选项说明:

-o, --output=<file name>     output file name

-p, --peb-size=<bytes>       size of the physical eraseblock of the flash

                             this UBI image is created for in bytes,

                             kilobytes (KiB), or megabytes (MiB)

                             (mandatory parameter),这里是物理擦除快大小

-m, --min-io-size=<bytes>    minimum input/output unit size of the flash

                             in bytes

-s, --sub-page-size=<bytes>  minimum input/output unit used for UBI

                             headers, e.g. sub-page size in case of NAND

                             flash (equivalent to the minimum input/output

                             unit size by default) 查看上面手动挂载时的信息

-O, --vid-hdr-offset=<num>   offset if the VID header from start of the

                             physical eraseblock (default is the next

                             minimum I/O unit or sub-page after the EC

                             header) 查看上面手动挂载时的VID信息

下面给出一个创建rootfs.ubifs镜像文件:

[lingyun@localhost rootfs]$ cd tools/
[lingyun@localhost tools]$ ls
build_ubifs.sh  install_shared_library.sh
[lingyun@localhost tools]$ 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
#+--------------------------------------------------------------------------------------------


#===================================================================
#  U-BOOT print the Rootfs partition UBI information for reference +
#===================================================================
#U-Boot> mtdparts default
#U-Boot> mtdparts 


#device nand0 <nand0>, # parts = 4
# #: name                size            offset          mask_flags
# 0: bootloader          0x00100000      0x00000000      0
# 1: kernel              0x00500000      0x00100000      0
# 2: rootfs              0x00a00000      0x00600000      0
# 3: user                0x0f000000      0x01000000      0
# active partition: nand0,0 - (bootloader) 0x00100000 @ 0x00000000
#
# defaults:
#     mtdids  : nand0=nand0
#     mtdparts: mtdparts=nand0:1m(bootloader),5m(kernel),10m(rootfs),-(user)
#     U-Boot> 
#     U-Boot> ubi part rootfs
#     UBI: mtd1 is detached from ubi0
#     Creating 1 MTD partitions on "nand0":
#     0x000000600000-0x000001000000 : "mtd=2"
#     UBI: attaching mtd1 to ubi0
#     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: attached mtd1 to ubi0
#     UBI: MTD device name:            "mtd=2"
#     UBI: MTD device size:            10 MiB
#     UBI: number of good PEBs:        80
#     UBI: number of bad 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:             74
#     UBI: total number of reserved PEBs: 6
#     UBI: number of PEBs reserved for bad PEB handling: 2
#     UBI: max/mean erase counter: 1/1
#U-Boot> 


#Default setting by UBIFS
sub_page_size=512
vid_head_offset=512


CPU=arm920t


#-r, -d, --root=DIR   root filesystem source code tree
rootfs_dir=rootfs_tree


    exit;
fi

                                                                                                             
#-m, minimum I/O unit size, it's 2K(the Page size) on K9F2G08, refer to "UBI: smallest flash I/O unit:    2048" 
page_size_in_bytes=2048
#echo "Page size [$page_size_in_bytes] bytes."


#It's 64 pages per block on K9F2G08
pages_per_block=64
block_size_in_bytes=`expr $page_size_in_bytes \* $pages_per_block`
#echo "[$pages_per_block] pages per block and [$block_size_in_bytes] bytes"


#It's 2048 blocks on K9F2G08
blocks_per_device=2048
#echo "Blocks per device  [$blocks_per_device]"


#-e, logical erase block size, fixed on K9F2G08, refer to u-boot information "UBI: logical eraseblock size:  129024 bytes"
# logical erase block size is physical erase block size minus 1 page for UBI
logical_pages_per_block=`expr $pages_per_block - 1`
logical_erase_block_size=`expr $page_size_in_bytes \* $logical_pages_per_block`
#echo "Logical erase block size:  [$logical_erase_block_size] bytes."


# wear_level_reserved_blocks is 1% of total blcoks per device
wear_level_reserved_blocks=`expr $blocks_per_device / 100`
#echo "Reserved blocks for wear level [$wear_level_reserved_blocks]"


#The rootfs partition size in bytes
partition_sizeM=20
partition_size_in_bytes=`expr $partition_sizeM \* 1024 \* 1024`
partition_physical_blocks=`expr $partition_size_in_bytes / $block_size_in_bytes`
#echo "Partition size [$partition_size_in_bytes] bytes and [$partition_physical_blocks] blocks."


#Logical blocks on a partition = physical blocks on a partitiion - reserved for wear level 
patition_logical_blocks=`expr $partition_physical_blocks - $wear_level_reserved_blocks`
#echo "Logical blocks in a partition [$patition_logical_blocks]"


#File-system volume = Logical blocks in a partition * Logical erase block size
fs_vol_size=`expr $patition_logical_blocks \* $logical_erase_block_size`
#echo "File-system volume [$fs_vol_size] bytes."


config_file=rootfs_ubinize.cfg
image_name=rootfs_ubifs.img


echo ""
echo "Generating $image_name file by mkfs.ubifs..."
set -x
sudo mkfs.ubifs -x lzo -m $page_size_in_bytes -e $logical_erase_block_size -c $patition_logical_blocks -r $rootfs_dir -o $image_name
set +x


echo
echo "Generating configuration file..."
echo "[ubifs-volume]" > $config_file
echo "mode=ubi" >> $config_file
echo "image=$image_name" >> $config_file
echo "vol_id=0" >> $config_file
echo "vol_size=$fs_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 /tftp/ubifs-$CPU.img -m $page_size_in_bytes -p $block_size_in_bytes -s $sub_page_size -O $vid_head_offset
$config_file
set +x
sudo rm -f $image_name $config_file


[lingyun@localhost tools]$ sh build_ubifs.sh 

执行后就会在/tftp目录下生成ubifs-arm920t.img镜像文件,更名为rootfs.ubifs


6、根据第一步中分区表的信息,将rootfs.ubifs烧录到开发板中

(1)下面是开发板中低环境变量

[ s3c2440@fulinux ]# pri
cpu=s3c2440
bbl=nand erase 0 100000;tftp 30008000 u-boot-$cpu.bin;nand write 30008000 0 $filesize
norbbl=erase bank 1;tftp 30008000 u-boot-$cpu.bin;cp.b 30008000 0 $filesize
bkr=tftp 30008000 uImage-$cpu.gz;nand erase 100000 400000;nand write 30008000 100000 $filesize
brdfs=tftp 30800000 ramdisk-$cpu.gz;nand erase 500000 a00000;nand write 30800000 500000 $filesize
bubifs=tftp 30800000 ubifs-$cpu.img;nand erase 0x02e00000 0x01400000;nand write 0x30800000 0x2e00000 0x4c0000
bootcmd_ramdisk=nand read 30008000 100000 400000;nand read 30800000 500000 a00000;bootm 30008000
bootcmd_rootfs=nand read 30008000 100000 400000;bootm 30008000
tpb=tftp 30008000 uImage-$cpu.gz;tftp 30800000 ramdisk-$cpu.gz;bootm 30008000 
bootargs_ramdisk=console=ttyS0,115200 mem=64M initrd=0x30800000,16M root=/dev/ram0 rw loglevel=7
bootargs_ubifs=console=ttyS0,115200 mem=64M ubi.mtd=5 root=ubi0:rootfs rootwait rootfstype=ubifs rw
mtdids=nand0=nand0
mtdparts=mtdparts=nand0:1M@0x0(u-boot),5M@0x100000(kernel),10M@0x600000(ramdisk),10M@0x1000000(cramfs),20M@0x1a00000(yaffs2),20M@0x2e00000(ubifs),-(users)
bootdelay=1
baudrate=115200
ethaddr=08:00:3e:26:0a:6b
ethact=dm9000
bcramfs=tftp 30800000 rootfs.cramfs;nand erase f00000 600000;nand write 30800000 f00000 600000
filesize=533000
fileaddr=30800000
netmask=255.255.255.0
ipaddr=192.168.1.244
serverip=192.168.1.3
bootargs=noinitrd root=/dev/mtdblock3 rootfstype=cramfs init=/linuxrc console=ttyS0,115200
bootcmd_cramfs=nand read 30008000 100000 400000;bootm 30008000
bootcmd=run bootcmd_cramfs
stdin=serial
stdout=serial
stderr=serial

Environment size: 1570/131068 bytes

[ s3c2440@fulinux ]# 


(2)下面设置一个烧录rootfs.ubifs的环境变量

[ s3c2440@fulinux ]#set bubifs 'tftp 30008000 ubifs-$cpu.img;nand erase 6e00000 900000;nand write 30008000 6e00000 900000'

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

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

[ s3c2440@fulinux ]# set bootcmd 'run bootcmd_rootfs'

[ s3c2440@fulinux ]# save

(3)下载ubifs-arm920t.img镜像文件

[ s3c2440@fulinux ]# run bubjfs

dm9000 i/o: 0x20000300, id: 0x90000a46 
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:6b
could not establish link
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.3; our IP address is 192.168.1.111
Filename 'ubifs-arm920t.img'.
Load address: 0x30008000
Loading: T #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #############################################################
done
Bytes transferred = 8519680 (820000 hex)


NAND erase: device 0 offset 0x6e00000, size 0x900000
Erasing at 0x76e0000 -- 100% complete.
OK


NAND write: device 0 offset 0x6e00000, size 0x900000
 9437184 bytes written: OK


7、启动内核

[ s3c2440@fulinux ]#boot

NAND read: device 0 offset 0x100000, size 0x400000
 4194304 bytes read: OK
## Booting kernel from Legacy Image at 30008000 ...
   Image Name:   Linux Kernel
   Created:      2013-04-24  11:49:03 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2612516 Bytes = 2.5 MiB
   Load Address: 30008000
   Entry Point:  30008040
   Verifying Checksum ... OK
   XIP Kernel Image ... OK
OK
OS entry point: 30008040
Image entry point=30008040


Starting kernel ...


Uncompressing Linux... done, booting the kernel.
Linux version 3.0.0 (lingyun@localhost.localdomain) (gcc version 4.5.4 (Buildroot 2012.08) ) #2 Wed Apr 24 19:49:00 CST 2013
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: SMDK2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, Copyright 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: console=ttyS0,115200 mem=64M ubi.mtd=6 root=ubi0:rootfs rootwait rootfstype=ubifs rw
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 59468k/59468k available, 6068k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    DMA     : 0xffc00000 - 0xffe00000   (   2 MB)
    vmalloc : 0xc4800000 - 0xf6000000   ( 792 MB)
    lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .init : 0xc0008000 - 0xc002f000   ( 156 kB)
      .text : 0xc002f000 - 0xc04f3000   (4880 kB)
      .data : 0xc04f4000 - 0xc0523c40   ( 192 kB)
       .bss : 0xc0523c64 - 0xc05500c4   ( 178 kB)
NR_IRQS:85
irq: clearing pending ext status 00080000
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttyS0] enabled
Calibrating delay loop... 201.52 BogoMIPS (lpj=503808)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
gpiochip_add: gpios 288..303 (GPIOK) failed to register
gpiochip_add: gpios 320..334 (GPIOL) failed to register
gpiochip_add: gpios 352..353 (GPIOM) failed to register
NET: Registered protocol family 16
S3C Power Management, Copyright 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, Copyright 2003-2006 Simtec Electronics
DMA channel 0 at c4804000, irq 33
DMA channel 1 at c4804040, irq 34
DMA channel 2 at c4804080, irq 35
DMA channel 3 at c48040c0, irq 36
S3C244X: Clock Support, DVS off
s3c-adc s3c24xx-adc: attached adc driver
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
Advanced Linux Sound Architecture Driver Version 1.0.24.
cfg80211: Calling CRDA to update world regulatory domain
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
NetWinder Floating Point Emulator V0.97 (extended precision)
NTFS driver 2.1.30 [Flags: R/W].
JFFS2 version 2.2. (NAND) (SUMMARY)  © 2001-2006 Red Hat, Inc.
msgmni has been set to 116
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Console: switching to colour frame buffer device 60x34
fb0: s3c2410fb frame buffer device
s3c2440-uart.0: ttyS0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: ttyS1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: ttyS2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
loop: module loaded
at24 0-0050: 65536 byte 24c512 EEPROM, writable, 128 bytes/write
physmap platform flash device: 00400000 at 08000000
physmap-flash physmap-flash.0: map_probe failed
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 221 at 0x000001ba0000
Bad eraseblock 1592 at 0x00000c700000
Creating 11 MTD partitions on "NAND":
0x000000000000-0x000000100000 : "mtdblock0 u-boot 1MB"
0x000000100000-0x000000500000 : "mtdblock1 kernel 4MB"
0x000000500000-0x000000f00000 : "mtdblock2 ramdisk 10MB"
0x000000f00000-0x000001e00000 : "mtdblock3 cramfs 15MB"
0x000001e00000-0x000004600000 : "mtdblock3 jffs2 40MB"
0x000004600000-0x000006e00000 : "mtdblock4 yaffs2 40MB"
0x000006e00000-0x000009600000 : "mtdblock5 ubifs 40MB"
0x000009600000-0x000009700000 : "mtdblock6 info 1MB"
0x000009700000-0x00000bf00000 : "mtdblock7 apps 40MB"
0x00000bf00000-0x00000e700000 : "mtdblock8 data 40MB"
0x00000e700000-0x000010000000 : "mtdblock9 backup 25MB"
UBI: attaching mtd6 to ubi0
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:       5
UBI: attached mtd6 to ubi0
UBI: MTD device name:            "mtdblock5 ubifs 40MB"
UBI: MTD device size:            40 MiB
UBI: number of good PEBs:        320
UBI: number of bad PEBs:         0
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:     1
UBI: available PEBs:             0
UBI: total number of reserved PEBs: 320
UBI: number of PEBs reserved for bad PEB handling: 3
UBI: max/mean erase counter: 1/0
UBI: image sequence number:  435262471
UBI: background thread "ubi_bgt0d" started, PID 449
PPP generic driver version 2.4.2
PPP Deflate Compression module registered
PPP BSD Compression module registered
PPP MPPE Compression module registered
NET: Registered protocol family 24
dm9000 Ethernet Driver, V1.31
eth0: dm9000a at c48b6300,c48b8304 IRQ 51 MAC: 08:00:3e:26:0a:6b (chip)
usbcore: registered new interface driver rt2800usb
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
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
usb usb1: New USB device found, idVendor=1d6b, idProduct=0001
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: S3C24XX OHCI
usb usb1: Manufacturer: Linux 3.0.0 ohci_hcd
usb usb1: SerialNumber: s3c24xx
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usbcore: registered new interface driver usbserial
usbserial: USB Serial Driver core
USB Serial support registered for ch341-uart
usbcore: registered new interface driver ch341
USB Serial support registered for FTDI USB Serial Device
usbcore: registered new interface driver ftdi_sio
ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver
USB Serial support registered for GSM modem (1-port)
usbcore: registered new interface driver option
option: v0.7.2:USB Driver for GSM modems
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
mousedev: PS/2 mouse device common for all mice
samsung-ts s3c2440-ts: driver attached, registering input device
input: S3C24XX TouchScreen as /devices/virtual/input/input0
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c-rtc s3c2410-rtc: rtc disabled, re-enabling
s3c-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
s3c-sdi s3c2440-sdi: mmc0 - using pio, sw SDIO IRQ
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
S3C24XX_UDA134X SoC Audio driver
UDA134X SoC Audio Codec
asoc: uda134x-hifi <-> s3c24xx-iis mapping ok
ALSA device list:
  #0: S3C24XX_UDA134X
Netfilter messages via NETLINK v0.30.
nf_conntrack version 0.5.0 (929 buckets, 3716 max)
ctnetlink v0.93: registering with nfnetlink.
xt_time: kernel timezone is -0000
ip_set: protocol 6
IPVS: Registered protocols (TCP, UDP, AH, ESP)
IPVS: Connection hash table configured (size=4096, memory=32Kbytes)
IPVS: Creating netns size=1008 id=0
IPVS: ipvs loaded.
IPVS: [rr] scheduler registered.
IPVS: [wrr] scheduler registered.
IPVS: [lc] scheduler registered.
IPVS: [wlc] scheduler registered.
IPVS: [lblc] scheduler registered.
IPVS: [lblcr] scheduler registered.
IPVS: [dh] scheduler registered.
IPVS: [sh] scheduler registered.
IPVS: [sed] scheduler registered.
IPVS: [nq] scheduler registered.
ip_tables: (C) 2000-2006 Netfilter Core Team
ipt_CLUSTERIP: ClusterIP Version 0.8 loaded successfully
arp_tables: (C) 2002 David S. Miller
TCP cubic registered
NET: Registered protocol family 17
lib80211: common routines for IEEE802.11 drivers
Registering the dns_resolver key type
s3c-rtc s3c2410-rtc: setting system clock to 2023-01-06 16:57:59 UTC (1673024279)
UBIFS: mounted UBI device 0, volume 0, name "rootfs"
UBIFS: file system size:   16773120 bytes (16380 KiB, 15 MiB, 130 LEBs)
UBIFS: journal size:       2580480 bytes (2520 KiB, 2 MiB, 20 LEBs)
UBIFS: media format:       w4/r0 (latest is w4/r0)
UBIFS: default compressor: lzo
UBIFS: reserved for root:  0 bytes (0 KiB)
VFS: Mounted root (ubifs filesystem) on device 0:11.
Freeing init memory: 156K
usb 1-1: new full speed USB device number 2 using s3c2410-ohci
usb 1-1: New USB device found, idVendor=05e3, idProduct=0606
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1: Product: USB Hub 2.0
hub 1-1:1.0: USB hub found
hub 1-1:1.0: 4 ports detected
UBI: attaching mtd8 to ubi8
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:       13
UBI: attached mtd8 to ubi8
UBI: MTD device name:            "mtdblock7 apps 40MB"
UBI: MTD device size:            40 MiB
UBI: number of good PEBs:        320
UBI: number of bad PEBs:         0
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:     1
UBI: available PEBs:             33
UBI: total number of reserved PEBs: 287
UBI: number of PEBs reserved for bad PEB handling: 3
UBI: max/mean erase counter: 2/1
UBI: image sequence number:  -232904551
UBI: background thread "ubi_bgt8d" started, PID 554
UBIFS: mounted UBI device 8, volume 0, name "apps"
UBIFS: file system size:   34965504 bytes (34146 KiB, 33 MiB, 271 LEBs)
UBIFS: journal size:       1806336 bytes (1764 KiB, 1 MiB, 14 LEBs)
UBIFS: media format:       w4/r0 (latest is w4/r0)
UBIFS: default compressor: lzo
UBIFS: reserved for root:  1651507 bytes (1612 KiB)
UBI: attaching mtd9 to ubi9
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:       13
UBI: attached mtd9 to ubi9
UBI: MTD device name:            "mtdblock8 data 40MB"
UBI: MTD device size:            40 MiB
UBI: number of good PEBs:        319
UBI: number of bad PEBs:         1
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:     1
UBI: available PEBs:             32
UBI: total number of reserved PEBs: 287
UBI: number of PEBs reserved for bad PEB handling: 3
UBI: max/mean erase counter: 2/1
UBI: image sequence number:  1359039830
UBI: background thread "ubi_bgt9d" started, PID 582
UBIFS: mounted UBI device 9, volume 0, name "data"
UBIFS: file system size:   34965504 bytes (34146 KiB, 33 MiB, 271 LEBs)
UBIFS: journal size:       1806336 bytes (1764 KiB, 1 MiB, 14 LEBs)
UBIFS: media format:       w4/r0 (latest is w4/r0)
UBIFS: default compressor: lzo
UBIFS: reserved for root:  1651507 bytes (1612 KiB)
dm9000 dm9000.0: eth0: link down


Copyright (C) 2012 GuoWenxue<guowenxue@gmail.com>
Default Password:  12345




fulinux login: dm9000 dm9000.0: eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1


Copyright (C) 2012 GuoWenxue<guowenxue@gmail.com>
Default Password:  12345




fulinux login: root
Password: 
~ >: ls
apps     data     home     lib      media    proc     stat     usr
backup   dev      info     linuxrc  mnt      root     sys      var
bin      etc      init     logs     opt      sbin     tmp
~ >: