WISE-PaaS/OTA Agent(risc linux)

From ESS-WIKI
Revision as of 11:17, 4 November 2016 by Jin.xin (talk | contribs)
Jump to: navigation, search

Introduction

This document demonstrates how to support our ota-agent solution under your risc arm linux.

Requirement

  • The storage(sd card, Nand flash) capacity need greate than 4G. 8G is recommended

Note

We take our rsb4220 (TI am335x platform) for example. For other platform, it is similar

Architecture

In order to support rollback, we requires the device to have a certain partition layout. At least four different partitions are needed:

  • one boot partition, containing the U-Boot bootloader and its environment
  • two partitions for storing the root file system and kernel. The kernel image file, zImage, and any device tree binary should be stored in directory /boot
  • one for persistent data

One of the rootfs and kernel partitions will be marked as the active partition, from which the kernel and rootfs will be booted. The other, called the inactive partition, will be used by the update mechanism to write the updated image. After an update their roles are swapped.

The persistent data partition stores data that needs to be preserved through an update.For our rsb4220, the partition layout is as follow:

  • /dev/mmcblk0p1 containing the u-boot
  • /dev/mmcblk0p2 containing the Current System, or named the active partition
  • /dev/mmcblk0p3 before update, it is blank, it will be used by the update mechanism to write the updated image
  • /dev/mmcblk0p4 persistent data

RTENOTITLE

How to support

uboot modification

modify uboot to let it can switch the boot partition. take our rsb4220 for example:

  • modify file include/configs/am335x_rsb4220.h
define CONFIG_LINUX_OTA
  • modify file arch/arm/lib/board.c


void  board_set_boot_device()
{
    int dev = (*(int *)0XC1000000);
    char *part;
    unsigned int partindex;
    part = getenv("boot_part");
    printf("boot_part index %s\n", part);
    partindex = part ? simple_strtoul (part, NULL, 10) : 0;

    switch(dev) {
    case 0:
    /* booting from MMC0*/
    printf("booting from SD\n");
    setenv("mmcdev", "0");
#ifdef CONFIG_LINUX_OTA
    if(partindex == 0){
        setenv("mmcroot", "/dev/mmcblk0p2 rw");
        setenv("loaduimage","ext2load mmc ${mmcdev}:2 ${kloadaddr} /boot/${bootfile}");
    }
    else if(partindex == 1){
        setenv("mmcroot", "/dev/mmcblk0p3 rw");
        setenv("loaduimage","ext2load mmc ${mmcdev}:3 ${kloadaddr} /boot/${bootfile}");
    }
    else{
        printf("## error: invalid part index, using part A\n");
        setenv("mmcroot", "/dev/mmcblk0p2 rw");
        setenv("loaduimage","ext2load mmc ${mmcdev}:2 ${kloadaddr} /boot/${bootfile}");
    }
#else
    setenv("mmcroot", "/dev/mmcblk0p2 rw");
#endif
#endif
    break;
    }
}

make sd card script

modify-env-tools under linux

refer to