一、挂载成功后,使用正常。有时会出现:
UBIFS error (pid 76): ubifs_read_node: bad node type (255 but expected 1)
UBIFS error (pid 76): ubifs_read_node: bad node at LEB 31:20480, LEB mapping status 0
UBIFS error (pid 76): do_readpage: cannot read page 0 of inode 70, error -22

1.在uboot里,setenv nand_root ubi0:rootfs rw ubi.mtd= (此处对应),2048
2.制作imgae时,mkfs.ubifs -c 这个参数要仔细计算,些参数影响较大,再就是改一下ubinize.cfg这个文件的相关参数,要经过计算

3.看驱动,以用硬件连接,不要造成flash的只读情况出现

二、还是ubifs_read_node 报错,还会有类似oops的错误

UBIFS: default compressor: LZO
UBIFS: reserved for root:  0 bytes (0 KiB)
UBIFS error (pid 0): ubifs_read_node: bad node type (255 but expected 9)
UBIFS error (pid 0): ubifs_read_node: bad node at LEB 85:60448
UBIFS error (pid 0): ubifs_iget: failed to read inode 1, error -22
Machine check in kernel mode.
Caused by (from msr): regs 0fe7ca88 Unknown values in msr
NIP: 0FFB7C80 XER: 00000000 LR: 0FFB7C5C REGS: 0fe7ca88 TRAP: 0200 DAR: 00000000
MSR: 0000b032 EE: 1 PR: 0 FP: 1 ME: 1 IR/DR: 11

GPR00: 0004434C 0FE7CB78 0FE7CF50 FFFF7FFF 0FFF8020 00000000 0FFF8020 FFFF7FF7
GPR08: 00021AE8 DC0FFF80 0FFF83F8 0FFF83F8 22044024 7037FFBF 0FFFB000 00000000
GPR16: 0FFECF7C 0FFF691C 00000000 00000000 0FEE1310 0FEDFB28 FFFFF000 0FEE0BA0
GPR24: 00000000 00000003 0FEE129C 00000001 00000001 0FFF9100 0FFFBFA8 0FEE0C88
Call backtrace:
0FEE0C88 0FFCABFC 0FFCBEE8 0FFCC050 0FFB6590 0FFBC468 0FFBBB78
0FFBBD98 0FFBD728 0FFBC468 0FFBBB78 0FFBBD98 0FFBE7D0 0FFA188C
0FFA05F0
machine check
Resetting the board.

解决办法:

关于这个oops的错误参考以下链接的修改

http://lists.denx.de/pipermail/u-boot/2011-October/103864.html

On Tue, Oct 4, 2011 at 6:08 PM, larsi <larsi at atlantis.wh2.tu-dresden.de> wrote:
> This patch fixes an issue when ubifs reads a bad superblock. Later it
> tries to free memory, that was not allocated, which freezes u-boot.
> This is fixed by looking for a non null pointer before free.
>
> Signed-off-by: Lars Poeschel <larsi at wh2.tu-dresden.de>
> Cc: Kyungmin Park <kmpark at infradead.org>
> ---
> The message I got before u-boot freezes:
> UBI: max/mean erase counter: 53/32
> UBIFS: mounted UBI device 0, volume 1, name "rootfs"
> UBIFS: mounted read-only
> UBIFS: file system size:   49140 bytes (50319360 KiB, 0 MiB, 49140 LEBs)
> UBIFS: journal size:       49 bytes (6838272 KiB, 0 MiB, 6678 LEBs)
> UBIFS: media format:       w4/r0 (latest is w4/r0)
> UBIFS: default compressor: LZO
> UBIFS: reserved for root:  0 bytes (0 KiB)
> UBIFS error (pid 0): ubifs_read_node: bad node type (255 but expected 9)
> UBIFS error (pid 0): ubifs_read_node: bad node at LEB 330:13104
> UBIFS error (pid 0): ubifs_iget: failed to read inode 1, error -22
> Error reading superblock on volume 'ubi:rootfs'!
>
>  fs/ubifs/super.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
> index 63b2164..20fb244 100644
> --- a/fs/ubifs/super.c
> +++ b/fs/ubifs/super.c
> @@ -848,8 +848,10 @@ void ubifs_umount(struct ubifs_info *c)
>        ubifs_debugging_exit(c);
>
>        /* Finally free U-Boot's global copy of superblock */
> -       free(ubifs_sb->s_fs_info);
> -       free(ubifs_sb);
> +       if (ubifs_sb != null) {
> +               free(ubifs_sb->s_fs_info);
> +               free(ubifs_sb);
> +       }
Which statement is problem? Basically free() check the null address.
so If ubifs_sb->s_fs_info doesn't have value its skipped. and ubifs_sb
is similar.

Thank you,
Kyungmin Park
>  }

但是关于ubifs_read_node: bad node type (255 but expected 9)

这个错误一直没找到精准的解决办法,开始的时候怀疑mkfs.ubifs的参数问题,各种修改也没好转

后来发现kernel的大小(烧写的时候的大小)不对,

kernel_img=a36800(写入大小)

ubi write 0x3000000 kernel$kernel_img

Load address: 0x3000000
Loading: #################################################################
         #################################################################
         #####################
done
Bytes transferred = 10792960 (a4b000 hex)(实际大小)

我记得修改过这个参数啊,唉

但不可否认的是改了这两个地方后,问题就解决了,如果写入的文件不完全或被破坏,ubimount时就会出错

使用ubifs格式的根文件系统,以及遇到的问题

http://www.360doc.com/content/14/1018/14/18578054_417913216.shtml

  • 配置内核,使其支持ubifs文件系统

    1)Device Drivers  --->Memory Technology Device (MTD) support  --->UBI - Unsorted block images  --->Enable UBI
    2)File systems  --->Miscellaneous filesystems  --->UBIFS file system support

  • 制作ubifs格式的根文件系统镜像

先说明一下,板子上既有NorFlash,又有NandFlash,其中根文件系统和应用程序放在NandFlash上,uboot和kernel放在NorFlash上,而根文件系统所在的mtd设备为mtd2,分区大小为34MiB

uboot kernel rootfs=34MiB app
  • ./mkfs.ubifs -v -r ./rootfs -o rootfs.img -m 2048 -e 129024 -c 272

   -r:制定文件内容的位置 
    -m:页面大小 
    -e:逻辑擦除块大小 
    -c:最大的逻辑擦除块数量

  1. mkfs.ubifs -m 2048 -e 129024 -c 1984 -o rootfs.ubifs -x none
  2.  
  3. -m 2048 (Minimum input/output unit size: 2048 bytes)
  4. -e 129024 (Default UBI LEB size: 129024 bytes, 126.0 KiB)
  5. -c 1984 (Amount of eraseblocks: 1984 (260046848 bytes, 248.0 MiB))
  6. -o rootfs.ubifs (output file)
  7. -x none (no compression)
  • ./ubinize -v -o rootfs.ubi -m 2048 -p 128KiB -s 2048 hi.cfg

     -p:物理擦除块大小 

     -m:页面大小

      -s: 最小的硬件输入输出页面大小,如:k9f1208为256(上下半页访问)

配置文件hi.cfg如下:

[ubifs]
mode=ubi
image=rootfs.img
vol_id=0
vol_size=34MiB
vol_type=dynamic
vol_alignment=1
vol_name=rootfs
vol_flag=autoresize

 然后修改uboot的环境变量:

setenv bootargs 'mem=288M console=ttyAMA0,115200
root=ubi0:rootfs rw rootflags=sync rootfstype=ubifs ubi.mtd=2
mtdparts=hi_sfc:5M(boot),1M(picture);hinand:34M(rootfs),8M(config),86M(app)';

保存环境变量,执行如下命令

setenv ipaddr 192.168.253.132;

setenv serverip 192.168.253.130;

setenv ethaddr 40:61:86:67:33:47;

mw.b 82000000 ff 2200000;

tftp 82000000 rootfs.ubi;

nand erase 0 2200000;

nand write 82000000 0 $(filesize);

sf probe 0;

sf read 0x82000000 0x100000 0x400000;

bootm 0x82000000

说明:

其实从上面的烧写命令可以看出,ubifs格式的镜像中是不包含oob信息的。

参见:http://www.cnblogs.com/pengdonglin137/p/3399071.html

出现如下错误信息:

UBI: attaching mtd2 to ubi0
UBI: physical eraseblock size: 131072 bytes (128 KiB)
UBI: logical eraseblock size: 126976 bytes
UBI: smallest flash I/O unit: 2048
UBI: VID header offset: 2048 (aligned 2048)
UBI: data offset: 4096
UBI: max. sequence number: 0
UBI error: vtbl_check: volume table check failed: record 0, error 9
UBI error: ubi_init: cannot attach mtd2
Fixed MDIO Bus: probed

原因:

参考     http://wiki.linpert.de/index.php?title=UBIFS#record_0.2C_error_9  

             http://lists.infradead.org/pipermail/linux-mtd/2009-April/025127.html

  1. But I took a look into the code, and the following is error 9:
  2.  
  3. if (reserved_pebs > ubi->good_peb_count) {
  4. dbg_err("too large reserved_pebs %d, good PEBs %d",
  5. reserved_pebs, ubi->good_peb_count);
  6. err = 9;
  7. goto bad;
  8. }
  9.  
  10. This means you created a too large UBI volume in the image,
  11. and your real flash is smaller.
  12.  
  13. Try to enable UBI debugging, and type dmesg, then you'll see
  14. reserved and real eraseblock numbers.

原因就是:在配置文件中,volume设为34MiB,太大了,因为整个mtd2分区总共才34MiB。

解决办法:将配置文件改为:

[ubifs]
mode=ubi
image=rootfs.img
vol_id=0
vol_size=32MiB
vol_type=dynamic
vol_alignment=1
vol_name=rootfs
vol_flag=autoresize

说明:

vol_id  表示volume的编号,一个ubi设备中可以有多个volume。(这种情况下,/dev下会出现 ubi0 和 ubi0_0)

vol_size 表示ubi0_0的大小,即volume0的大小

vol_type 表示volume0的类型,分为dynamic和static两种,其中dynamic类型的设备表示可以读写,static类型的设备表示只读

vol_name 表示volume0的名称,在挂载ubi分区是会使用到,如在bootargs中的root=ubi0:rootfs

然后重新执行:   ./ubinize -v -o rootfs.ubi -m 2048 -p 128KiB -s 2048 hi.cfg

当再次重启后,又出现如下错误信息:

UBIFS: parse sync
UBIFS error (pid 1): validate_sb: LEB size mismatch: 129024 in superblock, 126976 real
UBIFS error (pid 1): validate_sb: bad superblock, error 1

原因:

参考:http://www.linux-mtd.infradead.org/faq/ubifs.html#L_lebsz_mismatch

I see this UBIFS error: "validate_sb: LEB size mismatch: 129024 in superblock, 126976 real"

When you create an UBIFS image using the mkfs.ubifs utility, you specify LEB size using the -e option.
This is a very important parameter and you should specify it correctly
in order to have working UBIFS image. Indeed, LEB size is the major
UBIFS storage unit, e.g., UBIFS nodes never cross LEB boundaries,
garbage collection is performed on individual LEBs, etc.
See this section for more information.

The error message means that LEB size information which is stored in
the UBIFS superblock does not match the real LEB size, which UBIFS takes
from UBI. The superblock was created by the mkfs.ubifs utility, therefore you failed to pass the correct LEB size to the utility. Fix this by passing correct LEB size via the -e option.

原因是:逻辑块的大小与实际的大小不符

解决办法:

将-e选项的值由129024改成126976

重新执行:

 ./mkfs.ubifs -v -r ./rootfs -o rootfs.img -m 2048 -e 126976 -c 272

 ./ubinize -v -o rootfs.ubi -m 2048 -p 128KiB -s 2048 hi.cfg

重新烧写并重启。

还有一个需要注意的问题是,如果将-s选项的值搞错,如将2048写成了512,那么会有如下错误信息

UBI error: validate_ec_hdr: bad VID header offset 512, expected 2048
UBI error: validate_ec_hdr: bad EC header
UBI error: ubi_io_read_ec_hdr: validation failed for PEB 0
UBI error: ubi_init: cannot attach mtd2
Fixed MDIO Bus: probed

从错误提示中就可以看到解决方法:将-s选项的值改为2048即可。

参考:http://www.cnblogs.com/pengdonglin137/p/3404685.html

 UBI headers

UBI stores 2 small 64-byte headers at the beginning of each non-bad physical eraseblock:

  • erase counter header (or EC header) which contains the erase counter of the physical eraseblock (PEB) plus some other not so important information;
  • volume identifier header (or VID header) which stores volume ID and logical eraseblock (LEB) number this PEB belongs to (plus some other not so important information).

This is why logical eraseblocks are smaller than physical eraseblock - the headers take some flash space.

UBI headers position

The EC header always resides at offset 0 and takes 64 bytes, the VID
header resides at the next available min. I/O unit or sub-page, and also
takes 64 bytes. For example:

  • in case of NOR flash which has 1 byte min. I/O unit, the VID header resides at offset 64;
  • in case of NAND flash which does not have sub-pages, the VID header resides at the second NAND page;
  • in case of NAND flash which has sub-pages, the VID header resides at the second sub-page.

UBI utilizes sub-pages to lessen flash space overhead. The overhead
is less if NAND flash supports sub-pages (see here). Indeed, let's
consider a NAND flash with 128KiB eraseblocks and 2048-byte pages. If it
does not have sub-pages, UBI puts the the VID header at physical offset
2048, so LEB size becomes 124KiB (128KiB minus one NAND page which
stores the EC header and minus another NAND page which stores the VID
header. In opposite, if the NAND flash does have sub-pages, UBI puts the
VID header at physical offset 512 (the second sub-page), so LEB size
becomes 126KiB (128KiB minus one NAND page which is used for storing
both UBI headers). See this section for more information about where the
UBI headers are stored.

也就是说,对于上面的例子,如果有subpage(可以到/sys/class/mtd/其中的一个目录下使用cat命令去查看某个mtd设备的subpagesize参数),如果是512B,这有如下参数搭配(对于块大小是128KiB,页大小是2KB的NandFlash来说):

 ./mkfs.ubifs -v -r ./rootfs -o rootfs.img -m 2048 -e 129024 -c 272 

 ./ubinize -v -o rootfs.ubi -m 2048 -p 128KiB -s 512 hi.cfg

其中
-e表示的是逻辑块的大小,因为subpagesize大小是512(也就是-s选项的值),第一页的前512存放EC(实际用了前64B),接下来的512B(前64B)存放UBI
headers,逻辑块的大小就是128KiB-2KiB=126KiB,转化成十进制就是129024。

假如没有subpagesize,那么有如下搭配:

 ./mkfs.ubifs -v -r ./rootfs -o rootfs.img -m 2048 -e 126976 -c 272 

 ./ubinize -v -o rootfs.ubi -m 2048 -p 128KiB -s 2048 hi.cfg

其中,逻辑块的大小:128KiB-2KiB-2KiB=124KiB,转换成10进制就是126976,-s后面的值为页大小,即2048B。

https://blog.csdn.net/davion_zhang/article/details/47400553

http://www.360doc.com/content/14/1018/14/18578054_417913216.shtml

ubi问题总结的更多相关文章

  1. Linux UBI子系统设计初探

    问题领域 flash存储设备存在如下特点: 存在坏块 使用寿命较短 存储介质不稳定 读写速度慢 不支持随机访问(nand) 只能通过擦除将0改成1 最小读写单位为page or sub-page 便宜 ...

  2. UBI系统原理-中【转】

    转自:http://blog.chinaunix.net/uid-28236237-id-4217118.html UBI 文件头位置 EC头都放置在擦除块的开始偏移位置,占用64字节空间.之后防止V ...

  3. UBI系统原理分析【转】

    转自:http://blog.chinaunix.net/uid-28236237-id-4164656.html 综述 UBI全称Unsorted Block Images,是一种原始flash设备 ...

  4. UBI FAQ and HOWTO

    转:http://www.linux-mtd.infradead.org/faq/ubi.html UBI FAQ and HOWTO Table of contents How do I enabl ...

  5. nandsim ubi nand nor

    nandsim模拟mtd测试UBI模块 利用nandsim挂载ubi文件系统 MTD设备及JFFS2, UBIFS文件系统的使用简介 首先需要安装mtd_utils工具: sudo apt-get i ...

  6. UBI(unsorted block image )块管理

    一.介绍 ubi是unsorted block images的缩写,是由IBM开发设计的,它与ubifs有不同的含义,ubifs是一种文件系统(nokia开发的):而ubi是一种块管理工具,工作在mt ...

  7. page size == 4096 , nand size == 1GB, block size == 256kb 的ubi 文件系统制作

    mkubiimg.sh 2 sudo mkfs.ubifs -F -q -r rootfs_ecm_5410 -m 4096 -e 253952 -c 3600 -o ubifs.img 3 4 ec ...

  8. ubi 文件系统加载失败原因记录

    尝试升级 kernel 到 4.4.12版本,然后出现 kernel 加载 ubi 文件系统失败的现象,现象如下 [ 3.152220] ubi0 error: vtbl_check: too lar ...

  9. UBIFS文件系统简介 与 利用mkfs.ubifs和ubinize两个工具制作UBI镜像 (完整理解版本)

    UBI文件系统简介 在linux-2.6.27以前,谈到Flash文件系统,大家很多时候多会想到cramfs.jffs2.yaffs2等文件系统. 它们也都是基于文件系 统+mtd+flash设备的架 ...

  10. openwrt编译系统生成ubi镜像的各变量解析

    1.MKUBIFS_OPTS的作用 传递参数给mkfs.ubifs 2.MKUBIFS_OPTS传递了哪些参数? 传递了最小输入输出单元大小.逻辑擦除块大小.最大物理擦除块的个数,分别由选项-m.-e ...

随机推荐

  1. easy flash &easy log

    EASY FLASH: ENV 快速保存产品参数(k-v型no-sql数据库存储),支持 写平衡(磨损平衡) 及 掉电保护 功能 EasyFlash不仅能够实现对产品的 设定参数 或 运行日志 等信息 ...

  2. DHCP与DHCP中继原理与配置!(重点)

    一 .DHCP  服务概述 0:dhcp原理: 集中的管理.分配IP地址,使client动态的获得IP地址.Gateway地址.DNS服务器地址等信息,并能够提升地址的使用率.简单来说,DHCP就是一 ...

  3. [方法]季节调整与hp滤波方法

    进行时间序列的数据分析时,季节因素调整与hp滤波是进行数据处理与准备工作的常见必要环节.本文简要梳理季节调整与hp滤波的应用场景,以及在Python中的实现方法. 1. 季节调整方法 季节调整的目的是 ...

  4. CSS概述(最详细!!!)

    一.先综述 二.分述: 1.简介: 2.基本用法 3.引入方式: 4.盒模型         5.选择器:   6.常见文本样式及复合样式       7.改变行.块元素的属性: 8.标签显示与隐藏: ...

  5. 四、linux基础-系统目录_安装_相关命令_调度

    4 系统目录-安装-版本4.1系统目录Linux的文件系统是采用级层式的树状目录结构,在此结构中的最上层是根目录“/”,然后在此目录下再创建其他的目录. 在装完Linux系统以后会自动生成一下等目录, ...

  6. i.MX RT600之DMIC外设介绍及应用

    恩智浦的i.MX RT600是跨界处理器产品,同样也是i.MX RTxxx系列的开山之作.不同于i.MX RT1xxx系列单片机,i.MX RT600 采用了双核架构,将新一代Cortex-M33内核 ...

  7. 「JOI2019 Final」解题报告

    传送门 「JOI2019 Final」勇者比太郎 看懂题就很简单了,后缀和随便维护一下就好了,别用树状数组强加一个\(\log\)就行. 「JOI2019 Final」画展 显然可以先把所有的画框按大 ...

  8. :before 与 :after

    http://justcoding.iteye.com/blog/2032627  网址

  9. 源码安装openldap(转)

    Ubuntu安装OpenLDAP(附错误的详细解决办法) 1 下载OpenLDAP源码 http://www.openldap.org/software/download/ 或者 ftp://ftp. ...

  10. Batch批量替换hosts

    hosts文件替换 工作需要,要修改很多计算机的hosts文件,采用bat批量完成 解决的问题: 1.pc工作在非管理员权限,右键管理员权限太麻烦,因此采用执行中申请管理员权限的方式 2.hosts和 ...