[Warning: This post is a backup recovery from my previous Wordpress blog. All content was automatically converted accessing a MySQL database using a Python script (details). Mostly are in Portuguese but if you are interest I can translate to English. If you found any problem dont’t hesitate to contact me in comments.]
there are two tips when initializing MTD partition struct:
- use MTDPART_OFS_APPEND to define .offset
- 1024 multiple to .size (4MB = 4194304 bytes or 4 * 1024 * 1024)
static struct mtd_partition nand_flash_partitions[] = {
{
.name = “bootloader”,
.offset = 0,
.size = 3 * 1024 * 1024},
{
.name = “nand.kernel”,
.offset = MTDPART_OFS_APPEND,
.size = 5 * 1024 * 1024},
{
.name = “nand.rootfs”,
.offset = MTDPART_OFS_APPEND,
.size = 256 * 1024 * 1024},
{
.name = “nand.userfs1”,
.offset = MTDPART_OFS_APPEND,
.size = 256 * 1024 * 1024},
{
.name = “nand.userfs2”,
.offset = MTDPART_OFS_APPEND,
.size = MTDPART_SIZ_FULL},
};
<strong>static</strong> <strong>struct</strong> <span style="color: #2040a0;">mtd_partition</span> <span style="color: #2040a0;">nand_flash_partitions</span><span style="color: #4444ff;">[</span><span style="color: #4444ff;">]</span> <span style="color: #4444ff;">=</span> <span style="color: #4444ff;"><strong>{</strong></span>
<span style="color: #4444ff;"><strong>{</strong></span>
.<span style="color: #2040a0;">&nbname</span> <span style="color: #4444ff;">=</span> <span style="color: #008000;">"bootloader"</span>,
.<span style="color: #2040a0;">offset</span> <span style="color: #4444ff;">=</span> <span style="color: #ff0000;">0</span>,
.<span style="color: #2040a0;">size</span> <span style="color: #4444ff;">=</span> <span style="color: #ff0000;">3</span> <span style="color: #4444ff;">*</span> <span style="color: #ff0000;">1024</span> <span style="color: #4444ff;">*</span> <span style="color: #ff0000;">1024</span><span style="color: #4444ff;"><strong>}</strong></span>,
<span style="color: #4444ff;"><strong>{</strong></span>
.<span style="color: #2040a0;">name</span> <span style="color: #4444ff;">=</span> <span style="color: #008000;">"nand.kernel"</span>,
.<span style="color: #2040a0;">offset</span> <span style="color: #4444ff;">=</span> <span style="color: #2040a0;">MTDPART_OFS_APPEND</span>,
.<span style="color: #2040a0;">size</span> <span style="color: #4444ff;">=</span> <span style="color: #ff0000;">5</span> <span style="color: #4444ff;">*</span> <span style="color: #ff0000;">1024</span> <span style="color: #4444ff;">*</span> <span style="color: #ff0000;">1024</span><span style="color: #4444ff;"><strong>}</strong></span>,
<span style="color: #4444ff;"><strong>{</strong></span>
.<span style="color: #2040a0;">name</span> <span style="color: #4444ff;">=</span> <span style="color: #008000;">"nand.rootfs"</span>,
.<span style="color: #2040a0;">offset</span> <span style="color: #4444ff;">=</span> <span style="color: #2040a0;">MTDPART_OFS_APPEND</span>,
.<span style="color: #2040a0;">size</span> <span style="color: #4444ff;">=</span> <span style="color: #ff0000;">256</span> <span style="color: #4444ff;">*</span> <span style="color: #ff0000;">1024</span> <span style="color: #4444ff;">*</span> <span style="color: #ff0000;">1024</span><span style="color: #4444ff;"><strong>}</strong></span>,
<span style="color: #4444ff;"><strong>{</strong></span>
.<span style="color: #2040a0;">name</span> <span style="color: #4444ff;">=</span> <span style="color: #008000;">"nand.userfs1"</span>,
.<span style="color: #2040a0;">offset</span> <span style="color: #4444ff;">=</span> <span style="color: #2040a0;">MTDPART_OFS_APPEND</span>,
.<span style="color: #2040a0;">size</span> <span style="color: #4444ff;">=</span> <span style="color: #ff0000;">256</span> <span style="color: #4444ff;">*</span> <span style="color: #ff0000;">1024</span> <span style="color: #4444ff;">*</span> <span style="color: #ff0000;">1024</span><span style="color: #4444ff;"><strong>}</strong></span>,
<span style="color: #4444ff;"><strong>{</strong></span>
.<span style="color: #2040a0;">name</span> <span style="color: #4444ff;">=</span> <span style="color: #008000;">"nand.userfs2"</span>,
.<span style="color: #2040a0;">offset</span> <span style="color: #4444ff;">=</span> <span style="color: #2040a0;">MTDPART_OFS_APPEND</span>,
.<span style="color: #2040a0;">size</span> <span style="color: #4444ff;">=</span> <span style="color: #2040a0;">MTDPART_SIZ_FULL</span><span style="color: #4444ff;"><strong>}</strong></span>,
<span style="color: #4444ff;"><strong>}</strong></span><span style="color: #4444ff;">;</span>