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位机一 ...
随机推荐
- golang设计模式-成员变量赋值
常见golang的struct赋值有两种: 1)定义变量同时初始化 val := &Options{ UID:int(1), } 2)先定义变量,再赋值 val := new(Options) ...
- iOS 文字渐变色
// 创建UILabel UILabel *label = [[UILabel alloc] init]; label.text = @"我是渐变的label"; [label s ...
- 修改 CentOS 6.3 时区 和 时间
1.查看当前时区和时间 date -R 2.CentOS中时区是以文件形式存在,当前时区文件位于 /etc/localtime 其他时区文件位于 /usr/share/zoneinfo下,其中中国时区 ...
- u-boot支持LCD显示(基于TQ2440)
平台简介 Linux版本:Linux-3.14 u-boot版本:u-boot-2015.04 硬件:TQ2440(内存:64MB NandFlash:256MB) 作者:彭东林 邮箱:pengdo ...
- 引用日志log4net.dll的web.config配置
<configSections> <section name="log4net" type="log4net.Config.Log4NetConfigu ...
- 关于ComboGrid取值为非下拉框数据是,隐藏面板数据清空
$('#areaGuid').combogrid({ panelWidth: 300, idField: 'guid', textField: 'name', mode: 'remote', meth ...
- flask前端优化:css/js/html压缩
1.先压缩再传输,可以减少传输的大小,减少传输时间,但是压缩需要时间,所以最终页面显示是快了还是慢了,需要比较 2.先看html压缩模块:pip install Flask-HTMLmin 压缩前:大 ...
- http://blog.csdn.net/hahalzb/article/details/5889545
http://blog.csdn.net/hahalzb/article/details/5889545
- MySQL数据库分片技术调研
将这段时间了解的MySQL分片技术和主从复制只是整理清楚画了思维导图记录一下,希望能给需要的人一些帮助 P.S.:个人整理,可能会有错误之处,还望指出~ 要解决的问题 1.海量数据的操作超出单表.单库 ...
- Yahoo 股票数据抓取
Yahoo提供日线级别的历史数据,包括国内外各交易所的数据,可以写爬虫抓取数据做简单的分析. api基本格式如下: http://ichart.yahoo.com/table.csv?s=<st ...