[PATCH] urandom-seed: use seedrng for seeding the random number generator

2022-03-27 Thread Jason A. Donenfeld
The RNG can't actually be seeded from a shell script, due to the
reliance on ioctls. For this reason, the seedrng project provides a
basic script meant to be copy and pasted into projects like OpenWRT
and tweaked as needed: .

This commit imports it into the urandom-seed package and wires up the
init scripts to call it. This also is a significant improvement over the
current init script, which does not robustly handle cleaning up of seeds
and syncing to prevent reuse. Additionally, the existing script creates
a new seed immediately after writing an old one, which means that the
amount of entropy might actually regress, due to failing to credit the
old seed.

Closes: https://github.com/openwrt/openwrt/issues/9570
Signed-off-by: Jason A. Donenfeld 
---
 package/system/urandom-seed/Makefile  |   4 +-
 .../files/etc/init.d/urandom_seed |   2 +-
 .../files/lib/preinit/81_urandom_seed |  16 +-
 .../urandom-seed/files/sbin/urandom_seed  |  20 -
 package/system/urandom-seed/seedrng.c | 434 ++
 5 files changed, 441 insertions(+), 35 deletions(-)
 delete mode 100755 package/system/urandom-seed/files/sbin/urandom_seed
 create mode 100644 package/system/urandom-seed/seedrng.c

diff --git a/package/system/urandom-seed/Makefile 
b/package/system/urandom-seed/Makefile
index 7c5524a9db..f890c0b10a 100644
--- a/package/system/urandom-seed/Makefile
+++ b/package/system/urandom-seed/Makefile
@@ -9,7 +9,6 @@ include $(INCLUDE_DIR)/package.mk
 define Package/urandom-seed
   SECTION:=base
   CATEGORY:=Base system
-  DEPENDS:=+getrandom
   TITLE:=/etc/urandom.seed handling for OpenWrt
   URL:=https://openwrt.org/
 endef
@@ -19,11 +18,14 @@ define Build/Prepare
 endef
 
 define Build/Compile/Default
+   $(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_CPPFLAGS) $(TARGET_LDFLAGS) \
+   -std=gnu99 -o $(PKG_BUILD_DIR)/seedrng seedrng.c
 endef
 Build/Compile = $(Build/Compile/Default)
 
 define Package/urandom-seed/install
$(CP) ./files/* $(1)/
+   $(CP) $(PKG_BUILD_DIR)/seedrng $(1)/sbin/
 endef
 
 $(eval $(call BuildPackage,urandom-seed))
diff --git a/package/system/urandom-seed/files/etc/init.d/urandom_seed 
b/package/system/urandom-seed/files/etc/init.d/urandom_seed
index 17d9c13400..d6e81c6079 100755
--- a/package/system/urandom-seed/files/etc/init.d/urandom_seed
+++ b/package/system/urandom-seed/files/etc/init.d/urandom_seed
@@ -5,7 +5,7 @@ USE_PROCD=1
 
 start_service() {
 procd_open_instance "urandom_seed"
-procd_set_param command "/sbin/urandom_seed"
+procd_set_param command "/sbin/seedrng"
 procd_set_param stdout 1
 procd_set_param stderr 1
 procd_close_instance
diff --git a/package/system/urandom-seed/files/lib/preinit/81_urandom_seed 
b/package/system/urandom-seed/files/lib/preinit/81_urandom_seed
index 2adc6c47f0..b3014daeaf 100644
--- a/package/system/urandom-seed/files/lib/preinit/81_urandom_seed
+++ b/package/system/urandom-seed/files/lib/preinit/81_urandom_seed
@@ -2,21 +2,11 @@ log_urandom_seed() {
 echo "urandom-seed: $1" > /dev/kmsg
 }
 
-_do_urandom_seed() {
-[ -f "$1" ] || { log_urandom_seed "Seed file not found ($1)"; return; }
-[ -O "$1" -a -G "$1" -a ! -x "$1" ] || { log_urandom_seed "Wrong owner / 
permissions for $1"; return; }
-
-log_urandom_seed "Seeding with $1"
-cat "$1" > /dev/urandom
-}
-
 do_urandom_seed() {
 [ -c /dev/urandom ] || { log_urandom_seed "Something is wrong with 
/dev/urandom"; return; }
-
-_do_urandom_seed "/etc/urandom.seed"
-
-SEED="$(uci -q get system.@system[0].urandom_seed)"
-[ "${SEED:0:1}" = "/" -a "$SEED" != "/etc/urandom.seed" ] && 
_do_urandom_seed "$SEED"
+seedrng 2>&1 | while read -r line; do
+log_urandom_seed "$line"
+done
 }
 
 boot_hook_add preinit_main do_urandom_seed
diff --git a/package/system/urandom-seed/files/sbin/urandom_seed 
b/package/system/urandom-seed/files/sbin/urandom_seed
deleted file mode 100755
index 7043e8af4e..00
--- a/package/system/urandom-seed/files/sbin/urandom_seed
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-set -e
-
-trap '[ "$?" -eq 0 ] || echo "An error occured" >&2' EXIT
-
-save() {
-touch "$1.tmp"
-chown root:root "$1.tmp"
-chmod 600 "$1.tmp"
-getrandom 512 > "$1.tmp"
-mv "$1.tmp" "$1"
-echo "Seed saved ($1)"
-}
-
-SEED="$(uci -q get system.@system[0].urandom_seed || true)"
-[ "${SEED:0:1}" = "/" ] && save "$SEED"
-
-SEED=/etc/urandom.seed
-[ ! -f $SEED ] && save "$SEED"
-true
diff --git a/package/system/urandom-seed/seedrng.c 
b/package/system/urandom-seed/seedrng.c
new file mode 100644
index 00..9a2cb10f55
--- /dev/null
+++ b/package/system/urandom-seed/seedrng.c
@@ -0,0 +1,434 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT OR Apache-2.0)
+/*
+ * Copyright (C) 2022 Jason A. Donenfeld . All Rights 
Reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 

[PATCH] kernel: 5.15: fix mediatek usb module change

2022-03-27 Thread John Thomson
The mediatek USB kernel module xhci-mtk was restructed.
The module after kernel 5.13 is named xhci-mtk-hcd.
Link:
https://lore.kernel.org/all/0b62e21ddfacc1c2874726dd27ccab80c993f303.1615170625.git.chunfeng@mediatek.com/
Linux 14295a150050 ("usb: xhci-mtk: support to build xhci-mtk-hcd.ko")

Signed-off-by: John Thomson 
---
 package/kernel/linux/modules/usb.mk | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/package/kernel/linux/modules/usb.mk 
b/package/kernel/linux/modules/usb.mk
index c12150fc5c..a52ba745ef 100644
--- a/package/kernel/linux/modules/usb.mk
+++ b/package/kernel/linux/modules/usb.mk
@@ -1787,8 +1787,10 @@ define KernelPackage/usb-xhci-mtk
   DEPENDS:=+kmod-usb-xhci-hcd
   KCONFIG:=CONFIG_USB_XHCI_MTK
   HIDDEN:=1
-  FILES:=$(LINUX_DIR)/drivers/usb/host/xhci-mtk.ko
-  AUTOLOAD:=$(call AutoLoad,54,xhci-mtk,1)
+  FILES:= \
+$(LINUX_DIR)/drivers/usb/host/xhci-mtk.ko@lt5.13 \
+$(LINUX_DIR)/drivers/usb/host/xhci-mtk-hcd.ko@ge5.13
+  AUTOLOAD:=$(call AutoLoad,54,xhci-mtk@lt5.13 xhci-mtk-hcd@gt5.13,1)
   $(call AddDepends/usb)
 endef
 
-- 
2.35.1


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


[PATCH 3/3] ath79: add support for MikroTik RouterBOARD 911 Lite2/Lite5

2022-03-27 Thread Tomasz Maciej Nowak
Forward-port from ar71xx target the board introduced in commit
eb9e3651dd1a (" ar71xx: add support for the MikroTik RB911-2Hn/5Hn
boards"). Follow intallation instruction from that commit message, using
images found in ath79 directory. Be advised that the board accepts
10-30 V on PoE input.

Known issues
Compared to ar71xx target image, there is still small leak of current to
user LED, which makes it lit, although weaker, even if brightness is set
to 0. The cause of that is still unknown.

Signed-off-by: Tomasz Maciej Nowak 
---
 .../ar9344_mikrotik_routerboard-911-lite.dts  | 36 +++
 target/linux/ath79/image/mikrotik.mk  | 10 ++
 .../mikrotik/base-files/etc/board.d/01_leds   |  9 ++---
 .../base-files/etc/board.d/02_network |  2 ++
 .../etc/hotplug.d/firmware/10-ath9k-eeprom|  1 +
 5 files changed, 54 insertions(+), 4 deletions(-)
 create mode 100644 
target/linux/ath79/dts/ar9344_mikrotik_routerboard-911-lite.dts

diff --git a/target/linux/ath79/dts/ar9344_mikrotik_routerboard-911-lite.dts 
b/target/linux/ath79/dts/ar9344_mikrotik_routerboard-911-lite.dts
new file mode 100644
index ..d77078c5a22c
--- /dev/null
+++ b/target/linux/ath79/dts/ar9344_mikrotik_routerboard-911-lite.dts
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "ar9344_mikrotik_routerboard.dtsi"
+#include "ar9344_mikrotik_routerboard-16m-nor.dtsi"
+
+/ {
+   model = "MikroTik RouterBOARD 911-2Hn/5Hn (Lite2/Lite5)";
+   compatible = "mikrotik,routerboard-911-lite", "qca,ar9344";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_gpio_20>;
+
+   lan {
+   label = "green:lan";
+   gpios = < 20 GPIO_ACTIVE_LOW>;
+   };
+
+   power {
+   label = "green:power";
+   gpios = < 11 GPIO_ACTIVE_HIGH>;
+   default-state = "on";
+   };
+
+   led_user: user {
+   label = "green:user";
+   gpios = < 3 GPIO_ACTIVE_LOW>;
+   };
+};
+
+ {
+   enable_gpio_20: pinmux_gpio_out_function5 {
+   pinctrl-single,bits = <0x14 0x0 0xff>;
+   };
+};
diff --git a/target/linux/ath79/image/mikrotik.mk 
b/target/linux/ath79/image/mikrotik.mk
index dccb05e45a72..dd0d64fbe3b9 100644
--- a/target/linux/ath79/image/mikrotik.mk
+++ b/target/linux/ath79/image/mikrotik.mk
@@ -9,6 +9,16 @@ define Device/mikrotik_routerboard-493g
 endef
 TARGET_DEVICES += mikrotik_routerboard-493g
 
+define Device/mikrotik_routerboard-911-lite
+  $(Device/mikrotik_nor)
+  SOC := ar9344
+  DEVICE_MODEL := RouterBOARD 911 Lite2/Lite5 (2Hn/5Hn)
+  DEVICE_PACKAGES += rssileds
+  IMAGE_SIZE := 16256k
+  SUPPORTED_DEVICES += rb-911-2hn rb-911-5hn
+endef
+TARGET_DEVICES += mikrotik_routerboard-911-lite
+
 define Device/mikrotik_routerboard-912uag-2hpnd
   $(Device/mikrotik_nand)
   SOC := ar9342
diff --git a/target/linux/ath79/mikrotik/base-files/etc/board.d/01_leds 
b/target/linux/ath79/mikrotik/base-files/etc/board.d/01_leds
index ecc47e07c231..1c74ebbdef9b 100644
--- a/target/linux/ath79/mikrotik/base-files/etc/board.d/01_leds
+++ b/target/linux/ath79/mikrotik/base-files/etc/board.d/01_leds
@@ -6,10 +6,7 @@ board_config_update
 board=$(board_name)
 
 case "$board" in
-mikrotik,routerboard-lhg-2nd|\
-mikrotik,routerboard-mapl-2nd)
-   ucidef_set_led_netdev "lan" "lan" "green:lan" "eth0"
-   ;;
+mikrotik,routerboard-911-lite|\
 mikrotik,routerboard-lhg-5nd)
ucidef_set_led_netdev "lan" "lan" "green:lan" "eth0"
ucidef_set_rssimon "wlan0" "20" "1"
@@ -19,6 +16,10 @@ mikrotik,routerboard-lhg-5nd)
ucidef_set_led_rssi "rssimediumhigh" "rssimediumhigh" 
"green:rssimediumhigh" "wlan0" "60" "100"
ucidef_set_led_rssi "rssihigh" "rssihigh" "green:rssihigh" "wlan0" "80" 
"100"
;;
+mikrotik,routerboard-lhg-2nd|\
+mikrotik,routerboard-mapl-2nd)
+   ucidef_set_led_netdev "lan" "lan" "green:lan" "eth0"
+   ;;
 mikrotik,routerboard-wapr-2nd)
ucidef_set_rssimon "wlan0" "20" "1"
ucidef_set_led_rssi "rssilow" "rssilow" "green:rssilow" "wlan0" "1" 
"100"
diff --git a/target/linux/ath79/mikrotik/base-files/etc/board.d/02_network 
b/target/linux/ath79/mikrotik/base-files/etc/board.d/02_network
index cc4121f93e18..ba728c98a2fb 100644
--- a/target/linux/ath79/mikrotik/base-files/etc/board.d/02_network
+++ b/target/linux/ath79/mikrotik/base-files/etc/board.d/02_network
@@ -14,6 +14,7 @@ ath79_setup_interfaces()
ucidef_add_switch "switch1" \
"0@eth1" "1:lan:4" "2:lan:1" "3:lan:2" "4:lan:3"
;;
+   mikrotik,routerboard-911-lite|\
mikrotik,routerboard-912uag-2hpnd|\
mikrotik,routerboard-lhg-2nd|\
mikrotik,routerboard-lhg-5nd|\
@@ -38,6 +39,7 @@ ath79_setup_macs()
local mac_base="$(cat /sys/firmware/mikrotik/hard_config/mac_base)"
 
case "$board" in
+   mikrotik,routerboard-911-lite|\

[PATCH 1/3] ath79: mikrotik: stack ar9344 devices to single dtsi

2022-03-27 Thread Tomasz Maciej Nowak
Most of boards from MikroTik with AR9344 SoC (supported and
un-supported) replicate the same schematic, so stack common device nodes
to a single dtsi.

Signed-off-by: Tomasz Maciej Nowak 
---
 .../ar9344_mikrotik_routerboard-16m-nor.dtsi  |   8 -
 .../ar9344_mikrotik_routerboard-lhg-5nd.dts   |  90 ++---
 .../ar9344_mikrotik_routerboard-sxt-5n.dtsi   | 185 --
 ...ar9344_mikrotik_routerboard-sxt-5nd-r2.dts | 108 +-
 .../dts/ar9344_mikrotik_routerboard.dtsi  |  78 
 5 files changed, 198 insertions(+), 271 deletions(-)
 delete mode 100644 
target/linux/ath79/dts/ar9344_mikrotik_routerboard-sxt-5n.dtsi
 create mode 100644 target/linux/ath79/dts/ar9344_mikrotik_routerboard.dtsi

diff --git a/target/linux/ath79/dts/ar9344_mikrotik_routerboard-16m-nor.dtsi 
b/target/linux/ath79/dts/ar9344_mikrotik_routerboard-16m-nor.dtsi
index 4bf0731b1afe..727ea074c060 100644
--- a/target/linux/ath79/dts/ar9344_mikrotik_routerboard-16m-nor.dtsi
+++ b/target/linux/ath79/dts/ar9344_mikrotik_routerboard-16m-nor.dtsi
@@ -1,7 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 
-#include "ar9344.dtsi"
-
  {
status = "okay";
 
@@ -57,9 +55,3 @@
};
};
 };
-
- {
-   status = "okay";
-
-   qca,no-eeprom;
-};
diff --git a/target/linux/ath79/dts/ar9344_mikrotik_routerboard-lhg-5nd.dts 
b/target/linux/ath79/dts/ar9344_mikrotik_routerboard-lhg-5nd.dts
index 194a789fb216..b6de8c4b7b11 100644
--- a/target/linux/ath79/dts/ar9344_mikrotik_routerboard-lhg-5nd.dts
+++ b/target/linux/ath79/dts/ar9344_mikrotik_routerboard-lhg-5nd.dts
@@ -1,91 +1,27 @@
 // SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 
+#include "ar9344_mikrotik_routerboard.dtsi"
 #include "ar9344_mikrotik_routerboard-16m-nor.dtsi"
 
-#include 
-#include 
-
 / {
compatible = "mikrotik,routerboard-lhg-5nd", "qca,ar9344";
model = "MikroTik RouterBOARD LHG 5nD";
+};
 
-   aliases {
-   led-boot = _user;
-   led-failsafe = _user;
-   led-running = _user;
-   led-upgrade = _user;
-   };
-
-   leds {
-   compatible = "gpio-leds";
-
-   power {
-   label = "blue:power";
-   gpios = < 11 GPIO_ACTIVE_HIGH>;
-   default-state = "on";
-   };
-
-   rssilow {
-   label = "green:rssilow";
-   gpios = < 13 GPIO_ACTIVE_LOW>;
-   };
-
-   rssimediumlow {
-   label = "green:rssimediumlow";
-   gpios = < 12 GPIO_ACTIVE_LOW>;
-   };
-
-   rssimedium {
-   label = "green:rssimedium";
-   gpios = < 4 GPIO_ACTIVE_LOW>;
-   };
-
-   rssimediumhigh {
-   label = "green:rssimediumhigh";
-   gpios = < 21 GPIO_ACTIVE_LOW>;
-   };
-
-   rssihigh {
-   label = "green:rssihigh";
-   gpios = < 18 GPIO_ACTIVE_LOW>;
-   };
-
-   led_user: user {
-   label = "white:user";
-   gpios = < 20 GPIO_ACTIVE_LOW>;
-   };
-
-   lan {
-   label = "green:lan";
-   gpios = < 14 GPIO_ACTIVE_LOW>;
-   };
+ {
+   power {
+   label = "blue:power";
+   gpios = < 11 GPIO_ACTIVE_HIGH>;
+   default-state = "on";
};
 
-   keys {
-   compatible = "gpio-keys";
-
-   reset {
-   label = "reset";
-   linux,code = ;
-   gpios = < 15 GPIO_ACTIVE_LOW>;
-   debounce-interval = <60>;
-   };
+   led_user: user {
+   label = "white:user";
+   gpios = < 20 GPIO_ACTIVE_LOW>;
};
-};
-
- {
-   status = "okay";
 
-   phy-handle = <>;
-
-   gmac-config {
-   device = <>;
-   switch-phy-swap = <1>;
+   lan {
+   label = "green:lan";
+   gpios = < 14 GPIO_ACTIVE_LOW>;
};
 };
-
- {
-   status = "okay";
-
-   compatible = "syscon", "simple-mfd";
-};
diff --git a/target/linux/ath79/dts/ar9344_mikrotik_routerboard-sxt-5n.dtsi 
b/target/linux/ath79/dts/ar9344_mikrotik_routerboard-sxt-5n.dtsi
deleted file mode 100644
index 86136289de3c..
--- a/target/linux/ath79/dts/ar9344_mikrotik_routerboard-sxt-5n.dtsi
+++ /dev/null
@@ -1,185 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
-
-#include "ar9344.dtsi"
-
-#include 
-#include 
-
-/ {
-   compatible = "mikrotik,routerboard-sxt-5n", "qca,ar9344";
-   model = "MikroTik SXT 5N platform";
-
-   aliases {
-   led-boot = _user;
-   led-failsafe = _user;
-   led-running 

[PATCH 2/3] ath79: ar9344_mikrotik_routerboard: drop runnig LED alias

2022-03-27 Thread Tomasz Maciej Nowak
All boards which include this dtsi have a power LED, which is by default
ON on running system, so there's no need to replicate it. Let the user
decide what to do with it on running system.

Signed-off-by: Tomasz Maciej Nowak 
---
 target/linux/ath79/dts/ar9344_mikrotik_routerboard.dtsi | 1 -
 1 file changed, 1 deletion(-)

diff --git a/target/linux/ath79/dts/ar9344_mikrotik_routerboard.dtsi 
b/target/linux/ath79/dts/ar9344_mikrotik_routerboard.dtsi
index 10233e3d4eef..ccb3ea6b5d89 100644
--- a/target/linux/ath79/dts/ar9344_mikrotik_routerboard.dtsi
+++ b/target/linux/ath79/dts/ar9344_mikrotik_routerboard.dtsi
@@ -9,7 +9,6 @@
aliases {
led-boot = _user;
led-failsafe = _user;
-   led-running = _user;
led-upgrade = _user;
};
 
-- 
2.35.1


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


[PATCH v2 6/7] treewide: use upstream compatible for RedBoot FIS parser

2022-03-27 Thread Tomasz Maciej Nowak
No reason to keep that around, since upstream one does the same.

Signed-off-by: Tomasz Maciej Nowak 
---
 .../ath79/dts/ar7161_adtran_bsap1880.dtsi |  2 +-
 .../dts/bcm6348-inventel-livebox-1.dts|  2 +-
 target/linux/gemini/image/Makefile|  4 ++--
 ...t-add-of_match_table-with-DT-binding.patch | 22 ---
 ...t-add-of_match_table-with-DT-binding.patch | 22 ---
 5 files changed, 4 insertions(+), 48 deletions(-)
 delete mode 100644 
target/linux/generic/pending-5.10/419-mtd-redboot-add-of_match_table-with-DT-binding.patch
 delete mode 100644 
target/linux/generic/pending-5.15/419-mtd-redboot-add-of_match_table-with-DT-binding.patch

diff --git a/target/linux/ath79/dts/ar7161_adtran_bsap1880.dtsi 
b/target/linux/ath79/dts/ar7161_adtran_bsap1880.dtsi
index 5b4b6e3ddafd..d711ca92d3f4 100644
--- a/target/linux/ath79/dts/ar7161_adtran_bsap1880.dtsi
+++ b/target/linux/ath79/dts/ar7161_adtran_bsap1880.dtsi
@@ -87,7 +87,7 @@
partitions {
#address-cells = <1>;
#size-cells = <1>;
-   compatible = "ecoscentric,redboot-fis-partitions";
+   compatible = "redboot-fis";
};
};
 };
diff --git a/target/linux/bcm63xx/dts/bcm6348-inventel-livebox-1.dts 
b/target/linux/bcm63xx/dts/bcm6348-inventel-livebox-1.dts
index df204cc51ebf..0b541c608111 100644
--- a/target/linux/bcm63xx/dts/bcm6348-inventel-livebox-1.dts
+++ b/target/linux/bcm63xx/dts/bcm6348-inventel-livebox-1.dts
@@ -75,7 +75,7 @@
status = "okay";
 
partitions {
-   compatible = "ecoscentric,redboot-fis-partitions";
+   compatible = "redboot-fis";
};
 };
 
diff --git a/target/linux/gemini/image/Makefile 
b/target/linux/gemini/image/Makefile
index c84f1926dd53..3fce3172ed63 100644
--- a/target/linux/gemini/image/Makefile
+++ b/target/linux/gemini/image/Makefile
@@ -215,8 +215,8 @@ TARGET_DEVICES += storlink_sl93512r
 
 # The wiliboard images need some changes to be functional and buildable.
 #
-# The dts would need to use the ecoscentric,redboot-fis-partitions partition
-# parser to get the correct partition offsets and size.
+# The dts would need to use the redboot-fis partition parser to get
+# the correct partition offsets and size.
 #
 # The mkfwimage2 call need to be adjusted to reflect the real size of kernel
 # and rootfs. It is expected that the OEM firmware adjusts the on flash
diff --git 
a/target/linux/generic/pending-5.10/419-mtd-redboot-add-of_match_table-with-DT-binding.patch
 
b/target/linux/generic/pending-5.10/419-mtd-redboot-add-of_match_table-with-DT-binding.patch
deleted file mode 100644
index 7692f484ae0c..
--- 
a/target/linux/generic/pending-5.10/419-mtd-redboot-add-of_match_table-with-DT-binding.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= 
-Subject: [PATCH] mtd: redboot: add of_match_table with DT binding
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-This allows parsing RedBoot compatible partitions for properly described
-flash device in DT.
-
-Signed-off-by: Rafa?? Mi??ecki 

-
 a/drivers/mtd/parsers/redboot.c
-+++ b/drivers/mtd/parsers/redboot.c
-@@ -305,6 +305,7 @@ static int parse_redboot_partitions(stru
- 
- static const struct of_device_id mtd_parser_redboot_of_match_table[] = {
-   { .compatible = "redboot-fis" },
-+  { .compatible = "ecoscentric,redboot-fis-partitions" },
-   {},
- };
- MODULE_DEVICE_TABLE(of, mtd_parser_redboot_of_match_table);
diff --git 
a/target/linux/generic/pending-5.15/419-mtd-redboot-add-of_match_table-with-DT-binding.patch
 
b/target/linux/generic/pending-5.15/419-mtd-redboot-add-of_match_table-with-DT-binding.patch
deleted file mode 100644
index 3d176f85635d..
--- 
a/target/linux/generic/pending-5.15/419-mtd-redboot-add-of_match_table-with-DT-binding.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= 
-Subject: [PATCH] mtd: redboot: add of_match_table with DT binding
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-This allows parsing RedBoot compatible partitions for properly described
-flash device in DT.
-
-Signed-off-by: Rafa?? Mi??ecki 

-
 a/drivers/mtd/parsers/redboot.c
-+++ b/drivers/mtd/parsers/redboot.c
-@@ -304,6 +304,7 @@ nogood:
- 
- static const struct of_device_id mtd_parser_redboot_of_match_table[] = {
-   { .compatible = "redboot-fis" },
-+  { .compatible = "ecoscentric,redboot-fis-partitions" },
-   {},
- };
- MODULE_DEVICE_TABLE(of, mtd_parser_redboot_of_match_table);
-- 
2.35.1


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


[PATCH v2 7/7] ath79: bsap18x0: specify FIS directory location in dts

2022-03-27 Thread Tomasz Maciej Nowak
The redboot-fis parser has option to specify the location of FIS
directory, use that, instead of patching the parser to scan for it, and
specifying location in kernel config.

Tested-by: Brian Gonyer 
Signed-off-by: Tomasz Maciej Nowak 
---
 .../ath79/dts/ar7161_adtran_bsap1880.dtsi |  1 +
 target/linux/ath79/generic/config-default |  1 -
 .../408-mtd-redboot_partition_scan.patch  | 44 ---
 3 files changed, 1 insertion(+), 45 deletions(-)
 delete mode 100644 
target/linux/ath79/patches-5.10/408-mtd-redboot_partition_scan.patch

diff --git a/target/linux/ath79/dts/ar7161_adtran_bsap1880.dtsi 
b/target/linux/ath79/dts/ar7161_adtran_bsap1880.dtsi
index d711ca92d3f4..a4cd6b4c8d7d 100644
--- a/target/linux/ath79/dts/ar7161_adtran_bsap1880.dtsi
+++ b/target/linux/ath79/dts/ar7161_adtran_bsap1880.dtsi
@@ -88,6 +88,7 @@
#address-cells = <1>;
#size-cells = <1>;
compatible = "redboot-fis";
+   fis-index-block = <0xfd>;
};
};
 };
diff --git a/target/linux/ath79/generic/config-default 
b/target/linux/ath79/generic/config-default
index 0ac756642fe1..6739aa08d443 100644
--- a/target/linux/ath79/generic/config-default
+++ b/target/linux/ath79/generic/config-default
@@ -13,7 +13,6 @@ CONFIG_IP17XX_PHY=y
 CONFIG_LEDS_RESET=y
 CONFIG_MARVELL_PHY=y
 CONFIG_MICREL_PHY=y
-CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-3
 CONFIG_MTD_REDBOOT_PARTS=y
 CONFIG_MTD_SPLIT_EVA_FW=y
 CONFIG_PHY_AR7100_USB=y
diff --git 
a/target/linux/ath79/patches-5.10/408-mtd-redboot_partition_scan.patch 
b/target/linux/ath79/patches-5.10/408-mtd-redboot_partition_scan.patch
deleted file mode 100644
index e5b06e14a568..
--- a/target/linux/ath79/patches-5.10/408-mtd-redboot_partition_scan.patch
+++ /dev/null
@@ -1,44 +0,0 @@
 a/drivers/mtd/parsers/redboot.c
-+++ b/drivers/mtd/parsers/redboot.c
-@@ -90,12 +90,18 @@ static int parse_redboot_partitions(stru
- 
-   parse_redboot_of(master);
- 
-+  buf = vmalloc(master->erasesize);
-+  if (!buf)
-+  return -ENOMEM;
-+
-+ restart:
-   if ( directory < 0 ) {
-   offset = master->size + directory * master->erasesize;
-   while (mtd_block_isbad(master, offset)) {
-   if (!offset) {
-   nogood:
-   printk(KERN_NOTICE "Failed to find a non-bad 
block to check for RedBoot partition table\n");
-+  vfree(buf);
-   return -EIO;
-   }
-   offset -= master->erasesize;
-@@ -108,10 +114,6 @@ static int parse_redboot_partitions(stru
-   goto nogood;
-   }
-   }
--  buf = vmalloc(master->erasesize);
--
--  if (!buf)
--  return -ENOMEM;
- 
-   printk(KERN_NOTICE "Searching for RedBoot partition table in %s at 
offset 0x%lx\n",
-  master->name, offset);
-@@ -184,6 +186,11 @@ static int parse_redboot_partitions(stru
-   }
-   if (i == numslots) {
-   /* Didn't find it */
-+  if (offset + master->erasesize < master->size) {
-+  /* not at the end of the flash yet, maybe next block :) 
*/
-+  directory++;
-+  goto restart;
-+  }
-   printk(KERN_NOTICE "No RedBoot partition table detected in 
%s\n",
-  master->name);
-   ret = 0;
-- 
2.35.1


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


[PATCH v2 2/7] ath79: switch some RedBoot based divices to OKLI loader

2022-03-27 Thread Tomasz Maciej Nowak
After the kernel has switched version to 5.10, JA76PF2 and
RouterStations lost the capability to sysupgrade the OpenWrt version.
The cause is the lack of porting the patches responsible for partial
flash erase block writing and these boards FIS directory and RedBoot
config partitions share the same erase block. Because of that the FIS
directory can't be updated to accommodate kernel/rootfs partition size
changes. This could be remedied by bootloader update, but it is very
intrusive and could potentially lead to non-trivial recovery procedure,
if something went wrong. The less difficult option is to use OpenWrt
kernel loader, which will let us use static partition sizes and employ
mtd splitter, to dynamically adjust kernel and rootfs partition sizes.
On sysupgrade from ath79 19.07 or 21.02 image, which still let to modify
FIS directory, the loader will be written to kernel partition, while the
kernel+rootfs to rootfs partition.

The caveats are:
* image format changes, no possible upgrade from ar71xx target images
* downgrade to any older OpenWrt version will require TFTP recovery or
  usage of bootloader command line interface

To downgrade to 19.07 or 21.02, or to upgrade if one is already on
OpenWrt with kernel 5.10, for RouterStations use TFTP recovery
procedure. For JA76PF2 use instructions from this commit message:
0cc87b3bacee (" ath79: image: disable sysupgrade images for
routerstations and ja76pf2"), replacing kernel image with loader
(loader.bin suffix) and rootfs image with firmware (firmware.bin
suffix).

Fixes: 15aa53d7ee65 ("ath79: switch to Kernel 5.10")
Signed-off-by: Tomasz Maciej Nowak 
---
 .../linux/ath79/dts/ar7161_jjplus_ja76pf2.dts | 39 ++-
 .../ath79/dts/ar7161_ubnt_routerstation.dtsi  | 35 -
 .../etc/uci-defaults/05_fix-compat-version|  5 ++-
 .../base-files/lib/upgrade/platform.sh| 20 +-
 target/linux/ath79/image/Makefile |  8 
 target/linux/ath79/image/generic-ubnt.mk  | 26 -
 target/linux/ath79/image/generic.mk   | 25 
 7 files changed, 120 insertions(+), 38 deletions(-)

diff --git a/target/linux/ath79/dts/ar7161_jjplus_ja76pf2.dts 
b/target/linux/ath79/dts/ar7161_jjplus_ja76pf2.dts
index 93a029964a63..bcb017c88c54 100644
--- a/target/linux/ath79/dts/ar7161_jjplus_ja76pf2.dts
+++ b/target/linux/ath79/dts/ar7161_jjplus_ja76pf2.dts
@@ -4,6 +4,7 @@
 
 #include 
 #include 
+#include 
 
 / {
model = "jjPlus JA76PF2";
@@ -124,9 +125,45 @@
spi-max-frequency = <2500>;
 
partitions {
+   compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
-   compatible = "ecoscentric,redboot-fis-partitions";
+
+   partition@0 {
+   label = "RedBoot";
+   reg = <0x00 0x04>;
+   read-only;
+   };
+
+   partition@4 {
+   label = "loader";
+   reg = <0x04 0x02>;
+   };
+
+   partition@6 {
+   label = "firmware";
+   reg = <0x06 0xf8>;
+   compatible = "openwrt,uimage", "denx,uimage";
+   openwrt,ih-magic = ;
+   };
+
+   partition@fe {
+   label = "FIS directory";
+   reg = <0xfe 0x00f000>;
+   read-only;
+   };
+
+   partition@fef000 {
+   label = "RedBoot config";
+   reg = <0xfef000 0x001000>;
+   read-only;
+   };
+
+   partition@ff {
+   label = "Atheros Board Data";
+   reg = <0xff 0x1>;
+   read-only;
+   };
};
};
 };
diff --git a/target/linux/ath79/dts/ar7161_ubnt_routerstation.dtsi 
b/target/linux/ath79/dts/ar7161_ubnt_routerstation.dtsi
index 116bc9cfc2ff..172b0af1eb3b 100644
--- a/target/linux/ath79/dts/ar7161_ubnt_routerstation.dtsi
+++ b/target/linux/ath79/dts/ar7161_ubnt_routerstation.dtsi
@@ -4,6 +4,7 @@
 
 #include 
 #include 
+#include 
 
 / {
aliases {
@@ -62,7 +63,39 @@
spi-max-frequency = <2500>;
 
partitions {
-   compatible = "ecoscentric,redboot-fis-partitions";
+   compatible = "fixed-partitions";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   partition@0 {
+   

[PATCH v2 3/7] ath79: move image check for devices with RedBoot

2022-03-27 Thread Tomasz Maciej Nowak
Don't comence the switch to RAMFS when the image format is wrong. This
led to rebooting the device, which could lead to false impression that
upgrade succeded.
Being here, factor out the code responsible for upgrading RedBoot
devices to separate file.

Signed-off-by: Tomasz Maciej Nowak 
---
 .../base-files/lib/upgrade/platform.sh| 46 ++-
 .../base-files/lib/upgrade/redboot-fis.sh | 31 +
 2 files changed, 46 insertions(+), 31 deletions(-)
 create mode 100644 
target/linux/ath79/generic/base-files/lib/upgrade/redboot-fis.sh

diff --git a/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh 
b/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh
index 642a9891ff29..f161540a6877 100644
--- a/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh
@@ -8,35 +8,19 @@ REQUIRE_IMAGE_METADATA=1
 RAMFS_COPY_BIN='fw_printenv fw_setenv'
 RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
 
-redboot_fis_do_upgrade() {
-   local append
-   local sysup_file="$1"
-   local kern_part="$2"
-   local magic=$(get_magic_word "$sysup_file")
-
-   if [ "$magic" = "7379" ]; then
-   local board_dir=$(tar tf $sysup_file | grep -m 1 
'^sysupgrade-.*/$')
-
-   [ -f "$UPGRADE_BACKUP" ] && append="-j $UPGRADE_BACKUP"
-
-   if grep -q "mtd1.*loader" /proc/mtd; then
-   tar xf $sysup_file ${board_dir}kernel ${board_dir}root 
-O | \
-   mtd -r $append write - loader:firmware
-
-   else
-   local kern_length=$(tar xf $sysup_file 
${board_dir}kernel -O | wc -c)
-
-   tar xf $sysup_file ${board_dir}kernel ${board_dir}root 
-O | \
-   mtd -r $append 
-F$kern_part:$kern_length:0x8006,rootfs write - $kern_part:rootfs
-   fi
-   else
-   echo "Unknown image, aborting!"
-   return 1
-   fi
-}
-
 platform_check_image() {
-   return 0
+   local board=$(board_name)
+
+   case "$board" in
+   jjplus,ja76pf2|\
+   ubnt,routerstation|\
+   ubnt,routerstation-pro)
+   platform_check_image_redboot_fis "$1"
+   ;;
+   *)
+   return 0
+   ;;
+   esac
 }
 
 platform_do_upgrade() {
@@ -45,7 +29,7 @@ platform_do_upgrade() {
case "$board" in
adtran,bsap1800-v2|\
adtran,bsap1840)
-   redboot_fis_do_upgrade "$1" vmlinux_2
+   platform_do_upgrade_redboot_fis "$1" vmlinux_2
;;
allnet,all-wap02860ac|\
araknis,an-300-ap-i-n|\
@@ -66,7 +50,7 @@ platform_do_upgrade() {
platform_do_upgrade_failsafe_datachk "$1"
;;
jjplus,ja76pf2)
-   redboot_fis_do_upgrade "$1" linux
+   platform_do_upgrade_redboot_fis "$1" linux
;;
openmesh,a40|\
openmesh,a60|\
@@ -98,7 +82,7 @@ platform_do_upgrade() {
;;
ubnt,routerstation|\
ubnt,routerstation-pro)
-   redboot_fis_do_upgrade "$1" kernel
+   platform_do_upgrade_redboot_fis "$1" kernel
;;
*)
default_do_upgrade "$1"
diff --git a/target/linux/ath79/generic/base-files/lib/upgrade/redboot-fis.sh 
b/target/linux/ath79/generic/base-files/lib/upgrade/redboot-fis.sh
new file mode 100644
index ..f45d9a2e790e
--- /dev/null
+++ b/target/linux/ath79/generic/base-files/lib/upgrade/redboot-fis.sh
@@ -0,0 +1,31 @@
+platform_check_image_redboot_fis() {
+   if [ "$(get_magic_word "$1")" != "7379" ]; then
+   v "Unknown image format, aborting!"
+   return 1
+   else
+   return 0
+   fi
+}
+
+platform_do_upgrade_redboot_fis() {
+   local append
+   local sysup_file="$1"
+   local kern_part="$2"
+
+   if [ "$(get_magic_word "$sysup_file")" = "7379" ]; then
+   local board_dir=$(tar tf $sysup_file | grep -m 1 
'^sysupgrade-.*/$')
+
+   [ -f "$UPGRADE_BACKUP" ] && append="-j $UPGRADE_BACKUP"
+
+   if grep -q "mtd1.*loader" /proc/mtd; then
+   tar xf $sysup_file ${board_dir}kernel ${board_dir}root 
-O | \
+   mtd -r $append write - loader:firmware
+
+   else
+   local kern_length=$(tar xf $sysup_file 
${board_dir}kernel -O | wc -c)
+
+   tar xf $sysup_file ${board_dir}kernel ${board_dir}root 
-O | \
+   mtd -r $append 
-F$kern_part:$kern_length:0x8006,rootfs write - $kern_part:rootfs
+   fi
+   fi
+}
-- 
2.35.1


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


[PATCH v2 5/7] ath79: bsap18x0: pad rootfs image

2022-03-27 Thread Tomasz Maciej Nowak
This image is supposed to be written with help of bootloader to the
flash, but as it stands, it's not aligned to block size and RedBoot will
happily create non-aligned partition size in FIS directory. This could
lead to kernel to mark the partition as read-only, therefore pad the
image to block erase size boundary.

Signed-off-by: Tomasz Maciej Nowak 
---
 target/linux/ath79/image/generic.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/linux/ath79/image/generic.mk 
b/target/linux/ath79/image/generic.mk
index 24bd12d652b6..bc078efad53e 100644
--- a/target/linux/ath79/image/generic.mk
+++ b/target/linux/ath79/image/generic.mk
@@ -208,7 +208,7 @@ define Device/adtran_bsap1880
   IMAGE_SIZE := 11200k
   IMAGES += kernel.bin rootfs.bin
   IMAGE/kernel.bin := append-kernel
-  IMAGE/rootfs.bin := append-rootfs | pad-rootfs
+  IMAGE/rootfs.bin := append-rootfs | pad-rootfs | pad-to $$(BLOCKSIZE)
   IMAGE/sysupgrade.bin := append-rootfs | pad-rootfs | \
check-size | sysupgrade-tar rootfs=@ | append-metadata
 endef
-- 
2.35.1


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


[PATCH v2 4/7] ath79: ja76pf2: use nvmem cells to specify MAC adresses

2022-03-27 Thread Tomasz Maciej Nowak
The bootloader on this board hid the partition containig MAC addresses
and prevented adding this space to FIS directory, therefore those had to
be stored in RedBoot configuration as aliases to be able to assigne them
to proper interfaces. Now that fixed partition size are used instead of
redboot-fis parser, the partition containig MAC adresses could be
specified, and with marking it as nvmem cell, we can assign them without
userspace involvement.

Signed-off-by: Tomasz Maciej Nowak 
---
 target/linux/ath79/dts/ar7161_jjplus_ja76pf2.dts  | 15 +++
 .../generic/base-files/etc/board.d/02_network |  4 
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/target/linux/ath79/dts/ar7161_jjplus_ja76pf2.dts 
b/target/linux/ath79/dts/ar7161_jjplus_ja76pf2.dts
index bcb017c88c54..a3d66da61414 100644
--- a/target/linux/ath79/dts/ar7161_jjplus_ja76pf2.dts
+++ b/target/linux/ath79/dts/ar7161_jjplus_ja76pf2.dts
@@ -103,12 +103,16 @@
  {
status = "okay";
 
+   nvmem-cells = <_lan>;
+   nvmem-cell-names = "mac-address";
phy-handle = <>;
 };
 
  {
status = "okay";
 
+   nvmem-cells = <_wan>;
+   nvmem-cell-names = "mac-address";
phy-handle = <>;
 };
 
@@ -163,6 +167,17 @@
label = "Atheros Board Data";
reg = <0xff 0x1>;
read-only;
+   compatible = "nvmem-cells";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   macaddr_wan: macaddr@1000 {
+   reg = <0x1000 0x6>;
+   };
+
+   macaddr_lan: macaddr@1006 {
+   reg = <0x1006 0x6>;
+   };
};
};
};
diff --git a/target/linux/ath79/generic/base-files/etc/board.d/02_network 
b/target/linux/ath79/generic/base-files/etc/board.d/02_network
index bc32081910f8..a1d0a922c8b9 100644
--- a/target/linux/ath79/generic/base-files/etc/board.d/02_network
+++ b/target/linux/ath79/generic/base-files/etc/board.d/02_network
@@ -651,10 +651,6 @@ ath79_setup_macs()
wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
label_mac=$wan_mac
;;
-   jjplus,ja76pf2)
-   wan_mac=$(fconfig -s -r -d $(find_mtd_part "RedBoot config") -n 
alias/ethaddr)
-   lan_mac=$(macaddr_add "$wan_mac" 1)
-   ;;
mercury,mw4530r-v1|\
tplink,tl-wdr3600-v1|\
tplink,tl-wdr4300-v1|\
-- 
2.35.1


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


[PATCH v2 1/7] ath79: jj76pf2: enable TCN75 sensor

2022-03-27 Thread Tomasz Maciej Nowak
This SBC has Microchip TCN75 sensor, wich measures ambient temperature.
Specify it in dts to allow readout by applications using kernel hwmon
API.

Signed-off-by: Tomasz Maciej Nowak 
---
 target/linux/ath79/dts/ar7161_jjplus_ja76pf2.dts | 13 +
 target/linux/ath79/image/generic.mk  |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/target/linux/ath79/dts/ar7161_jjplus_ja76pf2.dts 
b/target/linux/ath79/dts/ar7161_jjplus_ja76pf2.dts
index 826b45ff513e..93a029964a63 100644
--- a/target/linux/ath79/dts/ar7161_jjplus_ja76pf2.dts
+++ b/target/linux/ath79/dts/ar7161_jjplus_ja76pf2.dts
@@ -32,6 +32,19 @@
clock-frequency = <4000>;
};
 
+   i2c {
+   compatible = "i2c-gpio";
+   sda-gpios = < 1 GPIO_ACTIVE_HIGH>;
+   scl-gpios = < 0 GPIO_ACTIVE_HIGH>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   sensor@48 {
+   compatible = "microchip,tcn75";
+   reg = <0x48>;
+   };
+   };
+
leds {
compatible = "gpio-leds";
 
diff --git a/target/linux/ath79/image/generic.mk 
b/target/linux/ath79/image/generic.mk
index 769c0ee1dab5..9d94c79212cc 100644
--- a/target/linux/ath79/image/generic.mk
+++ b/target/linux/ath79/image/generic.mk
@@ -1452,7 +1452,7 @@ define Device/jjplus_ja76pf2
   SOC := ar7161
   DEVICE_VENDOR := jjPlus
   DEVICE_MODEL := JA76PF2
-  DEVICE_PACKAGES += -kmod-ath9k -swconfig -wpad-basic-wolfssl -uboot-envtools 
fconfig
+  DEVICE_PACKAGES += -kmod-ath9k -swconfig -wpad-basic-wolfssl -uboot-envtools 
fconfig kmod-hwmon-lm75
   IMAGES += kernel.bin rootfs.bin
   IMAGE/kernel.bin := append-kernel
   IMAGE/rootfs.bin := append-rootfs | pad-rootfs
-- 
2.35.1


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


[PATCH v2 0/7] ath79: RedBoot devices cleanup and improvment

2022-03-27 Thread Tomasz Maciej Nowak
Main changes revolve around changing the image format for devices which
share FIS directory and RedBoot config on same flash erase block and
cleanup following aftermath of this change.

Tomasz Maciej Nowak (7):
v1 -> v2
  ath79: jj76pf2: enable TCN75 sensor
- none
  ath79: switch some RedBoot based divices to OKLI loader
- add Fixes: tag
  ath79: move image check for devices with RedBoot
- none
  ath79: ja76pf2: use nvmem cells to specify MAC adresses
- none
  ath79: bsap18x0: pad rootfs image
- none
  treewide: use upstream compatible for RedBoot FIS parser
- rebase
  ath79: bsap18x0: specify FIS directory location in dts
- replaced/extended "ath79: remove patch scaning for FIS directory"

 .../ath79/dts/ar7161_adtran_bsap1880.dtsi |  3 +-
 .../linux/ath79/dts/ar7161_jjplus_ja76pf2.dts | 67 ++-
 .../ath79/dts/ar7161_ubnt_routerstation.dtsi  | 35 +-
 .../generic/base-files/etc/board.d/02_network |  4 --
 .../etc/uci-defaults/05_fix-compat-version|  5 +-
 .../base-files/lib/upgrade/platform.sh| 46 +
 .../base-files/lib/upgrade/redboot-fis.sh | 31 +
 target/linux/ath79/generic/config-default |  1 -
 target/linux/ath79/image/Makefile |  8 ---
 target/linux/ath79/image/generic-ubnt.mk  | 26 ---
 target/linux/ath79/image/generic.mk   | 29 +---
 .../408-mtd-redboot_partition_scan.patch  | 44 
 .../dts/bcm6348-inventel-livebox-1.dts|  2 +-
 target/linux/gemini/image/Makefile|  4 +-
 ...t-add-of_match_table-with-DT-binding.patch | 22 --
 ...t-add-of_match_table-with-DT-binding.patch | 22 --
 16 files changed, 191 insertions(+), 158 deletions(-)
 create mode 100644 
target/linux/ath79/generic/base-files/lib/upgrade/redboot-fis.sh
 delete mode 100644 
target/linux/ath79/patches-5.10/408-mtd-redboot_partition_scan.patch
 delete mode 100644 
target/linux/generic/pending-5.10/419-mtd-redboot-add-of_match_table-with-DT-binding.patch
 delete mode 100644 
target/linux/generic/pending-5.15/419-mtd-redboot-add-of_match_table-with-DT-binding.patch

-- 
2.35.1


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


Re: [PATCH] ipq40xx: add support for Sony NCP-HG100/Cellular

2022-03-27 Thread Christian Lamparter
Hi,

On Sun, Mar 27, 2022 at 10:22 AM INAGAKI Hiroshi
 wrote:
>
> Sony NCP-HG100/Cellular is a IoT Gateway with 2.4/5 GHz band 11ac
> (WiFi-5) wireless function, based on IPQ4019.
>
> Specification:
>
> - SoC   : Qualcomm IPQ4019
> - RAM   : DDR3 512 MiB (H5TC4G63EFR)
> - Flash : eMMC 4 GiB (THGBMNG5D1LBAIT)
> - WLAN  : 2.4/5 GHz 2T2R (IPQ4019)
> - Ethernet  : 10/100/1000 Mbps x2
>   - Transceiver : Qualcomm QCA8072
> - WWAN  : Telit LN940A9
> - Z-Wave: Silicon Labs ZM5101
> - Bluetooth : Qualcomm CSR8811
> - Audio DAC : Realtek ALC5629
> - Audio Amp.: Realtek ALC1304
> - Voice Input Processor : Conexant CX20924
> - Micro Controller Unit : Nuvoton MINI54FDE
>   - RGB LED, Fan, Temp. sensors
> - Touch Sensor  : Cypress CY8C4014LQI
> - RGB LED driver: TI LP55231 (2x)
> - LEDs/Keys : 11x, 6x
> - UART  : through-hole on PCB
>   - J1: 3.3V, TX, RX, GND from tri-angle marking
>   - 115200n8
> - Power : 12 VDC, 2.5 A
>
> Flash instruction using initramfs image:
>
> 1. Prepare TFTP server with the IP address 192.168.132.100 and place the
>initramfs image to TFTP directory with the name "C0A88401.img"
>
> 2. Boot NCP-HG100/Cellular and interrupt after the message
>"Hit any key to stop autoboot:  2"
>
> 3. Perform the following commands and set bootcmd to allow booting from
>eMMC
>
>setenv bootcmd "mmc read 0x8400 0x2e22 0x4000 && bootm 0x8400"
>saveenv
>
> 4. Perform the following command to load/boot the OpenWrt initramfs image
>
>tftpboot && bootm
>
> 5. On the initramfs image, perform sysupgrade with the sysupgrade image
>(if needed, backup eMMC partitions by dd command and download to
>other place before performing sysupgrade)
>
> 6. Wait for ~120 seconds to complete flashing
>
> Known issues:
>
> - The primary uart is shared for debug console and Z-Wave chip. To use
>   it for debug console on OpenWrt, Z-Wave chip cannot be used.
>
> - There are no drivers for audio-related chips/functions in Linux Kernel
>   and OpenWrt, they cannot be used.
>
> - There is no driver for MINI54FDE Micro-Controller Unit, customized for
>   this device by the firmware in the MCU. This chip controls the
>   following functions, but they cannot be controlled in OpenWrt.
>
>   - RGB LED
>   - Fan
>   - Thermal Sensors (2x)

Does the MCU do adequate thermal control even without input from the
kernel/userspace? Don't want to let it overheat.

>
> - Currently, there is no driver or tool for CY8C4014LQI and cannot be
>   controlled. It cannot be exited from "booting mode" and moved to "normal
>   op mode" after booting. And also, the 4x buttons (mic mute, vol down,
>   vol up, alexa trigger) connected to the IC cannot be controlled.
>
>   - it can be exited from "booting mode" by installing and executing
> i2cset command:
>
> opkg update
> opkg install i2c-tools
> i2cset -y 1 0x14 0xf 1
>
> - There is a connection issue on the control by uqmi for the WWAN module.
>   But modemmanager can be used without any issues and the use of it is
>   recommended.
>
> - With the F2FS format, too many errors are reported on erasing eMMC
>   partition "rootfs_data" while booting:
>
>   [1.360270] sdhci: Secure Digital Host Controller Interface driver
>   [1.363636] sdhci: Copyright(c) Pierre Ossman
>   [1.369730] sdhci-pltfm: SDHCI platform and OF driver helper
>   [1.374729] sdhci_msm 7824900.sdhci: Got CD GPIO
>   ...
>   [1.413552] mmc0: SDHCI controller on 7824900.sdhci [7824900.sdhci] 
> using ADMA 64-bit
>   [1.528325] mmc0: new HS200 MMC card at address 0001
>   [1.530627] mmcblk0: mmc0:0001 004GA0 3.69 GiB
>   [1.533530] mmcblk0boot0: mmc0:0001 004GA0 partition 1 2.00 MiB
>   [1.537831] mmcblk0boot1: mmc0:0001 004GA0 partition 2 2.00 MiB
>   [1.542918] mmcblk0rpmb: mmc0:0001 004GA0 partition 3 512 KiB, chardev 
> (247:0)
>   [1.550323] Alternate GPT is invalid, using primary GPT.
>   [1.561669]  mmcblk0: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 
> p16 p17
>   ...
>   [8.841400] mount_root: loading kmods from internal overlay
>   [8.860241] kmodloader: loading kernel modules from 
> //etc/modules-boot.d/*
>   [8.863746] kmodloader: done loading kernel modules from 
> //etc/modules-boot.d/*
>   [9.240465] block: attempting to load /etc/config/fstab
>   [9.246722] block: unable to load configuration (fstab: Entry not found)
>   [9.246863] block: no usable configuration
>   [9.254883] mount_root: overlay filesystem in /dev/mmcblk0p17 has not 
> been formatted yet
>   [9.438915] urandom_read: 5 callbacks suppressed
>   [9.438924] random: mkfs.f2fs: uninitialized urandom read (16 bytes read)
>   [   12.243332] mmc_erase: erase error -110, status 0x800
>   [   12.246638] mmc0: cache flush 

[sdwalker/sdwalker.github.io] 62ea47: This week's update

2022-03-27 Thread Stephen Walker via openwrt-devel
The sender domain has a DMARC Reject/Quarantine policy which disallows
sending mailing list messages using the original "From" header.

To mitigate this problem, the original message has been wrapped
automatically by the mailing list software.--- Begin Message ---
  Branch: refs/heads/master
  Home:   https://github.com/sdwalker/sdwalker.github.io
  Commit: 62ea4738ba2e08b4f00d7d589c71a7adc2429272
  
https://github.com/sdwalker/sdwalker.github.io/commit/62ea4738ba2e08b4f00d7d589c71a7adc2429272
  Author: Stephen Walker 
  Date:   2022-03-27 (Sun, 27 Mar 2022)

  Changed paths:
M uscan/index-19.07.html
M uscan/index-21.02.html
M uscan/index.html
M uscan/js/sort.js

  Log Message:
  ---
  This week's update



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


[PATCH v2] ath79: add support for Ubiquiti NanoBeam M5

2022-03-27 Thread git
From: Jan-Niklas Burfeind 

Ubiquiti NanoBeam M5 devices are CPE equipment for customer locations
with one Ethernet port and a 5 GHz 300Mbps wireless interface.

Specificatons:

- Atheros AR9342
- 535 MHz CPU
- 64 MB RAM
- 8 MB Flash
- 1x 10/100 Mbps Ethernet with passive PoE input (24 V)
- 6 LEDs of which four are rssi
- 1 reset button
- UART (4-pin) header on PCB

Notes:

The device was supported by OpenWrt in ar71xx.

Flash instructions (web/ssh/tftp):

Loading the image via ssh vias a stock firmware prior "AirOS 5.6".
Downgrading stock is possible.

* Flashing is possible via AirOS software update page:
The "factory" ROM image is recognized as non-native and then installed 
correctly.
AirOS warns to better be familiar with the recovery procedure.

* Flashing can be done via ssh, which is becoming difficult due to legacy
keyexchange methods.

This is an exempary ssh-config:
KexAlgorithms +diffie-hellman-group1-sha1
HostKeyAlgorithms ssh-rsa
PubkeyAcceptedKeyTypes ssh-rsa
User ubnt

The password is ubnt.

Connecting via IPv6 link local worked best for me.

1. scp the factory image to /tmp
2. fwupdate.real -m /tmp/firmware_image_file.bin -d

* Alternatively tftp is possible:

1. Configure PC with static IP 192.168.1.2/24.
2. Enter the rescue mode. Power off the device, push the reset button on
   the device (or the PoE) and keep it pressed.
   Power on the device, while still pushing the reset button.
3. When all the leds blink at the same time, release the reset button.
4. Upload the firmware image file via TFTP:

tftp 192.168.1.20
tftp> bin
tftp> trace
Packet tracing on.
tftp> put firmware_image.bin

Signed-off-by: Jan-Niklas Burfeind 
---
 .../ath79/dts/ar9342_ubnt_nanobeam-m5.dts | 26 +++
 target/linux/ath79/image/generic-ubnt.mk  |  8 ++
 2 files changed, 34 insertions(+)
 create mode 100644 target/linux/ath79/dts/ar9342_ubnt_nanobeam-m5.dts

diff --git a/target/linux/ath79/dts/ar9342_ubnt_nanobeam-m5.dts 
b/target/linux/ath79/dts/ar9342_ubnt_nanobeam-m5.dts
new file mode 100644
index 00..6de557d990
--- /dev/null
+++ b/target/linux/ath79/dts/ar9342_ubnt_nanobeam-m5.dts
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "ar9342_ubnt_xw.dtsi"
+
+/ {
+   compatible = "ubnt,nanostation-loco-m-xw", "ubnt,xw", "qca,ar9342";
+   model = "Ubiquiti NanoBeam M5";
+};
+
+ {
+   status = "okay";
+
+   phy-mask = <0x1>;
+
+   phy1: ethernet-phy@1 {
+   reg = <1>;
+   phy-mode = "mii";
+   reset-gpios = < 0 GPIO_ACTIVE_LOW>;
+   };
+};
+
+ {
+   status = "okay";
+
+   phy-handle = <>;
+};
diff --git a/target/linux/ath79/image/generic-ubnt.mk 
b/target/linux/ath79/image/generic-ubnt.mk
index 0b613df62b..9de83d42c2 100644
--- a/target/linux/ath79/image/generic-ubnt.mk
+++ b/target/linux/ath79/image/generic-ubnt.mk
@@ -255,6 +255,14 @@ define Device/ubnt_nanobeam-ac-xc
 endef
 TARGET_DEVICES += ubnt_nanobeam-ac-xc
 
+define Device/ubnt_nanobeam-m5
+  $(Device/ubnt-xw)
+  DEVICE_MODEL := NanoBeam M5
+  DEVICE_PACKAGES += rssileds
+  SUPPORTED_DEVICES += loco-m-xw
+endef
+TARGET_DEVICES += ubnt_nanobeam-m5
+
 define Device/ubnt_nanobridge-m
   $(Device/ubnt-xm)
   SOC := ar7241
-- 
2.35.1


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


[PATCH] ipq40xx: add support for Sony NCP-HG100/Cellular

2022-03-27 Thread INAGAKI Hiroshi
Sony NCP-HG100/Cellular is a IoT Gateway with 2.4/5 GHz band 11ac
(WiFi-5) wireless function, based on IPQ4019.

Specification:

- SoC   : Qualcomm IPQ4019
- RAM   : DDR3 512 MiB (H5TC4G63EFR)
- Flash : eMMC 4 GiB (THGBMNG5D1LBAIT)
- WLAN  : 2.4/5 GHz 2T2R (IPQ4019)
- Ethernet  : 10/100/1000 Mbps x2
  - Transceiver : Qualcomm QCA8072
- WWAN  : Telit LN940A9
- Z-Wave: Silicon Labs ZM5101
- Bluetooth : Qualcomm CSR8811
- Audio DAC : Realtek ALC5629
- Audio Amp.: Realtek ALC1304
- Voice Input Processor : Conexant CX20924
- Micro Controller Unit : Nuvoton MINI54FDE
  - RGB LED, Fan, Temp. sensors
- Touch Sensor  : Cypress CY8C4014LQI
- RGB LED driver: TI LP55231 (2x)
- LEDs/Keys : 11x, 6x
- UART  : through-hole on PCB
  - J1: 3.3V, TX, RX, GND from tri-angle marking
  - 115200n8
- Power : 12 VDC, 2.5 A

Flash instruction using initramfs image:

1. Prepare TFTP server with the IP address 192.168.132.100 and place the
   initramfs image to TFTP directory with the name "C0A88401.img"

2. Boot NCP-HG100/Cellular and interrupt after the message
   "Hit any key to stop autoboot:  2"

3. Perform the following commands and set bootcmd to allow booting from
   eMMC

   setenv bootcmd "mmc read 0x8400 0x2e22 0x4000 && bootm 0x8400"
   saveenv

4. Perform the following command to load/boot the OpenWrt initramfs image

   tftpboot && bootm

5. On the initramfs image, perform sysupgrade with the sysupgrade image
   (if needed, backup eMMC partitions by dd command and download to
   other place before performing sysupgrade)

6. Wait for ~120 seconds to complete flashing

Known issues:

- The primary uart is shared for debug console and Z-Wave chip. To use
  it for debug console on OpenWrt, Z-Wave chip cannot be used.

- There are no drivers for audio-related chips/functions in Linux Kernel
  and OpenWrt, they cannot be used.

- There is no driver for MINI54FDE Micro-Controller Unit, customized for
  this device by the firmware in the MCU. This chip controls the
  following functions, but they cannot be controlled in OpenWrt.

  - RGB LED
  - Fan
  - Thermal Sensors (2x)

- Currently, there is no driver or tool for CY8C4014LQI and cannot be
  controlled. It cannot be exited from "booting mode" and moved to "normal
  op mode" after booting. And also, the 4x buttons (mic mute, vol down,
  vol up, alexa trigger) connected to the IC cannot be controlled.

  - it can be exited from "booting mode" by installing and executing
i2cset command:

opkg update
opkg install i2c-tools
i2cset -y 1 0x14 0xf 1

- There is a connection issue on the control by uqmi for the WWAN module.
  But modemmanager can be used without any issues and the use of it is
  recommended.

- With the F2FS format, too many errors are reported on erasing eMMC
  partition "rootfs_data" while booting:

  [1.360270] sdhci: Secure Digital Host Controller Interface driver
  [1.363636] sdhci: Copyright(c) Pierre Ossman
  [1.369730] sdhci-pltfm: SDHCI platform and OF driver helper
  [1.374729] sdhci_msm 7824900.sdhci: Got CD GPIO
  ...
  [1.413552] mmc0: SDHCI controller on 7824900.sdhci [7824900.sdhci] using 
ADMA 64-bit
  [1.528325] mmc0: new HS200 MMC card at address 0001
  [1.530627] mmcblk0: mmc0:0001 004GA0 3.69 GiB
  [1.533530] mmcblk0boot0: mmc0:0001 004GA0 partition 1 2.00 MiB
  [1.537831] mmcblk0boot1: mmc0:0001 004GA0 partition 2 2.00 MiB
  [1.542918] mmcblk0rpmb: mmc0:0001 004GA0 partition 3 512 KiB, chardev 
(247:0)
  [1.550323] Alternate GPT is invalid, using primary GPT.
  [1.561669]  mmcblk0: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 
p16 p17
  ...
  [8.841400] mount_root: loading kmods from internal overlay
  [8.860241] kmodloader: loading kernel modules from //etc/modules-boot.d/*
  [8.863746] kmodloader: done loading kernel modules from 
//etc/modules-boot.d/*
  [9.240465] block: attempting to load /etc/config/fstab
  [9.246722] block: unable to load configuration (fstab: Entry not found)
  [9.246863] block: no usable configuration
  [9.254883] mount_root: overlay filesystem in /dev/mmcblk0p17 has not been 
formatted yet
  [9.438915] urandom_read: 5 callbacks suppressed
  [9.438924] random: mkfs.f2fs: uninitialized urandom read (16 bytes read)
  [   12.243332] mmc_erase: erase error -110, status 0x800
  [   12.246638] mmc0: cache flush error -110
  [   15.134585] mmc_erase: erase error -110, status 0x800
  [   15.135891] mmc_erase: group start error -110, status 0x0
  [   15.139850] mmc_erase: group start error -110, status 0x0
  ...(too many the same errors)...
  [   17.350811] mmc_erase: group start error -110, status 0x0
  [   17.356197] mmc_erase: group start error -110, status 0x0
  [   17.439498] sdhci_msm 7824900.sdhci: