[OpenWrt-Devel] [PATCH v2 6/7] lantiq: set checksum when patching MAC address on ath10k

2019-09-22 Thread Adrian Schmutzler
One lantiq device uses ath10kcal_patch_mac, although all ath10k
eeproms have a checksum field and should use
ath10kcal_patch_mac_crc.
This might be because the field is not evaluated by the firmware at
the moment.

Nevertheless, this patch will use ath10kcal_patch_mac_crc for all
devices so the correct checksum is in place.

Signed-off-by: Adrian Schmutzler 

---

v2: New patch
---
 .../lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata 
b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
index 244635c6db..dbfd201193 100644
--- a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
+++ b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
@@ -11,7 +11,7 @@ case "$FIRMWARE" in
case $board in
bt,homehub-v5a)
caldata_extract_ubi "caldata" 0x5000 0x844
-   ath10kcal_patch_mac $(macaddr_add 
$(mtd_get_mac_binary_ubi caldata 0x110c) +3)
+   ath10kcal_patch_mac_crc $(macaddr_add 
$(mtd_get_mac_binary_ubi caldata 0x110c) +3)
;;
*)
caldata_die "board $board is not supported yet"
-- 
2.20.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v2 2/7] base-files: move xor() from caldata extraction to functions.sh

2019-09-22 Thread Adrian Schmutzler
The xor() function is defined in each of the caldata extraction
scripts for several targets. Move it to functions.sh to reduce
duplicate code.

Signed-off-by: Adrian Schmutzler 

---

v2: rebase
---
 package/base-files/files/lib/functions.sh  | 16 
 .../etc/hotplug.d/firmware/10-ath9k-eeprom | 15 ---
 .../etc/hotplug.d/firmware/11-ath10k-caldata   | 18 +-
 .../etc/hotplug.d/firmware/11-ath10k-caldata   | 17 +
 .../etc/hotplug.d/firmware/11-ath10k-caldata   | 17 +
 .../etc/hotplug.d/firmware/12-ath9k-eeprom | 16 
 6 files changed, 19 insertions(+), 80 deletions(-)

diff --git a/package/base-files/files/lib/functions.sh 
b/package/base-files/files/lib/functions.sh
index 860fc04510..81176431d1 100755
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -17,6 +17,22 @@ NO_EXPORT=1
 LOAD_STATE=1
 LIST_SEP=" "
 
+# xor multiple hex values of the same length
+xor() {
+   local val
+   local ret="0x$1"
+   local retlen=${#1}
+
+   shift
+   while [ -n "$1" ]; do
+   val="0x$1"
+   ret=$((ret ^ val))
+   shift
+   done
+
+   printf "%0${retlen}x" "$ret"
+}
+
 append() {
local var="$1"
local value="$2"
diff --git 
a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom 
b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
index 7911d0aa1e..0cdd783315 100644
--- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
+++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
@@ -42,21 +42,6 @@ ath9k_eeprom_extract_reverse() {
printf "%b" "$caldata" > /lib/firmware/$FIRMWARE
 }
 
-xor() {
-   local val
-   local ret="0x$1"
-   local retlen=${#1}
-
-   shift
-   while [ -n "$1" ]; do
-   val="0x$1"
-   ret=$((ret ^ val))
-   shift
-   done
-
-   printf "%0${retlen}x" "$ret"
-}
-
 ath9k_patch_fw_mac() {
local mac=$1
local mac_offset=$(($2))
diff --git 
a/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata 
b/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
index 446b729a2b..d34146121a 100644
--- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
+++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
@@ -1,23 +1,8 @@
 #!/bin/sh
 
+. /lib/functions.sh
 . /lib/functions/k2t.sh
 
-# xor multiple hex values of the same length
-xor() {
-   local val
-   local ret="0x$1"
-   local retlen=${#1}
-
-   shift
-   while [ -n "$1" ]; do
-   val="0x$1"
-   ret=$((ret ^ val))
-   shift
-   done
-
-   printf "%0${retlen}x" "$ret"
-}
-
 ath10kcal_die() {
echo "ath10cal: " "$*"
exit 1
@@ -79,7 +64,6 @@ ath10kcal_patch_mac_crc() {
 
 [ -e /lib/firmware/$FIRMWARE ] && exit 0
 
-. /lib/functions.sh
 . /lib/functions/system.sh
 
 board=$(board_name)
diff --git 
a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata 
b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
index be57646128..dfb0a0cf76 100644
--- a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
+++ b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
@@ -1,20 +1,6 @@
 #!/bin/sh
 
-# xor multiple hex values of the same length
-xor() {
-   local val
-   local ret="0x$1"
-   local retlen=${#1}
-
-   shift
-   while [ -n "$1" ]; do
-   val="0x$1"
-   ret=$((ret ^ val))
-   shift
-   done
-
-   printf "%0${retlen}x" "$ret"
-}
+. /lib/functions.sh
 
 ath10kcal_die() {
echo "ath10cal: " "$*"
@@ -88,7 +74,6 @@ ath10kcal_is_caldata_valid() {
 
 [ -e /lib/firmware/$FIRMWARE ] && exit 0
 
-. /lib/functions.sh
 . /lib/functions/system.sh
 
 board=$(board_name)
diff --git 
a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata 
b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
index bdc36070f2..c0fb1db16d 100644
--- a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
+++ b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
@@ -1,20 +1,6 @@
 #!/bin/sh
 
-# xor multiple hex values of the same length
-xor() {
-   local val
-   local ret="0x$1"
-   local retlen=${#1}
-
-   shift
-   while [ -n "$1" ]; do
-   val="0x$1"
-   ret=$((ret ^ val))
-   shift
-   done
-
-   printf "%0${retlen}x" "$ret"
-}
+. /lib/functions.sh
 
 ath10kcal_die() {
echo "ath10cal: " "$*"
@@ -71,7 +57,6 @@ ath10kcal_patch_mac_crc() {
 
 [ -e /lib/firmware/$FIRMWARE ] && exit 0
 
-. /lib/functions.sh
 . /lib/functions/system.sh
 
 board=$(board_name)
diff --git 
a/target/

[OpenWrt-Devel] [PATCH v2 7/7] lantiq: modify ath9k caldata extraction to reuse caldata.sh

2019-09-22 Thread Adrian Schmutzler
In lantiq, ath9k caldata extraction is implemented to work in two
alternate "modes", the standard one and another one with swapped
byte pairs.

This rearranges the functions so "standard" use is based on the
caldata.sh library, while only a single local function is required
for the special case.

Note that while the parameter for switching between normal and swab
is removed, the size of the caldata is added to the function calls
to stay consistent.

Signed-off-by: Adrian Schmutzler 

---

v2:
- Added this patch (previously separate [5/5] lantiq: modify ath9k caldata 
extraction to reuse caldata.sh)
- Made size in caldata_extract_swap a parameter to match other functions
---
 .../etc/hotplug.d/firmware/12-ath9k-eeprom| 62 +--
 1 file changed, 15 insertions(+), 47 deletions(-)

diff --git 
a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom 
b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom
index b5dba670b1..f3627c40ca 100644
--- a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom
+++ b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom
@@ -1,55 +1,23 @@
 #!/bin/sh
-# Based on ar71xx 10-ath9k-eeprom
 
 [ -e /lib/firmware/$FIRMWARE ] && exit 0
 
 . /lib/functions/caldata.sh
-. /lib/upgrade/nand.sh
 
-ath9k_eeprom_extract_raw() {
-   local source=$1
-   local offset=$(($2))
-   local swap=$3
-   local size=4096
-   local bs=1
-   local conv=
-
-   if [ $swap -gt 0 ]; then
-   bs=2
-   conv="conv=swab"
-   size=$((size / bs))
-   offset=$((offset / bs))
-   fi
-
-   dd if=$source of=/lib/firmware/$FIRMWARE bs=$bs skip=$offset 
count=$size $conv 2>/dev/null || \
-   caldata_die "failed to extract from $mtd"
-}
-
-ath9k_eeprom_extract() {
+caldata_extract_swap() {
local part=$1
local offset=$2
-   local swap=$3
+   local count=$3
local mtd
 
mtd=$(find_mtd_chardev $part)
-   [ -n "$mtd" ] || \
-   caldata_die "no mtd device found for partition $part"
-
-   ath9k_eeprom_extract_raw $mtd $offset $swap
-}
-
-ath9k_ubi_eeprom_extract() {
-   local part=$1
-   local offset=$2
-   local swap=$3
-   local ubidev=$(nand_find_ubi $CI_UBIPART)
-   local ubi
+   [ -n "$mtd" ] || caldata_die "no mtd device found for partition $part"
 
-   ubi=$(nand_find_volume $ubidev $part)
-   [ -n "$ubi" ] || \
-   caldata_die "no UBI volume found for $part"
+   offset=$(($offset / 2))
+   count=$(($count / 2))
 
-   ath9k_eeprom_extract_raw /dev/$ubi $offset $swap
+   dd if=$mtd of=/lib/firmware/$FIRMWARE bs=2 skip=$offset count=$count 
conv=swab 2>/dev/null || \
+   caldata_die "failed to extract calibration data from $mtd"
 }
 
 case "$FIRMWARE" in
@@ -60,25 +28,25 @@ case "$FIRMWARE" in
 
case "$board" in
arcadyan,arv7518pw)
-   ath9k_eeprom_extract "boardconfig" 0x400 1
+   caldata_extract_swap "boardconfig" 0x400 0x1000
;;
arcadyan,arv8539pw22)
-   ath9k_eeprom_extract "art" 0x400 1
+   caldata_extract_swap "art" 0x400 0x1000
;;
bt,homehub-v2b)
-   ath9k_eeprom_extract "art" 0x0 1
+   caldata_extract_swap "art" 0x0 0x1000
caldata_patch_fw_mac_crc "00:00:00:00:00:00" 
0x20c
;;
bt,homehub-v3a)
-   ath9k_eeprom_extract "art-copy" 0x0 1
+   caldata_extract_swap "art-copy" 0x0 0x1000
caldata_patch_fw_mac_crc $(macaddr_add 
$(mtd_get_mac_ascii uboot_env ethaddr) +2) 0x10c
;;
bt,homehub-v5a)
-   ath9k_ubi_eeprom_extract "caldata" 0x1000 0
+   caldata_extract_ubi "caldata" 0x1000 0x1000
caldata_patch_fw_mac_crc $(macaddr_add 
$(mtd_get_mac_binary_ubi caldata 0x110c) +2) 0x10c
;;
netgear,dgn3500|netgear,dgn3500b)
-   ath9k_eeprom_extract "calibration" 0xf000 0
+   caldata_extract "calibration" 0xf000 0x1000
caldata_patch_fw_mac_crc $(macaddr_add 
$(mtd_get_mac_ascii uboot-env ethaddr) +2) 0x20c
;;
avm,fritz3370-rev2-hynix|\
@@ -87,13 +55,13 @@ case "$FIRMWARE" in
caldata_extract_reverse "urlader" 0x1541 0x440
;;
   

[OpenWrt-Devel] [PATCH v2 0/7] Move caldata extraction and MAC patching to common file

2019-09-22 Thread Adrian Schmutzler
This is an update of my patchset unifying caldata extraction
and MAC patching. I've improved some tiny things and despite that
mostly done rebasing.
I've also included the patch for the special situation in lantiq
I sent separately for v1.

The patchset removes 417 lines of redundant code, which despite that
also included several variations of the same approach.

This has been tested on:
- ath79/ath9k: WDR4300 v1
- ath79/ath10k: Archer C60 v2
- ipq806x: TP-Link C2600

I would be happy about other tests, especially for ramips and lantiq.

#
#*** BLURB HERE ***
#
Adrian Schmutzler (7):
  treewide: fix hex2dec conversion for MAC address checksum offset
  base-files: move xor() from caldata extraction to functions.sh
  treewide: move calibration data extraction function to library
  treewide: move MAC address patch functions to common library
  ath79: set checksum when patching MAC address on ath10k
  lantiq: set checksum when patching MAC address on ath10k
  lantiq: modify ath9k caldata extraction to reuse caldata.sh

 package/base-files/files/lib/functions.sh |  16 ++
 .../base-files/files/lib/functions/caldata.sh | 128 ++
 .../etc/hotplug.d/firmware/10-ath9k-eeprom|  61 +--
 .../etc/hotplug.d/firmware/10-ath9k-eeprom| 162 --
 .../etc/hotplug.d/firmware/11-ath10k-caldata  | 159 +
 .../etc/hotplug.d/firmware/10-rt2x00-eeprom   |  27 +--
 .../etc/hotplug.d/firmware/11-ath10k-caldata  | 139 +++
 .../etc/hotplug.d/firmware/11-ath10k-caldata  | 100 ++-
 .../etc/hotplug.d/firmware/11-ath10k-caldata  |  37 +---
 .../etc/hotplug.d/firmware/12-ath9k-eeprom| 151 +++-
 .../etc/hotplug.d/firmware/10-ath9k-eeprom|  25 +--
 .../etc/hotplug.d/firmware/10-rt2x00-eeprom   |  48 +-
 12 files changed, 318 insertions(+), 735 deletions(-)
 create mode 100644 package/base-files/files/lib/functions/caldata.sh

-- 
2.20.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v2 1/7] treewide: fix hex2dec conversion for MAC address checksum offset

2019-09-22 Thread Adrian Schmutzler
If chksum_offset is converted by $(($...)) at the beginning, the
check [ -n "$chksum_offset" ] will always return true, as the
conversion yields "0" for an empty argument, and [ -n "0" ] is
true.

With this patch, the variable is not converted before the check,
but only when it's used in dd.

No conversion is done for use in hexdump, as this can deal with
hex value offsets.

Fixes: b133e466b08e ("treewide: convert WiFi caldata size and offset to 
hexadecimal")
Signed-off-by: Adrian Schmutzler 

---

This is also sent as separate patch, as it is a fix, while this
patchset is an enhancement.

Since this patchset however depends on the fix, it was included
here, as this is easier as describing the dependency.
---
 .../ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom   | 4 ++--
 .../lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git 
a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom 
b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
index 25d82a5f0d..7911d0aa1e 100644
--- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
+++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
@@ -60,7 +60,7 @@ xor() {
 ath9k_patch_fw_mac() {
local mac=$1
local mac_offset=$(($2))
-   local chksum_offset=$(($3))
+   local chksum_offset=$3
local xor_mac
local xor_fw_mac
local xor_fw_chksum
@@ -78,7 +78,7 @@ ath9k_patch_fw_mac() {
xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_mac)
 
printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \
-   dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 
seek=$chksum_offset count=2
+   dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 
seek=$(($chksum_offset)) count=2
}
 
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc 
oflag=seek_bytes bs=6 seek=$mac_offset count=1
diff --git 
a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom 
b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom
index 82f6885221..6f133c82a7 100644
--- a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom
+++ b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom
@@ -103,7 +103,7 @@ ath9k_patch_fw_mac_crc() {
 ath9k_patch_fw_mac() {
local mac=$1
local mac_offset=$(($2))
-   local chksum_offset=$(($3))
+   local chksum_offset=$3
local xor_mac
local xor_fw_mac
local xor_fw_chksum
@@ -121,7 +121,7 @@ ath9k_patch_fw_mac() {
xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_mac)
 
printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \
-   dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 
seek=$chksum_offset count=2
+   dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 
seek=$(($chksum_offset)) count=2
}
 
macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 
seek=$mac_offset count=6
-- 
2.20.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v2 5/7] ath79: set checksum when patching MAC address on ath10k

2019-09-22 Thread Adrian Schmutzler
Several devices use ath10kcal_patch_mac, although all ath10k
eeproms have a checksum field and should use
ath10kcal_patch_mac_crc.
This might be because the field is not evaluated by the firmware at
the moment.

Nevertheless, this patch will use ath10kcal_patch_mac_crc for all
devices so the correct checksum is in place.

Signed-off-by: Adrian Schmutzler 

---

v2: New patch
---
 .../etc/hotplug.d/firmware/11-ath10k-caldata  | 30 +--
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git 
a/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata 
b/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
index 3175d5a1f8..802ef4039e 100644
--- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
+++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
@@ -26,33 +26,33 @@ case "$FIRMWARE" in
;;
dlink,dir-859-a1)
caldata_extract "art" 0x5000 0x844
-   ath10kcal_patch_mac $(mtd_get_mac_ascii devdata "wlan5mac")
+   ath10kcal_patch_mac_crc $(mtd_get_mac_ascii devdata "wlan5mac")
;;
elecom,wrc-1750ghbk2-i)
caldata_extract "art" 0x5000 0x844
;;
engenius,ecb1750)
caldata_extract "art" 0x5000 0x844
-   ath10kcal_patch_mac $(mtd_get_mac_ascii u-boot-env athaddr)
+   ath10kcal_patch_mac_crc $(mtd_get_mac_ascii u-boot-env athaddr)
;;
engenius,epg5000|\
iodata,wn-ac1167dgr|\
iodata,wn-ac1600dgr2)
caldata_extract "art" 0x5000 0x844
-   ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_ascii 
u-boot-env ethaddr) +1)
+   ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_ascii 
u-boot-env ethaddr) +1)
;;
engenius,ews511ap)
caldata_extract "art" 0x5000 0x844
-   ath10kcal_patch_mac $(macaddr_add $(cat 
/sys/class/net/eth0/address) +1)
+   ath10kcal_patch_mac_crc $(macaddr_add $(cat 
/sys/class/net/eth0/address) +1)
;;
glinet,gl-ar750|\
glinet,gl-ar750s)
caldata_extract "art" 0x5000 0x844
-   ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) 
+1)
+   ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary art 
0x0) +1)
;;
glinet,gl-x750)
caldata_extract "art" 0x5000 0x844
-   ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary art 0x0) 
+2)
+   ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary art 
0x0) +2)
;;
nec,wg800hp)
caldata_extract "art" 0x5000 0x844
@@ -61,11 +61,11 @@ case "$FIRMWARE" in
ocedo,koala|\
ocedo,ursus)
caldata_extract "art" 0x5000 0x844
-   ath10kcal_patch_mac $(mtd_get_mac_binary art 0xc)
+   ath10kcal_patch_mac_crc $(mtd_get_mac_binary art 0xc)
;;
openmesh,om5p-ac-v2)
caldata_extract "art" 0x5000 0x844
-   ath10kcal_patch_mac $(macaddr_add $(cat 
/sys/class/net/eth0/address) +16)
+   ath10kcal_patch_mac_crc $(macaddr_add $(cat 
/sys/class/net/eth0/address) +16)
;;
qihoo,c301)
caldata_extract "radiocfg" 0x5000 0x844
@@ -77,29 +77,29 @@ case "$FIRMWARE" in
tplink,archer-c7-v5|\
tplink,archer-c25-v1)
caldata_extract "art" 0x5000 0x844
-   ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary info 
0x8) -1)
+   ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary info 
0x8) -1)
;;
tplink,archer-c5-v1|\
tplink,archer-c7-v2)
caldata_extract "art" 0x5000 0x844
-   ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary u-boot 
0x1fc00) -1)
+   ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary 
u-boot 0x1fc00) -1)
;;
tplink,archer-d50-v1)
caldata_extract "art" 0x5000 0x844
-   ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary romfile 
0xf100) +2)
+   ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary 
romfile 0xf100) +2)
;;
tplink,re350k-v1)
caldata_extract "art" 0x5000 0x844
-   ath10kcal_patch_mac $(macaddr_add $(mtd_get_mac_binary config 
0x10008) +2)
+   ath10kcal_patch_mac_crc $(macaddr_add $(mtd_get_mac_binary 
config 0x10008) +2)
;;
tplink,re355-v1|\
tplink,re450-v1)
caldata_extract "art" 0x5000 0x844
-   ath10kcal_patch_mac $(macaddr_add $(cat 
/sys/class/net/eth0/address) -2)
+   ath10kcal_patch_mac_crc $(macaddr_add $(cat 
/sys/class/net/eth0/address) -2)
;;
tplink,re450-

[OpenWrt-Devel] [PATCH v2 4/7] treewide: move MAC address patch functions to common library

2019-09-22 Thread Adrian Schmutzler
This unifies MAC address patch functions and moves them to a
common script. While those were implemented differently for
different targets, they all seem to do the same. The number of
different variants is significantly reduced by this patch.

Signed-off-by: Adrian Schmutzler 

---

v2: rebased, put chksum calculation into separate function
---
 .../base-files/files/lib/functions/caldata.sh | 53 +
 .../etc/hotplug.d/firmware/10-ath9k-eeprom| 12 +---
 .../etc/hotplug.d/firmware/10-ath9k-eeprom| 57 ---
 .../etc/hotplug.d/firmware/11-ath10k-caldata  | 31 --
 .../etc/hotplug.d/firmware/11-ath10k-caldata  | 25 
 .../etc/hotplug.d/firmware/11-ath10k-caldata  | 25 
 .../etc/hotplug.d/firmware/11-ath10k-caldata  |  9 +--
 .../etc/hotplug.d/firmware/12-ath9k-eeprom| 43 ++
 .../etc/hotplug.d/firmware/10-ath9k-eeprom|  3 +-
 .../etc/hotplug.d/firmware/10-rt2x00-eeprom   | 15 +
 10 files changed, 74 insertions(+), 199 deletions(-)

diff --git a/package/base-files/files/lib/functions/caldata.sh 
b/package/base-files/files/lib/functions/caldata.sh
index f2a306675f..db7aed5b4f 100644
--- a/package/base-files/files/lib/functions/caldata.sh
+++ b/package/base-files/files/lib/functions/caldata.sh
@@ -73,3 +73,56 @@ caldata_valid() {
return $?
 }
 
+caldata_patch_chksum() {
+   local mac=$1
+   local mac_offset=$(($2))
+   local chksum_offset=$(($3))
+   local xor_mac
+   local xor_fw_mac
+   local xor_fw_chksum
+
+   xor_mac=${mac//:/}
+   xor_mac="${xor_mac:0:4} ${xor_mac:4:4} ${xor_mac:8:4}"
+
+   xor_fw_mac=$(hexdump -v -n 6 -s $mac_offset -e '/1 "%02x"' 
/lib/firmware/$FIRMWARE)
+   xor_fw_mac="${xor_fw_mac:0:4} ${xor_fw_mac:4:4} ${xor_fw_mac:8:4}"
+
+   xor_fw_chksum=$(hexdump -v -n 2 -s $chksum_offset -e '/1 "%02x"' 
/lib/firmware/$FIRMWARE)
+   xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_mac)
+
+   printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \
+   dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 
seek=$chksum_offset count=2
+}
+
+caldata_patch_fw_mac() {
+   local mac=$1
+   local mac_offset=$(($2))
+   local chksum_offset=$3
+
+   [ -z "$mac" -o -z "$mac_offset" ] && return
+
+   [ -n "$chksum_offset" ] && caldata_patch_chksum "$mac" "$mac_offset" 
"$chksum_offset"
+
+   macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc 
oflag=seek_bytes bs=6 seek=$mac_offset count=1 || \
+   caldata_die "failed to write MAC address to eeprom file"
+}
+
+caldata_patch_fw_mac_crc() {
+   local mac=$1
+   local mac_offset=$2
+   local chksum_offset=$((mac_offset - 10))
+
+   caldata_patch_fw_mac "$mac" "$mac_offset" "$chksum_offset"
+}
+
+ath10kcal_patch_mac() {
+   local mac=$1
+
+   caldata_patch_fw_mac "$mac" 0x6
+}
+
+ath10kcal_patch_mac_crc() {
+   local mac=$1
+
+   caldata_patch_fw_mac "$mac" 0x6 0x2
+}
diff --git 
a/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom 
b/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
index 07100b1856..a03c3436cb 100644
--- a/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
+++ b/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
@@ -4,14 +4,6 @@
 
 . /lib/functions/caldata.sh
 
-ath9k_patch_firmware_mac() {
-   local mac=$1
-
-   [ -z "$mac" ] && return
-
-   macaddr_2bin $mac | dd of=/lib/firmware/$FIRMWARE conv=notrunc bs=1 
seek=2 count=6
-}
-
 board=$(board_name)
 
 case "$FIRMWARE" in
@@ -24,7 +16,7 @@ case "$FIRMWARE" in
caldata_extract_ubi "caldata" 0x5000 0x1000
else
caldata_extract "wifi_data" 0x5000 0x1000
-   ath9k_patch_firmware_mac $(mtd_get_mac_binary wifi_data 
0xc)
+   caldata_patch_fw_mac $(mtd_get_mac_binary wifi_data 
0xc) 0x2
fi
;;
*)
@@ -42,7 +34,7 @@ case "$FIRMWARE" in
caldata_extract_ubi "caldata" 0x1000 0x1000
else
caldata_extract "wifi_data" 0x1000 0x1000
-   ath9k_patch_firmware_mac $(mtd_get_mac_binary wifi_data 
0x0)
+   caldata_patch_fw_mac $(mtd_get_mac_binary wifi_data 
0x0) 0x2
fi
;;
*)
diff --git 
a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom 
b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
index 5ec13efd3f..5f53538229 100644
--- a/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
+++ b/target/linux/ath79/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
@@ -4,41 +4,6 @@
 
 . /lib/functions/caldata.sh
 
-ath9k_patch_fw_mac() {
-   local mac=$1
-   local mac_offset=$(($2))
-   local chksum_offset=$3
-   local xor_mac
-   local xor_fw_m

[OpenWrt-Devel] [PATCH v2 3/7] treewide: move calibration data extraction function to library

2019-09-22 Thread Adrian Schmutzler
This moves the almost identical calibration data extraction
functions present multiple times in several targets to a single
library file /lib/functions/caldata.sh.

Functions are renamed with more generic names to merge different
variants that only differ in their names.

Most of the targets used find_mtd_chardev, while some used
find_mtd_part inside the extraction code. To merge them, the more
abundant version with find_mtd_chardev is used in the common code.

Signed-off-by: Adrian Schmutzler 

---

Open questions:

1. I tested find_mtd_chardev and find_mtd_part on mpc85xx, both
gave the same result (one uses /dev/mtd*, the other one uses
/dev/mtdblock*). Is there any difference or advantage of one over
the other in this use-case?

2. For mpc85xx, there is a chained command with "dd if=... |
dd of..." used for caldata extraction. I'm a bit surprised about
the use of $count and $offset there and would be glad if someone
had a look.

v2: rebased
---
 .../base-files/files/lib/functions/caldata.sh |  75 +
 .../etc/hotplug.d/firmware/10-ath9k-eeprom|  49 ++---
 .../etc/hotplug.d/firmware/10-ath9k-eeprom|  90 +---
 .../etc/hotplug.d/firmware/11-ath10k-caldata  |  84 +--
 .../etc/hotplug.d/firmware/10-rt2x00-eeprom   |  27 +
 .../etc/hotplug.d/firmware/11-ath10k-caldata  | 101 +-
 .../etc/hotplug.d/firmware/11-ath10k-caldata  |  62 +++
 .../etc/hotplug.d/firmware/11-ath10k-caldata  |  28 +
 .../etc/hotplug.d/firmware/12-ath9k-eeprom|  36 ++-
 .../etc/hotplug.d/firmware/10-ath9k-eeprom|  24 ++---
 .../etc/hotplug.d/firmware/10-rt2x00-eeprom   |  37 ++-
 11 files changed, 207 insertions(+), 406 deletions(-)
 create mode 100644 package/base-files/files/lib/functions/caldata.sh

diff --git a/package/base-files/files/lib/functions/caldata.sh 
b/package/base-files/files/lib/functions/caldata.sh
new file mode 100644
index 00..f2a306675f
--- /dev/null
+++ b/package/base-files/files/lib/functions/caldata.sh
@@ -0,0 +1,75 @@
+# Copyright (C) 2019 OpenWrt.org
+
+. /lib/functions.sh
+. /lib/functions/system.sh
+
+caldata_die() {
+   echo "caldata: " "$*"
+   exit 1
+}
+
+caldata_extract() {
+   local part=$1
+   local offset=$(($2))
+   local count=$(($3))
+   local mtd
+
+   mtd=$(find_mtd_chardev $part)
+   [ -n "$mtd" ] || caldata_die "no mtd device found for partition $part"
+
+   dd if=$mtd of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count 
skip=$offset count=1 2>/dev/null || \
+   caldata_die "failed to extract calibration data from $mtd"
+}
+
+caldata_extract_ubi() {
+   local part=$1
+   local offset=$(($2))
+   local count=$(($3))
+   local ubidev
+   local ubi
+
+   . /lib/upgrade/nand.sh
+
+   ubidev=$(nand_find_ubi $CI_UBIPART)
+   ubi=$(nand_find_volume $ubidev $part)
+   [ -n "$ubi" ] || caldata_die "no UBI volume found for $part"
+
+   dd if=/dev/$ubi of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count 
skip=$offset count=1 2>/dev/null || \
+   caldata_die "failed to extract calibration data from $ubi"
+}
+
+caldata_extract_reverse() {
+   local part=$1
+   local offset=$2
+   local count=$(($3))
+   local mtd
+   local reversed
+   local caldata
+
+   mtd=$(find_mtd_chardev "$part")
+   reversed=$(hexdump -v -s $offset -n $count -e '/1 "%02x "' $mtd)
+
+   for byte in $reversed; do
+   caldata="\x${byte}${caldata}"
+   done
+
+   printf "%b" "$caldata" > /lib/firmware/$FIRMWARE
+}
+
+caldata_from_file() {
+   local source=$1
+   local offset=$(($2))
+   local count=$(($3))
+
+   dd if=$source of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count 
skip=$offset count=1 2>/dev/null || \
+   caldata_die "failed to extract calibration data from $source"
+}
+
+caldata_valid() {
+   local expected="$1"
+
+   magic=$(hexdump -v -n 2 -e '1/1 "%02x"' /lib/firmware/$FIRMWARE)
+   [[ "$magic" == "$expected" ]]
+   return $?
+}
+
diff --git 
a/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom 
b/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
index 272c084c99..07100b1856 100644
--- a/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
+++ b/target/linux/apm821xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
@@ -2,42 +2,7 @@
 
 [ -e /lib/firmware/$FIRMWARE ] && exit 0
 
-. /lib/functions.sh
-. /lib/functions/system.sh
-
-ath9k_eeprom_die() {
-   echo "ath9k eeprom: " "$*"
-   exit 1
-}
-
-ath9k_eeprom_extract() {
-   local part=$1
-   local offset=$(($2))
-   local count=$(($3))
-   local mtd
-
-   mtd=$(find_mtd_chardev $part)
-   [ -n "$mtd" ] || \
-   ath9k_eeprom_die "no mtd device found for partition $part"
-
-   dd if=$mtd of=/lib/firmware/$FIRMWARE iflag=skip_bytes bs=$count 
skip=$offset count=

[OpenWrt-Devel] [PATCH] ramips: initialize youhua, wr1200js WAN MAC addresses from flash

2019-09-22 Thread Adrian Schmutzler
This patch changes wan MAC address setup for youhua,wr1200js
from retrieving it by calculation to reading it from flash.

This has been checked on-device.

Signed-off-by: Adrian Schmutzler 
---
 target/linux/ramips/base-files/etc/board.d/02_network | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/linux/ramips/base-files/etc/board.d/02_network 
b/target/linux/ramips/base-files/etc/board.d/02_network
index 63644331e5..01e85527f3 100755
--- a/target/linux/ramips/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/base-files/etc/board.d/02_network
@@ -557,6 +557,7 @@ ramips_setup_macs()
phicomm,k2p|\
planex,vr500|\
samknows,whitebox-v8|\
+   youhua,wr1200js|\
youku,yk-l2|\
zbtlink,zbt-we3526)
wan_mac=$(mtd_get_mac_binary factory 0xe006)
-- 
2.20.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH v2] treewide: remove kmod-usb-core from DEVICE_PACKAGES

2019-09-22 Thread Adrian Schmutzler
This removes _all_ occurrences of kmod-usb-core from
DEVICE_PACKAGES and similar variables.

This package is pulled as dependency by one of the following
packages in any case:
- kmod-usb-chipidea
- kmod-usb-dwc2
- kmod-usb-ledtrig-usbport
- kmod-usb-ohci
- kmod-usb2
- kmod-usb2-pci
- kmod-usb3

Signed-off-by: Adrian Schmutzler 

---

v2: rebase
---
 .../ar71xx/generic/profiles/00-default.mk |   2 +-
 .../ar71xx/image/generic-legacy-devices.mk|  90 +--
 target/linux/ar71xx/image/generic-tp-link.mk  |  44 +++---
 target/linux/ar71xx/image/generic-ubnt.mk |   6 +-
 target/linux/ar71xx/image/generic.mk  | 144 +-
 target/linux/ar71xx/image/mikrotik.mk |   2 +-
 target/linux/ar71xx/image/nand.mk |  18 +--
 .../linux/ar71xx/image/tiny-legacy-devices.mk |   8 +-
 target/linux/ar71xx/image/tiny-tp-link.mk |  24 +--
 target/linux/ar71xx/image/tiny.mk |   2 +-
 .../ar71xx/mikrotik/profiles/00-default.mk|   2 +-
 .../linux/ar71xx/nand/profiles/00-default.mk  |   2 +-
 .../linux/ar71xx/tiny/profiles/00-default.mk  |   2 +-
 .../arc770/generic/profiles/00-default.mk |   2 +-
 .../archs38/generic/profiles/00-default.mk|   2 +-
 target/linux/ath79/image/generic-tp-link.mk   |  40 ++---
 target/linux/ath79/image/generic-ubnt.mk  |   4 +-
 target/linux/ath79/image/generic.mk   |  46 +++---
 target/linux/ath79/image/nand.mk  |   2 +-
 target/linux/ath79/image/tiny-tp-link.mk  |   8 +-
 target/linux/ath79/image/tiny.mk  |   2 +-
 .../linux/ath79/nand/profiles/00-default.mk   |   2 +-
 target/linux/gemini/Makefile  |   2 +-
 target/linux/ipq806x/Makefile |   2 +-
 .../ixp4xx/generic/profiles/200-NSLU2.mk  |   2 +-
 .../ixp4xx/generic/profiles/300-NAS100d.mk|   2 +-
 .../generic/profiles/400-DSMG600RevA.mk   |   2 +-
 .../ixp4xx/generic/profiles/500-USR8200.mk|   2 +-
 .../ixp4xx/harddisk/profiles/100-FSG3.mk  |   2 +-
 target/linux/mediatek/image/mt7622.mk |   6 +-
 target/linux/ramips/image/rt288x.mk   |   2 +-
 target/linux/ramips/image/rt305x.mk   |  74 -
 target/linux/ramips/image/rt3883.mk   |  12 +-
 .../ramips/mt7620/profiles/00-default.mk  |   2 +-
 .../ramips/mt7621/profiles/00-default.mk  |   2 +-
 .../ramips/mt76x8/profiles/00-default.mk  |   2 +-
 .../ramips/rt305x/profiles/00-default.mk  |   2 +-
 .../ramips/rt3883/profiles/00-default.mk  |   2 +-
 38 files changed, 286 insertions(+), 286 deletions(-)

diff --git a/target/linux/ar71xx/generic/profiles/00-default.mk 
b/target/linux/ar71xx/generic/profiles/00-default.mk
index f5ebdd2dd8..18fd385cc3 100644
--- a/target/linux/ar71xx/generic/profiles/00-default.mk
+++ b/target/linux/ar71xx/generic/profiles/00-default.mk
@@ -8,7 +8,7 @@
 define Profile/Default
NAME:=Default Profile (all drivers)
PACKAGES:= \
-   kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-usb-ledtrig-usbport
+   kmod-usb-ohci kmod-usb2 kmod-usb-ledtrig-usbport
PRIORITY := 1
 endef
 
diff --git a/target/linux/ar71xx/image/generic-legacy-devices.mk 
b/target/linux/ar71xx/image/generic-legacy-devices.mk
index 9cf405d48a..cbe039cd29 100644
--- a/target/linux/ar71xx/image/generic-legacy-devices.mk
+++ b/target/linux/ar71xx/image/generic-legacy-devices.mk
@@ -12,7 +12,7 @@ LEGACY_DEVICES += ALFANX
 
 define LegacyDevice/HORNETUB
   DEVICE_TITLE := ALFA Network Hornet-UB board (8MB flash, 32MB ram)
-  DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-ledtrig-usbport
+  DEVICE_PACKAGES := kmod-usb2 kmod-usb-ledtrig-usbport
 endef
 LEGACY_DEVICES += HORNETUB
 
@@ -23,7 +23,7 @@ LEGACY_DEVICES += TUBE2H8M
 
 define LegacyDevice/AP96
   DEVICE_TITLE := Atheros AP96 reference board
-  DEVICE_PACKAGES := kmod-usb-core kmod-usb2
+  DEVICE_PACKAGES := kmod-usb2
 endef
 LEGACY_DEVICES += AP96
 
@@ -39,7 +39,7 @@ LEGACY_DEVICES += ALFAAP120C
 
 define LegacyDevice/ALFAAP96
   DEVICE_TITLE := ALFA Network AP96 board
-  DEVICE_PACKAGES := kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-rtc-pcf2123
+  DEVICE_PACKAGES := kmod-usb-ohci kmod-usb2 kmod-rtc-pcf2123
 endef
 LEGACY_DEVICES += ALFAAP96
 
@@ -57,67 +57,67 @@ LEGACY_DEVICES += ALL0315N
 
 define LegacyDevice/AP121_8M
   DEVICE_TITLE := Atheros AP121 reference board (8MB flash)
-  DEVICE_PACKAGES := kmod-usb-core kmod-usb2
+  DEVICE_PACKAGES := kmod-usb2
 endef
 LEGACY_DEVICES += AP121_8M
 
 define LegacyDevice/AP121_16M
   DEVICE_TITLE := Atheros AP121 reference board (16MB flash)
-  DEVICE_PACKAGES := kmod-usb-core kmod-usb2
+  DEVICE_PACKAGES := kmod-usb2
 endef
 LEGACY_DEVICES += AP121_16M
 
 define LegacyDevice/AP132
   DEVICE_TITLE := Atheros AP132 reference board
-  DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-storage
+  DEVICE_PACKAGES := kmod-usb2 kmod-usb-storage
 endef
 LEGACY_DEVICES += AP132
 
 define LegacyDevice/AP135
   DEVICE_TITLE := Atheros AP135 reference bo

[OpenWrt-Devel] [PATCH] ipq40xx: abort ar40xx probe on missing PHYs

2019-09-22 Thread David Bauer
The ar40xx driver currently panics in case no QCA807x PHY has been
successfully probed. This happens when the external PHY is still
in reset when probing the ar40xx switch driver.

Note that this patch does not fix the root cause, ar40xx_probe now
simply fails instead of causing a kernel panic due to a nullpointer
dereference.

Signed-off-by: David Bauer 
---
 ...706-ar40xx-abort-probe-on-missig-phy.patch | 23 +++
 ...706-ar40xx-abort-probe-on-missig-phy.patch | 23 +++
 2 files changed, 46 insertions(+)
 create mode 100644 
target/linux/ipq40xx/patches-4.14/706-ar40xx-abort-probe-on-missig-phy.patch
 create mode 100644 
target/linux/ipq40xx/patches-4.19/706-ar40xx-abort-probe-on-missig-phy.patch

diff --git 
a/target/linux/ipq40xx/patches-4.14/706-ar40xx-abort-probe-on-missig-phy.patch 
b/target/linux/ipq40xx/patches-4.14/706-ar40xx-abort-probe-on-missig-phy.patch
new file mode 100644
index 00..19474bff0d
--- /dev/null
+++ 
b/target/linux/ipq40xx/patches-4.14/706-ar40xx-abort-probe-on-missig-phy.patch
@@ -0,0 +1,23 @@
+--- a/drivers/net/phy/ar40xx.c
 b/drivers/net/phy/ar40xx.c
+@@ -2021,6 +2021,12 @@ static int ar40xx_probe(struct platform_
+   /* register switch */
+   swdev = &priv->dev;
+ 
++  if (priv->mii_bus == NULL) {
++  dev_err(&pdev->dev, "Probe failed - Missing PHYs!\n");
++  ret = -ENODEV;
++  goto err_missing_phy;
++  }
++
+   swdev->alias = dev_name(&priv->mii_bus->dev);
+ 
+   swdev->cpu_port = AR40XX_PORT_CPU;
+@@ -2052,6 +2058,7 @@ err_unregister_switch:
+   unregister_switch(&priv->dev);
+ err_unregister_phy:
+   phy_driver_unregister(&ar40xx_phy_driver);
++err_missing_phy:
+   platform_set_drvdata(pdev, NULL);
+   return ret;
+ }
diff --git 
a/target/linux/ipq40xx/patches-4.19/706-ar40xx-abort-probe-on-missig-phy.patch 
b/target/linux/ipq40xx/patches-4.19/706-ar40xx-abort-probe-on-missig-phy.patch
new file mode 100644
index 00..19474bff0d
--- /dev/null
+++ 
b/target/linux/ipq40xx/patches-4.19/706-ar40xx-abort-probe-on-missig-phy.patch
@@ -0,0 +1,23 @@
+--- a/drivers/net/phy/ar40xx.c
 b/drivers/net/phy/ar40xx.c
+@@ -2021,6 +2021,12 @@ static int ar40xx_probe(struct platform_
+   /* register switch */
+   swdev = &priv->dev;
+ 
++  if (priv->mii_bus == NULL) {
++  dev_err(&pdev->dev, "Probe failed - Missing PHYs!\n");
++  ret = -ENODEV;
++  goto err_missing_phy;
++  }
++
+   swdev->alias = dev_name(&priv->mii_bus->dev);
+ 
+   swdev->cpu_port = AR40XX_PORT_CPU;
+@@ -2052,6 +2058,7 @@ err_unregister_switch:
+   unregister_switch(&priv->dev);
+ err_unregister_phy:
+   phy_driver_unregister(&ar40xx_phy_driver);
++err_missing_phy:
+   platform_set_drvdata(pdev, NULL);
+   return ret;
+ }
-- 
2.23.0


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] rpcd: file: add path based read/write/exec ACL checks

2019-09-22 Thread Andre Valentin
On 21.09.19 20:16, Andre Valentin wrote:
> Hi!
> 
> Im using file extension to get extra status from my device. But after the 
> change above, the calls over uhttpd are rejected with permission denied.

I've added a grant session call over http, it works now again.

Kind regards,

André




smime.p7s
Description: S/MIME Cryptographic Signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] iw: Update to version 5.3

2019-09-22 Thread Hauke Mehrtens
Wifi HE (ieee80211ax) parsing is currently only activated in the full
version because it increases the compressed size by 2.5KBytes.

This also activates link time optimization (LTO) again, the problem was
fixed upstream

This increases the uncompressed binary size of iw-tiny by about 1.7%

old:
34446 iw_5.0.1-1_mipsel_24kc.ipk
new:
35064 iw_5.3-1_mipsel_24kc.ipk

Signed-off-by: Hauke Mehrtens 
---
 package/network/utils/iw/Makefile |   9 +-
 .../utils/iw/patches/001-nl80211_h_sync.patch | 370 +++---
 .../utils/iw/patches/120-antenna_gain.patch   |   2 +-
 .../utils/iw/patches/200-reduce_size.patch|  72 ++--
 4 files changed, 97 insertions(+), 356 deletions(-)

diff --git a/package/network/utils/iw/Makefile 
b/package/network/utils/iw/Makefile
index 64438a1931..47bee53ca3 100644
--- a/package/network/utils/iw/Makefile
+++ b/package/network/utils/iw/Makefile
@@ -8,12 +8,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=iw
-PKG_VERSION:=5.0.1
+PKG_VERSION:=5.3
 PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=@KERNEL/software/network/iw
-PKG_HASH:=1e38ea794a223525b2ea7fe78fd14f2a56121e62e21ba5f9dbe8c494b35b5c0d
+PKG_HASH:=04afe857bc8dea67e461946de30ae1b012954b6965839c5c3fda7d0ed15505d5
 
 PKG_MAINTAINER:=Felix Fietkau 
 PKG_LICENSE:=GPL-2.0
@@ -46,7 +46,8 @@ TARGET_CPPFLAGS:= \
-I$(STAGING_DIR)/usr/include/libnl-tiny \
$(TARGET_CPPFLAGS) \
-DCONFIG_LIBNL20 \
-   -D_GNU_SOURCE
+   -D_GNU_SOURCE \
+   -flto
 
 ifeq ($(BUILD_VARIANT),full)
   TARGET_CPPFLAGS += -DIW_FULL
@@ -55,7 +56,7 @@ endif
 
 MAKE_FLAGS += \
CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -ffunction-sections 
-fdata-sections" \
-   LDFLAGS="$(TARGET_LDFLAGS) -Wl,--gc-sections" \
+   LDFLAGS="$(TARGET_LDFLAGS) -Wl,--gc-sections -flto" \
NL1FOUND="" NL2FOUND=Y \
NLLIBNAME="libnl-tiny" \
LIBS="-lm -lnl-tiny" \
diff --git a/package/network/utils/iw/patches/001-nl80211_h_sync.patch 
b/package/network/utils/iw/patches/001-nl80211_h_sync.patch
index 884261621e..1a5bdc0b54 100644
--- a/package/network/utils/iw/patches/001-nl80211_h_sync.patch
+++ b/package/network/utils/iw/patches/001-nl80211_h_sync.patch
@@ -1,336 +1,60 @@
 --- a/nl80211.h
 +++ b/nl80211.h
-@@ -11,7 +11,7 @@
-  * Copyright 2008 Jouni Malinen 
-  * Copyright 2008 Colin McCabe 
-  * Copyright 2015-2017Intel Deutschland GmbH
-- * Copyright (C) 2018 Intel Corporation
-+ * Copyright (C) 2018-2019 Intel Corporation
-  *
-  * Permission to use, copy, modify, and/or distribute this software for any
-  * purpose with or without fee is hereby granted, provided that the above
-@@ -235,6 +235,15 @@
-  */
- 
- /**
-+ * DOC: SAE authentication offload
-+ *
-+ * By setting @NL80211_EXT_FEATURE_SAE_OFFLOAD flag drivers can indicate they
-+ * support offloading SAE authentication for WPA3-Personal networks. In
-+ * %NL80211_CMD_CONNECT the password for SAE should be specified using
-+ * %NL80211_ATTR_SAE_PASSWORD.
-+ */
-+
-+/**
-  * enum nl80211_commands - supported nl80211 commands
-  *
-  * @NL80211_CMD_UNSPEC: unspecified command to catch errors
-@@ -1065,6 +1074,26 @@
-  *indicated by %NL80211_ATTR_WIPHY_FREQ and other attributes
-  *determining the width and type.
-  *
-+ * @NL80211_CMD_UPDATE_OWE_INFO: This interface allows the host driver to
-+ *offload OWE processing to user space. This intends to support
-+ *OWE AKM by the host drivers that implement SME but rely
-+ *on the user space for the cryptographic/DH IE processing in AP mode.
-+ *
-+ * @NL80211_CMD_PROBE_MESH_LINK: The requirement for mesh link metric
-+ *refreshing, is that from one mesh point we be able to send some data
-+ *frames to other mesh points which are not currently selected as a
-+ *primary traffic path, but which are only 1 hop away. The absence of
-+ *the primary path to the chosen node makes it necessary to apply some
-+ *form of marking on a chosen packet stream so that the packets can be
-+ *properly steered to the selected node for testing, and not by the
-+ *regular mesh path lookup. Further, the packets must be of type data
-+ *so that the rate control (often embedded in firmware) is used for
-+ *rate selection.
-+ *
-+ *Here attribute %NL80211_ATTR_MAC is used to specify connected mesh
-+ *peer MAC address and %NL80211_ATTR_FRAME is used to specify the frame
-+ *content. The frame is ethernet data.
-+ *
-  * @NL80211_CMD_MAX: highest used command number
-  * @__NL80211_CMD_AFTER_LAST: internal use
-  */
-@@ -1285,6 +1314,10 @@ enum nl80211_commands {
- 
-   NL80211_CMD_NOTIFY_RADAR,
- 
-+  NL80211_CMD_UPDATE_OWE_INFO,
-+
-+  NL80211_CMD_PROBE_MESH_LINK,
-+
-   /* add new commands above here */
- 
-   /* used to define NL80211_CMD_MAX below */
-@@ -1565,6 +1598,12 @@ enum nl80211_commands {
-  *(a u32 with flags from &enum nl80211_wpa_versions).
-  * @NL80211_ATTR_AKM_SUITES: Used w

Re: [OpenWrt-Devel] rpcd: file: add path based read/write/exec ACL checks

2019-09-22 Thread Jo-Philipp Wich
Hi,

> What do I have to do to enable access again, without calling ubus
> session grant like in the commit? Thank you!

you need to add the following sections:

"superuser": {
...
"read": {
"file": {
"/": [ "stat", "read" ],
"/*": [ "stat", "read" ]
}
},
"write": {
"file": {
"/": [ "write" ],
"/*": [ "write", "exec" ]
}
}
}

Depending on your use case, you might not need the "write" and "exec"
permissions at all.

The "exec" entry will allow invoking commands matching the path "/*"
(so, everything) and the "write" permission will allow (over)writing and
removing files matching the wildcard path.

Regards,
Jo



signature.asc
Description: OpenPGP digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [sdwalker/sdwalker.github.io] a8cdda: This week's update

2019-09-22 Thread Stephen Walker
  Branch: refs/heads/master
  Home:   https://github.com/sdwalker/sdwalker.github.io
  Commit: a8cdda328bc2290618b943506d84c496c6cf77c0
  
https://github.com/sdwalker/sdwalker.github.io/commit/a8cdda328bc2290618b943506d84c496c6cf77c0
  Author: Stephen Walker 
  Date:   2019-09-22 (Sun, 22 Sep 2019)

  Changed paths:
M uscan/index-18.06.html
M uscan/index.html

  Log Message:
  ---
  This week's update



___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] the change 'base-files, procd: add generic service status' breaks several packages

2019-09-22 Thread Dirk Brenken
On Sat, 2019-09-21 at 11:09 +0200, Petr Štetiar wrote:
> Dirk Brenken <
> d...@brenken.org
> > [2019-09-21 09:15:56]:
> 
> Hi,
> 
> > How to proceed?
> 
> can you please try following fix[1]? Thanks!
> 
> 1.  
> https://gitlab.com/ynezz/openwrt-packages/commit/79270c139f166550c8fcf89cc8f18135e3173ce5
> 
> 
> -- ynezz
> 
> ___
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> 
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
> 

I've tested your patch with adblock and it works for me - thank you.
Please bump the PKG_RELEASE in the Makefile as well.

Best regards
Dirk


signature.asc
Description: This is a digitally signed message part
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] Add support for Inventel DV4210

2019-09-22 Thread Daniel Gonzalez Cabanelas
Add support for the Inventel DV4210 router.

This is an Inventel Livebox 1 board. The patch supports the board with a CFE 
bootloader, and
a RAM mod (64 MB, tested).  The board originally comes with 8 MB flash.  Under 
this conditions
this old BCM6348 based board still runs quite fine with current snapshots.

Signed-off-by: Daniel Gonzalez Cabanelas 
---
 .../brcm63xx/base-files/etc/board.d/01_leds   |   1 +
 .../base-files/etc/board.d/02_network |   2 +-
 target/linux/brcm63xx/base-files/etc/diag.sh  |   1 +
 .../linux/brcm63xx/base-files/lib/brcm63xx.sh |   3 +
 target/linux/brcm63xx/dts/dv4210.dts  | 102 ++
 target/linux/brcm63xx/image/bcm63xx.mk|  13 +++
 .../patches-4.14/599-board_DV4210.patch   |  50 +
 7 files changed, 171 insertions(+), 1 deletion(-)
 create mode 100644 target/linux/brcm63xx/dts/dv4210.dts
 create mode 100644 target/linux/brcm63xx/patches-4.14/599-board_DV4210.patch

diff --git a/target/linux/brcm63xx/base-files/etc/board.d/01_leds 
b/target/linux/brcm63xx/base-files/etc/board.d/01_leds
index d25d37e847..00109ba112 100755
--- a/target/linux/brcm63xx/base-files/etc/board.d/01_leds
+++ b/target/linux/brcm63xx/base-files/etc/board.d/01_leds
@@ -69,6 +69,7 @@ homehub2a)
ucidef_set_led_usbdev "usb1" "USB1" "HOMEHUB2A:blue:phone" "1-1"
ucidef_set_led_usbdev "usb2" "USB2" "HOMEHUB2A:green:phone" "2-1"
;;
+dv4210|\
 livebox1)
ucidef_set_led_netdev "lan" "LAN" "Livebox1:red:traffic" "eth0"
ucidef_set_led_netdev "wan" "WAN" "Livebox1:red:adsl" "eth1"
diff --git a/target/linux/brcm63xx/base-files/etc/board.d/02_network 
b/target/linux/brcm63xx/base-files/etc/board.d/02_network
index a2ca5a37b3..0e384f82f6 100755
--- a/target/linux/brcm63xx/base-files/etc/board.d/02_network
+++ b/target/linux/brcm63xx/base-files/etc/board.d/02_network
@@ -145,8 +145,8 @@ bcm963268bu_p300)
ucidef_add_switch "switch0" \
"0:lan" "3:lan" "4:lan" "5:lan" "6:lan" "7:lan" "8t@eth0"
;;
-
 cpva502p |\
+dv4210 |\
 livebox1)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
;;
diff --git a/target/linux/brcm63xx/base-files/etc/diag.sh 
b/target/linux/brcm63xx/base-files/etc/diag.sh
index 34464ec44a..c673a75e40 100644
--- a/target/linux/brcm63xx/base-files/etc/diag.sh
+++ b/target/linux/brcm63xx/base-files/etc/diag.sh
@@ -114,6 +114,7 @@ set_state() {
hg655b)
status_led="HW65x:green:power"
;;
+   dv4210|\
livebox1)
status_led="Livebox1:red:adsl-fail-power"
;;
diff --git a/target/linux/brcm63xx/base-files/lib/brcm63xx.sh 
b/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
index 1676ae0abb..9c0c33cc31 100755
--- a/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
+++ b/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
@@ -177,6 +177,9 @@ brcm63xx_dt_detect() {
"Inteno VG50")
board_name="vg50"
;;
+   "Inventel DV4210")
+   board_name="dv4210"
+   ;;
"Inventel Livebox 1")
board_name="livebox1"
;;
diff --git a/target/linux/brcm63xx/dts/dv4210.dts 
b/target/linux/brcm63xx/dts/dv4210.dts
new file mode 100644
index 00..02975fe3b6
--- /dev/null
+++ b/target/linux/brcm63xx/dts/dv4210.dts
@@ -0,0 +1,102 @@
+/dts-v1/;
+
+#include "bcm6348.dtsi"
+
+#include 
+
+/ {
+   model = "Inventel DV4210";
+   compatible = "inventel,dv4210", "brcm,bcm6348";
+
+   chosen {
+   bootargs = "rootfstype=squashfs,jffs2 noinitrd 
console=ttyS0,115200";
+   stdout-path = "serial0:115200n8";
+   };
+
+   keys {
+   compatible = "gpio-keys-polled";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   poll-interval = <20>;
+
+   button1 {
+   label = "1";
+   gpios = <&pinctrl 36 1>;
+   linux,code = ;
+   debounce-interval = <60>;
+   };
+
+   button2 {
+   label = "2";
+   gpios = <&pinctrl 7 1>;
+   linux,code = ;
+   debounce-interval = <60>;
+   };
+   };
+
+   leds {
+   compatible = "gpio-leds";
+
+   red_adsl_fail {
+   label = "Livebox1:red:adsl-fail-power";
+   gpios = <&pinctrl 0 0>;
+   default-state = "on";
+   };
+
+   red_adsl {
+   label = "Livebox1:red:adsl";
+   gpios = <&pinctrl 1 0>;
+   };
+
+   red_traffic {
+   label = "Livebox1:red:traffic";
+   gpios = <&pinctrl 2 0>;
+   };
+
+   red_phone {
+   label = "Livebox1:red:phone";
+   gpio

Re: [OpenWrt-Devel] [PATCH] openssl: bump to 1.1.1d

2019-09-22 Thread Eneas Queiroz
On Tue, Sep 17, 2019 at 10:52 AM Eneas U de Queiroz
 wrote:
>
> This version fixes 3 low-severity vulnerabilities:
>
> - CVE-2019-1547: ECDSA remote timing attack
> - CVE-2019-1549: Fork Protection
> - CVE-2019-1563: Padding Oracle in PKCS7_dataDecode and
>  CMS_decrypt_set1_pkey
>
> Patches were refreshed.
>
> Signed-off-by: Eneas U de Queiroz 
>
> --
> Run-tested on WRT3200ACM, mvebu, running openwrt master, using uhttpd,
> nginx, openssl-util, and uclient-fetch; devcrypto engine specifically
> tested.
>
> This should be cherry-picked to openwrt-19.07 as well.
>

Can someone please cherry pick this to 19.07:
d868d0a5d7e1d76bb1a8980346d222fae55fa18b

If I should rather send a proper patch to list, please let me know.

BR

Eneas

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] openssl: bump to 1.1.1d

2019-09-22 Thread Petr Štetiar
Eneas Queiroz  [2019-09-22 22:29:07]:

Hi,

> Can someone please cherry pick this to 19.07:
> d868d0a5d7e1d76bb1a8980346d222fae55fa18b

done.

-- ynezz

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel