Hello
I'm having problem to understand some piece of code in MTD driver
#define ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y))
...
static struct mtd_partition my_parts[] =
{
{
.name = "boot",
.size = 0,
.offset = 0,
.mask_flags = MTD_WRITEABLE
},
{
.name = "linux",
.size = 0,
.offset = 0
},
{
.name = "rootfs",
.size = 0,
.offset = 0,
.mask_flags = MTD_WRITEABLE
},
{
.name = "nvram",
.size = 0,
.offset = 0
},
{
.name = 0,
.size = 0,
.offset = 0
}
}
...
i = (sizeof(bcm947xx_parts)/sizeof(struct mtd_partition)) - 2;
bcm947xx_parts[i].size = ROUNDUP(NVRAM_SPACE, mtd->erasesize);
bcm947xx_parts[i].offset = size - bcm947xx_parts[i].size;
So here are my questoins: 1) why is it necessary to round up the size of the partition? 2) could you help to understand how the rounding works? 3) flash driver in boot loader on the same platform doesn't do the rounding for this specific partition, so the flash layout has different offsets in the kernel side and in the bootloader. What is the reason for this?
Thanks in advance for any valuable comments !