10.2.3. 参数配置

首先需要搭建好基本的网络环境(使用网口或在C3模块)

10.2.3.1. RTOS配置

使能 OTA 相关配置,自动使能了 ENV 相关配置

在 工程 根目录下执行 scons –menuconfig,进入menuconfig的功能配置界面,按如下选择:

Local packages options  --->
    Third-party packages options  --->
        [*] ota_downloader: The firmware downloader which using on RT-Thread OTA component  --->
            [ ]   Enable HTTP/HTTPS OTA
            [ ]   Enable Ymodem OTA
            [*]   Enable Uart OTA
            Version (latest)  --->

    ZX packages options  --->
        [*] aic-env  --->
            -*-   Enable ENV interface and CMD
            [*]     Enable redundant environment support
            (env)   Env part name
            (env_r) Env redundant part name
            (4096)  Environment Size
            [ ]     Enable ENV debug
            -*-   Enable A/B system support
        [*] aic-ota  --->
            [ ]   Enable OTA downloader debug
            [*]   Enable OTA interface

备注

为了方便配置, 使能 AIC_OTA_INTERFACE 后, 会自动选上 AIC_ENV_INTERFACE , AIC_AB_SYSTEM_INTERFACE

10.2.3.2. Boot 配置

使能 ENV 相关配置

在 工程 根目录下执行 scons –menuconfig,进入menuconfig的功能配置界面,按如下选择:

Local packages options  --->
    ZX packages options  --->
        [*]   Enable ENV interface and CMD
        [*]     Enable redundant environment support
        (env)   Env part name
        (env_r) Env redundant part name
        (4096)  Environment Size
        [ ]     Enable ENV debug
        [*]   Enable A/B system support in bootloader

10.2.3.3. application 配置

开启 AIC_AB_SYSTEM_INTERFACE 后,在对应app demo下,需在main.c中手动添加挂载代码

int main(void)
{
#ifdef AIC_AB_SYSTEM_INTERFACE
    char target[32] = { 0 };
    enum boot_device boot_dev = aic_get_boot_device();

    if (boot_dev != BD_SDMC0) {

        aic_ota_status_update();
        aic_get_rodata_to_mount(target);
        printf("Mount APP in blk %s\n", target);

        if (dfs_mount(target, "/rodata", "elm", 0, 0) < 0)
            printf("Failed to mount elm\n");

        memset(target, 0, sizeof(target));

        aic_get_data_to_mount(target);
        printf("Mount APP in blk %s\n", target);

        if (dfs_mount(target, "/data", "elm", 0, 0) < 0)
            printf("Failed to mount elm\n");
    }
#endif
    return 0;
}

10.2.3.4. 配置说明

ZX OTA 采用A/B 系统方案,需要配置双系统分区,即在对应工程配置的 image_cfg.json 文件中配置分区表(以M4为例)

{
    "spi-nand": { // Device, The name should be the same with string in image:info:media:type
        "size": "128m", // Size of SPI NAND
        "partitions": {
            "spl": { "size": "1m" },
            "env":      { "size": "256k" },
            "env_r":    { "size": "256k" },
            "os":  { "size": "4m" },
            "os_r":  { "size": "4m" },
            "rodata":  { "size": "8m" },
            "rodata_r":  { "size": "8m" },
            "data": {
                "size": "15m",
                "nftl": { // Volume in NFTL device
                    "data": { "size": "-" },
                },
            },
            "data_r": {
                "size": "15m",
                "nftl": { // Volume in NFTL device
                    "data": { "size": "-" },
                }
            },
        },
    },
    "image": {
        "info": { // Header information about image
            "platform": "m4",
            "product": "ZX7D0N",
            "version": "1.0.0",
            "media": {
                "type": "spi-nand",
                "device_id": 0,
                "array_organization": [
                    { "page": "2k", "block": "128k", "oob": "64" },
            //        { "page": "4k", "block": "256k", "oob": "128" },
                ],
            }
        },
        "updater": { // Image writer which is downloaded to RAM by USB
            "ddr": {
                "file": "usbupg-ddr-init.aic",
                "attr": ["required", "run"],
                "ram": "0x00103000"
            },
            "spl": {
                "file": "bootloader.aic",
                "attr": ["required", "run"],
                "ram": "0x41000000"
            },
        },
        "target": { // Image components which will be burn to device's partitions
            "spl": {
                "file": "bootloader.aic",
                "attr": ["mtd", "required"],
                "part": ["spl"]
            },
            "env": {
                "file": "env.bin",
                "attr": ["mtd", "optional"],
                "part": ["env","env_r"]
            },
            "os": {
                "file": "m4_os.itb",
                "attr": ["mtd", "required"],
                "part": ["os"]
            },
            "rodata": {
                "file": "rodata.fatfs",
                "attr": ["mtd", "optional"],
                "part": ["rodata"]
            },
            "data": {
                "file": "data.fatfs",
                "attr": ["block", "optional"],
                "part": ["data"]
            },
        },
    },
    "temporary": { // Pre-proccess to generate image components from raw data
        "aicboot": {
            "usbupg-ddr-init.aic": { // No loader, only PreBootProgram to initialize DDR
                "head_ver": "0x00010001",
                "resource": {
                    "private": "ddr_init.bin",
                    "pbp": "m4.pbp",
                },
            },
            "bootloader.aic": {
                "head_ver": "0x00010001",
                "loader": {
                    "file": "bootloader.bin",
                    "load address": "0x42000000",
                    "entry point":  "0x42000100",
                },
                "resource": {
                    "private": "ddr_init.bin",
                    "pbp": "m4.pbp",
                },
            },
        },
        "uboot_env": {
            "env.bin": {
                "file": "env.txt",
                "size": "4096",
                "redundant": "enable",
            },
        },
        "itb": {
            "m4_os.itb": {
                "its": "m4_os.its"
            },
        },
    },
}

具体说明请参考: 设计说明