So I am trying to port OpenWRT to my router (Ruijie RG-EW1200G PRO). It stores it's own mac address from partition called product_info
, and it is storred in a weird way. My other router is storring it's own mac addresses in a binary form, while ruijie's one is storing ONE mac address in text and it calculates others simply by adding 1 to original mac. How can I assign those macs in DTS?
Here is the dump of my product_info
partition: https://pastebin.com/0RsmDbe0
frollic
February 14, 2024, 12:15pm
2
look (for instance) at the DTS for DIR-2660 https://git.openwrt.org/?p=openwrt/openwrt.git;a=commit;h=b5dd746cbb1aaf91f4b68e9f3eda97413550d904
&wifi0 {
mtd-mac-address = <&factory 0xe000>;
mtd-mac-address-increment = <1>;
};
&wifi1 {
mtd-mac-address = <&factory 0xe000>;
mtd-mac-address-increment = <2>;
};
Since it’s stored in a list of variables, you can’t AFAIK do it in the DTS since the MAC address isn’t at a fixed offset.
Instead, you can use the 02_network file to obtain the value of the variable. In your case:
label_mac=$(mtd_get_mac_ascii product_info ethaddr)
Look for 02_network files under different targets for more examples.
So I added lines into /etc/board.d/02_network into both functions:
ramips_setup_interfaces()
{
...
ruijie,rg-ew1200g_pro|\
...
}
...
ramips_setup_macs()
{
ruijie,rg-ew1200g_pro)
label_mac=$(mtd_get_mac_ascii product_info ethaddr)
;;
...
}
It still generates random mac but folowing lines appeared in bootlog:
ip: SIOCGIFFLAGS: No such device
ip: can't find device 'lan'
sendto(): Network unreachable
sendto(): Network unreachable
ip: can't find device 'lan'
ip: SIOCGIFFLAGS: No such device
In case of what, I defined ports in DTS like that:
&switch0 {
ports {
wan: port@0 {
status = "okay";
label = "wan";
};
port@1 {
status = "okay";
label = "lan3";
};
port@2 {
status = "okay";
label = "lan2";
};
port@3 {
status = "okay";
label = "lan1";
};
};
};
What I am still doing wrong?
You’re obtaining the MAC address but not setting it.
Take a look at https://github.com/openwrt/openwrt/blob/main/target/linux/ipq40xx/base-files/etc/board.d/02_network
Can’t speak for the other issue(s) you may have though.
system
Closed
February 24, 2024, 7:00pm
7
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.