How do I compile openwrt to flash MT7603_EPAELNA_2T2R_V12.bin to eeprom_factory_0

I have a board using a MT7621 CPU with an external MT7603E WIFI chip.

The dts partition has an eeprom_factory_0 and eeprom_factory_8000, is it used to store the MT7603E calibration data?

I got MT7603_EPAELNA_2T2R_V12.bin file from the vendor, how do I compile openwrt to flash MT7603_EPAELNA_2T2R_V12.bin to eeprom_factory_0?

The dts content:

&spi0 {
        status = "okay";

        m25p80@0 {
                compatible = "jedec,spi-nor";
                reg = <0>;
                spi-max-frequency = <24000000>;

                partitions {
                        compatible = "fixed-partitions";
                        #address-cells = <1>;
                        #size-cells = <1>;
                        broken-flash-reset;

                        partition@0 {
                                label = "u-boot";
                                reg = <0x0 0x30000>;
                                read-only;
                        };

                        partition@30000 {
                                label = "u-boot-env";
                                reg = <0x30000 0x10000>;
                        };

                        factory: partition@40000 {
                                label = "factory";
                                reg = <0x40000 0x10000>;

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

                                eeprom_factory_0: eeprom@0 {
                                        reg = <0x0 0x4da8>;
                                };

                                eeprom_factory_8000: eeprom@8000 {
                                        reg = <0x8000 0x4da8>;
                                };

                                macaddr_factory_e000: macaddr@e000 {
                                        reg = <0xe000 0x6>;
                                };

                                macaddr_factory_e006: macaddr@e006 {
                                        reg = <0xe006 0x6>;
                                };
                        };

                        partition@50000 {
                                compatible = "denx,uimage";
                                label = "firmware";
                                reg = <0x50000 0>;
                        };
                };
        };
};

&pcie {
        status = "okay";
};

&pcie0 {
        wifi@0,0 {
                compatible = "mediatek,mt76";
                reg = <0x0000 0 0 0 0>;
                nvmem-cells = <&eeprom_factory_0>;
                nvmem-cell-names = "eeprom";
                ieee80211-freq-limit = <2400000 2500000>;
        };
};

&pcie1 {
        wifi@0,0 {
                compatible = "mediatek,mt76";
                reg = <0x0000 0 0 0 0>;
                nvmem-cells = <&eeprom_factory_8000>;
                nvmem-cell-names = "eeprom";
                ieee80211-freq-limit = <5000000 6000000>;
        };
};

Uhm, you just flash it!?
eeprom_factory_0 starts at 0x0 in your factory partition. The first 0x4da8 bytes you write to 0x0 in you factory partition end up in eeprom_factory_0

Also if you do it from OpenWrt itself, load mtd_rw module or modify the device tree to have that partition not marked as read-only.

Flush it in directly with the dd command line?

Like dd if=./eeprom.bin of=/dev/mtd2 bs=1

Is it possible to compile eeprom.bin directly into openwrt?

It is not possible to write to mtd devices with dd as these are not block devices. Use mtd utility instead.

While you're right, it's not marked as "read-only" in the DT posted above.

You could have just done a web search. Among the first results is this patch:
https://patchwork.kernel.org/project/linux-wireless/patch/YSWdoKIaVCqAU6nG@makrotopia.org/

So you can embed the EEPROM directly in the FDT (dts). You cannot load from file. See the source file for reference:

1 Like

Hi @andyboeh , What should I do if I want to embed the EEPROM directly into the FDT (dts)? Is there a reference for this?

I search whole openwrt, not found eeprom-data reference.

Reading through the links posted and/or the documentation would be a good start:

https://www.kernel.org/doc/Documentation/devicetree/bindings/net/wireless/mediatek%2Cmt76.yaml

Then you haven't searched hard enough - this is one of the results:

2 Likes

Thank you @andyboeh

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.