[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:
>>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
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"
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list