3. NAND Flash Partition

3.1. About mtd

memorytechnologydevicethat is, MTD (Memory Technology Device, abbreviatewriteis MTD) , is Linux systemin devicefile systemonecategory, mainneed toused to flashstoreapplication, isa type offlashstoreconvertreplacelayer (Flash Transl ation Layer, FTL) . create MTD subsystemmainneed tocurrentisprovideonebetween flashhardwaredriverprogram withapplicationprogrambetweenabstractlayer.

3.2. Partition Table

CVITEK solution flash partitions are defined in XML. Take boards/default/partition/partition_spinand_page_2k.xml as an example:

<physical_partition type="spinand">
    <partition label="fip" size_in_kb="2560" file="fip.bin"/>
    <partition label="BOOT" size_in_kb="8192" file="boot.spinand"/>
    <partition label="MISC" size_in_kb="384" file="logo.jpg" />
    <partition label="ENV" size_in_kb="128" file="" />
    <partition label="ROOTFS" size_in_kb="71680" file="rootfs.spinand" />
    <partition label="SYSTEM" size_in_kb="20480" file="system.spinand" mountpoint="" type="ubifs" />
    <partition label="CFG" size_in_kb="4096" file="cfg.spinand" mountpoint="/mnt/cfg" type="ubifs" />
    <partition label="DATA" file="" mountpoint="/mnt/data" type="ubifs" />
</physical_partition>

with 2KB page size 128KB blocksize NAND flash isexample: byxmlfileondata, willeachpartitionsizeconversionbecomeblocksizeafter (formula: blockcount = partition size / singleblocksize) , as shown below:

Partition

Start block offset

Number of blocks

Binary files

FIP

0

20

fip.bin

BOOT

24

64

boot.spinand

MISC

Sequential order (skip bad blocks)

3

logo.jpg

ENV

Sequential order (skip bad blocks)

1

Null (no content)

ENV_BAK

Sequential order (skip bad blocks)

1

Null (no content)

ROOTFS

Sequential order (skip bad blocks)

560

rootfs.spinand

SYSTEM

Sequential order (skip bad blocks)

160

system.spinand

CFG

Sequential order (skip bad blocks)

32

cfg.spinand

DATA

Sequential order (skip bad blocks)

Don’t Care

Null (no content)

3.3. Burning Rules

3.3.1. SV Partition

The SV partition is bound to the processor. Select and burn the binary with a 2KB or 4KB page size; do not modify the partition contents.with2KB page sizeisexample, pleasewillblock 0, 1, 2, 3allburning182x_sv_2k_pg.bin, ifencounterbad blockthenskiptheblock. If beforefouritemblockallisbad block, pleasedo notusetheSPI NAND flash.

3.3.2. FIP Partition

The FIP partition contains two parts: processingdevicerelatedBootloader(noneopen source), u-boot. CVITEK compileflowwillautomaticwillbothopenpacketbecomeone fip.bin.

The NAND burning logic is:from block 0~19 betweensequentiallyselectgood block, totala total ofburningtwo copies, first copywillwritein block 0~9, second copywillburningin block 10~19, backups of each other.

fip.binprogram itself intospinand largeapproximatelywilluseto 3~4item blocks, but because spinand specialnessproblem, block maywillappearbad blockcondition, thereforeremaining unused block reserveused to appearbad blockwhenuse.

Example 1

If there are no bad blocks, willfirst copy fip.bin burningtoblock 0, 1, 2, 3, 4; second copyfip.binburningtoblock 9, 10, 11, 12, 13.

Example 2

If blocks 4 and 11 are bad, pleasewillfirst copy fip.bin burningtoblock 0, 1, 2, 3, 5; second copy fip.bin burningtoblock 9, 10, 12, 13, 14

3.3.3. Other Partitions

Burn sequentially according to the partition table configuration. Skip a bad block and burn to the next good block.

3.4. NAND Partition Alignment

The partition size must be aligned to the NAND flash erase size, erase size can checkread nand flash spec manual, currenthas 128/256k erase size, If cannotgetto nand flash erase size sizecan defaultaccording to 256k sizefor align