Nandflash镜像尾部不应填充0xFF
Nandflash镜像文件系统尾部经常被填充0xFF以补齐大小,这样做是错误的,可能会有意想不到的bug。包括JFFS2、UBIFS等。
因此建议丢弃多余的0xFF。
出自:http://www.linux-mtd.infradead.org/doc/ubi.html
If your UBI image contains UBIFS file system, and your flash is NAND, you may have to drop 0xFF bytes the end of input PEB data. This is very important, although not required for all NAND flashes. Sometimes a failure to do this may result in very unpleasant problems which might be difficult to debug later. So we recommend to always do this.
The reason for this is that UBIFS treats NAND pages which contain only 0xFF bytes (let's refer them to as empty NAND pages) as free. For example, suppose the first NAND page of a PEB has some data, the second one is empty, the third one also has some data, the fourth one and the rest of NAND pages are empty as well. In this case UBIFS will treat all NAND pages starting from the fourth one as free, and will write data there. If the flasher program has already written 0xFF's to these pages, then any new UBIFS data will cause a second write. However, many NAND flashes require NAND pages to be written only once, even if the data contains only 0xFF bytes.
To put it differently, writing 0xFF bytes may have side-effects. What the flasher has to do is to drop all empty NAND pages from the end of the PEB buffer before writing it. It is not necessary to drop all empty NAND pages, just the last ones. This means that the flasher does not have to scan whole buffer for 0xFF's. It is enough to scan the buffer from the end and stop on the first non-0xFF byte. This is much faster. Here is the code from UBI which does the right thing.
/**
* calc_data_len - calculate how much real data are stored in a buffer.
* @ubi: UBI device description object
* @buf: a buffer with the contents of the physical eraseblock
* @length: the buffer length
*
* This function calculates how much "real data" is stored in @buf and returns
* the length. Continuous 0xFF bytes at the end of the buffer are not
* considered as "real data".
*/
int ubi_calc_data_len(const struct ubi_device *ubi, const void *buf,
int length)
{
int i;
for (i = length - 1; i >= 0; i--)
if (((const uint8_t *)buf)[i] != 0xFF)
break;
/* The resulting length must be aligned to the minimum flash I/O size */
length = ALIGN(i + 1, ubi->min_io_size);
return length;
}
This function is called before writing the buf buffer to the PEB. The purpose of this function is to drop 0xFF's from the end and prevent the situation described above. The ubi->min_io_size is the minimal input/output unit size which is equivalent to NAND page size.
By the way, we experienced the similar problems with JFFS2. The JFFS2 images generated by the mkfs.jffs2 program were padded to the physical eraseblock size and were later flashed to our NAND. The flasher did not bother skipping empty NAND pages. When JFFS2 was mounted, it wrote to those NAND pages, and the writes did not fail. But later we observed weird ECC errors. It took a while to find out the problem. In other words, this is also relevant to JFFS2 images.
An alternative to this approach is to enable the "free space fixup" option when generating the UBIFS file system using mkfs.ubifs. This will allow your flasher to not have to worry about 0xFF bytes at the end of PEBs, which is particularly useful if you need to use an industrial flash programmer to write a UBI image. More information is available here.
Nandflash镜像尾部不应填充0xFF的更多相关文章
- s3c2440对nandflash的操作
转:http://blog.csdn.net/zhaocj/article/details/5795254 nandflash在对大容量的数据存储中发挥着重要的作用.相对于norflash,它具有一些 ...
- 教程:在 VM Depot 中查找 Azure 可用的虚拟机镜像
发布于 2014-07-08 作者 陈 忠岳 对于 Azure 的社区管理虚拟机资源库--VM Depot--的用户来说,网站的搜索功能已得到极大的改善.这一搜索能力的增强,可以帮助用户更容易地 ...
- Docker镜像构建
一.简介 在构建容器化应用时,相当重要的步骤莫过于镜像制作,本文将介绍镜像制作方法以及镜像制作的建议.通常镜像的制作有两种方式: 使用现有的容器使用docker commit 生成镜像 使用Docke ...
- 镜像仓库管理:与Portus不得不说的那些事
背景: 目前在做一个云计算相关的项目,其中有这样一个需求:每个平台用户都有自己的docker镜像仓库(docker registry),用户可以对自己的镜像仓库的push/pull权限进行管理,也就是 ...
- XenServer创建镜像Storage
Youtube:https://www.youtube.com/watch?v=-AK3nauKUw0 在安装了XenServer后,是没有镜像Storage的,我们可以在XenCenter中创建一个 ...
- node官方docker镜像运行bower 提示 permission denied 解决方法
在使用node官方docker镜像部署node应用时,应用需要npm的scripts中运行bower install 来安装前端包,但是用docker 构建时失败,提示 permission dein ...
- QEMU支持的几种常见的镜像文件格式
qemu-img支持非常多种的文件格式,可以通过"qemu-img -h"查看其命令帮助得到,它支持二十多种格式:blkdebug.blkverify.bochs.cloop.c ...
- jffs2根文件系统制作
http://www.eetop.cn/blog/html/98/510998-20964.html 作者:刘洪涛,华清远见嵌入式学院高级讲师,ARM公司授权ATC讲师. JFFS2是Flash上应用 ...
- C结构体中数据的内存对齐问题
转自:http://www.cnblogs.com/qwcbeyond/archive/2012/05/08/2490897.html 32位机一般默认4字节对齐(32位机机器字长4字节),64位机一 ...
随机推荐
- 关于char类型的说明
#include<iostream> using namespace std; int main() { char ch=128;//VC编译器默认是有符号的.但c并未明确给出.由编译器 ...
- ListView(下)自定义适配器
(一) 1.效果图 2.activity_main.xml <?xml version="1.0" encoding="utf-8"?> <L ...
- Why DNS Based Global Server Load Balancing (GSLB) Doesn’t Work
Why DNS Based Global Server Load Balancing (GSLB) Doesn't Work
- C#的Xamarin开发小米盒子应用并以WCF实现微信通知
对于熟悉C#语言的开发人员而言,用Xamarin开发Android应用也是一个不错的选择.小米盒子是Android系统.当然也就能够使用Xamarin来开发.首选来看效果图. watermark/2/ ...
- UI 层级问题
UI 用overlay的话 不会有自己的camre 直接画到backbuffer上 比较推荐 分层的事情就用sorting order解决就可以了 下一步就是能不能拿到 ugui的shader了 UI ...
- java.io.IOException: Attempted read from closed stream. 异常,解决
在HttpClient请求的时候,返回结果解析时出现java.io.IOException: Attempted read from closed stream. 异常,解决 原因是EntityUti ...
- jquery.cookie.js操作cookie实现“记住密码”,很简单很强大
//初始化页面时验证是否记住了密码 $(document).ready(function() { if ($.cookie("rmbUser") == "true&quo ...
- lodash forIn forOwn 遍历对象属性
_.forIn(object, [iteratee=_.identity]) 使用 iteratee 遍历对象的自身和继承的可枚举属性. function Foo() { this.a = 1; th ...
- JUDE工具类图制作
1. 类图图形元素 2. 连接线条 线的关系解释如下: 3. 创建一个类
- PHP-php-fpm配置优化
前言: 1.少安装PHP模块, 费内存 2.调高linux内核打开文件数量,可以使用这些命令(必须是root帐号)(我是修改/etc/rc.local,加入ulimit -SHn 51200的) ec ...