设计说明
OTA 策略描述文件:sw-description
OTA 升级包中, 需要包含 description 文件, 以及本次升级使用到的各个文件, 例如 Kernel, RootFS。 整个 OTA 升级包是 cpio 格式,
且要求 description 文件在第一个位置, 包名称要求以.swu 结尾才能被 SWUpdate 程序识别到。
sw-description 文件是 SWUpdate 官方规定的 OTA 策略描述文件, 具体语法可以参考 SWUpdate 官方文档, 使用 libconfig 格式。
Luban 为 eMMC SPINAND 提供了一个示例, 参考 sw-images.cfg, 默认指定路径如下:
${TARGET_BOARD_DIR}/swupdate/sw-description: sw-description
SPINAND sw-description 文件使用说明software =
{
/*版本号和描述符*/
version = "1.0.0.0";
description = "Firmware update for Luban Project";
stable = {
/*
* upgrade_recovery stage:
* Running in main system, and upgrade the "recovery" partition,
* then reboot to the new recovery system
* Step1: Download image and upgrade the "recovery" partition
* Step2: Setup bootenv "swu_entry, boot_partition, boot_os, swu_status"
* Step3: Reboot to the new recovery system to run "upgrade_kernel"
*/
/*
* 内层 entry, upgrade_recovery,
* 当调用 swupdate xxx -e stable,upgrade_recovery 时, 会匹配到这部分, 执行{}内的动作,
* 可以修改, 调用的时候传入匹配的字符串即可
*/
upgrade_recovery = {
images: (
{
filename = "recovery"; //烧录文件名称
device = "/dev/mtd8"; //对应设备节点
type = "flash"; //操作 mtd 分区
sha256 = "@recovery"; //自动获取对应镜像的 sha256 值
}
);
/*
* Some key env variables:
* swu_boardname: The selected board name. Here is "stable"
* swu_entry: The upgrade entry selection. Value can be
* "upgrade_recovery" and "upgrade_kernel"
* boot_os: SPL Falcon mode flag. Should be set to "no"
* during OTA
* swu_status: OTA status flag, Value can be "progress",
* "finish"
* swu_reboot: When this flag is set to "yes", the
* system will be reboot when all works done for current
* stage.
*/
/*
* image 处理完以后, 需要设置一些标志, 切换状态,
* swu_entry= upgrade_kernel, 下次升级 upgrade_kernel,
* boot_partition= recovery, 下次引导 recovery 里面的内核启动,
* boot_os= no, 临时关闭 Falcon 模式, 请查看后面注释信息,
* swu_status OTA 升级的状态, 备用, Luban 添加,
* swu_reboot=yes,升级 recovery 完成, 和外部脚本配合, 指示外部脚本做 reboot 动作
*/
bootenv: (
{
name = "swu_entry";
value = "upgrade_kernel";
},
{
name = "boot_partition";
value = "recovery";
},
{
name = "boot_os";
value = "no";
},
{
name = "swu_status";
value = "progress";
},
{
name = "swu_reboot";
value = "yes";
}
);
};
/*
* upgrade_kernel stage:
* Running in Recovery system, it will upgrade some key
* partitions, then reboot to main system.
* Step1: Download and upgrade partitons
* Step2: Setup ENV variables, and mark OTA "finish"
* Step3: Reboot to main system
*/
upgrade_kernel = {
images: (
{
filename = "logo";
device = "/dev/mtd5";
type = "flash";
sha256 = "@logo";
},
{
filename = "kernel";
device = "/dev/mtd6";
type = "flash";
sha256 = "@kernel";
},
{
filename = "rootfs";
volume = "rootfs"; //ubi 分区名称
installed-directly = true; //读取升级镜像使用流控方式, 不用先拷贝到本地 flash 上
sha256 = "@rootfs";
}
);
bootenv: (
{
name = "boot_partition";
value = "kernel";
},
{
name = "swu_param"; //情况环境变量
value = "";
},
{
name = "swu_boardname";
value = "";
},
{
name = "swu_entry";
value = "";
},
{
name = "swu_status";
value = "finish";
},
{
name = "swu_reboot";
value = "yes";
}
);
};
};
}
U-Boot 环境变量 partition 用来指导主系统和 Recovery 系统之间切换过程。
当 Boot 使能了 Falcon 功能, SPL 程序会直接引导内核启动, 不会执行 Boot 程序,
也就不会判断环境变量 partition 进行系统之间的切换, 因此需要通过设置 boot_os=no,
临时关闭 Falcon 功能。
eMMC sw-description 文件使用说明software =
{
version = "1.0.0.0";
description = "Firmware update for Luban Project";
stable = {
/*
* upgrade_recovery stage:
* Running in main system, and upgrade the "recovery" partition,
* then reboot to the new recovery system
* Step1: Download image and upgrade the "recovery" partition
* Step2: Setup bootenv "swu_entry, boot_partition, boot_os, swu_status"
* Step3: Reboot to the new recovery system to run "upgrade_kernel"
*/
upgrade_recovery = {
images: (
{
filename = "recovery";
device = "/dev/mmcblk0p10";
type = "raw"; //eMMC 存储介质
sha256 = "@recovery";
}
);
/*
* Some key env variables:
* swu_boardname: The selected board name. Here is "stable"
* swu_entry: The upgrade entry selection. Value can be
* "upgrade_recovery" and "upgrade_kernel"
* boot_os: SPL Falcon mode flag. Should be set to "no"
* during OTA
* swu_status: OTA status flag, Value can be "progress",
* "finish"
* swu_reboot: When this flag is set to "yes", the
* system will be reboot when all works done for current
* stage.
*/
bootenv: (
{
name = "swu_entry";
value = "upgrade_kernel";
},
{
name = "boot_partition";
value = "recovery";
},
{
name = "boot_os";
value = "no";
},
{
name = "swu_status";
value = "progress";
},
{
name = "swu_reboot";
value = "yes";
}
);
};
/*
* upgrade_recovery stage:
* Running in main system, and upgrade the "recovery" partition,
* then reboot to the new recovery system
* Step1: Download image and upgrade the "recovery" partition
* Step2: Setup bootenv "swu_entry, boot_partition, boot_os, swu_status"
* Step3: Reboot to the new recovery system to run "upgrade_kernel"
*/
upgrade_kernel = {
images: (
{
filename = "logo";
device = "/dev/mmcblk0p8";
type = "raw";
sha256 = "@logo";
},
{
filename = "kernel";
device = "/dev/mmcblk0p9";
type = "raw";
sha256 = "@kernel";
},
{
filename = "rootfs";
device = "/dev/mmcblk0p11";
type = "raw";
installed-directly = true; //使用流控方式
sha256 = "@rootfs";
}
);
bootenv: (
{
name = "boot_partition";
value = "kernel";
},
{
name = "swu_param";
value = "";
},
{
name = "swu_boardname";
value = "";
},
{
name = "swu_entry";
value = "";
},
{
name = "swu_status";
value = "finish";
},
{
name = "swu_reboot";
value = "yes";
}
);
};
};
}