大破雑記帳

個人用メモな雑記ブログ いろんなことをざっくりと。

OpenWrtデュアルブート思案メモ

u-boot-envとかfixedなどのNVMEMから特定keyの値を取得し、DeviceTreeで指定された値と照合して、一致する場合はそのパーティションのmtdsplit他によるkernel + rootfs取り出しを実行させるやつ

NVMEMのu-boot-envドライバのprobeが走るのはspi-norのmtdパース後であり、firmware*パーティションのcompatibleからparserかmtdsplit探して走らせる際には利用できない
あるいはfirmware*の後にあるパーティションにインデックス情報が格納されている場合は、上記同様にfirmware*のkernel + rootfs取り出しに間に合わない

結果、spi-norのmtdのprobeが終わった後、u-boot-envなりfirmware*後方パーティションがprobeされた後に、新たにmtdデバイスを追加する形を採る必要がある

/ {
    boot-partition {
        compatible = "openwrt,bootpart-selector";

        nvmem-cells = <&ubootenv_bootpartition>;
        nvmem-cell-names = "bootname";

        openwrt,bootparts = <&firmware1>, <&firmware2>;
        openwrt,bootname = "1","2";

        /* または
        nvmem-cells = <&fwinfo_bootindex>;
        nvmem-cell-names = "bootindex";

        openwrt,bootparts = <&firmware1>, <&firmware2>;
        openwrt,bootname = <1>, <2>;
        */

        /* 新規に作成するmtdデバイスにバインド, parentは元のfirmware*か? */
        partition {
            compatible = "denx,uimage";
            label = "bootpart";
        };
    };
};


partitions {
    compatible = "fixed-partitions";

    partition@30000 {
        compatible = "denx,u-boot-env";
        reg = <0x30000 0x10000>;
        label = "u-boot-env";
        read-only;

        ubootenv_bootpartition: bootpartition {
        };
    };

    partition@40000 {
        reg = <0x40000 0x10000>;
        label = "fwinfo";
        read-only;

        nvmem-layout {
            compatible = "fixed-layout";
            #address-cells = <1>;
            #size-cells = <1>;

            fwinfo_bootindex: bootindex@4 {
                reg = <0x4 0x1>;
            };
        };
    };

    firmware1: partition@50000 {
        reg = <0x50000 0xd00000>;
        label = "firmware";
    };

    firmware2: partition@d50000 {
        reg = <0xd50000 0xd00000>;
        label = "firmware2";
    };
};