嵌入式系統系統升級內核雙備份的實現方式

轉載:https://www.xuebuyuan.com/1023344.html

 

1.nand flash MTD分區

        kernels/linux-2.6.31.1-cavm1/drivers/mtd/maps/xxxxx-flash.c 

        /* MTD partitions: From CNW5602 32MB
         * mtd0: 0x000C0000 00020000 "bootloader"
         * mtd1: 0x00040000 00020000 "factory_config"
         * mtd2: 0x00100000 00020000 "sysconfig"
         * mtd3: 0x00DE0000 00020000 "kernel_and_fs"
         * mtd4: 0x00020000 00020000 "bootloader_env"
         * mtd5: 0x00DE0000 00020000 "kernel_and_fs_backup"
        * mtd6: 0x001E0000 00020000 "syslog"
        * mtd7: 0x00020000 00020000 "transconfig"
        * mtd8: 0x00020000 00020000 "factoryconfig"
*/
static struct mtd_partition xxx_flash_partitions[] = {
{
.name = "bootloader", /* u-boot 6 sector (768KB), 0x20000-0xC0000: Reserved Space */
.size = 0x000C0000, /* 0x00000000 .. 0x000BFFFF */
.offset = 0,
.mask_flags = MTD_WRITEABLE, /* force read-only */
}, {
.name = "factory_config", /* Static Configuration from factory, (256KB = 128KB used + 128KB reserved) */
.size = 0x00040000, /* 0x000C0000 .. 0x000FFFFF */
.offset = MTDPART_OFS_APPEND,
.mask_flags = MTD_WRITEABLE, /* force read-only */
}, {
.name = "sysconfig", /* sysconfig 8 sector (1024KB) */
.size = 0x00100000, /* 0x00100000 .. 0x001FFFFF */
.offset = MTDPART_OFS_APPEND,
}, {
.name = "kernel_and_fs", /* Linux Kernel and File System (bootpImage) (14208KB) */
.size = 0x00DE0000, /* 0x00200000 .. 0x00FDFFFF */
.offset = MTDPART_OFS_APPEND,
}, {
.name = "bootloader_env", /* bottom 1 sector (128KB) for u-boot env variables */
.size = 0x00020000, /* 0x00FE0000 .. 0x00FFFFFF */
.offset = MTDPART_OFS_APPEND,
}, {
.name = "kernel_and_fs_backup", /* Linux Kernel and File System (bootpImage) (14208KB) */
.size = 0x00DE0000, /* 0x01000000 .. 0x01DDFFFF */
.offset = MTDPART_OFS_APPEND,
}, {
.name = "syslog", /* syslog 15 sector (1920KB) */
.size = 0x001E0000, /* 0x01DE0000 .. 0x01FBFFFF */
.offset = MTDPART_OFS_APPEND,
}, {
.name = "transconfig", /* transconfig 1 sector (128KB) */
.size = 0x00020000, /* 0x01FC0000 .. 0x01FDFFFF */
.offset = MTDPART_OFS_APPEND,
}, {
.name = "factoryconfig", /* factoryconfig 1 sector (128KB) */
.size = MTDPART_SIZ_FULL, /* 0x01FE0000 .. 0x01FFFFFF */ /* MTDPART_SIZ_FULL= 0x00020000 */
.offset = MTDPART_OFS_APPEND,
}
};
2.在應用層讀寫open("/dev/mtd3", O_RDWR);

1.nand flash MTD分區

        kernels/linux-2.6.31.1-cavm1/drivers/mtd/maps/xxxxx-flash.c 

        /* MTD partitions: From CNW5602 32MB
         * mtd0: 0x000C0000 00020000 "bootloader"
         * mtd1: 0x00040000 00020000 "factory_config"
         * mtd2: 0x00100000 00020000 "sysconfig"
         * mtd3: 0x00DE0000 00020000 "kernel_and_fs"
         * mtd4: 0x00020000 00020000 "bootloader_env"
         * mtd5: 0x00DE0000 00020000 "kernel_and_fs_backup"
        * mtd6: 0x001E0000 00020000 "syslog"
        * mtd7: 0x00020000 00020000 "transconfig"
        * mtd8: 0x00020000 00020000 "factoryconfig"
*/
static struct mtd_partition xxx_flash_partitions[] = {
{
.name = "bootloader", /* u-boot 6 sector (768KB), 0x20000-0xC0000: Reserved Space */
.size = 0x000C0000, /* 0x00000000 .. 0x000BFFFF */
.offset = 0,
.mask_flags = MTD_WRITEABLE, /* force read-only */
}, {
.name = "factory_config", /* Static Configuration from factory, (256KB = 128KB used + 128KB reserved) */
.size = 0x00040000, /* 0x000C0000 .. 0x000FFFFF */
.offset = MTDPART_OFS_APPEND,
.mask_flags = MTD_WRITEABLE, /* force read-only */
}, {
.name = "sysconfig", /* sysconfig 8 sector (1024KB) */
.size = 0x00100000, /* 0x00100000 .. 0x001FFFFF */
.offset = MTDPART_OFS_APPEND,
}, {
.name = "kernel_and_fs", /* Linux Kernel and File System (bootpImage) (14208KB) */
.size = 0x00DE0000, /* 0x00200000 .. 0x00FDFFFF */
.offset = MTDPART_OFS_APPEND,
}, {
.name = "bootloader_env", /* bottom 1 sector (128KB) for u-boot env variables */
.size = 0x00020000, /* 0x00FE0000 .. 0x00FFFFFF */
.offset = MTDPART_OFS_APPEND,
}, {
.name = "kernel_and_fs_backup", /* Linux Kernel and File System (bootpImage) (14208KB) */
.size = 0x00DE0000, /* 0x01000000 .. 0x01DDFFFF */
.offset = MTDPART_OFS_APPEND,
}, {
.name = "syslog", /* syslog 15 sector (1920KB) */
.size = 0x001E0000, /* 0x01DE0000 .. 0x01FBFFFF */
.offset = MTDPART_OFS_APPEND,
}, {
.name = "transconfig", /* transconfig 1 sector (128KB) */
.size = 0x00020000, /* 0x01FC0000 .. 0x01FDFFFF */
.offset = MTDPART_OFS_APPEND,
}, {
.name = "factoryconfig", /* factoryconfig 1 sector (128KB) */
.size = MTDPART_SIZ_FULL, /* 0x01FE0000 .. 0x01FFFFFF */ /* MTDPART_SIZ_FULL= 0x00020000 */
.offset = MTDPART_OFS_APPEND,
}
};
2.在應用層讀寫open("/dev/mtd3", O_RDWR);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章