flash 问题记录

1.flash中有页page,扇区sector,块block等概念。但是可能不同的flash描述不一样。有些是page组成sector,有些是sector组成page。如何区分?直接去看芯片手册。

2.以IS25LQ016B SQPI flash为例(直接搜IS25LQ016B就能找到芯片手册)。下面摘取手册中的原文。

GENERAL DESCRIPTION
The IS25LQ032B/016B/080B (32/16/8M-bit) Serial Flash memory offers a storage solution with flexibility and
performance in a simplified pin count package. ISSI’s “Industry Standard Serial Interface” is for systems that have
limited space, pins, and power. The device is accessed through a 4-wire SPI Interface consisting of a Serial Data
Input (SI), Serial Data Output (SO), Serial Clock (SCK), and Chip Enable (CE#) pins, which also serve as multi-
function I/O pins in Dual and Quad modes (see pin descriptions). The IS25xQ series of Flash is ideal for code
shadowing to RAM, execute in place (XIP) operations, and storing non-volatile data.
The memory array is organized into programmable pages of 256-bytes each. The device supports page program
mode where 1 to 256 bytes of data can be programmed into the memory with one command. Pages can be erased in
groups of 4Kbyte sectors, 32Kbyte blocks, 64Kbyte blocks, and/or the entire chip. The uniform sectors and blocks
allow greater flexibility for a variety of applications requiring solid data retention.
The device supports the standard Serial Peripheral Interface (SPI), Dual/Quad output (SPI), and Dual/Quad I/O (SPI).
Clock frequencies of up to 104MHz for all read modes allow for equivalent clock rates of up to 416MHz (104MHz x 4)
which equates to 52Mbytes/S of throughput. These transfer rates can outperform 16-bit Parallel Flash memories
allowing for efficient memory access for a XIP (execute in place) operation. The device is manufactured using industry
leading non-volatile memory technology and offered in industry standard lead-free packages. See Ordering
Information for the density and package combinations available

可以看到,这个flash 的page是256B,一条命令可以写入256B。也是最基本的写入单位。假如是1000B的固件,需要分4次写入,前面3次每次写入256B,最后一次呢?

根据手册,最后一次写入剩余的 1000 - 256 * 3 = 232 B 。

目前使用的bin档,打开后发现在最后用0填充了固件,估计就是为了使固件大小是对其的?是page的整数倍?(需要考证,我这只是猜想)

某个固件大小是143 KB (146,432 字节),打开后发现最后补了11*16B的0.

一些注意事项和原因:

flash在写之前一定要擦除,因为flash擦除是往里面写1的过程,而烧录的话只是将里面需要写0的地方写成0。所以一定得先擦除再烧录。

这个flash的sector大小都是一样的(4K),但是有些flash的sector大小是不一样的,至于获取sector大小,芯片手册应该有。

原文地址:https://www.cnblogs.com/gsp1004/p/11433222.html