Overview
SPI Flash, divided into SPI Flash, DUAL SPI Flash, QUAD SPI Flash,
3-wire SPI, 4-wire SPI, 6-wire SPI. In the case of clock, the more the number of lines in theory, the faster
NOR Flash versus NAND flash
NOR disadvantage: The price is expensive, small capacity, erasing block large, erasing speed is slow, NOR flash life of 100,000 times, far less than NAND flash 1 million times. Nor can be programmed in single-byte, which means that only one byte is updated at a time
NOR Advantages: Fast reading speed, stability will not appear bit reversal, do not need EDC and ECC, do not need bad block management NOR Flash usually write a byte at a time, NAND flash memory must write multiple bytes at a time (usually 512 bytes)
The pros and cons of NOR Flash determine its Application field: it is suitable for storing key data that is rarely modified, such as bootloader kernel, and is not suitable for large and often modified data such as user maps, library files, etc.
3 Wire SPI
Normal SPI uses four lines: Clock, CS, Mosi, MISO. Mosi miso can be merged into a single line (slave out/slave in SISO) to achieve Half-duplex. Mainly used to achieve low speed transmission
DUAL SPI
For SPI Flash, Full-duplex is not commonly used, so expand the two data lines so that they support half-duplex transmission, doubling the speed of data transfer. You can send a command byte request into dual mode, and then the Mosi becomes SIO0 (serial I/O 0) and miso becomes SIO1.
This mode is mainly for SPI ROM, SPI Flash devices, the need for large data transmission
QUAD SPI
The quad SPI also adds two I/O lines (SIO2 SIO3), which can transmit four data bits in one clock cycle. Enables quad mode by using special commands.
Double Data Rate
In addition to using multiple I/O lines, some devices also increase transmission rates through DDR technology
SPI NOR Flash file system support
NOR Flash and ordinary mechanical hard drive, SSD, eMMC The biggest difference is NOR flash before writing, need to ensure that the location is already erased, so it is not suitable to use the traditional EXT2/3/4, Fat/ntfs and other file systems
Even the Yaffs class file system is not suitable for nor flash
jffs and JFFS2
All two file systems can support nor flash, and provide garbage collection, bad block management, and wear balance. Both have file system mount slow problem, not suitable for large-capacity flash
Yaffs/yaffs2
has been kicked out of the main core, basically abandoned.
CRAMFS/SQUASHFS
Regular read-only file system, all support data compression, realize simple, fast, if nor flash storage file system is read-only, try to use them. These regular file systems work on legacy block devices and require kernel support
Config_mtd_blkdevs=y
Config_mtd_block=y
EXT2/3/4 Fat/ntfs
Block device file systems that support reading and writing are not suitable for working on nor Flash because nor Flash writes can result in erasure operations, slow speed, and impact life.
MTD Simulation block device
Open Config_mtd_block and Config_mtd_blkdevs.
Several block devices will be added to the/dev/after startup
root@devm:~# ls/dev/mtd
mtd0 mtd1 mtd2 mtd3 mtdblock0 mtdblock2 mtd0ro Mtd1ro mtd2ro mtd3ro mtdblock1 mtdblock3
using MKFS.EXT4, Format Mtdblock,
root@evm:~# mkfs.ext4/dev/mtdblock3
mke2fs 1.42.9 (28-dec-2013)
filesystem label=
OS type:linux
Block size=1024 (log=0)
Fragment size=1024 (log=0) stride=0 blocks, stripe width=0 blocks 1856 inodes
, 7424 b Locks
371 Blocks (5.00%) reserved for the super user of the The "the", "the", Block=1 Maximum filesystem
/>1 block group
8192 blocks/group, 8192 fragments per group
1856 inodes per group
allocating group Tabl Es:done
Writing inode tables:done
Creating Journal (1024 Blocks): Done
writing superblocks and Filesyste M accounting Information:done
write Cramfs mirroring using the DD command
First, create a cramefs mirror in the host
Mkfs.cramfs rootfs/cramfs.img
DD Command Import Mirror
root@evm:~# DD if=/dev/mtdblock3 of=cramfs.img
14848+0 Records in
14848+0 records out
root@evm:~#
-rw-r--r-- 1 root root 7602176 1 00:24 kaka.img
NOR Flash uses JFFS2
NOR Flash on JFFS2, JFFS2 operation via MTD interface NOR Flash create JFFS2 mirrors
The MKFS.JFFS2 tool is in the Mtd-utils toolkit
sudo apt-get install mtd-utils
mkfs.jffs2-r rootfs/-o jffs2.img--pad=0x800000
--pad=0x800000 If you do not add this parameter, the resulting mirrored size (file system size) is determined by the size of the rootfs/small content; We can force the file system size to be specified by this parameter.
Burn write JFFS2 Mirror
There are two ways to write a burn:
1. Download jffs2.img to DRAM in Uboot and then use SF Write command to burn DRAM content to nor flash
2. Use DD if=jffs2.img Of=/dev/mtdblock4 after entering the system
Both are actually the same in nature, are directly to the image of the nor flash in memory
mount JFFS2 File System
First kernel to support the JFFS2 file system, execute the following command
Mount-t jffs2/dev/mtdblock4/mnt
file system mount Speed
Because the JFFS2 needs to perform a scan during the mount process and construct the file system, the JFFS2 mount time is much larger than the EXT4 file system on the same size Mtdblock
File system size is 0x740000 (7.25MB)
EXT4 mount Time
root@evm:~# times mount-t ext4/dev/mtdblock3/mnt real 0m 0.06s
user 0m 0.00s
sys 0m 0.00s
JFFS2 mount Time
root@evm:~# times mount-t jffs2/dev/mtdblock3/mnt real 0m 0.34s
user 0m 0.00s
SYS 0m 0.33s