Edit online

烧录镜像配置文件

4 Dec 2024
Read time: 3 minute(s)

使用 mk_image.py 制作烧录镜像时,需要提供 image_cfg.json 镜像配置文件。

通过嵌套对象的方式,image_cfg.json 描述了一个待生成的镜像文件所包含的信息和数据,如下列代码所示,该描述文件分为以下部分:
  • 镜像烧录的目标设备描述,详情可查看分区表描述

  • 最终Image 文件描述,包括信息和内容排布,由 info 数据,updater 数据和 target 数据组成。

  • 中间文件描述,制作 image 的过程中需要生成和使用的临时文件。

{
    "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" },
            "os":  { "size": "2m" },
            "rodata":  { "size": "4m" },
            "data":  { "size": "28m" },
        },
    },
    "image": {
        "info": { // Header information about image
            "platform": "d21x",
            "product": "demo128_nand",
            "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"
            },
            "bootloader": {
                "file": "bootloader.aic",
                "attr": ["required", "run"],
                "ram": "0x41000000"
            },
        },
        "target": { // Image components which will be burn to device's partitions
            "bootloader": {
                "file": "bootloader.aic",
                "attr": ["mtd", "required"],
                "part": ["spl"]
            },
            "os": {
                "file": "os.aic",
                "attr": ["mtd", "required"],
                "part": ["os"]
            },
            "res": {
                "file": "app.fatfs",
                "attr": ["mtd", "optional"],
                "part": ["rodata"]
            },
            "app": {
                "file": "page_2k_block_128k_oob_64_data.uffs",
                "attr": ["uffs", "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": "d21x.pbp",
                },
            },
            "bootloader.aic": {
                "head_ver": "0x00010001",
                "loader": {
                    "file": "bootloader.bin",
                    "load address": "0x42000000",
                    "entry point":  "0x42000100",
                },
                "resource": {
                    "private": "ddr_init.bin",
                    "pbp": "d21x.pbp",
                },
            },
            "os.aic": {
                "head_ver": "0x00010001",
                "loader": {
                    "file": "d21x.bin",
                    "load address": "0x40000000",
                    "entry point":  "0x40000100",
                    "run in dram": "false",
                }
            },
        },
    },
}