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

Yousong Zhou yszhou4tech at gmail.com
Mon Oct 12 08:03:39 EDT 2015

On 10 October 2015 at 22:04, 康 <kangxn at 163.com> wrote:
> At 2015-09-29 10:10:41, "Yousong Zhou" <yszhou4tech at gmail.com> wrote:
>>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.
>>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

Another patch to get phy macaddress like what
does for ralink,mtd-eeprom?

 [1] http://sprunge.us/eKMI
 [2] ramips:Add support for HiWiFi HC5761,

diff --git a/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 @@
 . /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"
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org

More information about the openwrt-devel mailing list