Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ramips: fix Xiaomi MiWiFi Mini board switch port define #2497

Closed

Conversation

ui-patrick-chen
Copy link
Contributor

Fix Xiaomi MiWiFi Mini LAN port define :

LAN speed: 100M
LAN ports: 2
WAN speed: 100M
WAN ports: 1

current setting is 1 WAN/ 4 LAN port, so fix it.

@adschm
Copy link
Member

adschm commented Oct 16, 2019

Hi, please shorten your commit title and add a commit description.
I should be fine if you just use for the commit what you did for the PR (title and first comment...). Keep the Signed-off of course.

Despite, since you own this device, can you check whether it has a valid MAC address in factory 0x2e?

. /lib/functions.sh
. /lib/functions/system.sh
mtd_get_mac_binary factory 0x2e

(Using 0x28 instead of 0x2e will return the MAC address currently used for ethernet).

@ui-patrick-chen
Copy link
Contributor Author

Hi @adrianschmutzler ,
I fixed the commit title and description, check it please.

I bought my device in Taiwan, not sure same setting in all markets.
Address 0x2e show 00:d0:59:XX:XX:XX (I think this is a Foxconn manufature OUI and MAC address)
Address 0x28 show my br-lan MAC address in OpenWRT.

@adschm
Copy link
Member

adschm commented Oct 16, 2019

Hi, thanks for the update.
To be grammatically correct, you should change "define" to "definition" in the commit title. If the title becomes to long then, remove the word "board".
Despite, the first word after "ramips:" should start with a lower-case letter.

I had another look at the content:
"0:lan:2" "1:lan:1"

This will label internal port 0 with "2" and internal port 1 with "1" in GUI. You did not explicitly comment about it, so I just want to make sure you do this on intention.

Concerning the MAC addresses:
https://github.com/openwrt/openwrt/blob/3ddcddd0e0dc1afcba28f1b2d02eb2854b51e337/target/linux/ramips/base-files/etc/board.d/02_network#L724-L726

At the moment, the address at 0x28 is set to eth0, and is inherited for WAN.
For br-lan, you should get the address with local bit set. Since this is odd, I justed wanted to exploit the opportunity to check whether another MAC can be used instead the local bit.
However, your response looks like I do not have reason to touch that until someone really verifies with stock firmware.

@kofec
Copy link

kofec commented Oct 16, 2019

I will check when back home. @changeway You have mac on label on case e.g:
http://i.imgur.com/kt9jCSE.jpg

@kofec
Copy link

kofec commented Oct 16, 2019

In my case (xiaomi mini) the correct address is on 0x28:

mtd_get_mac_binary factory 0x28
f0:b4:29:XX:XX:XX

and this addess is assign to eth0
and the same address in on label on case

@adschm
Copy link
Member

adschm commented Oct 16, 2019

@kofec
So, wan/eth0.2 should be the same as eth0, but br-lan/eth0.1 should be f2:b4:29:XX:XX:XX then.

I just think that this local bit is uncommon, so I was curious whether a wan MAC address was there.
Since this is not the case, maybe the local bit is correct and was actually there in vendor firmware.

@adschm
Copy link
Member

adschm commented Oct 16, 2019

@kofec Thanks for confirming the label MAC address. It's already in the DTS, as I originally took it from Gluon's list, but a real check is always better.

@changeway Thanks for checking the address and for allowing me to hijack this PR for the discussion.

Based on OpenWRT Table of Hardware > Xiaomi > Xiaomi Mi WiFi Mini

Switch Ports Defaults:
0, 1: LAN
4: WAN
6: CPU

Port in Web GUI (word printed on bottom of case)
WAN(Internet) map to switch port 4
LAN1(.) map to switch port 1
LAN2(..) map to switch port 0
CPU map to switch port 6

current setting is 1 WAN/ 4 LAN port, fix it.

Signed-off-by: Chih-Wei Chen <changeway@gmail.com>
@ui-patrick-chen
Copy link
Contributor Author

Hi @adrianschmutzler commit description updated, review it please.

I connected the MiWiFi Mini from home to office remotely.
I'm in office so that I am able to check the label on case.

The br-lan MAC address is match the MAC address show on the label.

For the MAC address, I use hexdump to check on "Factory" partition.

I had another old board with stock firmware :

root@XiaoQiang:/# cat /proc/mtd
dev: size erasesize name
mtd0: 01000000 00010000 "ALL"
mtd1: 00030000 00010000 "Bootloader"
mtd2: 00010000 00010000 "Config"
mtd3: 00010000 00010000 "Factory"
mtd4: 00c80000 00010000 "OS1"
mtd5: 00b2ccdc 00010000 "rootfs"
mtd6: 00200000 00010000 "OS2"
mtd7: 00100000 00010000 "overlay"
mtd8: 00010000 00010000 "crash"
mtd9: 00020000 00010000 "reserved"
mtd10: 00fb0000 00010000 "firmware"

root@XiaoQiang:/# hexdump -C /dev/mtd3ro
00000000 20 76 05 01 10 48 b1 09 b6 f0 ff ff ff ff ff ff | v...H..........|
00000010 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000020 ff ff ff ff ff ff ff ff 00 d0 59 60 00 03 00 d0 |..........Y....| 00000030 59 60 00 04 22 0c 04 04 ff ff 15 01 55 77 a8 aa |Y..".......Uw..|
00000040 8c 88 ff ff 0d 00 00 00 00 00 00 00 00 00 ff ff |................|
00000050 ff ff 11 11 11 11 11 11 11 11 11 12 12 12 13 13 |................|
00000060 16 16 16 16 16 16 17 17 17 17 17 17 18 18 80 ff |................|
00000070 ff ff 80 ff ff ff 00 f4 ff ff ff ff ff ff ff ff |................|
00000080 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|

00008000 62 76 00 00 10 48 b1 e5 bb a0 62 76 c3 14 00 00 |bv...H....bv....|
00008010 00 00 62 76 c3 14 00 00 00 00 ff ff ff ff ff ff |..bv............|
00008020 ff ff 37 d8 9d 00 60 7f fd 9b ff ff ff ff ff ff |..7...`.........|
00008030 ff ff ff ff 22 ff 00 20 ff ff b7 01 00 00 00 00 |....".. ........|
00008040 00 00 ff df 00 00 00 00 00 00 00 00 00 00 e0 01 |................|
00008050 00 00 00 00 00 00 84 0a 1a 00 00 00 83 0b 1a 00 |................|
00008060 00 00 7a 06 20 00 00 7a 06 22 80 80 78 08 22 80 |..z. ..z."..x.".|
00008070 80 7e 02 22 c1 c1 76 16 22 c2 c2 75 1c 22 c2 c1 |.~."..v."..u."..|
00008080 79 0a 21 00 00 79 0a 21 80 80 7b 06 21 80 80 77 |y.!..y.!..{.!..w|

root@XiaoQiang:/# ifconfig
br-lan Link encap:Ethernet HWaddr 00:D0:59:60:00:03
inet addr:192.168.31.1 Bcast:192.168.31.255 Mask:255.255.255.0
inet6 addr: fe80::2d0:59ff:fe60:3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:368 (368.0 B)

wl0 Link encap:Ethernet HWaddr 10:48:B1:E5:BB:A0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:13

wl1 Link encap:Ethernet HWaddr 10:48:B1:09:B6:F0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:4

I think the MAC address is saved in the factory partition

MAC address on label is MT7620 setting at address 0x0028
wl1 interface MAC address, WiFi 2.4G by MT7620 at address 0x0004

wl0 interface MAC address, WiFi 5G by MT7612 at address 0x8004

@adschm
Copy link
Member

adschm commented Oct 17, 2019

Thanks for clarifying the commit message.

From your hexdump, I actually find a valid-looking address also in 0x2e:
0x28: 00 d0 59 60 00 03 (used for br-lan)
0x2e: 00 d0 59 60 00 04

So, can you check which address is actually used for the WAN on the stock firmware?

@hauke hauke added the target/ramips pull request/issue for ramips target label Oct 19, 2019
@ui-patrick-chen
Copy link
Contributor Author

I setup a switch with mirror port function.

The WAN use the same MAC address : 00 d0 59 60 00 03
https://imgur.com/IKIo79e

In the Web-UI only show one MAC address
https://imgur.com/PebuiAC

Xiaomi MiWiFi Mini use the same MAC address for WAN and LAN on the stock firmware.
This is also the only one MAC address seen on label.

@adschm
Copy link
Member

adschm commented Oct 21, 2019

@changeway
Thanks for the extensive testing. I've sent a patch for the MAC topic to the mailing list:
https://patchwork.ozlabs.org/patch/1180603/

For reviewer:
The patch of this PR is small and should be ready for merge.

jow- pushed a commit that referenced this pull request Oct 22, 2019
Based on stock firmware tests, both LAN and WAN ports use the
MAC address from 0x28 on factory partition.

In OpenWrt, this one is already set in DTS. This patch removes the
local bit set in 02_network previously, and adjusts LAN/WAN
addresses as on stock firmware.

Note that in tests we found a MAC address in 0x2e that is the one
in 0x28 plus 1. Since stock firmware does not use it though, we
do not use it either.

Thanks to Chih-Wei Chen for testing this on his device.

ref: #2497

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
jollaman999 pushed a commit to jollaman999/openwrt that referenced this pull request Oct 26, 2019
Based on stock firmware tests, both LAN and WAN ports use the
MAC address from 0x28 on factory partition.

In OpenWrt, this one is already set in DTS. This patch removes the
local bit set in 02_network previously, and adjusts LAN/WAN
addresses as on stock firmware.

Note that in tests we found a MAC address in 0x2e that is the one
in 0x28 plus 1. Since stock firmware does not use it though, we
do not use it either.

Thanks to Chih-Wei Chen for testing this on his device.

ref: openwrt/openwrt#2497

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
@adschm
Copy link
Member

adschm commented Oct 31, 2019

Thanks. Pulled into my staging tree, will merge this to master in the next days.

@adschm adschm closed this Oct 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
target/ramips pull request/issue for ramips target
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants