根文件系统制作之ubifs

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

无排序区块图像文件系统(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不兼容。

JFFS2运行在MTD设备之上,而UBIFS则只能工作于UBI volume之上。也可以说,UBIFS涉及了三个子系统:

1. MTD子系统, 提供对flash芯片的访问接口,MTD子系统提供了MTD device的概念,比如/dev/mtdxMTD可以认为是raw flash

2. UBI subsystem,为flash device提供了wear-levelingvolume management功能;UBI工作在MTD设备之上,提供了UBI volumeUBIMTD设备的高层次表示,对上层屏蔽了一些MTD不得不处理的问题,比如wearing以及坏块管理

3. UBIFS文件系统,工作于UBI之上



以下是UBIFS的一些特点:

Ø 可扩展性:UBIFSflash尺寸有着很好的扩展性; 也就是说mount时间,内存消耗以及I/O速度都不依赖与flash尺寸(对于内存消耗并不是完全准确的,但是依赖性非常的低);UBIFS可以很好的适应GB flashes;  当然UBI本身还有扩展性的问题,无论如何UBI/UBIFS都比JFFS2的可扩展性好,此外如果UBI成为瓶颈,还可以通过升级UBI而不需改变UBIFS

Ø 快速mount:不像JFFS2UBIFSmount阶段不需要扫描整个文件系统,UBIFS mount介质的时间只是毫秒级,时间不依赖与flash的尺寸;然而UBI的初始化时间是依赖flash的尺寸的,因此必须把这个时间考虑在内

Ø write-back 支持: 回写或者叫延迟写更准确些吧,同JFFS2write-through(立即写入内存)相比可以显著的提高文件系统的吞吐量。

Ø 异常unmount适应度:UBIFS是一个日志文件系统可以容忍突然掉电以及unclean重启;UBIFS通过replay日志来恢复unclean unmount,在这种情况下replay会消耗一些时间,因此mount时间会稍微增加,但是replay过程并不会扫描整个flash介质,所以UBIFSmount时间大概在几分之一秒。

Ø 快速I/O - 即使我们disable write-back(可以在unmount时使用-o sync mount选项), UBIFS的性能仍然接近JFFS2;记住,JFFS2的同步I/O是非常惊人的,因为JFFS2不需要在flash上维护indexing data结构, 所以就没有因此而带来的负担; 而UBIFS恰恰是有index数据的。UBIFS之所以够快是因为UBIFS提交日志的方式:不是把数据从一个地方移动到另外一个位置,而只是把数据的地址加到文件系统的index,然后选择不同的eraseblock作为新的日志块,此外还有multi-headed日志方式等技巧。

Ø on-the_flight compression - 存储在flash介质上的数据是压缩的;同时也可以灵活的针对单个文件来打开关闭压缩; 例如,可能需要针对某个特定的文件打开压缩,或者可能缺省方式下支持压缩,但是对多媒体文件则关闭压缩。

Ø 可恢复性 - UBIFS可以从index破坏后恢复;UBIFS中的每一片信息都有一个header来描述,因此可以通过扫描这个flash介质来重构文件系统,这点和JFFS2非常类似;想像一下,如果你擦出了FAT文件系统的FAT表,那么对于FAT FS是致命的错误,但是如果擦除UBIFSindex,你人然可以重构文件系统,当然这需要一个特定的用户空间程序来做这个恢复

Ø 完整性 - UBIFS通过写checksumflash介质上来保证数据的完整性,UBIFS不会无视损坏文件数据或meta-data; 缺省的情况,UBIFS仅仅检查meta-dataCRC,但是你可以通过mount选项,强制进行data CRC的检查


下面我们开始正式进行ubifs制作

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


[fanmaolin@Centeros ~]$ cd fl2440/roofts/roofts/etc/
[fanmaolin@Centeros etc]$ vim mdev.conf 


根文件系统制作之ubifs


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文件中的下面两行注释掉。

#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#第二处需要注释的地方


 添加内核对ubifs的支持

export TERM=vt100 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)                     

       

   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)       


make

 制作映像文件

mkfs.ubifs已经在制作jaffs2文件系统时制作好

sudo cp mkfs.ubifs /usr/bin/

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

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


sudo cp ubinize /usr/bin/


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


[fanmaolin@Centeros roofts]$ vim build_ubifs.sh 



"build_ubifs.sh" 132L, 4876C
#!/bin/sh
#+--------------------------------------------------------------------------------------------
#|Description: This shell script is used to generate a UBIFS rootfs for K9F2G08 nandflash
#+--------------------------------------------------------------------------------------------


VERSION=1.0.0
ROOTFS_DIR=roofts
INSTALL_PATH=/home/fanmaolin/fl2440/roofts/roofts


#===================================================================
#  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
"build_ubifs.sh" 132L, 4876C                                                                                                       
PEB_SIZE=128KiB
LEB_SIZE=129024


#UBIFS: file system size:   63479808 bytes (61992 KiB, 60 MiB, 492 LEBs)
#80MiB value
LEB_COUNT=313  (参数传递很重要,一定要根据自己的内核分区来做)


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
                           

 sh build_ubifs.sh 


根文件系统制作之ubifs


 添加ubootubifs支持


set bubifs 'tftp 30008000 rootfs.ubifs;nand erase 1000000 2800000;nand write 30008000 1000000 280000'

set bootargs_ubifs 'console=ttyS0,115200 mem=64M ubi.mtd=2 root=ubi0:rootfs rootwait rootfstype=ubifs rw'

set bootargs  'console=ttyS0,115200 mem=64M ubi.mtd=6 root=ubi0:rootfs rootwait rootfstype=ubifs rw'

set bootcmd_rootfs 'nand read 30008000 100000 400000;bootm 30008000'

set bootcmd 'run bootcmd_rootfs'

save


[fl2440@lingyun]# run bkr
dm9000 i/o: 0x20000300, id: 0x90000a46 
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:5b
could not establish link
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.2; our IP address is 192.168.1.168
Filename 'linuxrom-s3c2440.bin'.
Load address: 0x30008000
Loading: T #################################################################
         #################################################################
         ############################################
done
Bytes transferred = 2540876 (26c54c hex)


NAND erase: device 0 offset 0x100000, size 0x800000
Erasing at 0x8e0000 -- 100% complete.
OK


NAND write: device 0 offset 0x100000, size 0x800000
 8388608 bytes written: OK
[fl2440@lingyun]# run bubifs
dm9000 i/o: 0x20000300, id: 0x90000a46 
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:5b
could not establish link
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.2; our IP address is 192.168.1.168
Filename 'rootfs.ubifs.bin'.
Load address: 0x30008000
Loading: T #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #########################
done
Bytes transferred = 7995392 (7a0000 hex)


NAND erase: device 0 offset 0x1000000, size 0x2800000
Erasing at 0x37e0000 -- 100% complete.
OK


NAND write: device 0 offset 0x1000000, size 0x900000
 9437184 bytes written: OK
[fl2440@lingyun]# 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:      2017-03-24   8:53:28 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2540812 Bytes = 2.4 MiB
   Load Address: 30008000
   Entry Point:  30008040
   Verifying Checksum ... OK
   XIP Kernel Image ... OK
OK


Starting kernel ...


Uncompressing Linux... done, booting the kernel.
Linux version 3.0.0 (fanmaolin@Centeros.ocaldomain) (gcc version 4.5.4 (Buildroot 2012.08) ) #16 Fri Mar 24 16:53:14 CST 2017
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.600 MHz, memory 101.400 MHz, peripheral 50.700 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 10160
Kernel command line: console=ttyS0,115200 mem=40M ubi.mtd=2 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: 40MB = 40MB total
Memory: 35496k/35496k available, 5464k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    DMA     : 0xffc00000 - 0xffe00000   (   2 MB)
    vmalloc : 0xc3000000 - 0xf6000000   ( 816 MB)
    lowmem  : 0xc0000000 - 0xc2800000   (  40 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .init : 0xc0008000 - 0xc0027000   ( 124 kB)
      .text : 0xc0027000 - 0xc0491298   (4521 kB)
      .data : 0xc0492000 - 0xc04b6660   ( 146 kB)
       .bss : 0xc04b6684 - 0xc04e985c   ( 205 kB)
SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS:85
irq: clearing pending ext status 00080800
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... 202.54 BogoMIPS (lpj=506368)
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
S3C244X: Clock Support, DVS off
bio: create slab <bio-0> at 0
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 99 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
Advanced Linux Sound Architecture Driver Version 1.0.24.
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.
NTFS driver 2.1.30 [Flags: R/W].
JFFS2 version 2.2. (NAND) ? 2001-2006 Red Hat, Inc.
msgmni has been set to 69
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Console: switching to colour frame buffer device 60x53
fb0: s3c2410fb frame 


U-Boot 2010.09 (Mar 08 2017 - 10:15:52)


DRAM:  64 MiB
NAND:  256 MiB
In:    serial
Out:   serial
Err:   serial
Net:   dm9000
Hit any key to stop autoboot:  0 


NAND read: device 0 offset 0x100000, size 0x400000
 4194304 bytes read: OK
## Booting kernel from Legacy Image at 30008000 ...
   Image Name:   Linux kernel
   Created:      2017-03-24   8:53:28 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2540812 Bytes = 2.4 MiB
   Load Address: 30008000
   Entry Point:  30008040
   Verifying Checksum ... OK
   XIP Kernel Image ... OK
OK


Starting kernel ...


Uncompressing Linux... done, booting the kernel.
Linux version 3.0.0 (fanmaolin@Centeros.ocaldomain) (gcc version 4.5.4 (Buildroot 2012.08) ) #16 Fri Mar 24 16:53:14 CST 2017
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.600 MHz, memory 101.400 MHz, peripheral 50.700 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 10160
Kernel command line: console=ttyS0,115200 mem=40M ubi.mtd=2 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: 40MB = 40MB total
Memory: 35496k/35496k available, 5464k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    DMA     : 0xffc00000 - 0xffe00000   (   2 MB)
    vmalloc : 0xc3000000 - 0xf6000000   ( 816 MB)
    lowmem  : 0xc0000000 - 0xc2800000   (  40 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .init : 0xc0008000 - 0xc0027000   ( 124 kB)
      .text : 0xc0027000 - 0xc0491298   (4521 kB)
      .data : 0xc0492000 - 0xc04b6660   ( 146 kB)
       .bss : 0xc04b6684 - 0xc04e985c   ( 205 kB)
SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS:85
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttyS0] enabled
Calibrating delay loop... 202.54 BogoMIPS (lpj=506368)
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
S3C244X: Clock Support, DVS off
bio: create slab <bio-0> at 0
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 99 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
Advanced Linux Sound Architecture Driver Version 1.0.24.
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.
NTFS driver 2.1.30 [Flags: R/W].
JFFS2 version 2.2. (NAND) ? 2001-2006 Red Hat, Inc.
msgmni has been set to 69
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Console: switching to colour frame buffer device 60x53
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
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 651 at 0x000005160000
Bad eraseblock 825 at 0x000006720000
Bad eraseblock 1667 at 0x00000d060000
Bad eraseblock 1787 at 0x00000df60000
Bad eraseblock 1879 at 0x00000eae0000
Creating 5 MTD partitions on "NAND":
0x000000000000-0x000000100000 : "bootloader"
0x000000100000-0x000001000000 : "linux"
0x000001000000-0x000003800000 : "rootfs"
0x000003800000-0x000009c00000 : "apps"
0x000000000000-0x000010000000 : "data"
UBI: attaching mtd2 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:       0
UBI: volume 0 ("rootfs") re-sized from 313 to 313 LEBs
UBI: attached mtd2 to ubi0
UBI: MTD device name:            "rootfs"
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:  1869742398
UBI: background thread "ubi_bgt0d" started, PID 673
dm9000 Ethernet Driver, V1.31
dm9000 dm9000: eth%d: Invalid ethernet MAC address. Please set using ifconfig
eth0: dm9000a at c30a6300,c30a8304 IRQ 51 MAC: 1e:b4:ac:04:bf:67 (random)
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
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usbcore: registered new interface driver libusual
mousedev: PS/2 mouse device common for all mice
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
i2c /dev entries driver
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
cpuidle: using governor ladder
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
ALSA device list:
  No soundcards found.
TCP cubic registered
NET: Registered protocol family 17
Registering the dns_resolver key type
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
UBIFS: mounted UBI device 0, volume 0, name "rootfs"
UBIFS: file system size:   39094272 bytes (38178 KiB, 37 MiB, 303 LEBs)
UBIFS: journal size:       5419008 bytes (5292 KiB, 5 MiB, 42 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:13.
Freeing init memory: 124K
usb 1-1: new full speed USB device number 2 using s3c2410-ohci
hub 1-1:1.0: USB hub found
hub 1-1:1.0: 4 ports detected
dm9000 dm9000: eth0: link down
dm9000 dm9000: eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1


Copyright (C) 2017 fanmaolin<fanmaolin@gmail.com>
root login: root
>: ls
apps     data     etc      init     linuxrc  proc     sbin     tmp      var
bin      dev      info     lib      mnt      root     sys      usr
>: 


OK


问题总结:

1、 UBI: attaching mtd2 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:       0 UBI error: vtbl_check: volume table check failed: record 0, error 9 ubiattach: UBI_IOCATT: Invalid argument



解决方法: 制作ubifs时传参有问题,修改脚本中LEB_COUNT参数,要先用initramfs启动,然后挂载到roofts分区,查看LEB参数(有些开发板是PEB)然后进行修改 nand erase 1000000

>: ubiattach -m 2 /dev/ubi_ctrl(其实执行这一步之后就可以查看参数了)
http://blog.csdn.net/liuzijiang1123/article/details/49559607(参考他人博客手动挂载)


2、

出现如下错误: 问题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?)
解决:问题1,2,3的解决方法是 linux内核中make menuconfig  Device Drivers  ---> 
        <*> Memory Technology Device (MTD) support  --->
              <*>   NAND Device Support  --->                         [ ]   Verify NAND page writes //不要选这个即可解决~

3、

Kernel panic - not syncing: No init found. Try passing init= option to kernel


解决方法:

我结合自己的制作过程并参考博客http://blog.csdn.net/charliewangg12/article/details/42030235后检查了自己的动态库,果真有问题要重新制作交叉编译器,然后再返回制作根文件系统树时:

拷贝交叉编译器中的动态库到相应的目录下

重新进行这一步。。。然后再次制作ubifs就可以了。


根文件系统到这里就全部完成了,收获良多,我也同时希望和大家一起讨论遇到的各种问题。