Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix readonly ubiquiti airmax #3141

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/user/supported_devices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ ath79-generic

* Ubiquiti

- NanoBeam 5AC 19 (XC)
- NanoBeam M5 (XW)
- NanoStation Loco M2/M5 (XW)
- NanoStation M2/M5 (XW)
- UniFi AC Lite
- UniFi AC LR
- UniFi AC Mesh
Expand Down
1 change: 1 addition & 0 deletions package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ if platform.match('ath79', 'generic', {
'tplink,wbs210-v1',
'tplink,wbs210-v2',
'tplink,wbs510-v1',
'ubnt,nanostation-m-xw',
'ubnt,unifi-ap-pro',
}) then
lan_ifname, wan_ifname = wan_ifname, lan_ifname
Expand Down
4 changes: 4 additions & 0 deletions package/gluon-core/luasrc/usr/lib/lua/gluon/platform.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ function M.is_outdoor_device()
'tplink,wbs210-v1',
'tplink,wbs210-v2',
'tplink,wbs510-v1',
'ubnt,nanobeam-ac-xc',
'ubnt,nanobeam-m5-xw',
'ubnt,nanostation-loco-m-xw',
'ubnt,nanostation-m-xw',
'ubnt,uk-ultra',
'ubnt,unifi-ap-outdoor-plus',
'ubnt,unifiac-mesh',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
From: David Bauer <[email protected]>
Date: Thu, 4 Jan 2024 12:47:08 +0100
Subject: mtd: spi-nor: add property to unlock entire chip

Add a new device-tree porperty "swp-disable" which can be added to
spi-nor OF-nodes to indicate the whole flash-chip should be unlocked.

This avoids changing the default behavior of all SPI-NOR chips and helps
to indicate devices which require the old kernel behavior explicitly.

Signed-off-by: David Bauer <[email protected]>
[backport to openwrt-23.05]
Signed-off-by: Tom Herbers <[email protected]>

diff --git a/target/linux/ath79/patches-5.15/401-mtd-nor-support-mtd-name-from-device-tree.patch b/target/linux/ath79/patches-5.15/401-mtd-nor-support-mtd-name-from-device-tree.patch
index 36f5331bd017f9727185889f33f0575c93397952..d0caed4d579ab1c3a18f5dffb32b7ab5ec91dfbc 100644
--- a/target/linux/ath79/patches-5.15/401-mtd-nor-support-mtd-name-from-device-tree.patch
+++ b/target/linux/ath79/patches-5.15/401-mtd-nor-support-mtd-name-from-device-tree.patch
@@ -10,7 +10,7 @@ Signed-off-by: Abhimanyu Vishwakarma <[email protected]>

--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
-@@ -3108,6 +3108,7 @@ int spi_nor_scan(struct spi_nor *nor, co
+@@ -3110,6 +3110,7 @@ int spi_nor_scan(struct spi_nor *nor, co
struct device *dev = nor->dev;
struct mtd_info *mtd = &nor->mtd;
struct device_node *np = spi_nor_get_flash_node(nor);
@@ -18,7 +18,7 @@ Signed-off-by: Abhimanyu Vishwakarma <[email protected]>
int ret;
int i;

-@@ -3162,7 +3163,12 @@ int spi_nor_scan(struct spi_nor *nor, co
+@@ -3164,7 +3165,12 @@ int spi_nor_scan(struct spi_nor *nor, co
if (ret)
return ret;

diff --git a/target/linux/generic/hack-5.15/400-mtd-spi-nor-add-property-to-unlock-entire-chip.patch b/target/linux/generic/hack-5.15/400-mtd-spi-nor-add-property-to-unlock-entire-chip.patch
new file mode 100644
index 0000000000000000000000000000000000000000..2ebac01bde5401d0a137058c2ed7fa777b31266d
--- /dev/null
+++ b/target/linux/generic/hack-5.15/400-mtd-spi-nor-add-property-to-unlock-entire-chip.patch
@@ -0,0 +1,34 @@
+From 228fcb0738a9e582a15666e717bb2fc5078c694c Mon Sep 17 00:00:00 2001
+From: David Bauer <[email protected]>
+Date: Thu, 4 Jan 2024 12:44:06 +0100
+Subject: [PATCH] mtd: spi-nor: add property to unlock entire chip
+
+Add a new device-tree porperty "swp-disable" which can be added to
+spi-nor OF-nodes to indicate the whole flash-chip should be unlocked.
+
+This avoids changing the default behavior of all SPI-NOR chips and helps
+to indicate devices which require the old kernel behavior explicitly.
+
+Signed-off-by: David Bauer <[email protected]>
+---
+ drivers/mtd/spi-nor/core.c | 2 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/drivers/mtd/spi-nor/core.c
++++ b/drivers/mtd/spi-nor/core.c
+@@ -2820,6 +2820,7 @@ static int spi_nor_quad_enable(struct sp
+
+ static int spi_nor_init(struct spi_nor *nor)
+ {
++ struct device_node *np = spi_nor_get_flash_node(nor);
+ int err;
+
+ err = spi_nor_octal_dtr_enable(nor, true);
+@@ -2845,6 +2846,7 @@ static int spi_nor_init(struct spi_nor *
+ * SNOR_F_SWP_IS_VOLATILE.
+ */
+ if (IS_ENABLED(CONFIG_MTD_SPI_NOR_SWP_DISABLE) ||
++ of_property_read_bool(np, "swp-disable") ||
+ (IS_ENABLED(CONFIG_MTD_SPI_NOR_SWP_DISABLE_ON_VOLATILE) &&
+ nor->flags & SNOR_F_SWP_IS_VOLATILE))
+ spi_nor_try_unlock_all(nor);
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
From: David Bauer <[email protected]>
Date: Sun, 7 Jan 2024 21:16:07 +0100
Subject: ath79: unlock full flash on Ubiquiti airMax boards

Instead of unlocking full flash on all devices, selectively unlock the
full flash on Ubiquiti airMax boards.

The flash unlock was only necessary on these boards in the first place.

Signed-off-by: David Bauer <[email protected]>
[added swp-disable flag for qca955x_ubnt_xc]
Signed-off-by: Tom Herbers <[email protected]>

diff --git a/target/linux/ath79/dts/ar724x_ubnt_xm.dtsi b/target/linux/ath79/dts/ar724x_ubnt_xm.dtsi
index 341d0bad0d6f700abfc4bbee69c776ed21839c93..66779042555705e57c9316342103098df12d6849 100644
--- a/target/linux/ath79/dts/ar724x_ubnt_xm.dtsi
+++ b/target/linux/ath79/dts/ar724x_ubnt_xm.dtsi
@@ -22,6 +22,7 @@
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <25000000>;
+ swp-disable;

partitions {
compatible = "fixed-partitions";
diff --git a/target/linux/ath79/dts/ar9342_ubnt_wa.dtsi b/target/linux/ath79/dts/ar9342_ubnt_wa.dtsi
index ba0f7ad23e52940b1bc4ec2971a8d8e8c73062a6..60d930e434a866a6a891814b7eaec1025d898aef 100644
--- a/target/linux/ath79/dts/ar9342_ubnt_wa.dtsi
+++ b/target/linux/ath79/dts/ar9342_ubnt_wa.dtsi
@@ -36,6 +36,7 @@
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <25000000>;
+ swp-disable;

partitions {
compatible = "fixed-partitions";
diff --git a/target/linux/ath79/dts/ar9342_ubnt_xw.dtsi b/target/linux/ath79/dts/ar9342_ubnt_xw.dtsi
index ce49c10e5ccb5bc634444cd2dbbce1deb60ef73c..5ddf89488ceb3958926465413515de33506e5817 100644
--- a/target/linux/ath79/dts/ar9342_ubnt_xw.dtsi
+++ b/target/linux/ath79/dts/ar9342_ubnt_xw.dtsi
@@ -64,6 +64,7 @@
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <25000000>;
+ swp-disable;

partitions {
compatible = "fixed-partitions";
diff --git a/target/linux/ath79/dts/qca955x_ubnt_xc.dtsi b/target/linux/ath79/dts/qca955x_ubnt_xc.dtsi
index 0f803945db632873a6d7e97cb0a482106354e8c2..196e1b5382f5508610a65247832e47006a3ca11b 100644
--- a/target/linux/ath79/dts/qca955x_ubnt_xc.dtsi
+++ b/target/linux/ath79/dts/qca955x_ubnt_xc.dtsi
@@ -16,6 +16,7 @@
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <25000000>;
+ swp-disable;

partitions {
compatible = "fixed-partitions";
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
From: Tom Herbers <[email protected]>
Date: Wed, 31 Jul 2024 14:43:13 +0200
Subject: Revert "ath79: generic: disable SPI-NOR write protect unconditionally"

This reverts commit c55aaa7c9a98e7c0a5e1ea8293a534dc5b395cf3.

diff --git a/target/linux/ath79/generic/config-default b/target/linux/ath79/generic/config-default
index 09ea9d93d7a567897c9de5fdd925cb13de332930..06f264b626a72be16854e6f984a2ee4f8b3b906a 100644
--- a/target/linux/ath79/generic/config-default
+++ b/target/linux/ath79/generic/config-default
@@ -14,8 +14,6 @@ CONFIG_LEDS_RESET=y
CONFIG_MARVELL_PHY=y
CONFIG_MICREL_PHY=y
CONFIG_MTD_REDBOOT_PARTS=y
-CONFIG_MTD_SPI_NOR_SWP_DISABLE=y
-# CONFIG_MTD_SPI_NOR_SWP_DISABLE_ON_VOLATILE is not set
CONFIG_MTD_SPLIT_EVA_FW=y
CONFIG_NVMEM_SYSFS=y
CONFIG_NVMEM_U_BOOT_ENV=y
10 changes: 10 additions & 0 deletions targets/ath79-generic
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,16 @@ device('tp-link-wbs510-v1', 'tplink_wbs510-v1')

-- Ubiquiti

device('ubiquiti-nanobeam-ac-gen1-xc', 'ubnt_nanobeam-ac-xc', {
packages = ATH10K_PACKAGES_QCA9880,
})

device('ubiquiti-nanobeam-m5-xw', 'ubnt_nanobeam-m5-xw')

device('ubiquiti-nanostation-loco-m-xw', 'ubnt_nanostation-loco-m-xw')

device('ubiquiti-nanostation-m-xw', 'ubnt_nanostation-m-xw')

device('ubiquiti-unifi-ac-lite', 'ubnt_unifiac-lite', {
factory = false,
packages = ATH10K_PACKAGES_QCA9880,
Expand Down