目标:

  • 将多个组件(内核、DTB、ramdisk、资源文件等)打包成一个镜像文件。让uboot能快速启动内核。

注意点:

  • 128M RAM:0x0800 0000

  • uboot需要将boot.img镜像放到ddr中某个位置

mtd read 0x02000000 0x04400000 0x800000
  • 从nand的0x04400000位置读取0x800000(8M)数据到ddr的0x02000000

  • 内核load = <0x03000000>; 尽量不和boot.img在ddr的8M地址冲突

  • 内核启动之后,会释放uboot占用的ddr,boot.img占用的ddr也释放,uboot通过FIT加载的设备树的ddr也会释放,除了内核不会被释放(0x03000000开始的部分)

1. 创建boot.its文件

/dts-v1/;
/ {
    description = "RV1106 NAND boot image";
    #address-cells = <1>;

    images {
        kernel@1 {
            data = /incbin/("zImage");
            type = "kernel";
            arch = "arm";
            os = "linux";
            compression = "none";
            load = <0x03000000>; // 告诉uboot将内核放到ddr的0x03000000
            entry = <0x03000000>; 
        };
        fdt@1 {
            data = /incbin/("rv1106g-evb1-v11-spi-nand-cvr.dtb");
            type = "flat_dt";
            arch = "arm";
            compression = "none";
            // load = <0x02800000>; 不分配地址,让uboot自己分配
        };
		/*
		resource@1 {
            data = /incbin/("resource.img");
            type = "firmware";
            arch = "arm";
            compression = "none";
            load = <0x06000000>;
        };
		*/
    };

    configurations {
        default = "conf@1";
        conf@1 {
            kernel = "kernel@1";
            fdt = "fdt@1";
			//loadables = "resource@1";
        };
    };
};

2. **生成FIT格式的数据

../uboot/tools/mkimage -f ./boot.its ./boot.img

3. 如果用到resource,需要修改设备树

rv1106g-evb1-v11-spi-nand-cvr.dts

/ {
    reserved-memory {
        #address-cells = <1>;
        #size-cells = <1>;
        ranges;

        /* 假设 resources.img 大小为 8MB */
        resource: resource@0x3f800000 {
            compatible = "rockchip,resource";
            reg = <0x3f800000 0x800000>; /* 从 1016MB 处开始,预留 8MB */
            no-map;
        };
    };
};