atheros: update script to get the mac from the device tree
https://jira.digi.com/browse/DEL-637 Signed-off-by: Javier Viguera <javier.viguera@digi.com>
This commit is contained in:
parent
255b409288
commit
735e36ce8e
|
|
@ -20,27 +20,20 @@ set -e
|
||||||
[ "${IFACE}" != "wlan0" ] && exit 0
|
[ "${IFACE}" != "wlan0" ] && exit 0
|
||||||
|
|
||||||
FIRMWARE_DIR="/lib/firmware/ath6k/AR6003/hw2.1.1"
|
FIRMWARE_DIR="/lib/firmware/ath6k/AR6003/hw2.1.1"
|
||||||
RAM_DRIVE="/var/run"
|
|
||||||
MAC_FILENAME="softmac"
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Get the wlan MAC address from kernel command line. Use a default
|
# Get the wlan MAC address from kernel command line. Use a default
|
||||||
# value if the address has not been set.
|
# value if the address has not been set.
|
||||||
#
|
#
|
||||||
MAC_ADDR="$(sed -ne 's,.\+ethaddr2=\([^[:blank:]]\+\)[[:blank:]].*,\1,g;T;p' /proc/cmdline)"
|
if [ -f "/proc/device-tree/wireless/mac-address" ]; then
|
||||||
|
MAC_ADDR="$(hexdump -ve '1/1 "%02X" ":"' /proc/device-tree/wireless/mac-address | sed 's/:$//g')"
|
||||||
|
else
|
||||||
|
MAC_ADDR="$(sed -ne 's,^.*ethaddr2=\([^[:blank:]]\+\)[:blank:]*.*,\1,g;T;p' /proc/cmdline)"
|
||||||
|
fi
|
||||||
if [ -z "${MAC_ADDR}" -o "${MAC_ADDR}" = "00:00:00:00:00:00" ]; then
|
if [ -z "${MAC_ADDR}" -o "${MAC_ADDR}" = "00:00:00:00:00:00" ]; then
|
||||||
MAC_ADDR="00:04:F3:4C:B1:D3"
|
MAC_ADDR="00:04:F3:4C:B1:D3"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mac1="$(echo ${MAC_ADDR} | cut -d':' -f1)"
|
|
||||||
mac2="$(echo ${MAC_ADDR} | cut -d':' -f2)"
|
|
||||||
mac3="$(echo ${MAC_ADDR} | cut -d':' -f3)"
|
|
||||||
mac4="$(echo ${MAC_ADDR} | cut -d':' -f4)"
|
|
||||||
mac5="$(echo ${MAC_ADDR} | cut -d':' -f5)"
|
|
||||||
mac6="$(echo ${MAC_ADDR} | cut -d':' -f6)"
|
|
||||||
|
|
||||||
printf "\x${mac1}\x${mac2}\x${mac3}\x${mac4}\x${mac5}\x${mac6}" > ${RAM_DRIVE}/${MAC_FILENAME}
|
|
||||||
|
|
||||||
# We need to write the WLAN MAC address to softmac in the ath6k firmware
|
# We need to write the WLAN MAC address to softmac in the ath6k firmware
|
||||||
# directory. However, we don't want to rewrite the file if it already exists
|
# directory. However, we don't want to rewrite the file if it already exists
|
||||||
# and the address is the same because we don't want to wear out NAND flash.
|
# and the address is the same because we don't want to wear out NAND flash.
|
||||||
|
|
@ -48,10 +41,19 @@ printf "\x${mac1}\x${mac2}\x${mac3}\x${mac4}\x${mac5}\x${mac6}" > ${RAM_DRIVE}/$
|
||||||
# So create the file on the RAM DRIVE first and compare the two. Only update
|
# So create the file on the RAM DRIVE first and compare the two. Only update
|
||||||
# the copy on NAND if the address has changed.
|
# the copy on NAND if the address has changed.
|
||||||
#
|
#
|
||||||
if ! cmp -s ${RAM_DRIVE}/${MAC_FILENAME} ${FIRMWARE_DIR}/${MAC_FILENAME}; then
|
mac1="$(echo ${MAC_ADDR} | cut -d':' -f1)"
|
||||||
cp ${RAM_DRIVE}/${MAC_FILENAME} ${FIRMWARE_DIR}/${MAC_FILENAME}
|
mac2="$(echo ${MAC_ADDR} | cut -d':' -f2)"
|
||||||
|
mac3="$(echo ${MAC_ADDR} | cut -d':' -f3)"
|
||||||
|
mac4="$(echo ${MAC_ADDR} | cut -d':' -f4)"
|
||||||
|
mac5="$(echo ${MAC_ADDR} | cut -d':' -f5)"
|
||||||
|
mac6="$(echo ${MAC_ADDR} | cut -d':' -f6)"
|
||||||
|
|
||||||
|
TMP_MACFILE="$(mktemp -t softmac.XXXXXX)"
|
||||||
|
printf "\x${mac1}\x${mac2}\x${mac3}\x${mac4}\x${mac5}\x${mac6}" > ${TMP_MACFILE}
|
||||||
|
if ! cmp -s ${TMP_MACFILE} ${FIRMWARE_DIR}/softmac; then
|
||||||
|
cp ${TMP_MACFILE} ${FIRMWARE_DIR}/softmac
|
||||||
fi
|
fi
|
||||||
rm -f ${RAM_DRIVE}/${MAC_FILENAME}
|
rm -f ${TMP_MACFILE}
|
||||||
|
|
||||||
# Figure out which wireless region we are in. The US has rules for
|
# Figure out which wireless region we are in. The US has rules for
|
||||||
# what channels can be used and at what power level. We use a different set of
|
# what channels can be used and at what power level. We use a different set of
|
||||||
|
|
@ -59,13 +61,10 @@ rm -f ${RAM_DRIVE}/${MAC_FILENAME}
|
||||||
# in OTP will be set to 0x0 for the US. Once we know the region, make sure the
|
# in OTP will be set to 0x0 for the US. Once we know the region, make sure the
|
||||||
# appropriate calibration file is loaded.
|
# appropriate calibration file is loaded.
|
||||||
#
|
#
|
||||||
if [ -e "/sys/kernel/machine/name" ]; then
|
MACHINE="$(cat /proc/device-tree/digi,machine,name 2>/dev/null || \
|
||||||
MACHINE="$(cat /sys/kernel/machine/name)"
|
cat /sys/kernel/machine/name)"
|
||||||
REGION_CODE="$(cat /sys/kernel/${MACHINE}/mod_cert)"
|
REGION_CODE="$(cat /proc/device-tree/digi,hwid,cert 2>/dev/null || \
|
||||||
elif [ -e "/proc/device-tree/digi,hwid,cert" ]; then
|
cat /sys/kernel/${MACHINE}/mod_cert)"
|
||||||
REGION_CODE="$(cat /proc/device-tree/digi,hwid,cert)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
US_CODE="0x0"
|
US_CODE="0x0"
|
||||||
BDATA_SOURCE="Digi_6203-6233-World.bin"
|
BDATA_SOURCE="Digi_6203-6233-World.bin"
|
||||||
if [ -n "${REGION_CODE}" -a "${US_CODE}" = "${REGION_CODE}" ]; then
|
if [ -n "${REGION_CODE}" -a "${US_CODE}" = "${REGION_CODE}" ]; then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue