diff mbox

[OpenWrt-Devel,v2,1/3] ramips: Add DTS files for HiWiFi HC5x61 models

Message ID CAECwjAhm=Nz0a_LTb619Zg5Ok04d1fw2WsPcBoEkhYTD-FOwMQ@mail.gmail.com
State Rejected
Headers show

Commit Message

Yousong Zhou Oct. 12, 2015, 12:03 p.m. UTC
On 10 October 2015 at 22:04, εΊ· <kangxn@163.com> wrote:
>
> At 2015-09-29 10:10:41, "Yousong Zhou" <yszhou4tech@gmail.com> wrote:
>>Hi,
>>
>>Previously this year, there were 2 attempts to add support for HC5661
>>and HC5761 to OpenWrt trunk [1,2].  I only had a HC5661 and it was
>>quite a while ago but the issues then should still remain.
>>
>>The first is about how MAC address is to be read.  The
>>"mtd-mac-address" DTS directives apparently won't work.  And if I
>>remember correctly simply reading and setting it for lan and wan also
>>has flaws that the WiFi interface still get the default hardcoded MAC
>>address by the driver.  The best way I can think of to workaround this
>>is to add a directive similar to what "mtd-mac-address" does for
>>binary-encoded MACs.
>>"target/linux/generic/patches-4.1/681-NET-add-of_get_mac_address_mtd.patch"
>>can work as a reference.
>
> Today I implemented the "mtd-mac-address-ascii" function, ethernet address
> works fine, but WiFi mac address remains the hardcoded one. It seems the
> driver read mac  from factory partition, and unfortunately all HiWiFi
> devices has the same mac in factory data...
>

I see and should have thought of that earlier...

I had the following patch (whitespace clean at [1]) in my local tree
at the time when I found mac addresses of those wifi interfaces were
not right.  Surely it's hacky and a cleaner approach has to be crafted
out.  The patch in link [2] tried to work around this by forging
together an eeprom file with correct mac address, still too hacky I
guess.

Another patch to get phy macaddress like what
package/kernel/mac80211/patches/605-rt2x00-load-eeprom-on-SoC-from-a-mtd-device-defines-.patch
does for ralink,mtd-eeprom?

 [1] http://sprunge.us/eKMI
 [2] ramips:Add support for HiWiFi HC5761,
https://lists.openwrt.org/pipermail/openwrt-devel/2015-April/032643.html

openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
diff mbox

Patch

diff --git a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
index e6241de..0d41e1f 100644
--- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
+++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
@@ -1,6 +1,9 @@ 
 #!/bin/sh
 . /lib/netifd/netifd-wireless.sh
 . /lib/netifd/hostapd.sh
+# Needed by mtd_get_mac_ascii
+. /lib/functions.sh
+. /lib/functions/system.sh

 init_wireless_driver "$@"

@@ -330,9 +333,18 @@  mac80211_generate_mac() {
     local phy="$1"
     local id="${macidx:-0}"

-    local ref="$(cat /sys/class/ieee80211/${phy}/macaddress)"
     local mask="$(cat /sys/class/ieee80211/${phy}/address_mask)"

+    local ref
+    case $(cat /tmp/sysinfo/board_name) in
+        hiwifi-hc5661)
+            ref=$(mtd_get_mac_ascii "bdinfo" "Vfac_mac ")
+            ;;
+        *)
+            ref="$(cat /sys/class/ieee80211/${phy}/macaddress)"
+            ;;
+    esac
+
     [ "$mask" = "00:00:00:00:00:00" ] && mask="ff:ff:ff:ff:ff:ff";
     local oIFS="$IFS"; IFS=":"; set -- $mask; IFS="$oIFS"
_______________________________________________