Dual Image on EnGenius Designed ARM-based Product Families
I – Introduction
The bootloader does some low-level hardware initialization, such as processor, memory, ethernet, flash, PCI, UART, and so on. After setting system configurations, the bootloader loads the kernel and passes startup information including serial port speeds, clock rates, the table of partitions and other hardware configuration data.
When the kernel is loaded, it configures the hardware, allocates the memory, loads the drivers, inserts the modules, mounts the root filesystem, and runs the pre-init processes. The final step is spawning the init process, the first user space process. The three types on the ARM-based OpenWRT are NOR-only, NAND-only and NOR plus-NAND.
II – Procedure
I. NOR flash only
1. Bootloader : When the power on, the bootloader will check the dual image flag, “active_fw”
1.1. Append additional partitions to mtdparts : kernel_1 and rootfs_1
1.2. Load the target kernel to the memory
1.3. Assign a active root filesystem partition by setting the bootargs.
1.3.1. If “active_fw=0” => root=rootfs
1.3.2. If “active_fw=1” => root=rootfs_1
1.4. If boot kernel fail, swap active firmware partition
2. Kernel Space : parses the bootargs assigned by bootloader, and mount the root filesystem.
3. User space : when system upgrade
3.1. If “active_fw=1” =>
3.1.1. flash kernel and rootfs
3.1.2. set active_fw=0
3.1.3. reboot
3.2. If “active_fw=0” =>
3.2.1. flash kernel_1 and rootfs_1
3.2.2. set active_fw=0
3.2.3. reboot
II.. NAND flash only
The procedure is the same as ‘NOR flash only’.
III.. NOR + NAND
1. Bootloader : When the power on, the bootloader will check the dual image flag, “active_fw”
1.1. Append two NAND partitions named rootfs and fs2
1.1.1 If “active_fw=0” =>
The upper half of NAND is named rootfs and the another one is named fs2.
1.1.2 If “active_fw=1” =>
The upper half of NAND is named fs2 and the another one is named rootfs.
1.2. Load the target kernel to the memory
1.3. If boot kernel fail, swap active firmware partition
2. Kernel Space : Under the NOR+NAND structure, we always use the partition named rootfs as the root filesystem.
3. User space : when system upgrade
The procedure is the same as ‘NOR flash only’.
lll – Implement
MTD partitions: two equal parts for two firm-wares
II. Dual image flag: set a active firmware partition
III. System upgrade: Always upgrade the inactive firmware partition
IV. Auto recovery: If the uboot finds the boot fail from this firmware partition, active the another firmware partition.
A. NOR flash only
1. Create two firmware partitions
1.1. modify the nor-partition.xml to tell the bootloader the new partitions info
1.2. modify the sys_flash_map.mk to tell the kernel mtd partition table
2. Dual image flag
2.1. Modify board.c to add “active_fw” to uboot de-fault env
2.2. Modify the cmd_bootipq.c to swap the boot args(root= rootfs or root= rootfs_1).
3. System upgrade
3.1. check “active_fw” and flash the target firmware [email protected]
3.1.1. “active_fw=1” => flash kernel and rootfs
3.1.2. “active_fw=0” => flash kernel_1 and rootfs_1
4. Auto recovery
4.1. Modify the board.c to make sure the uboot catch-es the return value from the boot function
B. NAND flash only
The procedure is the same as ‘NOR flash only’.
C. NOR + NAND
1. Create two firmware partitions
1.1. Modify bootipq.c to add a partitions named fs2
1.2. Modify bootm.c to pass the atags partition info. to kernel
2. Dual image flag
2.1. add “active_fw” to uboot default env
3. System upgrade
3.1. check “active_fw” and flash the target firmware [email protected]
3.1.1. Flash the fs2 partition
4. Auto recovery
4.1. Modify the board.c to make sure the uboot catch-es the return value from the boot function