ucentral: development update

* update base 21.02 revision
* update v5.10 support
* fix captive portal
* cleanup ucentral-* packages
* update ucentral-* packages
* cleanup profiles
* fix worflow

Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin
2021-04-07 11:45:57 +02:00
parent 0fa5d55f90
commit 256c322f85
61 changed files with 14866 additions and 10459 deletions

View File

@@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: false
matrix:
target: ['e8450', 'ea8300', 'wf194c', 'zyxel_gs1900-10hp', 'edgecore_ecs4100-12ph']
target: ['cig_wf188', 'cig_wf194c', 'edgecore_eap101', 'edgecore_eap102', 'edgecore_ecs4100-12ph', 'edgecore_ecw5211', 'linksys_e8450', 'linksys_ea8300', 'zyxel_gs1900-10hp']
steps:
- uses: actions/checkout@v2
@@ -31,7 +31,8 @@ jobs:
run: |
BRANCH=$(git rev-parse --abbrev-ref HEAD)
LOWERCASE_TARGET=`echo ${{ matrix.target }} | tr '[:upper:]' '[:lower:]'`
TAR_NAME="$LOWERCASE_TARGET-$BRANCH.tar.gz"
HASH=$(git rev-parse --short HEAD)
TAR_NAME="$LOWERCASE_TARGET-$BRANCH-$HASH.tar.gz"
ls openwrt/bin/targets/
tar cfz "$TAR_NAME" -C openwrt/bin/targets/ .
curl -u $GH_BUILD_USERNAME:$GH_BUILD_PASSWORD -T "$TAR_NAME" "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/$LOWERCASE_TARGET/uCentral/dev/"$TAR_NAME""
curl -u $GH_BUILD_USERNAME:$GH_BUILD_PASSWORD -T "$TAR_NAME" "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/uCentral/$LOWERCASE_TARGET/"$TAR_NAME""

View File

@@ -1,7 +1,7 @@
From 9a1f2adebe2245175462a6b2758d78b292072505 Mon Sep 17 00:00:00 2001
From 98ff38f7b7cd28c035b9c2e36a45af17f85c5244 Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@nbd.name>
Date: Thu, 22 Oct 2020 10:29:34 +0200
Subject: [PATCH 01/22] build: build kernel image before building
Subject: [PATCH 01/37] build: build kernel image before building
modules/packages
This is needed for linux 5.10, where modules.builtin is generated from

View File

@@ -1,7 +1,7 @@
From 6923e03f687b00c0394d34194364b56d04a79d8f Mon Sep 17 00:00:00 2001
From cf2dbd13b7dd8c8c52fc3378da69ebae454520aa Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@nbd.name>
Date: Wed, 17 Feb 2021 13:49:14 +0100
Subject: [PATCH 09/22] build: fix build with CONFIG_STRIP_KERNEL_EXPORTS
Subject: [PATCH 02/37] build: fix build with CONFIG_STRIP_KERNEL_EXPORTS
Only use symtab.h on the final kernel link

View File

@@ -1,41 +0,0 @@
From cc135eeb1b77fc084e4154d25e13e42b7a2d9150 Mon Sep 17 00:00:00 2001
From: David Bauer <mail@david-bauer.net>
Date: Tue, 16 Feb 2021 22:51:18 +0100
Subject: [PATCH 03/22] generic: ar8216: fix kernel 5.10 compile error
Signed-off-by: David Bauer <mail@david-bauer.net>
---
target/linux/generic/files/drivers/net/phy/ar8216.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.c b/target/linux/generic/files/drivers/net/phy/ar8216.c
index acfa0ebecd..d48a415d50 100644
--- a/target/linux/generic/files/drivers/net/phy/ar8216.c
+++ b/target/linux/generic/files/drivers/net/phy/ar8216.c
@@ -891,7 +891,11 @@ ar8216_phy_write(struct ar8xxx_priv *priv, int addr, int regnum, u16 val)
static int
ar8229_hw_init(struct ar8xxx_priv *priv)
{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)
+ phy_interface_t phy_if_mode;
+#else
int phy_if_mode;
+#endif
if (priv->initialized)
return 0;
@@ -899,7 +903,11 @@ ar8229_hw_init(struct ar8xxx_priv *priv)
ar8xxx_write(priv, AR8216_REG_CTRL, AR8216_CTRL_RESET);
ar8xxx_reg_wait(priv, AR8216_REG_CTRL, AR8216_CTRL_RESET, 0, 1000);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)
+ of_get_phy_mode(priv->pdev->of_node, &phy_if_mode);
+#else
phy_if_mode = of_get_phy_mode(priv->pdev->of_node);
+#endif
if (phy_if_mode == PHY_INTERFACE_MODE_GMII) {
ar8xxx_write(priv, AR8229_REG_OPER_MODE0,
--
2.25.1

View File

@@ -1,45 +0,0 @@
From e1053344ae44ac022e1e8262169d7194442d78a6 Mon Sep 17 00:00:00 2001
From: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Date: Tue, 16 Feb 2021 22:56:06 +0100
Subject: [PATCH 04/22] generic: ar8216: update version switch for
of_get_phy_mode fix
Kernel has changed the of_get_phy_mode API in commit 0c65b2b90d13
("net: of_get_phy_mode: Change API to solve int/unit warnings").
This is already included in kernel 5.5, so fix the version switch
(though this will not actually matter for the versions we support).
Similar driver adjustments to account for the API change will
probably be necessary to various other local drivers.
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
---
target/linux/generic/files/drivers/net/phy/ar8216.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.c b/target/linux/generic/files/drivers/net/phy/ar8216.c
index d48a415d50..ef0fc54949 100644
--- a/target/linux/generic/files/drivers/net/phy/ar8216.c
+++ b/target/linux/generic/files/drivers/net/phy/ar8216.c
@@ -891,7 +891,7 @@ ar8216_phy_write(struct ar8xxx_priv *priv, int addr, int regnum, u16 val)
static int
ar8229_hw_init(struct ar8xxx_priv *priv)
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 5, 0)
phy_interface_t phy_if_mode;
#else
int phy_if_mode;
@@ -903,7 +903,7 @@ ar8229_hw_init(struct ar8xxx_priv *priv)
ar8xxx_write(priv, AR8216_REG_CTRL, AR8216_CTRL_RESET);
ar8xxx_reg_wait(priv, AR8216_REG_CTRL, AR8216_CTRL_RESET, 0, 1000);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 5, 0)
of_get_phy_mode(priv->pdev->of_node, &phy_if_mode);
#else
phy_if_mode = of_get_phy_mode(priv->pdev->of_node);
--
2.25.1

View File

@@ -1,36 +0,0 @@
From c3a5b35f6971a4c6daed3674badb6718058f5ebe Mon Sep 17 00:00:00 2001
From: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Date: Tue, 16 Feb 2021 23:16:00 +0100
Subject: [PATCH 05/22] kernel: 5.10: fix busy wait loop in mediatek PPE code
Reapply changes added to 5.4 but not copied to 5.10:
3da4acaa7bba ("kernel: fix busy wait loop in mediatek PPE code")
The intention is for the loop to timeout if the body does not succeed.
The current logic calls time_is_before_jiffies(timeout) which is false
until after the timeout, so the loop body never executes.
time_is_after_jiffies(timeout) will return true until timeout is less
than jiffies, which is the intended behavior here.
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
---
...5-net-ethernet-mtk_eth_soc-add-support-for-initializin.patch | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/linux/generic/pending-5.10/770-15-net-ethernet-mtk_eth_soc-add-support-for-initializin.patch b/target/linux/generic/pending-5.10/770-15-net-ethernet-mtk_eth_soc-add-support-for-initializin.patch
index fa4803211a..09282175b0 100644
--- a/target/linux/generic/pending-5.10/770-15-net-ethernet-mtk_eth_soc-add-support-for-initializin.patch
+++ b/target/linux/generic/pending-5.10/770-15-net-ethernet-mtk_eth_soc-add-support-for-initializin.patch
@@ -185,7 +185,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
+{
+ unsigned long timeout = jiffies + HZ;
+
-+ while (time_is_before_jiffies(timeout)) {
++ while (time_is_after_jiffies(timeout)) {
+ if (!(ppe_r32(ppe, MTK_PPE_GLO_CFG) & MTK_PPE_GLO_CFG_BUSY))
+ return 0;
+
--
2.25.1

View File

@@ -1,7 +1,7 @@
From 9f0be984310a4d2bdacf94e53bd198aba3fa8675 Mon Sep 17 00:00:00 2001
From 53e43a9bedff657125f9023384c588eca871ef97 Mon Sep 17 00:00:00 2001
From: John Crispin <john@phrozen.org>
Date: Sat, 20 Feb 2021 08:36:43 +0100
Subject: [PATCH 18/22] sysupgrade-nand: allow limiting rootfs_data by setting
Subject: [PATCH 05/37] sysupgrade-nand: allow limiting rootfs_data by setting
env variable
Check if firmware environment variable 'rootfs_data_max' exists and is

View File

@@ -1,43 +0,0 @@
From c7c270cedef77aa077f1f0dcc31964b43d573597 Mon Sep 17 00:00:00 2001
From: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Date: Tue, 16 Feb 2021 23:25:00 +0100
Subject: [PATCH 06/22] kernel: hack-5.10: make UDP tunneling user-selectable
This applies another patch from 5.4 to 5.10 as well:
de09355f74c3 ("kernel/hack-5.4: make UDP tunneling user-selectable")
UDP tunneling support isn't user-selectable, but it's required by WireGuard
which is, for the time being, an out-of-tree module. We currently work around
this issue by selecting an unrelated module which depends on UDP tunnelling
(VXLAN). This is inconvenient, as it implies this unrelated module needs to be
built-in when doing a monolithic build.
Fix this inconvenience by making UDP tunneling user-selectable in the kernel
configuration.
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
---
.../generic/hack-5.10/249-udp-tunnel-selection.patch | 11 +++++++++++
1 file changed, 11 insertions(+)
create mode 100644 target/linux/generic/hack-5.10/249-udp-tunnel-selection.patch
diff --git a/target/linux/generic/hack-5.10/249-udp-tunnel-selection.patch b/target/linux/generic/hack-5.10/249-udp-tunnel-selection.patch
new file mode 100644
index 0000000000..2c74298dfe
--- /dev/null
+++ b/target/linux/generic/hack-5.10/249-udp-tunnel-selection.patch
@@ -0,0 +1,11 @@
+--- a/net/ipv4/Kconfig
++++ b/net/ipv4/Kconfig
+@@ -315,7 +315,7 @@ config NET_IPVTI
+ on top.
+
+ config NET_UDP_TUNNEL
+- tristate
++ tristate "IP: UDP tunneling support"
+ select NET_IP_TUNNEL
+ default n
+
--
2.25.1

View File

@@ -1,7 +1,7 @@
From 071191934f2b2eeb080f5e60f405ccc43c2d2ed8 Mon Sep 17 00:00:00 2001
From fa6f7e0c0d7bf5d6c9697096e598372b52f51085 Mon Sep 17 00:00:00 2001
From: Daniel Golle <daniel@makrotopia.org>
Date: Sat, 30 Jan 2021 13:58:16 +0000
Subject: [PATCH 19/22] uboot-mediatek: add support for linksys e8450
Subject: [PATCH 06/37] uboot-mediatek: add support for linksys e8450
Build U-Boot for the Linksys E8450 in order to have support for UBI.
The loader has a default environment with scripts handling the reset

View File

@@ -1,347 +0,0 @@
From 56c65b4ffa04a202b777e8119aaa8069264d7789 Mon Sep 17 00:00:00 2001
From: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Date: Tue, 16 Feb 2021 23:31:40 +0100
Subject: [PATCH 07/22] kernel: 5.10: add missing partitions doc syntax commit
This patch has been added to 5.4, but not been copied to 5.10:
7495acb55573 ("kernel: backport mtd commit converting partitions doc syntax")
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
---
...convert-fixed-partitions-to-the-json.patch | 324 ++++++++++++++++++
1 file changed, 324 insertions(+)
create mode 100644 target/linux/generic/backport-5.10/401-v5.11-dt-bindings-mtd-convert-fixed-partitions-to-the-json.patch
diff --git a/target/linux/generic/backport-5.10/401-v5.11-dt-bindings-mtd-convert-fixed-partitions-to-the-json.patch b/target/linux/generic/backport-5.10/401-v5.11-dt-bindings-mtd-convert-fixed-partitions-to-the-json.patch
new file mode 100644
index 0000000000..8aded43526
--- /dev/null
+++ b/target/linux/generic/backport-5.10/401-v5.11-dt-bindings-mtd-convert-fixed-partitions-to-the-json.patch
@@ -0,0 +1,324 @@
+From 04e9ab75267489224364fa510a88ada83e11c325 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Thu, 10 Dec 2020 18:23:52 +0100
+Subject: [PATCH] dt-bindings: mtd: convert "fixed-partitions" to the
+ json-schema
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This standardizes its documentation, allows validating with Makefile
+checks and helps writing DTS files.
+
+Noticeable changes:
+1. Dropped "Partitions can be represented by sub-nodes of a flash
+ device." as we also support subpartitions (don't have to be part of
+ flash device node)
+2. Dropped "to Linux" as bindings are meant to be os agnostic.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Link: https://lore.kernel.org/r/20201210172352.31632-1-zajec5@gmail.com
+Signed-off-by: Rob Herring <robh@kernel.org>
+---
+ .../devicetree/bindings/mtd/partition.txt | 131 +--------------
+ .../mtd/partitions/fixed-partitions.yaml | 152 ++++++++++++++++++
+ 2 files changed, 154 insertions(+), 129 deletions(-)
+ create mode 100644 Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
+
+--- a/Documentation/devicetree/bindings/mtd/partition.txt
++++ b/Documentation/devicetree/bindings/mtd/partition.txt
+@@ -24,137 +24,10 @@ another partitioning method.
+ Available bindings are listed in the "partitions" subdirectory.
+
+
+-Fixed Partitions
+-================
+-
+-Partitions can be represented by sub-nodes of a flash device. This can be used
+-on platforms which have strong conventions about which portions of a flash are
+-used for what purposes, but which don't use an on-flash partition table such
+-as RedBoot.
+-
+-The partition table should be a subnode of the flash node and should be named
+-'partitions'. This node should have the following property:
+-- compatible : (required) must be "fixed-partitions"
+-Partitions are then defined in subnodes of the partitions node.
++Deprecated: partitions defined in flash node
++============================================
+
+ For backwards compatibility partitions as direct subnodes of the flash device are
+ supported. This use is discouraged.
+ NOTE: also for backwards compatibility, direct subnodes that have a compatible
+ string are not considered partitions, as they may be used for other bindings.
+-
+-#address-cells & #size-cells must both be present in the partitions subnode of the
+-flash device. There are two valid values for both:
+-<1>: for partitions that require a single 32-bit cell to represent their
+- size/address (aka the value is below 4 GiB)
+-<2>: for partitions that require two 32-bit cells to represent their
+- size/address (aka the value is 4 GiB or greater).
+-
+-Required properties:
+-- reg : The partition's offset and size within the flash
+-
+-Optional properties:
+-- label : The label / name for this partition. If omitted, the label is taken
+- from the node name (excluding the unit address).
+-- read-only : This parameter, if present, is a hint to Linux that this
+- partition should only be mounted read-only. This is usually used for flash
+- partitions containing early-boot firmware images or data which should not be
+- clobbered.
+-- lock : Do not unlock the partition at initialization time (not supported on
+- all devices)
+-- slc-mode: This parameter, if present, allows one to emulate SLC mode on a
+- partition attached to an MLC NAND thus making this partition immune to
+- paired-pages corruptions
+-
+-Examples:
+-
+-
+-flash@0 {
+- partitions {
+- compatible = "fixed-partitions";
+- #address-cells = <1>;
+- #size-cells = <1>;
+-
+- partition@0 {
+- label = "u-boot";
+- reg = <0x0000000 0x100000>;
+- read-only;
+- };
+-
+- uimage@100000 {
+- reg = <0x0100000 0x200000>;
+- };
+- };
+-};
+-
+-flash@1 {
+- partitions {
+- compatible = "fixed-partitions";
+- #address-cells = <1>;
+- #size-cells = <2>;
+-
+- /* a 4 GiB partition */
+- partition@0 {
+- label = "filesystem";
+- reg = <0x00000000 0x1 0x00000000>;
+- };
+- };
+-};
+-
+-flash@2 {
+- partitions {
+- compatible = "fixed-partitions";
+- #address-cells = <2>;
+- #size-cells = <2>;
+-
+- /* an 8 GiB partition */
+- partition@0 {
+- label = "filesystem #1";
+- reg = <0x0 0x00000000 0x2 0x00000000>;
+- };
+-
+- /* a 4 GiB partition */
+- partition@200000000 {
+- label = "filesystem #2";
+- reg = <0x2 0x00000000 0x1 0x00000000>;
+- };
+- };
+-};
+-
+-flash@3 {
+- partitions {
+- compatible = "fixed-partitions";
+- #address-cells = <1>;
+- #size-cells = <1>;
+-
+- partition@0 {
+- label = "bootloader";
+- reg = <0x000000 0x100000>;
+- read-only;
+- };
+-
+- firmware@100000 {
+- label = "firmware";
+- reg = <0x100000 0xe00000>;
+- compatible = "brcm,trx";
+- };
+-
+- calibration@f00000 {
+- label = "calibration";
+- reg = <0xf00000 0x100000>;
+- compatible = "fixed-partitions";
+- ranges = <0 0xf00000 0x100000>;
+- #address-cells = <1>;
+- #size-cells = <1>;
+-
+- partition@0 {
+- label = "wifi0";
+- reg = <0x000000 0x080000>;
+- };
+-
+- partition@80000 {
+- label = "wifi1";
+- reg = <0x080000 0x080000>;
+- };
+- };
+- };
+-};
+--- /dev/null
++++ b/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
+@@ -0,0 +1,152 @@
++# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
++%YAML 1.2
++---
++$id: http://devicetree.org/schemas/mtd/partitions/fixed-partitions.yaml#
++$schema: http://devicetree.org/meta-schemas/core.yaml#
++
++title: Fixed partitions
++
++description: |
++ This binding can be used on platforms which have strong conventions about
++ which portions of a flash are used for what purposes, but which don't use an
++ on-flash partition table such as RedBoot.
++
++ The partition table should be a node named "partitions". Partitions are then
++ defined as subnodes.
++
++maintainers:
++ - Rafał Miłecki <rafal@milecki.pl>
++
++properties:
++ compatible:
++ const: fixed-partitions
++
++ "#address-cells": true
++
++ "#size-cells": true
++
++patternProperties:
++ "@[0-9a-f]+$":
++ description: node describing a single flash partition
++ type: object
++
++ properties:
++ reg:
++ description: partition's offset and size within the flash
++ maxItems: 1
++
++ label:
++ description: The label / name for this partition. If omitted, the label
++ is taken from the node name (excluding the unit address).
++
++ read-only:
++ description: This parameter, if present, is a hint that this partition
++ should only be mounted read-only. This is usually used for flash
++ partitions containing early-boot firmware images or data which should
++ not be clobbered.
++ type: boolean
++
++ lock:
++ description: Do not unlock the partition at initialization time (not
++ supported on all devices)
++ type: boolean
++
++ slc-mode:
++ description: This parameter, if present, allows one to emulate SLC mode
++ on a partition attached to an MLC NAND thus making this partition
++ immune to paired-pages corruptions
++ type: boolean
++
++ required:
++ - reg
++
++required:
++ - "#address-cells"
++ - "#size-cells"
++
++additionalProperties: true
++
++examples:
++ - |
++ partitions {
++ compatible = "fixed-partitions";
++ #address-cells = <1>;
++ #size-cells = <1>;
++
++ partition@0 {
++ label = "u-boot";
++ reg = <0x0000000 0x100000>;
++ read-only;
++ };
++
++ uimage@100000 {
++ reg = <0x0100000 0x200000>;
++ };
++ };
++ - |
++ partitions {
++ compatible = "fixed-partitions";
++ #address-cells = <1>;
++ #size-cells = <2>;
++
++ /* a 4 GiB partition */
++ partition@0 {
++ label = "filesystem";
++ reg = <0x00000000 0x1 0x00000000>;
++ };
++ };
++ - |
++ partitions {
++ compatible = "fixed-partitions";
++ #address-cells = <2>;
++ #size-cells = <2>;
++
++ /* an 8 GiB partition */
++ partition@0 {
++ label = "filesystem #1";
++ reg = <0x0 0x00000000 0x2 0x00000000>;
++ };
++
++ /* a 4 GiB partition */
++ partition@200000000 {
++ label = "filesystem #2";
++ reg = <0x2 0x00000000 0x1 0x00000000>;
++ };
++ };
++ - |
++ partitions {
++ compatible = "fixed-partitions";
++ #address-cells = <1>;
++ #size-cells = <1>;
++
++ partition@0 {
++ label = "bootloader";
++ reg = <0x000000 0x100000>;
++ read-only;
++ };
++
++ firmware@100000 {
++ compatible = "brcm,trx";
++ label = "firmware";
++ reg = <0x100000 0xe00000>;
++ };
++
++ calibration@f00000 {
++ compatible = "fixed-partitions";
++ label = "calibration";
++ reg = <0xf00000 0x100000>;
++ ranges = <0 0xf00000 0x100000>;
++ #address-cells = <1>;
++ #size-cells = <1>;
++
++ partition@0 {
++ label = "wifi0";
++ reg = <0x000000 0x080000>;
++ };
++
++ partition@80000 {
++ label = "wifi1";
++ reg = <0x080000 0x080000>;
++ };
++ };
++ };
--
2.25.1

View File

@@ -1,7 +1,7 @@
From ce99ccf70f226ea3aac19120ab8634b8cb6a1478 Mon Sep 17 00:00:00 2001
From afdb544b7378d99ad776e8b2bc66a00dbeb48c06 Mon Sep 17 00:00:00 2001
From: Daniel Golle <daniel@makrotopia.org>
Date: Fri, 12 Feb 2021 03:09:39 +0000
Subject: [PATCH 20/22] uboot-envtools: add defaults for linksys-e8450-ubi
Subject: [PATCH 07/37] uboot-envtools: add defaults for linksys-e8450-ubi
Add U-Boot environment configuration for the Linksys E8450 (UBI) to
allow access to the bootloader environment from OpenWrt via

View File

@@ -1,226 +0,0 @@
From cebbb0ffa366e356268afe15fb243682313e02fc Mon Sep 17 00:00:00 2001
From: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Date: Tue, 16 Feb 2021 23:39:32 +0100
Subject: [PATCH 08/22] kernel: 5.10: refresh patches
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
---
.../generic/hack-5.10/531-debloat_lzma.patch | 33 ++++++++++---------
...t-command-line-parameters-from-users.patch | 10 +++---
...ble-add-offload-support-for-xmit-pat.patch | 15 +++++----
...dd-support-for-threaded-NAPI-polling.patch | 15 +++++----
.../pending-5.10/834-ledtrig-libata.patch | 4 +--
5 files changed, 41 insertions(+), 36 deletions(-)
diff --git a/target/linux/generic/hack-5.10/531-debloat_lzma.patch b/target/linux/generic/hack-5.10/531-debloat_lzma.patch
index 0854872ffa..2f70eee3e9 100644
--- a/target/linux/generic/hack-5.10/531-debloat_lzma.patch
+++ b/target/linux/generic/hack-5.10/531-debloat_lzma.patch
@@ -710,26 +710,26 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
{
UInt32 dicSize;
Byte d;
-@@ -935,33 +883,11 @@ static SRes LzmaDec_AllocateProbs2(CLzma
+@@ -935,7 +883,7 @@ static SRes LzmaDec_AllocateProbs2(CLzma
return SZ_OK;
}
-SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
--{
-- CLzmaProps propNew;
-- RINOK(LzmaProps_Decode(&propNew, props, propsSize));
-- RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
-- p->prop = propNew;
-- return SZ_OK;
--}
--
--SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
+static SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
{
CLzmaProps propNew;
-- SizeT dicBufSize;
RINOK(LzmaProps_Decode(&propNew, props, propsSize));
- RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
+@@ -943,28 +891,6 @@ SRes LzmaDec_AllocateProbs(CLzmaDec *p,
+ p->prop = propNew;
+ return SZ_OK;
+ }
+-
+-SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc)
+-{
+- CLzmaProps propNew;
+- SizeT dicBufSize;
+- RINOK(LzmaProps_Decode(&propNew, props, propsSize));
+- RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
- dicBufSize = propNew.dicSize;
- if (p->dic == 0 || dicBufSize != p->dicBufSize)
- {
@@ -742,9 +742,12 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
- }
- }
- p->dicBufSize = dicBufSize;
- p->prop = propNew;
- return SZ_OK;
- }
+- p->prop = propNew;
+- return SZ_OK;
+-}
+
+ SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
+ const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode,
--- a/lib/lzma/LzmaEnc.c
+++ b/lib/lzma/LzmaEnc.c
@@ -53,7 +53,7 @@ void LzmaEncProps_Init(CLzmaEncProps *p)
diff --git a/target/linux/generic/pending-5.10/330-MIPS-kexec-Accept-command-line-parameters-from-users.patch b/target/linux/generic/pending-5.10/330-MIPS-kexec-Accept-command-line-parameters-from-users.patch
index 5a0e44b76b..2808c95322 100644
--- a/target/linux/generic/pending-5.10/330-MIPS-kexec-Accept-command-line-parameters-from-users.patch
+++ b/target/linux/generic/pending-5.10/330-MIPS-kexec-Accept-command-line-parameters-from-users.patch
@@ -267,15 +267,15 @@ Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
+ EXPORT(kexec_argv_buf)
+ .skip KEXEC_COMMAND_LINE_SIZE
+ .size kexec_argv_buf, KEXEC_COMMAND_LINE_SIZE
++
++kexec_argv:
++ EXPORT(kexec_argv)
++ .skip KEXEC_ARGV_SIZE
++ .size kexec_argv, KEXEC_ARGV_SIZE
-relocate_new_kernel_size:
- EXPORT(relocate_new_kernel_size)
- PTR relocate_new_kernel_end - relocate_new_kernel
- .size relocate_new_kernel_size, PTRSIZE
-+kexec_argv:
-+ EXPORT(kexec_argv)
-+ .skip KEXEC_ARGV_SIZE
-+ .size kexec_argv, KEXEC_ARGV_SIZE
-+
+kexec_relocate_new_kernel_end:
+ EXPORT(kexec_relocate_new_kernel_end)
diff --git a/target/linux/generic/pending-5.10/640-11-netfilter-flowtable-add-offload-support-for-xmit-pat.patch b/target/linux/generic/pending-5.10/640-11-netfilter-flowtable-add-offload-support-for-xmit-pat.patch
index 5e3c7e031a..508dc90e14 100644
--- a/target/linux/generic/pending-5.10/640-11-netfilter-flowtable-add-offload-support-for-xmit-pat.patch
+++ b/target/linux/generic/pending-5.10/640-11-netfilter-flowtable-add-offload-support-for-xmit-pat.patch
@@ -85,12 +85,14 @@ tag to the driver.
- n = dst_neigh_lookup(dst_cache, daddr);
- if (!n)
- return -ENOENT;
-+ this_tuple = &flow->tuplehash[dir].tuple;
-
+-
- read_lock_bh(&n->lock);
- nud_state = n->nud_state;
- ether_addr_copy(ha, n->ha);
- read_unlock_bh(&n->lock);
++ this_tuple = &flow->tuplehash[dir].tuple;
+
+- if (!(nud_state & NUD_VALID)) {
+ switch (this_tuple->xmit_type) {
+ case FLOW_OFFLOAD_XMIT_DIRECT:
+ ether_addr_copy(ha, this_tuple->out.h_dest);
@@ -102,8 +104,7 @@ tag to the driver.
+ n = dst_neigh_lookup(dst_cache, daddr);
+ if (!n)
+ return -ENOENT;
-
-- if (!(nud_state & NUD_VALID)) {
++
+ read_lock_bh(&n->lock);
+ nud_state = n->nud_state;
+ ether_addr_copy(ha, n->ha);
@@ -143,8 +144,7 @@ tag to the driver.
+ struct flow_action_entry *entry;
+ struct net_device *dev;
+ int ifindex;
-
-- rt = (struct rtable *)flow->tuplehash[dir].tuple.dst_cache;
++
+ this_tuple = &flow->tuplehash[dir].tuple;
+ switch (this_tuple->xmit_type) {
+ case FLOW_OFFLOAD_XMIT_DIRECT:
@@ -158,7 +158,8 @@ tag to the driver.
+ default:
+ return;
+ }
-+
+
+- rt = (struct rtable *)flow->tuplehash[dir].tuple.dst_cache;
+ dev = dev_get_by_index(net, ifindex);
+ if (!dev)
+ return;
diff --git a/target/linux/generic/pending-5.10/690-net-add-support-for-threaded-NAPI-polling.patch b/target/linux/generic/pending-5.10/690-net-add-support-for-threaded-NAPI-polling.patch
index 79b7832f2a..2979934926 100644
--- a/target/linux/generic/pending-5.10/690-net-add-support-for-threaded-NAPI-polling.patch
+++ b/target/linux/generic/pending-5.10/690-net-add-support-for-threaded-NAPI-polling.patch
@@ -214,7 +214,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
napi_hash_del(napi);
list_del_rcu(&napi->dev_list);
napi_free_frags(napi);
-@@ -6788,52 +6881,18 @@ EXPORT_SYMBOL(__netif_napi_del);
+@@ -6788,53 +6881,19 @@ EXPORT_SYMBOL(__netif_napi_del);
static int napi_poll(struct napi_struct *n, struct list_head *repoll)
{
@@ -228,7 +228,8 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
have = netpoll_poll_lock(n);
- weight = n->weight;
--
++ work = __napi_poll(n, &do_repoll);
+
- /* This NAPI_STATE_SCHED test is for avoiding a race
- * with netpoll's poll_napi(). Only the entity which
- * obtains the lock and sees NAPI_STATE_SCHED set will
@@ -246,8 +247,8 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
- n->poll, work, weight);
-
- if (likely(work < weight))
-- goto out_unlock;
-+ work = __napi_poll(n, &do_repoll);
++ if (!do_repoll)
+ goto out_unlock;
- /* Drivers must not modify the NAPI state if they
- * consume the entire weight. In such cases this code
@@ -256,8 +257,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
- */
- if (unlikely(napi_disable_pending(n))) {
- napi_complete(n);
-+ if (!do_repoll)
- goto out_unlock;
+- goto out_unlock;
- }
-
- if (n->gro_bitmask) {
@@ -268,9 +268,10 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
- }
-
- gro_normal_list(n);
-
+-
/* Some drivers may have called napi_schedule
* prior to exhausting their budget.
+ */
@@ -11288,6 +11347,10 @@ static int __init net_dev_init(void)
sd->backlog.weight = weight_p;
}
diff --git a/target/linux/generic/pending-5.10/834-ledtrig-libata.patch b/target/linux/generic/pending-5.10/834-ledtrig-libata.patch
index 623e48085d..a52e712d8c 100644
--- a/target/linux/generic/pending-5.10/834-ledtrig-libata.patch
+++ b/target/linux/generic/pending-5.10/834-ledtrig-libata.patch
@@ -106,11 +106,11 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
+ for (i = 0; i < host->n_ports; i++) {
+ if (unlikely(!host->ports[i]->ledtrig))
+ continue;
-+
+
+ snprintf(host->ports[i]->ledtrig_name,
+ sizeof(host->ports[i]->ledtrig_name), "ata%u",
+ host->ports[i]->print_id);
-
++
+ host->ports[i]->ledtrig->name = host->ports[i]->ledtrig_name;
+
+ if (led_trigger_register(host->ports[i]->ledtrig)) {
--
2.25.1

View File

@@ -1,7 +1,7 @@
From 7af6b8d742289a728629ecae929a0f8fa441ba3f Mon Sep 17 00:00:00 2001
From c07c28c4cbd35e1cfd5033b1da6226d1a54f0454 Mon Sep 17 00:00:00 2001
From: John Crispin <john@phrozen.org>
Date: Tue, 16 Mar 2021 10:46:51 +0100
Subject: [PATCH 22/22] realtek: update to latest owrt HEAD
Subject: [PATCH 08/37] realtek: update to latest owrt HEAD
Signed-off-by: John Crispin <john@phrozen.org>
---

View File

@@ -0,0 +1,31 @@
From a8c9777a9edb012fd67d2419b207a7c591f08aba Mon Sep 17 00:00:00 2001
From: John Crispin <john@phrozen.org>
Date: Wed, 7 Apr 2021 10:46:26 +0200
Subject: [PATCH 09/37] include: set kernel-version.mk
Signed-off-by: John Crispin <john@phrozen.org>
---
include/kernel-version.mk | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/kernel-version.mk b/include/kernel-version.mk
index aff812e57f..ace6d45149 100644
--- a/include/kernel-version.mk
+++ b/include/kernel-version.mk
@@ -6,9 +6,13 @@ ifdef CONFIG_TESTING_KERNEL
KERNEL_PATCHVER:=$(KERNEL_TESTING_PATCHVER)
endif
+LINUX_VERSION-4.4 = .60
LINUX_VERSION-5.4 = .108
+LINUX_VERSION-5.10 = .27
+LINUX_KERNEL_HASH-4.4.60 = 2cd8df6f1ac6a5329c5a286ec9b5956215977221a1b731597ed169fff74a9659
LINUX_KERNEL_HASH-5.4.108 = f212ac07c21bd33e6898fdbb2ddba2a454f74578bbe7bef8fe4dbbbc0ec52172
+LINUX_KERNEL_HASH-5.10.27 = d99dc9662951299c53a0a8d8c8d0a72a16ff861d20e927c0f9b14f63282d69d9
remove_uri_prefix=$(subst git://,,$(subst http://,,$(subst https://,,$(1))))
sanitize_uri=$(call qstrip,$(subst @,_,$(subst :,_,$(subst .,_,$(subst -,_,$(subst /,_,$(1)))))))
--
2.25.1

View File

@@ -1,60 +0,0 @@
From c0484713ff059736b169496d396f722af5db31c0 Mon Sep 17 00:00:00 2001
From: Daniel Golle <daniel@makrotopia.org>
Date: Sun, 14 Feb 2021 20:17:31 +0000
Subject: [PATCH 10/22] kernel: update kernel 5.10 to 5.10.16
Compile and runtime-tested on mediatek/mt7622
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
include/kernel-version.mk | 4 ++--
.../491-ubi-auto-create-ubiblock-device-for-rootfs.patch | 2 +-
.../pending-5.10/760-net-dsa-mv88e6xxx-fix-vlan-setup.patch | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/kernel-version.mk b/include/kernel-version.mk
index 035692f3e3..26f24bae42 100644
--- a/include/kernel-version.mk
+++ b/include/kernel-version.mk
@@ -7,10 +7,10 @@ ifdef CONFIG_TESTING_KERNEL
endif
LINUX_VERSION-5.4 = .105
-LINUX_VERSION-5.10 = .14
+LINUX_VERSION-5.10 = .16
LINUX_KERNEL_HASH-5.4.105 = 244e4cd16184285df55ec5a9501daba011aa8b85c5527ee05eab4592e70fb8b6
-LINUX_KERNEL_HASH-5.10.14 = fa27b79f198b5be969e497ed5461860df48e0591c85e60699fc8be26837a1d2a
+LINUX_KERNEL_HASH-5.10.16 = 536fe3ea273bfcc72b3571d3b3a7ff0a5bcdc16068efd22e42c4f9d03c200a37
remove_uri_prefix=$(subst git://,,$(subst http://,,$(subst https://,,$(1))))
sanitize_uri=$(call qstrip,$(subst @,_,$(subst :,_,$(subst .,_,$(subst -,_,$(subst /,_,$(1)))))))
diff --git a/target/linux/generic/pending-5.10/491-ubi-auto-create-ubiblock-device-for-rootfs.patch b/target/linux/generic/pending-5.10/491-ubi-auto-create-ubiblock-device-for-rootfs.patch
index 61fcbac92e..e5ee2c8656 100644
--- a/target/linux/generic/pending-5.10/491-ubi-auto-create-ubiblock-device-for-rootfs.patch
+++ b/target/linux/generic/pending-5.10/491-ubi-auto-create-ubiblock-device-for-rootfs.patch
@@ -53,7 +53,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
static void ubiblock_remove_all(void)
{
struct ubiblock *next;
-@@ -684,6 +722,10 @@ int __init ubiblock_init(void)
+@@ -684,6 +725,10 @@ int __init ubiblock_init(void)
*/
ubiblock_create_from_param();
diff --git a/target/linux/generic/pending-5.10/760-net-dsa-mv88e6xxx-fix-vlan-setup.patch b/target/linux/generic/pending-5.10/760-net-dsa-mv88e6xxx-fix-vlan-setup.patch
index e6a3d15b79..42b91fe4c3 100644
--- a/target/linux/generic/pending-5.10/760-net-dsa-mv88e6xxx-fix-vlan-setup.patch
+++ b/target/linux/generic/pending-5.10/760-net-dsa-mv88e6xxx-fix-vlan-setup.patch
@@ -17,7 +17,7 @@ Signed-off-by: DENG Qingfang <dqfext@gmail.com>
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
-@@ -2853,6 +2853,7 @@ static int mv88e6xxx_setup(struct dsa_sw
+@@ -2857,6 +2857,7 @@ static int mv88e6xxx_setup(struct dsa_sw
chip->ds = ds;
ds->slave_mii_bus = mv88e6xxx_default_mdio_bus(chip);
--
2.25.1

View File

@@ -0,0 +1,45 @@
From ea0fbd7e8fcf269feaf54b639512651faf96dcfd Mon Sep 17 00:00:00 2001
From: John Crispin <john@phrozen.org>
Date: Wed, 7 Apr 2021 11:11:04 +0200
Subject: [PATCH 10/37] mt76: update to latest HEAD revision
Signed-off-by: John Crispin <john@phrozen.org>
---
package/kernel/mt76/Makefile | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/package/kernel/mt76/Makefile b/package/kernel/mt76/Makefile
index 45375ef564..c58d9aa9f6 100644
--- a/package/kernel/mt76/Makefile
+++ b/package/kernel/mt76/Makefile
@@ -8,9 +8,9 @@ PKG_LICENSE_FILES:=
PKG_SOURCE_URL:=https://github.com/openwrt/mt76
PKG_SOURCE_PROTO:=git
-PKG_SOURCE_DATE:=2021-02-14
-PKG_SOURCE_VERSION:=289cd7804587dc48f776d450db9cd3762692a370
-PKG_MIRROR_HASH:=91885feca9d935586c6e33a8e3734bfa61991d869bf42ac0d1c8c3b19bfa9653
+PKG_SOURCE_DATE:=2021-04-07
+PKG_SOURCE_VERSION:=813db729c02ffa74fdda6d461afeb5aabc5706bb
+PKG_MIRROR_HASH:=63bd913f8ba3e85ae7a4575737a2c66377ebf59fa543e025150c650dd9ae13f2
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
PKG_BUILD_PARALLEL:=1
@@ -407,6 +407,14 @@ define KernelPackage/mt7915e/install
$(1)/lib/firmware/mediatek
endef
+define KernelPackage/mt7921e/install
+ $(INSTALL_DIR) $(1)/lib/firmware/mediatek
+ cp \
+ $(PKG_BUILD_DIR)/firmware/WIFI_MT7961_patch_mcu_1_2_hdr.bin \
+ $(PKG_BUILD_DIR)/firmware/WIFI_RAM_CODE_MT7961_1.bin \
+ $(1)/lib/firmware/mediatek
+endef
+
define Package/mt76-test/install
mkdir -p $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/mt76-test $(1)/usr/sbin
--
2.25.1

View File

@@ -1,910 +0,0 @@
From 4ff7b77727cc6c4ed02fa89ced3aaa3d9437bf22 Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@nbd.name>
Date: Thu, 9 Apr 2020 09:53:24 +0200
Subject: [PATCH 11/22] mediatek: implement bad-block management table support
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../mediatek/mt7622-elecom-wrc-2533gent.dts | 2 +
target/linux/mediatek/mt7622/config-5.4 | 1 +
target/linux/mediatek/mt7623/config-5.4 | 1 +
target/linux/mediatek/mt7629/config-5.4 | 1 +
.../patches-5.4/0310-mtk-bmt-support.patch | 837 ++++++++++++++++++
5 files changed, 842 insertions(+)
create mode 100644 target/linux/mediatek/patches-5.4/0310-mtk-bmt-support.patch
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7622-elecom-wrc-2533gent.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7622-elecom-wrc-2533gent.dts
index 2ac1c6a671..3971ce0389 100644
--- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7622-elecom-wrc-2533gent.dts
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7622-elecom-wrc-2533gent.dts
@@ -514,6 +514,8 @@
spi-max-frequency = <104000000>;
reg = <0>;
+ mediatek,bmt-v2;
+
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
diff --git a/target/linux/mediatek/mt7622/config-5.4 b/target/linux/mediatek/mt7622/config-5.4
index 1b0b1e36a6..cdb73bd7bc 100644
--- a/target/linux/mediatek/mt7622/config-5.4
+++ b/target/linux/mediatek/mt7622/config-5.4
@@ -396,6 +396,7 @@ CONFIG_MT753X_GSW=y
CONFIG_MTD_NAND_CORE=y
CONFIG_MTD_NAND_ECC_SW_HAMMING=y
CONFIG_MTD_NAND_MTK=y
+CONFIG_MTD_NAND_MTK_BMT=y
CONFIG_MTD_RAW_NAND=y
CONFIG_MTD_SPI_NAND=y
CONFIG_MTD_SPI_NOR=y
diff --git a/target/linux/mediatek/mt7623/config-5.4 b/target/linux/mediatek/mt7623/config-5.4
index dbd3055d3b..839eb71008 100644
--- a/target/linux/mediatek/mt7623/config-5.4
+++ b/target/linux/mediatek/mt7623/config-5.4
@@ -332,6 +332,7 @@ CONFIG_MODULES_USE_ELF_REL=y
# CONFIG_MT753X_GSW is not set
CONFIG_MTD_BLOCK2MTD=y
CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_NAND_MTK_BMT is not set
CONFIG_MTD_SPI_NOR=y
CONFIG_MTD_SPLIT_FIRMWARE=y
CONFIG_MTD_SPLIT_UIMAGE_FW=y
diff --git a/target/linux/mediatek/mt7629/config-5.4 b/target/linux/mediatek/mt7629/config-5.4
index 7fe01d1748..6ecde5ced6 100644
--- a/target/linux/mediatek/mt7629/config-5.4
+++ b/target/linux/mediatek/mt7629/config-5.4
@@ -240,6 +240,7 @@ CONFIG_MT753X_GSW=y
CONFIG_MTD_NAND_CORE=y
CONFIG_MTD_NAND_ECC_SW_HAMMING=y
CONFIG_MTD_NAND_MTK=y
+# CONFIG_MTD_NAND_MTK_BMT is not set
CONFIG_MTD_RAW_NAND=y
CONFIG_MTD_SPI_NAND=y
CONFIG_MTD_SPI_NOR=y
diff --git a/target/linux/mediatek/patches-5.4/0310-mtk-bmt-support.patch b/target/linux/mediatek/patches-5.4/0310-mtk-bmt-support.patch
new file mode 100644
index 0000000000..2a23f8c3dc
--- /dev/null
+++ b/target/linux/mediatek/patches-5.4/0310-mtk-bmt-support.patch
@@ -0,0 +1,837 @@
+--- a/drivers/mtd/nand/Kconfig
++++ b/drivers/mtd/nand/Kconfig
+@@ -5,3 +5,7 @@ config MTD_NAND_CORE
+ source "drivers/mtd/nand/onenand/Kconfig"
+ source "drivers/mtd/nand/raw/Kconfig"
+ source "drivers/mtd/nand/spi/Kconfig"
++
++config MTD_NAND_MTK_BMT
++ bool "Support MediaTek NAND Bad-block Management Table"
++ default n
+--- a/drivers/mtd/nand/Makefile
++++ b/drivers/mtd/nand/Makefile
+@@ -2,6 +2,7 @@
+
+ nandcore-objs := core.o bbt.o
+ obj-$(CONFIG_MTD_NAND_CORE) += nandcore.o
++obj-$(CONFIG_MTD_NAND_MTK_BMT) += mtk_bmt.o
+
+ obj-y += onenand/
+ obj-y += raw/
+--- /dev/null
++++ b/drivers/mtd/nand/mtk_bmt.c
+@@ -0,0 +1,766 @@
++/*
++ * Copyright (c) 2017 MediaTek Inc.
++ * Author: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
++ * Copyright (c) 2020 Felix Fietkau <nbd@nbd.name>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License version 2 as
++ * published by the Free Software Foundation.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ */
++
++#include <linux/slab.h>
++#include <linux/gfp.h>
++#include <linux/kernel.h>
++#include <linux/of.h>
++#include <linux/mtd/nand.h>
++#include <linux/mtd/partitions.h>
++#include <linux/mtd/mtk_bmt.h>
++#include <linux/module.h>
++#include <linux/debugfs.h>
++
++#define MAIN_SIGNATURE_OFFSET 0
++#define OOB_SIGNATURE_OFFSET 1
++#define BBPOOL_RATIO 2
++
++#define BBT_LOG(fmt, ...) pr_debug("[BBT][%s|%d] "fmt"\n", __func__, __LINE__, ##__VA_ARGS__)
++
++/* Maximum 8k blocks */
++#define BB_TABLE_MAX 0x2000U
++#define BMT_TABLE_MAX (BB_TABLE_MAX * BBPOOL_RATIO / 100)
++#define BMT_TBL_DEF_VAL 0x0
++
++/*
++ * Burner Bad Block Table
++ * --------- Only support SLC Nand Chips!!!!!!!!!!! ----------
++ */
++
++struct bbbt {
++ char signature[3];
++ /* This version is used to distinguish the legacy and new algorithm */
++#define BBMT_VERSION 2
++ unsigned char version;
++ /* Below 2 tables will be written in SLC */
++ u16 bb_tbl[BB_TABLE_MAX];
++ struct bbmt {
++ u16 block;
++#define NO_MAPPED 0
++#define NORMAL_MAPPED 1
++#define BMT_MAPPED 2
++ u16 mapped;
++ } bmt_tbl[BMT_TABLE_MAX];
++};
++
++static struct bmt_desc {
++ struct mtd_info *mtd;
++
++ int (*_read_oob) (struct mtd_info *mtd, loff_t from,
++ struct mtd_oob_ops *ops);
++ int (*_write_oob) (struct mtd_info *mtd, loff_t to,
++ struct mtd_oob_ops *ops);
++ const struct nand_ops *nand_ops;
++
++ struct bbbt *bbt;
++
++ struct dentry *debugfs_dir;
++
++ u32 pg_size;
++ u32 blk_size;
++ u16 pg_shift;
++ u16 blk_shift;
++ /* bbt logical address */
++ u16 pool_lba;
++ /* bbt physical address */
++ u16 pool_pba;
++ /* Maximum count of bad blocks that the vendor guaranteed */
++ u16 bb_max;
++ /* Total blocks of the Nand Chip */
++ u16 total_blks;
++ /* The block(n) BMT is located at (bmt_tbl[n]) */
++ u16 bmt_blk_idx;
++ /* How many pages needs to store 'struct bbbt' */
++ u32 bmt_pgs;
++
++ /* to compensate for driver level remapping */
++ u8 oob_offset;
++} bmtd = {0};
++
++static unsigned char *nand_bbt_buf;
++static unsigned char *nand_data_buf;
++
++/* -------- Unit conversions -------- */
++static inline u32 blk_pg(u16 block)
++{
++ return (u32)(block << (bmtd.blk_shift - bmtd.pg_shift));
++}
++
++/* -------- Nand operations wrapper -------- */
++static inline int
++bbt_nand_read(u32 page, unsigned char *dat, int dat_len,
++ unsigned char *fdm, int fdm_len)
++{
++ struct mtd_oob_ops ops = {
++ .mode = MTD_OPS_PLACE_OOB,
++ .ooboffs = bmtd.oob_offset,
++ .oobbuf = fdm,
++ .ooblen = fdm_len,
++ .datbuf = dat,
++ .len = dat_len,
++ };
++
++ return bmtd._read_oob(bmtd.mtd, page << bmtd.pg_shift, &ops);
++}
++
++static inline int bbt_nand_erase(u16 block)
++{
++ struct nand_device *nand = mtd_to_nanddev(bmtd.mtd);
++ loff_t addr = (loff_t)block << bmtd.blk_shift;
++ struct nand_pos pos;
++
++ nanddev_offs_to_pos(nand, addr, &pos);
++ return bmtd.nand_ops->erase(nand, &pos);
++}
++
++/* -------- Bad Blocks Management -------- */
++static int
++read_bmt(u16 block, unsigned char *dat, unsigned char *fdm, int fdm_len)
++{
++ u32 len = bmtd.bmt_pgs << bmtd.pg_shift;
++
++ return bbt_nand_read(blk_pg(block), dat, len, fdm, fdm_len);
++}
++
++static int write_bmt(u16 block, unsigned char *dat)
++{
++ struct mtd_oob_ops ops = {
++ .mode = MTD_OPS_PLACE_OOB,
++ .ooboffs = OOB_SIGNATURE_OFFSET + bmtd.oob_offset,
++ .oobbuf = "bmt",
++ .ooblen = 3,
++ .datbuf = dat,
++ .len = bmtd.bmt_pgs << bmtd.pg_shift,
++ };
++ loff_t addr = (loff_t)block << bmtd.blk_shift;
++
++ return bmtd._write_oob(bmtd.mtd, addr, &ops);
++}
++
++static u16 find_valid_block(u16 block)
++{
++ u8 fdm[4];
++ int ret;
++ int loop = 0;
++
++retry:
++ if (block >= bmtd.total_blks)
++ return 0;
++
++ ret = bbt_nand_read(blk_pg(block), nand_data_buf, bmtd.pg_size,
++ fdm, sizeof(fdm));
++ /* Read the 1st byte of FDM to judge whether it's a bad
++ * or not
++ */
++ if (ret || fdm[0] != 0xff) {
++ pr_info("nand: found bad block 0x%x\n", block);
++ if (loop >= bmtd.bb_max) {
++ pr_info("nand: FATAL ERR: too many bad blocks!!\n");
++ return 0;
++ }
++
++ loop++;
++ block++;
++ goto retry;
++ }
++
++ return block;
++}
++
++/* Find out all bad blocks, and fill in the mapping table */
++static int scan_bad_blocks(struct bbbt *bbt)
++{
++ int i;
++ u16 block = 0;
++
++ /* First time download, the block0 MUST NOT be a bad block,
++ * this is guaranteed by vendor
++ */
++ bbt->bb_tbl[0] = 0;
++
++ /*
++ * Construct the mapping table of Normal data area(non-PMT/BMTPOOL)
++ * G - Good block; B - Bad block
++ * ---------------------------
++ * physical |G|G|B|G|B|B|G|G|G|G|B|G|B|
++ * ---------------------------
++ * What bb_tbl[i] looks like:
++ * physical block(i):
++ * 0 1 2 3 4 5 6 7 8 9 a b c
++ * mapped block(bb_tbl[i]):
++ * 0 1 3 6 7 8 9 b ......
++ * ATTENTION:
++ * If new bad block ocurred(n), search bmt_tbl to find
++ * a available block(x), and fill in the bb_tbl[n] = x;
++ */
++ for (i = 1; i < bmtd.pool_lba; i++) {
++ bbt->bb_tbl[i] = find_valid_block(bbt->bb_tbl[i - 1] + 1);
++ BBT_LOG("bb_tbl[0x%x] = 0x%x", i, bbt->bb_tbl[i]);
++ if (bbt->bb_tbl[i] == 0)
++ return -1;
++ }
++
++ /* Physical Block start Address of BMT pool */
++ bmtd.pool_pba = bbt->bb_tbl[i - 1] + 1;
++ if (bmtd.pool_pba >= bmtd.total_blks - 2) {
++ pr_info("nand: FATAL ERR: Too many bad blocks!!\n");
++ return -1;
++ }
++
++ BBT_LOG("pool_pba=0x%x", bmtd.pool_pba);
++ i = 0;
++ block = bmtd.pool_pba;
++ /*
++ * The bmt table is used for runtime bad block mapping
++ * G - Good block; B - Bad block
++ * ---------------------------
++ * physical |G|G|B|G|B|B|G|G|G|G|B|G|B|
++ * ---------------------------
++ * block: 0 1 2 3 4 5 6 7 8 9 a b c
++ * What bmt_tbl[i] looks like in initial state:
++ * i:
++ * 0 1 2 3 4 5 6 7
++ * bmt_tbl[i].block:
++ * 0 1 3 6 7 8 9 b
++ * bmt_tbl[i].mapped:
++ * N N N N N N N B
++ * N - Not mapped(Available)
++ * M - Mapped
++ * B - BMT
++ * ATTENTION:
++ * BMT always in the last valid block in pool
++ */
++ while ((block = find_valid_block(block)) != 0) {
++ bbt->bmt_tbl[i].block = block;
++ bbt->bmt_tbl[i].mapped = NO_MAPPED;
++ BBT_LOG("bmt_tbl[%d].block = 0x%x", i, block);
++ block++;
++ i++;
++ }
++
++ /* i - How many available blocks in pool, which is the length of bmt_tbl[]
++ * bmtd.bmt_blk_idx - bmt_tbl[bmtd.bmt_blk_idx].block => the BMT block
++ */
++ bmtd.bmt_blk_idx = i - 1;
++ bbt->bmt_tbl[bmtd.bmt_blk_idx].mapped = BMT_MAPPED;
++
++ if (i < 1) {
++ pr_info("nand: FATAL ERR: no space to store BMT!!\n");
++ return -1;
++ }
++
++ pr_info("[BBT] %d available blocks in BMT pool\n", i);
++
++ return 0;
++}
++
++static bool is_valid_bmt(unsigned char *buf, unsigned char *fdm)
++{
++ struct bbbt *bbt = (struct bbbt *)buf;
++ u8 *sig = (u8*)bbt->signature + MAIN_SIGNATURE_OFFSET;
++
++
++ if (memcmp(bbt->signature + MAIN_SIGNATURE_OFFSET, "BMT", 3) == 0 &&
++ memcmp(fdm + OOB_SIGNATURE_OFFSET, "bmt", 3) == 0) {
++ if (bbt->version == BBMT_VERSION)
++ return true;
++ }
++ BBT_LOG("[BBT] BMT Version not match,upgrage preloader and uboot please! sig=%02x%02x%02x, fdm=%02x%02x%02x",
++ sig[0], sig[1], sig[2],
++ fdm[1], fdm[2], fdm[3]);
++ return false;
++}
++
++static u16 get_bmt_index(struct bbmt *bmt)
++{
++ int i = 0;
++
++ while (bmt[i].block != BMT_TBL_DEF_VAL) {
++ if (bmt[i].mapped == BMT_MAPPED)
++ return i;
++ i++;
++ }
++ return 0;
++}
++
++static struct bbbt *scan_bmt(u16 block)
++{
++ u8 fdm[4];
++
++ if (block < bmtd.pool_lba)
++ return NULL;
++
++ if (read_bmt(block, nand_bbt_buf, fdm, sizeof(fdm)))
++ return scan_bmt(block - 1);
++
++ if (is_valid_bmt(nand_bbt_buf, fdm)) {
++ bmtd.bmt_blk_idx = get_bmt_index(((struct bbbt *)nand_bbt_buf)->bmt_tbl);
++ if (bmtd.bmt_blk_idx == 0) {
++ pr_info("[BBT] FATAL ERR: bmt block index is wrong!\n");
++ return NULL;
++ }
++ pr_info("[BBT] BMT.v2 is found at 0x%x\n", block);
++ return (struct bbbt *)nand_bbt_buf;
++ } else
++ return scan_bmt(block - 1);
++}
++
++/* Write the Burner Bad Block Table to Nand Flash
++ * n - write BMT to bmt_tbl[n]
++ */
++static u16 upload_bmt(struct bbbt *bbt, int n)
++{
++ u16 block;
++
++retry:
++ if (n < 0 || bbt->bmt_tbl[n].mapped == NORMAL_MAPPED) {
++ pr_info("nand: FATAL ERR: no space to store BMT!\n");
++ return (u16)-1;
++ }
++
++ block = bbt->bmt_tbl[n].block;
++ BBT_LOG("n = 0x%x, block = 0x%x", n, block);
++ if (bbt_nand_erase(block)) {
++ bbt->bmt_tbl[n].block = 0;
++ /* erase failed, try the previous block: bmt_tbl[n - 1].block */
++ n--;
++ goto retry;
++ }
++
++ /* The signature offset is fixed set to 0,
++ * oob signature offset is fixed set to 1
++ */
++ memcpy(bbt->signature + MAIN_SIGNATURE_OFFSET, "BMT", 3);
++ bbt->version = BBMT_VERSION;
++
++ if (write_bmt(block, (unsigned char *)bbt)) {
++ bbt->bmt_tbl[n].block = 0;
++
++ /* write failed, try the previous block in bmt_tbl[n - 1] */
++ n--;
++ goto retry;
++ }
++
++ /* Return the current index(n) of BMT pool (bmt_tbl[n]) */
++ return n;
++}
++
++static u16 find_valid_block_in_pool(struct bbbt *bbt)
++{
++ int i;
++
++ if (bmtd.bmt_blk_idx == 0)
++ goto error;
++
++ for (i = 0; i < bmtd.bmt_blk_idx; i++) {
++ if (bbt->bmt_tbl[i].block != 0 && bbt->bmt_tbl[i].mapped == NO_MAPPED) {
++ bbt->bmt_tbl[i].mapped = NORMAL_MAPPED;
++ return bbt->bmt_tbl[i].block;
++ }
++ }
++
++error:
++ pr_info("nand: FATAL ERR: BMT pool is run out!\n");
++ return 0;
++}
++
++/* We met a bad block, mark it as bad and map it to a valid block in pool,
++ * if it's a write failure, we need to write the data to mapped block
++ */
++static bool update_bmt(u16 block)
++{
++ u16 mapped_blk;
++ struct bbbt *bbt;
++
++ bbt = bmtd.bbt;
++ mapped_blk = find_valid_block_in_pool(bbt);
++ if (mapped_blk == 0)
++ return false;
++
++ /* Map new bad block to available block in pool */
++ bbt->bb_tbl[block] = mapped_blk;
++ bmtd.bmt_blk_idx = upload_bmt(bbt, bmtd.bmt_blk_idx);
++
++ return true;
++}
++
++u16 get_mapping_block_index(int block)
++{
++ int mapping_block;
++
++ if (block < bmtd.pool_lba)
++ mapping_block = bmtd.bbt->bb_tbl[block];
++ else
++ mapping_block = block;
++ BBT_LOG("0x%x mapped to 0x%x", block, mapping_block);
++
++ return mapping_block;
++}
++
++static int
++mtk_bmt_read(struct mtd_info *mtd, loff_t from,
++ struct mtd_oob_ops *ops)
++{
++ struct mtd_oob_ops cur_ops = *ops;
++ int retry_count = 0;
++ loff_t cur_from;
++ int ret;
++
++ ops->retlen = 0;
++ ops->oobretlen = 0;
++
++ while (ops->retlen < ops->len || ops->oobretlen < ops->ooblen) {
++ u32 offset = from & (bmtd.blk_size - 1);
++ u32 block = from >> bmtd.blk_shift;
++ u32 cur_block;
++
++ cur_block = get_mapping_block_index(block);
++ cur_from = ((loff_t)cur_block << bmtd.blk_shift) + offset;
++
++ cur_ops.oobretlen = 0;
++ cur_ops.retlen = 0;
++ cur_ops.len = min_t(u32, mtd->erasesize - offset,
++ ops->len - ops->retlen);
++ ret = bmtd._read_oob(mtd, cur_from, &cur_ops);
++ if (ret < 0) {
++ update_bmt(block);
++ if (retry_count++ < 10)
++ continue;
++
++ return ret;
++ }
++
++ ops->retlen += cur_ops.retlen;
++ ops->oobretlen += cur_ops.oobretlen;
++
++ cur_ops.datbuf += cur_ops.retlen;
++ cur_ops.oobbuf += cur_ops.oobretlen;
++ cur_ops.ooblen -= cur_ops.oobretlen;
++
++ if (!cur_ops.len)
++ cur_ops.len = mtd->erasesize - offset;
++
++ from += cur_ops.len;
++ retry_count = 0;
++ }
++
++ return 0;
++}
++
++static int
++mtk_bmt_write(struct mtd_info *mtd, loff_t to,
++ struct mtd_oob_ops *ops)
++{
++ struct mtd_oob_ops cur_ops = *ops;
++ int retry_count = 0;
++ loff_t cur_to;
++ int ret;
++
++ ops->retlen = 0;
++ ops->oobretlen = 0;
++
++ while (ops->retlen < ops->len || ops->oobretlen < ops->ooblen) {
++ u32 offset = to & (bmtd.blk_size - 1);
++ u32 block = to >> bmtd.blk_shift;
++ u32 cur_block;
++
++ cur_block = get_mapping_block_index(block);
++ cur_to = ((loff_t)cur_block << bmtd.blk_shift) + offset;
++
++ cur_ops.oobretlen = 0;
++ cur_ops.retlen = 0;
++ cur_ops.len = min_t(u32, bmtd.blk_size - offset,
++ ops->len - ops->retlen);
++ ret = bmtd._write_oob(mtd, cur_to, &cur_ops);
++ if (ret < 0) {
++ update_bmt(block);
++ if (retry_count++ < 10)
++ continue;
++
++ return ret;
++ }
++
++ ops->retlen += cur_ops.retlen;
++ ops->oobretlen += cur_ops.oobretlen;
++
++ cur_ops.datbuf += cur_ops.retlen;
++ cur_ops.oobbuf += cur_ops.oobretlen;
++ cur_ops.ooblen -= cur_ops.oobretlen;
++
++ if (!cur_ops.len)
++ cur_ops.len = mtd->erasesize - offset;
++
++ to += cur_ops.len;
++ retry_count = 0;
++ }
++
++ return 0;
++}
++
++
++
++static int
++mtk_bmt_erase(struct nand_device *nand, const struct nand_pos *pos)
++{
++ struct nand_pos new_pos = *pos;
++ int retry_count = 0;
++ int ret;
++
++retry:
++ new_pos.eraseblock = get_mapping_block_index(pos->eraseblock);
++
++ ret = bmtd.nand_ops->erase(nand, &new_pos);
++ if (ret) {
++ update_bmt(pos->eraseblock);
++ if (retry_count++ < 10)
++ goto retry;
++ }
++
++ return ret;
++}
++
++static bool
++mtk_bmt_isbad(struct nand_device *nand, const struct nand_pos *pos)
++{
++ struct nand_pos new_pos = *pos;
++ int retry_count = 0;
++ bool ret;
++
++retry:
++ new_pos.eraseblock = get_mapping_block_index(pos->eraseblock);
++
++ ret = bmtd.nand_ops->isbad(nand, &new_pos);
++ if (ret) {
++ update_bmt(pos->eraseblock);
++ if (retry_count++ < 10)
++ goto retry;
++ }
++
++ return ret;
++}
++
++static int
++mtk_bmt_markbad(struct nand_device *nand, const struct nand_pos *pos)
++{
++ struct nand_pos new_pos = *pos;
++
++ new_pos.eraseblock = get_mapping_block_index(new_pos.eraseblock);
++ update_bmt(pos->eraseblock);
++
++ return bmtd.nand_ops->markbad(nand, &new_pos);
++}
++
++static void
++mtk_bmt_replace_ops(struct mtd_info *mtd)
++{
++ static const struct nand_ops mtk_bmt_nand_ops = {
++ .erase = mtk_bmt_erase,
++ .isbad = mtk_bmt_isbad,
++ .markbad = mtk_bmt_markbad,
++ };
++ struct nand_device *nand = mtd_to_nanddev(mtd);
++
++ bmtd.nand_ops = nand->ops;
++ bmtd._read_oob = mtd->_read_oob;
++ bmtd._write_oob = mtd->_write_oob;
++
++ mtd->_read_oob = mtk_bmt_read;
++ mtd->_write_oob = mtk_bmt_write;
++ nand->ops = &mtk_bmt_nand_ops;
++}
++
++static int mtk_bmt_debug_mark_good(void *data, u64 val)
++{
++ u32 block = val >> bmtd.blk_shift;
++
++ bmtd.bbt->bb_tbl[block] = block;
++ bmtd.bmt_blk_idx = upload_bmt(bmtd.bbt, bmtd.bmt_blk_idx);
++
++ return 0;
++}
++
++static int mtk_bmt_debug_mark_bad(void *data, u64 val)
++{
++ u32 block = val >> bmtd.blk_shift;
++
++ update_bmt(block);
++
++ return 0;
++}
++
++DEFINE_DEBUGFS_ATTRIBUTE(fops_mark_good, NULL, mtk_bmt_debug_mark_good, "%llu\n");
++DEFINE_DEBUGFS_ATTRIBUTE(fops_mark_bad, NULL, mtk_bmt_debug_mark_bad, "%llu\n");
++
++static void
++mtk_bmt_add_debugfs(void)
++{
++ struct dentry *dir;
++
++ dir = bmtd.debugfs_dir = debugfs_create_dir("mtk-bmt", NULL);
++ if (!dir)
++ return;
++
++ debugfs_create_file_unsafe("mark_good", S_IWUSR, dir, NULL, &fops_mark_good);
++ debugfs_create_file_unsafe("mark_bad", S_IWUSR, dir, NULL, &fops_mark_bad);
++}
++
++void mtk_bmt_detach(struct mtd_info *mtd)
++{
++ struct nand_device *nand = mtd_to_nanddev(mtd);
++
++ if (bmtd.mtd != mtd)
++ return;
++
++ if (bmtd.debugfs_dir)
++ debugfs_remove_recursive(bmtd.debugfs_dir);
++ bmtd.debugfs_dir = NULL;
++
++ kfree(nand_bbt_buf);
++ kfree(nand_data_buf);
++
++ mtd->_read_oob = bmtd._read_oob;
++ mtd->_write_oob = bmtd._write_oob;
++ mtd->size = bmtd.total_blks << bmtd.blk_shift;
++ nand->ops = bmtd.nand_ops;
++
++ memset(&bmtd, 0, sizeof(bmtd));
++}
++
++/* total_blocks - The total count of blocks that the Nand Chip has */
++int mtk_bmt_attach(struct mtd_info *mtd)
++{
++ struct device_node *np;
++ struct bbbt *bbt;
++ u32 bufsz;
++ u32 block;
++ u16 total_blocks, pmt_block;
++ int ret = 0;
++ u32 bmt_pool_size;
++
++ if (bmtd.mtd)
++ return -ENOSPC;
++
++ np = mtd_get_of_node(mtd);
++ if (!np)
++ return 0;
++
++ if (!of_property_read_bool(np, "mediatek,bmt-v2"))
++ return 0;
++
++ if (of_property_read_u32(np, "mediatek,bmt-pool-size",
++ &bmt_pool_size) != 0)
++ bmt_pool_size = 80;
++
++ if (of_property_read_u8(np, "mediatek,bmt-oob-offset",
++ &bmtd.oob_offset) != 0)
++ bmtd.oob_offset = 8;
++
++ bmtd.mtd = mtd;
++ mtk_bmt_replace_ops(mtd);
++
++ bmtd.blk_size = mtd->erasesize;
++ bmtd.blk_shift = ffs(bmtd.blk_size) - 1;
++ bmtd.pg_size = mtd->writesize;
++ bmtd.pg_shift = ffs(bmtd.pg_size) - 1;
++ total_blocks = mtd->size >> bmtd.blk_shift;
++ pmt_block = total_blocks - bmt_pool_size - 2;
++
++ mtd->size = pmt_block << bmtd.blk_shift;
++
++ /*
++ * ---------------------------------------
++ * | PMT(2blks) | BMT POOL(totalblks * 2%) |
++ * ---------------------------------------
++ * ^ ^
++ * | |
++ * pmt_block pmt_block + 2blocks(pool_lba)
++ *
++ * ATTETION!!!!!!
++ * The blocks ahead of the boundary block are stored in bb_tbl
++ * and blocks behind are stored in bmt_tbl
++ */
++
++ bmtd.pool_lba = (u16)(pmt_block + 2);
++ bmtd.total_blks = total_blocks;
++ bmtd.bb_max = bmtd.total_blks * BBPOOL_RATIO / 100;
++
++ /* 3 buffers we need */
++ bufsz = round_up(sizeof(struct bbbt), bmtd.pg_size);
++ bmtd.bmt_pgs = bufsz >> bmtd.pg_shift;
++
++ nand_bbt_buf = kzalloc(bufsz, GFP_KERNEL);
++ nand_data_buf = kzalloc(bmtd.pg_size, GFP_KERNEL);
++
++ if (!nand_bbt_buf || !nand_data_buf) {
++ pr_info("nand: FATAL ERR: allocate buffer failed!\n");
++ ret = -1;
++ goto error;
++ }
++
++ memset(nand_bbt_buf, 0xff, bufsz);
++ memset(nand_data_buf, 0xff, bmtd.pg_size);
++
++ BBT_LOG("bbtbuf=0x%p(0x%x) dat=0x%p(0x%x)",
++ nand_bbt_buf, bufsz, nand_data_buf, bmtd.pg_size);
++ BBT_LOG("pool_lba=0x%x total_blks=0x%x bb_max=0x%x",
++ bmtd.pool_lba, bmtd.total_blks, bmtd.bb_max);
++
++ /* Scanning start from the first page of the last block
++ * of whole flash
++ */
++ bbt = scan_bmt(bmtd.total_blks - 1);
++ if (!bbt) {
++ /* BMT not found */
++ if (bmtd.total_blks > BB_TABLE_MAX + BMT_TABLE_MAX) {
++ pr_info("nand: FATAL: Too many blocks, can not support!\n");
++ ret = -1;
++ goto error;
++ }
++
++ bbt = (struct bbbt *)nand_bbt_buf;
++ memset(bbt->bmt_tbl, BMT_TBL_DEF_VAL, sizeof(bbt->bmt_tbl));
++
++ if (scan_bad_blocks(bbt)) {
++ ret = -1;
++ goto error;
++ }
++
++ /* BMT always in the last valid block in pool */
++ bmtd.bmt_blk_idx = upload_bmt(bbt, bmtd.bmt_blk_idx);
++ block = bbt->bmt_tbl[bmtd.bmt_blk_idx].block;
++ pr_notice("[BBT] BMT.v2 is written into PBA:0x%x\n", block);
++
++ if (bmtd.bmt_blk_idx == 0)
++ pr_info("nand: Warning: no available block in BMT pool!\n");
++ else if (bmtd.bmt_blk_idx == (u16)-1) {
++ ret = -1;
++ goto error;
++ }
++ }
++ mtk_bmt_add_debugfs();
++
++ bmtd.bbt = bbt;
++ return 0;
++
++error:
++ mtk_bmt_detach(mtd);
++ return ret;
++}
++
++
++MODULE_LICENSE("GPL");
++MODULE_AUTHOR("Xiangsheng Hou <xiangsheng.hou@mediatek.com>, Felix Fietkau <nbd@nbd.name>");
++MODULE_DESCRIPTION("Bad Block mapping management v2 for MediaTek NAND Flash Driver");
++
+--- a/drivers/mtd/nand/spi/core.c
++++ b/drivers/mtd/nand/spi/core.c
+@@ -18,6 +18,7 @@
+ #include <linux/slab.h>
+ #include <linux/spi/spi.h>
+ #include <linux/spi/spi-mem.h>
++#include <linux/mtd/mtk_bmt.h>
+
+ static int spinand_read_reg_op(struct spinand_device *spinand, u8 reg, u8 *val)
+ {
+@@ -1099,6 +1100,8 @@ static int spinand_probe(struct spi_mem
+ if (ret)
+ return ret;
+
++ mtk_bmt_attach(mtd);
++
+ ret = mtd_device_register(mtd, NULL, 0);
+ if (ret)
+ goto err_spinand_cleanup;
+@@ -1124,6 +1127,7 @@ static int spinand_remove(struct spi_mem
+ if (ret)
+ return ret;
+
++ mtk_bmt_detach(mtd);
+ spinand_cleanup(spinand);
+
+ return 0;
+--- /dev/null
++++ b/include/linux/mtd/mtk_bmt.h
+@@ -0,0 +1,18 @@
++#ifndef __MTK_BMT_H
++#define __MTK_BMT_H
++
++#ifdef CONFIG_MTD_NAND_MTK_BMT
++int mtk_bmt_attach(struct mtd_info *mtd);
++void mtk_bmt_detach(struct mtd_info *mtd);
++#else
++static inline int mtk_bmt_attach(struct mtd_info *mtd)
++{
++ return 0;
++}
++
++static inline void mtk_bmt_detach(struct mtd_info *mtd)
++{
++}
++#endif
++
++#endif
--
2.25.1

View File

@@ -1,215 +0,0 @@
From 1572b27651f11ac0e8f14a543815963147eb26ae Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@nbd.name>
Date: Wed, 3 Feb 2021 19:34:29 +0100
Subject: [PATCH 13/22] mediatek: add support for configuring BMT table size
via device tree
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../patches-5.10/330-mtk-bmt-support.patch | 59 ++++++++++++-------
1 file changed, 37 insertions(+), 22 deletions(-)
diff --git a/target/linux/mediatek/patches-5.10/330-mtk-bmt-support.patch b/target/linux/mediatek/patches-5.10/330-mtk-bmt-support.patch
index 5c20952611..504c602c50 100644
--- a/target/linux/mediatek/patches-5.10/330-mtk-bmt-support.patch
+++ b/target/linux/mediatek/patches-5.10/330-mtk-bmt-support.patch
@@ -23,7 +23,7 @@
obj-y += raw/
--- /dev/null
+++ b/drivers/mtd/nand/mtk_bmt.c
-@@ -0,0 +1,766 @@
+@@ -0,0 +1,781 @@
+/*
+ * Copyright (c) 2017 MediaTek Inc.
+ * Author: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
@@ -56,7 +56,7 @@
+#define BBT_LOG(fmt, ...) pr_debug("[BBT][%s|%d] "fmt"\n", __func__, __LINE__, ##__VA_ARGS__)
+
+/* Maximum 8k blocks */
-+#define BB_TABLE_MAX 0x2000U
++#define BB_TABLE_MAX bmtd.table_size
+#define BMT_TABLE_MAX (BB_TABLE_MAX * BBPOOL_RATIO / 100)
+#define BMT_TBL_DEF_VAL 0x0
+
@@ -71,14 +71,15 @@
+#define BBMT_VERSION 2
+ unsigned char version;
+ /* Below 2 tables will be written in SLC */
-+ u16 bb_tbl[BB_TABLE_MAX];
-+ struct bbmt {
-+ u16 block;
++ u16 bb_tbl[];
++};
++
++struct bbmt {
++ u16 block;
+#define NO_MAPPED 0
+#define NORMAL_MAPPED 1
+#define BMT_MAPPED 2
-+ u16 mapped;
-+ } bmt_tbl[BMT_TABLE_MAX];
++ u16 mapped;
+};
+
+static struct bmt_desc {
@@ -94,6 +95,7 @@
+
+ struct dentry *debugfs_dir;
+
++ u32 table_size;
+ u32 pg_size;
+ u32 blk_size;
+ u16 pg_shift;
@@ -152,6 +154,11 @@
+}
+
+/* -------- Bad Blocks Management -------- */
++static inline struct bbmt *bmt_tbl(struct bbbt *bbbt)
++{
++ return (struct bbmt *)&bbbt->bb_tbl[bmtd.table_size];
++}
++
+static int
+read_bmt(u16 block, unsigned char *dat, unsigned char *fdm, int fdm_len)
+{
@@ -269,8 +276,8 @@
+ * BMT always in the last valid block in pool
+ */
+ while ((block = find_valid_block(block)) != 0) {
-+ bbt->bmt_tbl[i].block = block;
-+ bbt->bmt_tbl[i].mapped = NO_MAPPED;
++ bmt_tbl(bbt)[i].block = block;
++ bmt_tbl(bbt)[i].mapped = NO_MAPPED;
+ BBT_LOG("bmt_tbl[%d].block = 0x%x", i, block);
+ block++;
+ i++;
@@ -280,7 +287,7 @@
+ * bmtd.bmt_blk_idx - bmt_tbl[bmtd.bmt_blk_idx].block => the BMT block
+ */
+ bmtd.bmt_blk_idx = i - 1;
-+ bbt->bmt_tbl[bmtd.bmt_blk_idx].mapped = BMT_MAPPED;
++ bmt_tbl(bbt)[bmtd.bmt_blk_idx].mapped = BMT_MAPPED;
+
+ if (i < 1) {
+ pr_info("nand: FATAL ERR: no space to store BMT!!\n");
@@ -332,7 +339,7 @@
+ return scan_bmt(block - 1);
+
+ if (is_valid_bmt(nand_bbt_buf, fdm)) {
-+ bmtd.bmt_blk_idx = get_bmt_index(((struct bbbt *)nand_bbt_buf)->bmt_tbl);
++ bmtd.bmt_blk_idx = get_bmt_index(bmt_tbl((struct bbbt *)nand_bbt_buf));
+ if (bmtd.bmt_blk_idx == 0) {
+ pr_info("[BBT] FATAL ERR: bmt block index is wrong!\n");
+ return NULL;
@@ -351,15 +358,15 @@
+ u16 block;
+
+retry:
-+ if (n < 0 || bbt->bmt_tbl[n].mapped == NORMAL_MAPPED) {
++ if (n < 0 || bmt_tbl(bbt)[n].mapped == NORMAL_MAPPED) {
+ pr_info("nand: FATAL ERR: no space to store BMT!\n");
+ return (u16)-1;
+ }
+
-+ block = bbt->bmt_tbl[n].block;
++ block = bmt_tbl(bbt)[n].block;
+ BBT_LOG("n = 0x%x, block = 0x%x", n, block);
+ if (bbt_nand_erase(block)) {
-+ bbt->bmt_tbl[n].block = 0;
++ bmt_tbl(bbt)[n].block = 0;
+ /* erase failed, try the previous block: bmt_tbl[n - 1].block */
+ n--;
+ goto retry;
@@ -372,7 +379,7 @@
+ bbt->version = BBMT_VERSION;
+
+ if (write_bmt(block, (unsigned char *)bbt)) {
-+ bbt->bmt_tbl[n].block = 0;
++ bmt_tbl(bbt)[n].block = 0;
+
+ /* write failed, try the previous block in bmt_tbl[n - 1] */
+ n--;
@@ -391,9 +398,9 @@
+ goto error;
+
+ for (i = 0; i < bmtd.bmt_blk_idx; i++) {
-+ if (bbt->bmt_tbl[i].block != 0 && bbt->bmt_tbl[i].mapped == NO_MAPPED) {
-+ bbt->bmt_tbl[i].mapped = NORMAL_MAPPED;
-+ return bbt->bmt_tbl[i].block;
++ if (bmt_tbl(bbt)[i].block != 0 && bmt_tbl(bbt)[i].mapped == NO_MAPPED) {
++ bmt_tbl(bbt)[i].mapped = NORMAL_MAPPED;
++ return bmt_tbl(bbt)[i].block;
+ }
+ }
+
@@ -471,6 +478,7 @@
+ ops->retlen += cur_ops.retlen;
+ ops->oobretlen += cur_ops.oobretlen;
+
++ cur_ops.ooboffs = 0;
+ cur_ops.datbuf += cur_ops.retlen;
+ cur_ops.oobbuf += cur_ops.oobretlen;
+ cur_ops.ooblen -= cur_ops.oobretlen;
@@ -521,6 +529,7 @@
+ ops->retlen += cur_ops.retlen;
+ ops->oobretlen += cur_ops.oobretlen;
+
++ cur_ops.ooboffs = 0;
+ cur_ops.datbuf += cur_ops.retlen;
+ cur_ops.oobbuf += cur_ops.oobretlen;
+ cur_ops.ooblen -= cur_ops.oobretlen;
@@ -673,7 +682,7 @@
+ u32 block;
+ u16 total_blocks, pmt_block;
+ int ret = 0;
-+ u32 bmt_pool_size;
++ u32 bmt_pool_size, bmt_table_size;
+
+ if (bmtd.mtd)
+ return -ENOSPC;
@@ -693,9 +702,14 @@
+ &bmtd.oob_offset) != 0)
+ bmtd.oob_offset = 8;
+
++ if (of_property_read_u32(np, "mediatek,bmt-table-size",
++ &bmt_table_size) != 0)
++ bmt_table_size = 0x2000U;
++
+ bmtd.mtd = mtd;
+ mtk_bmt_replace_ops(mtd);
+
++ bmtd.table_size = bmt_table_size;
+ bmtd.blk_size = mtd->erasesize;
+ bmtd.blk_shift = ffs(bmtd.blk_size) - 1;
+ bmtd.pg_size = mtd->writesize;
@@ -723,7 +737,8 @@
+ bmtd.bb_max = bmtd.total_blks * BBPOOL_RATIO / 100;
+
+ /* 3 buffers we need */
-+ bufsz = round_up(sizeof(struct bbbt), bmtd.pg_size);
++ bufsz = round_up(sizeof(struct bbbt) +
++ bmt_table_size * sizeof(struct bbmt), bmtd.pg_size);
+ bmtd.bmt_pgs = bufsz >> bmtd.pg_shift;
+
+ nand_bbt_buf = kzalloc(bufsz, GFP_KERNEL);
@@ -756,7 +771,7 @@
+ }
+
+ bbt = (struct bbbt *)nand_bbt_buf;
-+ memset(bbt->bmt_tbl, BMT_TBL_DEF_VAL, sizeof(bbt->bmt_tbl));
++ memset(bmt_tbl(bbt), BMT_TBL_DEF_VAL, bmtd.table_size * sizeof(struct bbmt));
+
+ if (scan_bad_blocks(bbt)) {
+ ret = -1;
@@ -765,7 +780,7 @@
+
+ /* BMT always in the last valid block in pool */
+ bmtd.bmt_blk_idx = upload_bmt(bbt, bmtd.bmt_blk_idx);
-+ block = bbt->bmt_tbl[bmtd.bmt_blk_idx].block;
++ block = bmt_tbl(bbt)[bmtd.bmt_blk_idx].block;
+ pr_notice("[BBT] BMT.v2 is written into PBA:0x%x\n", block);
+
+ if (bmtd.bmt_blk_idx == 0)
--
2.25.1

View File

@@ -1,43 +0,0 @@
From 29da2c500a856b214e9a0eca3ccdc98a6470da48 Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@nbd.name>
Date: Wed, 3 Feb 2021 20:37:03 +0100
Subject: [PATCH 14/22] kernel: add support for enabling fit firmware partition
parser via cmdline
This is useful for dual-boot setups where the loader sets variables depending
on the flash boot partition.
For example the Linksys E8450 sets mtdparts=master for the first partition
and mtdparts=slave for the second one.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c
index 67ee33d085..5cc1658dbd 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c
@@ -49,6 +49,8 @@ mtdsplit_fit_parse(struct mtd_info *mtd,
const struct mtd_partition **pparts,
struct mtd_part_parser_data *data)
{
+ struct device_node *np = mtd_get_of_node(mtd);
+ const char *cmdline_match = NULL;
struct fdt_header hdr;
size_t hdr_len, retlen;
size_t offset;
@@ -57,6 +59,10 @@ mtdsplit_fit_parse(struct mtd_info *mtd,
struct mtd_partition *parts;
int ret;
+ of_property_read_string(np, "openwrt,cmdline-match", &cmdline_match);
+ if (cmdline_match && !strstr(saved_command_line, cmdline_match))
+ return -ENODEV;
+
hdr_len = sizeof(struct fdt_header);
/* Parse the MTD device & search for the FIT image location */
--
2.25.1

View File

@@ -1,757 +0,0 @@
From f0d0621227f82d56676485cb31918c17fb3ed564 Mon Sep 17 00:00:00 2001
From: John Crispin <john@phrozen.org>
Date: Tue, 2 Feb 2021 16:29:58 +0100
Subject: [PATCH 15/22] mediatek: add linksys-e8450 support
Signed-off-by: John Crispin <john@phrozen.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
.../dts/mediatek/mt7622-linksys-e8450.dts | 488 ++++++++++++++++++
target/linux/mediatek/image/mt7622.mk | 10 +
.../mt7622/base-files/etc/board.d/01_leds | 18 +
.../mt7622/base-files/etc/board.d/02_network | 11 +-
.../mt7622/base-files/etc/init.d/bootcount | 11 +
.../mt7622/base-files/lib/upgrade/platform.sh | 8 +
...Add-support-for-the-Fidelix-FM35X1GA.patch | 122 +++++
7 files changed, 667 insertions(+), 1 deletion(-)
create mode 100644 target/linux/mediatek/files-5.10/arch/arm64/boot/dts/mediatek/mt7622-linksys-e8450.dts
create mode 100755 target/linux/mediatek/mt7622/base-files/etc/board.d/01_leds
create mode 100755 target/linux/mediatek/mt7622/base-files/etc/init.d/bootcount
create mode 100644 target/linux/mediatek/patches-5.10/340-mtd-spinand-Add-support-for-the-Fidelix-FM35X1GA.patch
diff --git a/target/linux/mediatek/files-5.10/arch/arm64/boot/dts/mediatek/mt7622-linksys-e8450.dts b/target/linux/mediatek/files-5.10/arch/arm64/boot/dts/mediatek/mt7622-linksys-e8450.dts
new file mode 100644
index 0000000000..00b11690f0
--- /dev/null
+++ b/target/linux/mediatek/files-5.10/arch/arm64/boot/dts/mediatek/mt7622-linksys-e8450.dts
@@ -0,0 +1,488 @@
+/*
+ * SPDX-License-Identifier: (GPL-2.0 OR MIT)
+ */
+
+/dts-v1/;
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/gpio/gpio.h>
+
+#include "mt7622.dtsi"
+#include "mt6380.dtsi"
+
+/ {
+ model = "Linksys E8450";
+ compatible = "linksys,e8450", "mediatek,mt7622";
+
+ aliases {
+ serial0 = &uart0;
+ led-boot = &led_power;
+ led-failsafe = &led_power;
+ led-running = &led_power;
+ led-upgrade = &led_power;
+ };
+
+ chosen {
+ stdout-path = "serial0:115200n8";
+ bootargs = "earlycon=uart8250,mmio32,0x11002000 console=ttyS0,115200n1 swiotlb=512";
+ };
+
+ cpus {
+ cpu@0 {
+ proc-supply = <&mt6380_vcpu_reg>;
+ sram-supply = <&mt6380_vm_reg>;
+ };
+
+ cpu@1 {
+ proc-supply = <&mt6380_vcpu_reg>;
+ sram-supply = <&mt6380_vm_reg>;
+ };
+ };
+
+ gpio-keys {
+ compatible = "gpio-keys";
+
+ factory {
+ label = "reset";
+ linux,code = <KEY_RESTART>;
+ gpios = <&pio 0 GPIO_ACTIVE_LOW>;
+ };
+
+ wps {
+ label = "wps";
+ linux,code = <KEY_WPS_BUTTON>;
+ gpios = <&pio 102 GPIO_ACTIVE_LOW>;
+ };
+ };
+
+ gpio-leds {
+ compatible = "gpio-leds";
+
+ led_power: power_blue {
+ label = "power:blue";
+ gpios = <&pio 95 GPIO_ACTIVE_LOW>;
+ default-state = "on";
+ };
+
+ power_orange {
+ label = "power:orange";
+ gpios = <&pio 96 GPIO_ACTIVE_LOW>;
+ default-state = "off";
+ };
+
+ inet_blue {
+ label = "inet:blue";
+ gpios = <&pio 97 GPIO_ACTIVE_LOW>;
+ default-state = "off";
+ };
+
+ inet_orange {
+ label = "inet:orange";
+ gpios = <&pio 98 GPIO_ACTIVE_LOW>;
+ default-state = "off";
+ };
+ };
+
+ memory {
+ reg = <0 0x40000000 0 0x40000000>;
+ };
+
+ reg_1p8v: regulator-1p8v {
+ compatible = "regulator-fixed";
+ regulator-name = "fixed-1.8V";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <1800000>;
+ regulator-always-on;
+ };
+
+ reg_3p3v: regulator-3p3v {
+ compatible = "regulator-fixed";
+ regulator-name = "fixed-3.3V";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-boot-on;
+ regulator-always-on;
+ };
+
+ reg_5v: regulator-5v {
+ compatible = "regulator-fixed";
+ regulator-name = "fixed-5V";
+ regulator-min-microvolt = <5000000>;
+ regulator-max-microvolt = <5000000>;
+ regulator-boot-on;
+ regulator-always-on;
+ };
+};
+
+&bch {
+ status = "okay";
+};
+
+&btif {
+ status = "okay";
+};
+
+&cir {
+ pinctrl-names = "default";
+ pinctrl-0 = <&irrx_pins>;
+ status = "okay";
+};
+
+&eth {
+ pinctrl-names = "default";
+ pinctrl-0 = <&eth_pins>;
+ status = "okay";
+
+ gmac0: mac@0 {
+ compatible = "mediatek,eth-mac";
+ reg = <0>;
+ phy-mode = "2500base-x";
+
+ fixed-link {
+ speed = <2500>;
+ full-duplex;
+ pause;
+ };
+ };
+
+ mdio-bus {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ switch@0 {
+ compatible = "mediatek,mt7531";
+ reg = <0>;
+ reset-gpios = <&pio 54 0>;
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port@0 {
+ reg = <0>;
+ label = "lan1";
+ };
+
+ port@1 {
+ reg = <1>;
+ label = "lan2";
+ };
+
+ port@2 {
+ reg = <2>;
+ label = "lan3";
+ };
+
+ port@3 {
+ reg = <3>;
+ label = "lan4";
+ };
+
+ port@4 {
+ reg = <4>;
+ label = "wan";
+ };
+
+ port@6 {
+ reg = <6>;
+ label = "cpu";
+ ethernet = <&gmac0>;
+ phy-mode = "2500base-x";
+
+ fixed-link {
+ speed = <2500>;
+ full-duplex;
+ pause;
+ };
+ };
+ };
+ };
+
+ };
+};
+
+&pcie0 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pcie0_pins>;
+ status = "okay";
+};
+
+&pcie1 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pcie1_pins>;
+ status = "okay";
+};
+
+&slot0 {
+ mt7915@0,0 {
+ reg = <0x0000 0 0 0 0>;
+ mediatek,mtd-eeprom = <&factory 0x05000>;
+ };
+};
+
+&pio {
+ /* Attention: GPIO 90 is used to switch between PCIe@1,0 and
+ * SATA functions. i.e. output-high: PCIe, output-low: SATA
+ */
+// asm_sel {
+// gpio-hog;
+// gpios = <90 GPIO_ACTIVE_HIGH>;
+// output-high;
+// };
+
+ eth_pins: eth-pins {
+ mux {
+ function = "eth";
+ groups = "mdc_mdio", "rgmii_via_gmac2";
+ };
+ };
+
+ irrx_pins: irrx-pins {
+ mux {
+ function = "ir";
+ groups = "ir_1_rx";
+ };
+ };
+
+ irtx_pins: irtx-pins {
+ mux {
+ function = "ir";
+ groups = "ir_1_tx";
+ };
+ };
+
+ pcie0_pins: pcie0-pins {
+ mux {
+ function = "pcie";
+ groups = "pcie0_pad_perst",
+ "pcie0_1_waken",
+ "pcie0_1_clkreq";
+ };
+ };
+
+ pcie1_pins: pcie1-pins {
+ mux {
+ function = "pcie";
+ groups = "pcie1_pad_perst",
+ "pcie1_0_waken",
+ "pcie1_0_clkreq";
+ };
+ };
+
+ pmic_bus_pins: pmic-bus-pins {
+ mux {
+ function = "pmic";
+ groups = "pmic_bus";
+ };
+ };
+
+ pwm7_pins: pwm1-2-pins {
+ mux {
+ function = "pwm";
+ groups = "pwm_ch7_2";
+ };
+ };
+
+ wled_pins: wled-pins {
+ mux {
+ function = "led";
+ groups = "wled";
+ };
+ };
+
+ /* Serial NAND is shared pin with SPI-NOR */
+ serial_nand_pins: serial-nand-pins {
+ mux {
+ function = "flash";
+ groups = "snfi";
+ };
+ };
+
+ spic0_pins: spic0-pins {
+ mux {
+ function = "spi";
+ groups = "spic0_0";
+ };
+ };
+
+ spic1_pins: spic1-pins {
+ mux {
+ function = "spi";
+ groups = "spic1_0";
+ };
+ };
+
+ uart0_pins: uart0-pins {
+ mux {
+ function = "uart";
+ groups = "uart0_0_tx_rx" ;
+ };
+ };
+
+ uart2_pins: uart2-pins {
+ mux {
+ function = "uart";
+ groups = "uart2_1_tx_rx" ;
+ };
+ };
+
+ watchdog_pins: watchdog-pins {
+ mux {
+ function = "watchdog";
+ groups = "watchdog";
+ };
+ };
+};
+
+&pwm {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pwm7_pins>;
+ status = "okay";
+};
+
+&pwrap {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pmic_bus_pins>;
+
+ status = "okay";
+};
+
+&sata {
+ status = "disabled";
+};
+
+&sata_phy {
+ status = "disabled";
+};
+
+&snfi {
+ pinctrl-names = "default";
+ pinctrl-0 = <&serial_nand_pins>;
+ status = "okay";
+
+ spi_nand@0 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "spi-nand";
+ spi-max-frequency = <104000000>;
+ reg = <0>;
+
+ mediatek,bmt-v2;
+ mediatek,bmt-table-size = <0x1000>;
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ label = "Preloader";
+ reg = <0x00000 0x0080000>;
+ read-only;
+ };
+
+ partition@80000 {
+ label = "ATF";
+ reg = <0x80000 0x0040000>;
+ };
+
+ partition@c0000 {
+ label = "u-boot";
+ reg = <0xc0000 0x0080000>;
+ };
+
+ partition@140000 {
+ label = "u-boot-env";
+ reg = <0x140000 0x0080000>;
+ };
+
+ factory: partition@1c0000 {
+ label = "factory";
+ reg = <0x1c0000 0x0100000>;
+ };
+
+ partition@300000 {
+ label = "devinfo";
+ reg = <0x300000 0x020000>;
+ };
+
+ partition@320000 {
+ label = "senv";
+ reg = <0x320000 0x020000>;
+ };
+
+ partition@360000 {
+ label = "bootseq";
+ reg = <0x360000 0x020000>;
+ };
+
+ partition@500000 {
+ label = "firmware1";
+ compatible = "denx,fit";
+ openwrt,cmdline-match = "mtdparts=master";
+ reg = <0x500000 0x1E00000>;
+ };
+
+ partition@2300000 {
+ label = "firmware2";
+ compatible = "denx,fit";
+ openwrt,cmdline-match = "mtdparts=slave";
+ reg = <0x2300000 0x1E00000>;
+ };
+
+ partition@4100000 {
+ label = "data";
+ reg = <0x4100000 0x1900000>;
+ };
+
+ partition@5100000 {
+ label = "mfg";
+ reg = <0x5a00000 0x1400000>;
+ };
+ };
+ };
+};
+
+&spi0 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&spic0_pins>;
+ status = "okay";
+};
+
+&spi1 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&spic1_pins>;
+ status = "okay";
+};
+
+&ssusb {
+ vusb33-supply = <&reg_3p3v>;
+ vbus-supply = <&reg_5v>;
+ status = "okay";
+};
+
+&u3phy {
+ status = "okay";
+};
+
+&uart0 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart0_pins>;
+ status = "okay";
+};
+
+&uart2 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart2_pins>;
+ status = "okay";
+};
+
+&watchdog {
+ pinctrl-names = "default";
+ pinctrl-0 = <&watchdog_pins>;
+ status = "okay";
+};
+
+&wmac {
+ mediatek,mtd-eeprom = <&factory 0x0000>;
+ status = "okay";
+};
diff --git a/target/linux/mediatek/image/mt7622.mk b/target/linux/mediatek/image/mt7622.mk
index 74f6eba19a..efaa3bcaa3 100644
--- a/target/linux/mediatek/image/mt7622.mk
+++ b/target/linux/mediatek/image/mt7622.mk
@@ -36,6 +36,16 @@ define Device/elecom_wrc-2533gent
endef
TARGET_DEVICES += elecom_wrc-2533gent
+define Device/linksys_e8450
+ DEVICE_VENDOR := Linksys
+ DEVICE_MODEL := E8450
+ DEVICE_DTS := mt7622-linksys-e8450
+ DEVICE_DTS_DIR := $(DTS_DIR)/mediatek
+ DEVICE_PACKAGES := kmod-usb-ohci kmod-usb2 kmod-usb3 kmod-ata-ahci-mtk \
+ kmod-mt7615e kmod-mt7615-firmware kmod-mt7915
+endef
+TARGET_DEVICES += linksys_e8450
+
define Device/mediatek_mt7622-rfb1
DEVICE_VENDOR := MediaTek
DEVICE_MODEL := MTK7622 rfb1 AP
diff --git a/target/linux/mediatek/mt7622/base-files/etc/board.d/01_leds b/target/linux/mediatek/mt7622/base-files/etc/board.d/01_leds
new file mode 100755
index 0000000000..e74944a65f
--- /dev/null
+++ b/target/linux/mediatek/mt7622/base-files/etc/board.d/01_leds
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+. /lib/functions/leds.sh
+. /lib/functions/uci-defaults.sh
+
+board=$(board_name)
+
+board_config_update
+
+case $board in
+linksys,e8450)
+ ucidef_set_led_netdev "wan" "WAN" "inet:blue" "wan"
+ ;;
+esac
+
+board_config_flush
+
+exit 0
diff --git a/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network b/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network
index 3a409c8ec9..f6cd4ba3fc 100755
--- a/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network
+++ b/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network
@@ -10,7 +10,8 @@ mediatek_setup_interfaces()
case $board in
bananapi,bpi-r64-rootdisk|\
- bananapi,bpi-r64)
+ bananapi,bpi-r64|\
+ linksys,e8450)
ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3" wan
;;
mediatek,mt7622-rfb1)
@@ -31,7 +32,15 @@ mediatek_setup_macs()
local board="$1"
case $board in
+ linksys,e8450)
+ wan_mac=$(mtd_get_mac_ascii devinfo wan_mac_addr)
+ lan_mac=$(mtd_get_mac_ascii devinfo lan_mac_addr)
+ label_mac=$wan_mac
+ ;;
esac
+ [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
+ [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
+ [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
}
board_config_update
diff --git a/target/linux/mediatek/mt7622/base-files/etc/init.d/bootcount b/target/linux/mediatek/mt7622/base-files/etc/init.d/bootcount
new file mode 100755
index 0000000000..bc4eeb6530
--- /dev/null
+++ b/target/linux/mediatek/mt7622/base-files/etc/init.d/bootcount
@@ -0,0 +1,11 @@
+#!/bin/sh /etc/rc.common
+
+START=99
+
+boot() {
+ case $(board_name) in
+ linksys,e8450)
+ mtd erase senv || true
+ ;;
+ esac
+}
diff --git a/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh
index 8144476943..95ac8b5657 100755
--- a/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh
+++ b/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh
@@ -10,6 +10,14 @@ platform_do_upgrade() {
mediatek,mt7622,ubi)
nand_do_upgrade "$1"
;;
+ linksys,e8450)
+ if grep -q mtdparts=slave /proc/cmdline; then
+ PART_NAME=firmware2
+ else
+ PART_NAME=firmware1
+ fi
+ default_do_upgrade "$1"
+ ;;
*)
default_do_upgrade "$1"
;;
diff --git a/target/linux/mediatek/patches-5.10/340-mtd-spinand-Add-support-for-the-Fidelix-FM35X1GA.patch b/target/linux/mediatek/patches-5.10/340-mtd-spinand-Add-support-for-the-Fidelix-FM35X1GA.patch
new file mode 100644
index 0000000000..69a9297e1f
--- /dev/null
+++ b/target/linux/mediatek/patches-5.10/340-mtd-spinand-Add-support-for-the-Fidelix-FM35X1GA.patch
@@ -0,0 +1,122 @@
+From ea0df4552efcdcc2806fe6eba0540b5f719d80b6 Mon Sep 17 00:00:00 2001
+From: Davide Fioravanti <pantanastyle@gmail.com>
+Date: Fri, 8 Jan 2021 15:35:24 +0100
+Subject: [PATCH 1/1] mtd: spinand: Add support for the Fidelix FM35X1GA
+
+Datasheet: http://www.hobos.com.cn/upload/datasheet/DS35X1GAXXX_100_rev00.pdf
+
+Signed-off-by: Davide Fioravanti <pantanastyle@gmail.com>
+---
+ drivers/mtd/nand/spi/Makefile | 2 +-
+ drivers/mtd/nand/spi/core.c | 1 +
+ drivers/mtd/nand/spi/fidelix.c | 80 ++++++++++++++++++++++++++++++++++
+ include/linux/mtd/spinand.h | 1 +
+ 4 files changed, 83 insertions(+), 1 deletion(-)
+ create mode 100644 drivers/mtd/nand/spi/fidelix.c
+
+--- a/drivers/mtd/nand/spi/Makefile
++++ b/drivers/mtd/nand/spi/Makefile
+@@ -1,3 +1,3 @@
+ # SPDX-License-Identifier: GPL-2.0
+-spinand-objs := core.o gigadevice.o macronix.o micron.o paragon.o toshiba.o winbond.o
++spinand-objs := core.o fidelix.o gigadevice.o macronix.o micron.o paragon.o toshiba.o winbond.o
+ obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
+--- a/drivers/mtd/nand/spi/core.c
++++ b/drivers/mtd/nand/spi/core.c
+@@ -755,6 +755,7 @@ static const struct nand_ops spinand_ops
+ };
+
+ static const struct spinand_manufacturer *spinand_manufacturers[] = {
++ &fidelix_spinand_manufacturer,
+ &gigadevice_spinand_manufacturer,
+ &macronix_spinand_manufacturer,
+ &micron_spinand_manufacturer,
+--- /dev/null
++++ b/drivers/mtd/nand/spi/fidelix.c
+@@ -0,0 +1,76 @@
++// SPDX-License-Identifier: GPL-2.0
++/*
++ * Copyright (c) 2020 Davide Fioravanti <pantanastyle@gmail.com>
++ */
++
++#include <linux/device.h>
++#include <linux/kernel.h>
++#include <linux/mtd/spinand.h>
++
++#define SPINAND_MFR_FIDELIX 0xE5
++#define FIDELIX_ECCSR_MASK 0x0F
++
++static SPINAND_OP_VARIANTS(read_cache_variants,
++ SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
++ SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
++ SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
++
++static SPINAND_OP_VARIANTS(write_cache_variants,
++ SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
++ SPINAND_PROG_LOAD(true, 0, NULL, 0));
++
++static SPINAND_OP_VARIANTS(update_cache_variants,
++ SPINAND_PROG_LOAD_X4(false, 0, NULL, 0),
++ SPINAND_PROG_LOAD(false, 0, NULL, 0));
++
++static int fm35x1ga_ooblayout_ecc(struct mtd_info *mtd, int section,
++ struct mtd_oob_region *region)
++{
++ if (section > 3)
++ return -ERANGE;
++
++ region->offset = (16 * section) + 8;
++ region->length = 8;
++
++ return 0;
++}
++
++static int fm35x1ga_ooblayout_free(struct mtd_info *mtd, int section,
++ struct mtd_oob_region *region)
++{
++ if (section > 3)
++ return -ERANGE;
++
++ region->offset = (16 * section) + 2;
++ region->length = 6;
++
++ return 0;
++}
++
++static const struct mtd_ooblayout_ops fm35x1ga_ooblayout = {
++ .ecc = fm35x1ga_ooblayout_ecc,
++ .free = fm35x1ga_ooblayout_free,
++};
++
++static const struct spinand_info fidelix_spinand_table[] = {
++ SPINAND_INFO("FM35X1GA",
++ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x71),
++ NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
++ NAND_ECCREQ(4, 512),
++ SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
++ &write_cache_variants,
++ &update_cache_variants),
++ SPINAND_HAS_QE_BIT,
++ SPINAND_ECCINFO(&fm35x1ga_ooblayout, NULL)),
++};
++
++static const struct spinand_manufacturer_ops fidelix_spinand_manuf_ops = {
++};
++
++const struct spinand_manufacturer fidelix_spinand_manufacturer = {
++ .id = SPINAND_MFR_FIDELIX,
++ .name = "Fidelix",
++ .chips = fidelix_spinand_table,
++ .nchips = ARRAY_SIZE(fidelix_spinand_table),
++ .ops = &fidelix_spinand_manuf_ops,
++};
+--- a/include/linux/mtd/spinand.h
++++ b/include/linux/mtd/spinand.h
+@@ -238,6 +238,7 @@ struct spinand_manufacturer {
+ };
+
+ /* SPI NAND manufacturers */
++extern const struct spinand_manufacturer fidelix_spinand_manufacturer;
+ extern const struct spinand_manufacturer gigadevice_spinand_manufacturer;
+ extern const struct spinand_manufacturer macronix_spinand_manufacturer;
+ extern const struct spinand_manufacturer micron_spinand_manufacturer;
--
2.25.1

View File

@@ -1,42 +0,0 @@
From d8505bfc5491c7b3c9cfb6a58380c115f83ffeb7 Mon Sep 17 00:00:00 2001
From: Daniel Golle <daniel@makrotopia.org>
Date: Sat, 30 Jan 2021 23:08:27 +0000
Subject: [PATCH 16/22] mediatek: linksys-e8450: fix wifi and lan4
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
target/linux/mediatek/image/mt7622.mk | 2 +-
.../linux/mediatek/mt7622/base-files/etc/board.d/02_network | 4 +---
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/target/linux/mediatek/image/mt7622.mk b/target/linux/mediatek/image/mt7622.mk
index efaa3bcaa3..df9e0d7d17 100644
--- a/target/linux/mediatek/image/mt7622.mk
+++ b/target/linux/mediatek/image/mt7622.mk
@@ -42,7 +42,7 @@ define Device/linksys_e8450
DEVICE_DTS := mt7622-linksys-e8450
DEVICE_DTS_DIR := $(DTS_DIR)/mediatek
DEVICE_PACKAGES := kmod-usb-ohci kmod-usb2 kmod-usb3 kmod-ata-ahci-mtk \
- kmod-mt7615e kmod-mt7615-firmware kmod-mt7915
+ kmod-mt7615e kmod-mt7615-firmware kmod-mt7915e
endef
TARGET_DEVICES += linksys_e8450
diff --git a/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network b/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network
index f6cd4ba3fc..3d2b9ffe49 100755
--- a/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network
+++ b/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network
@@ -11,9 +11,7 @@ mediatek_setup_interfaces()
case $board in
bananapi,bpi-r64-rootdisk|\
bananapi,bpi-r64|\
- linksys,e8450)
- ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3" wan
- ;;
+ linksys,e8450|\
mediatek,mt7622-rfb1)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" wan
;;
--
2.25.1

View File

@@ -1,754 +0,0 @@
From 86c2de0e5b6b800525df4abf533366c34554064f Mon Sep 17 00:00:00 2001
From: Daniel Golle <daniel@makrotopia.org>
Date: Mon, 15 Feb 2021 14:37:17 +0000
Subject: [PATCH 17/22] image: add support for building FIT image with
filesystem
Allow for single (external-data) FIT image to hold kernel, dtb and
squashfs. In that way, the bootloader verify the system integrity
including the rootfs, flashing sysupgrade and factory on many platforms
becomes much easier.
In short: mkimage has a parameter '-E' which allows generating FIT
images with 'external' data rather than embedding the data into the
device-tree blob itself. In this way, the FIT structure itself remains
small and can be parsed easily (rather than having to page around
megabytes of image content). This patch makes use of that and adds
support for adding sub-images of type 'filesystem' which are used to
store the squashfs. Now U-Boot can verify the whole OS and the new
partition parsers added in the Linux kernel can detect the filesystem
sub-images and create partitions for them, and select the active
rootfs volume based on the configuration in FIT.
This new FIT partition parser works for NOR flash (on top of mtdblock),
NAND flash (on top of ubiblock) as well as classic block devices
(ie. eMMC, SDcard, SATA, NVME, ...) as well as .
See the follow-up commits for a good example of its use (on SPI-NAND).
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
include/image-commands.mk | 3 +-
package/base-files/files/lib/upgrade/nand.sh | 102 +++++---
scripts/mkits.sh | 45 +++-
target/linux/generic/config-5.10 | 1 +
.../generic/files/block/partitions/fit.c | 234 ++++++++++++++++++
.../400-block-fit-partition-parser.patch | 96 +++++++
...to-create-ubiblock-device-for-rootfs.patch | 5 +-
7 files changed, 442 insertions(+), 44 deletions(-)
create mode 100644 target/linux/generic/files/block/partitions/fit.c
create mode 100644 target/linux/generic/hack-5.10/400-block-fit-partition-parser.patch
diff --git a/include/image-commands.mk b/include/image-commands.mk
index 51e745958e..bddbed6052 100644
--- a/include/image-commands.mk
+++ b/include/image-commands.mk
@@ -200,11 +200,12 @@ define Build/fit
$(TOPDIR)/scripts/mkits.sh \
-D $(DEVICE_NAME) -o $@.its -k $@ \
$(if $(word 2,$(1)),-d $(word 2,$(1))) -C $(word 1,$(1)) \
+ $(if $(word 3,$(1)),-r $(IMAGE_ROOTFS) -f $(subst _,$(comma),$(DEVICE_NAME))) \
-a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
$(if $(DEVICE_FDT_NUM),-n $(DEVICE_FDT_NUM)) \
-c $(if $(DEVICE_DTS_CONFIG),$(DEVICE_DTS_CONFIG),"config@1") \
-A $(LINUX_KARCH) -v $(LINUX_VERSION)
- PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new
+ PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage $(if $(word 3,$(1)),-E -B 0x1000 -p 0x1000) -f $@.its $@.new
@mv $@.new $@
endef
diff --git a/package/base-files/files/lib/upgrade/nand.sh b/package/base-files/files/lib/upgrade/nand.sh
index e6f58df4f5..5bc9ff83f9 100644
--- a/package/base-files/files/lib/upgrade/nand.sh
+++ b/package/base-files/files/lib/upgrade/nand.sh
@@ -3,13 +3,13 @@
. /lib/functions.sh
-# 'kernel' partition on NAND contains the kernel
+# 'kernel' partition or UBI volume on NAND contains the kernel
CI_KERNPART="${CI_KERNPART:-kernel}"
# 'ubi' partition on NAND contains UBI
CI_UBIPART="${CI_UBIPART:-ubi}"
-# 'rootfs' partition on NAND contains the rootfs
+# 'rootfs' UBI volume on NAND contains the rootfs
CI_ROOTPART="${CI_ROOTPART:-rootfs}"
ubi_mknod() {
@@ -117,9 +117,11 @@ nand_restore_config() {
nand_upgrade_prepare_ubi() {
local rootfs_length="$1"
local rootfs_type="$2"
- local has_kernel="${3:-0}"
+ local kernel_length="$3"
local has_env="${4:-0}"
+ [ -n "$rootfs_length" -o -n "$kernel_length" ] || return 1
+
local mtdnum="$( find_mtd_index "$CI_UBIPART" )"
if [ ! "$mtdnum" ]; then
echo "cannot find ubi mtd partition $CI_UBIPART"
@@ -148,23 +150,24 @@ nand_upgrade_prepare_ubi() {
local root_ubivol="$( nand_find_volume $ubidev $CI_ROOTPART )"
local data_ubivol="$( nand_find_volume $ubidev rootfs_data )"
- # remove ubiblock device of rootfs
- local root_ubiblk="ubiblock${root_ubivol:3}"
- if [ "$root_ubivol" -a -e "/dev/$root_ubiblk" ]; then
- echo "removing $root_ubiblk"
- if ! ubiblock -r /dev/$root_ubivol; then
- echo "cannot remove $root_ubiblk"
- return 1;
+ local ubiblk ubiblkvol
+ for ubiblk in /dev/ubiblock*_? ; do
+ [ -e "$ubiblk" ] || continue
+ echo "removing ubiblock${ubiblk:13}"
+ ubiblkvol=ubi${ubiblk:13}
+ if ! ubiblock -r /dev/$ubiblkvol; then
+ echo "cannot remove $ubiblk"
+ return 1
fi
- fi
+ done
# kill volumes
[ "$kern_ubivol" ] && ubirmvol /dev/$ubidev -N $CI_KERNPART || true
- [ "$root_ubivol" ] && ubirmvol /dev/$ubidev -N $CI_ROOTPART || true
+ [ "$root_ubivol" -a "$root_ubivol" != "$kern_ubivol" ] && ubirmvol /dev/$ubidev -N $CI_ROOTPART || true
[ "$data_ubivol" ] && ubirmvol /dev/$ubidev -N rootfs_data || true
# update kernel
- if [ "$has_kernel" = "1" ]; then
+ if [ -n "$kernel_length" ]; then
if ! ubimkvol /dev/$ubidev -N $CI_KERNPART -s $kernel_length; then
echo "cannot create kernel volume"
return 1;
@@ -172,15 +175,17 @@ nand_upgrade_prepare_ubi() {
fi
# update rootfs
- local root_size_param
- if [ "$rootfs_type" = "ubifs" ]; then
- root_size_param="-m"
- else
- root_size_param="-s $rootfs_length"
- fi
- if ! ubimkvol /dev/$ubidev -N $CI_ROOTPART $root_size_param; then
- echo "cannot create rootfs volume"
- return 1;
+ if [ -n "$rootfs_length" ]; then
+ local root_size_param
+ if [ "$rootfs_type" = "ubifs" ]; then
+ root_size_param="-m"
+ else
+ root_size_param="-s $rootfs_length"
+ fi
+ if ! ubimkvol /dev/$ubidev -N $CI_ROOTPART $rootfs_size_param; then
+ echo "cannot create rootfs volume"
+ return 1;
+ fi
fi
# create rootfs_data for non-ubifs rootfs
@@ -232,7 +237,7 @@ nand_upgrade_ubinized() {
nand_upgrade_ubifs() {
local rootfs_length=$( (cat $1 | wc -c) 2> /dev/null)
- nand_upgrade_prepare_ubi "$rootfs_length" "ubifs" "0" "0"
+ nand_upgrade_prepare_ubi "$rootfs_length" "ubifs" "" ""
local ubidev="$( nand_find_ubi "$CI_UBIPART" )"
local root_ubivol="$(nand_find_volume $ubidev $CI_ROOTPART)"
@@ -241,39 +246,59 @@ nand_upgrade_ubifs() {
nand_do_upgrade_success
}
+nand_upgrade_fit() {
+ local fit_file="$1"
+ local fit_length="$(wc -c < "$fit_file")"
+
+ nand_upgrade_prepare_ubi "" "" "$fit_length" "1"
+
+ local fit_ubidev="$(nand_find_ubi "$CI_UBIPART")"
+ local fit_ubivol="$(nand_find_volume $fit_ubidev "$CI_KERNPART")"
+ ubiupdatevol /dev/$fit_ubivol -s $fit_length $fit_file
+
+ nand_do_upgrade_success
+}
+
nand_upgrade_tar() {
local tar_file="$1"
local kernel_mtd="$(find_mtd_index $CI_KERNPART)"
- local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
+ local board_dir=$(tar tf "$tar_file" | grep -m 1 '^sysupgrade-.*/$')
board_dir=${board_dir%/}
- local kernel_length=$( (tar xf $tar_file ${board_dir}/kernel -O | wc -c) 2> /dev/null)
- local rootfs_length=$( (tar xf $tar_file ${board_dir}/root -O | wc -c) 2> /dev/null)
+ kernel_length=$( (tar xf "$tar_file" ${board_dir}/kernel -O | wc -c) 2> /dev/null)
+ local has_rootfs=0
+ local rootfs_length
+ local rootfs_type
- local rootfs_type="$(identify_tar "$tar_file" ${board_dir}/root)"
+ tar tf "$tar_file" ${board_dir}/root 1>/dev/null 2>/dev/null && has_rootfs=1
+ [ "$has_rootfs" = "1" ] && {
+ rootfs_length=$( (tar xf "$tar_file" ${board_dir}/root -O | wc -c) 2> /dev/null)
+ rootfs_type="$(identify_tar "$tar_file" ${board_dir}/root)"
+ }
local has_kernel=1
local has_env=0
[ "$kernel_length" != 0 -a -n "$kernel_mtd" ] && {
- tar xf $tar_file ${board_dir}/kernel -O | mtd write - $CI_KERNPART
+ tar xf "$tar_file" ${board_dir}/kernel -O | mtd write - $CI_KERNPART
}
- [ "$kernel_length" = 0 -o ! -z "$kernel_mtd" ] && has_kernel=0
+ [ "$kernel_length" = 0 -o ! -z "$kernel_mtd" ] && has_kernel=
- nand_upgrade_prepare_ubi "$rootfs_length" "$rootfs_type" "$has_kernel" "$has_env"
+ nand_upgrade_prepare_ubi "$rootfs_length" "$rootfs_type" "${has_kernel:+$kernel_length}" "$has_env"
local ubidev="$( nand_find_ubi "$CI_UBIPART" )"
[ "$has_kernel" = "1" ] && {
- local kern_ubivol="$(nand_find_volume $ubidev $CI_KERNPART)"
- tar xf $tar_file ${board_dir}/kernel -O | \
+ local kern_ubivol="$( nand_find_volume $ubidev $CI_KERNPART )"
+ tar xf "$tar_file" ${board_dir}/kernel -O | \
ubiupdatevol /dev/$kern_ubivol -s $kernel_length -
}
- local root_ubivol="$(nand_find_volume $ubidev $CI_ROOTPART)"
- tar xf $tar_file ${board_dir}/root -O | \
- ubiupdatevol /dev/$root_ubivol -s $rootfs_length -
-
+ [ "$has_rootfs" = "1" ] && {
+ local root_ubivol="$( nand_find_volume $ubidev $CI_ROOTPART )"
+ tar xf "$tar_file" ${board_dir}/root -O | \
+ ubiupdatevol /dev/$root_ubivol -s $rootfs_length -
+ }
nand_do_upgrade_success
}
@@ -281,9 +306,10 @@ nand_upgrade_tar() {
nand_do_upgrade() {
local file_type=$(identify $1)
- [ ! "$(find_mtd_index "$CI_UBIPART")" ] && CI_UBIPART="rootfs"
+ [ ! "$( find_mtd_index "$CI_UBIPART" )" ] && CI_UBIPART="rootfs"
case "$file_type" in
+ "fit") nand_upgrade_fit $1;;
"ubi") nand_upgrade_ubinized $1;;
"ubifs") nand_upgrade_ubifs $1;;
*) nand_upgrade_tar $1;;
@@ -309,7 +335,7 @@ nand_do_platform_check() {
local control_length=$( (tar xf $tar_file sysupgrade-$board_name/CONTROL -O | wc -c) 2> /dev/null)
local file_type="$(identify $2)"
- [ "$control_length" = 0 -a "$file_type" != "ubi" -a "$file_type" != "ubifs" ] && {
+ [ "$control_length" = 0 -a "$file_type" != "ubi" -a "$file_type" != "ubifs" -a "$file_type" != "fit" ] && {
echo "Invalid sysupgrade file."
return 1
}
diff --git a/scripts/mkits.sh b/scripts/mkits.sh
index bb629d6fca..3d68fdacbc 100755
--- a/scripts/mkits.sh
+++ b/scripts/mkits.sh
@@ -23,18 +23,23 @@ usage() {
printf "\n\t-c ==> set config name 'config'"
printf "\n\t-a ==> set load address to 'addr' (hex)"
printf "\n\t-e ==> set entry point to 'entry' (hex)"
+ printf "\n\t-f ==> set device tree compatible string"
printf "\n\t-v ==> set kernel version to 'version'"
printf "\n\t-k ==> include kernel image 'kernel'"
printf "\n\t-D ==> human friendly Device Tree Blob 'name'"
printf "\n\t-n ==> fdt unit-address 'address'"
printf "\n\t-d ==> include Device Tree Blob 'dtb'"
+ printf "\n\t-r ==> include RootFS blob"
+ printf "\n\t-H ==> specify hash algo instead of SHA1"
printf "\n\t-o ==> create output file 'its_file'\n"
exit 1
}
FDTNUM=1
+ROOTFSNUM=1
+HASH=sha1
-while getopts ":A:a:c:C:D:d:e:k:n:o:v:" OPTION
+while getopts ":A:a:c:C:D:d:e:f:k:n:o:v:r:S" OPTION
do
case $OPTION in
A ) ARCH=$OPTARG;;
@@ -44,9 +49,12 @@ do
D ) DEVICE=$OPTARG;;
d ) DTB=$OPTARG;;
e ) ENTRY_ADDR=$OPTARG;;
+ f ) COMPATIBLE=$OPTARG;;
k ) KERNEL=$OPTARG;;
n ) FDTNUM=$OPTARG;;
o ) OUTPUT=$OPTARG;;
+ r ) ROOTFS=$OPTARG;;
+ S ) HASH=$OPTARG;;
v ) VERSION=$OPTARG;;
* ) echo "Invalid option passed to '$0' (options:$*)"
usage;;
@@ -62,11 +70,16 @@ fi
ARCH_UPPER=$(echo "$ARCH" | tr '[:lower:]' '[:upper:]')
+if [ -n "${COMPATIBLE}" ]; then
+ COMPATIBLE_PROP="compatible = \"${COMPATIBLE}\";"
+fi
+
# Conditionally create fdt information
if [ -n "${DTB}" ]; then
FDT_NODE="
fdt@$FDTNUM {
description = \"${ARCH_UPPER} OpenWrt ${DEVICE} device tree blob\";
+ ${COMPATIBLE_PROP}
data = /incbin/(\"${DTB}\");
type = \"flat_dt\";
arch = \"${ARCH}\";
@@ -75,13 +88,34 @@ if [ -n "${DTB}" ]; then
algo = \"crc32\";
};
hash@2 {
- algo = \"sha1\";
+ algo = \"${HASH}\";
};
};
"
FDT_PROP="fdt = \"fdt@$FDTNUM\";"
fi
+if [ -n "${ROOTFS}" ]; then
+ dd if="${ROOTFS}" of="${ROOTFS}.pagesync" bs=4096 conv=sync
+ ROOTFS_NODE="
+ rootfs@$ROOTFSNUM {
+ description = \"${ARCH_UPPER} OpenWrt ${DEVICE} rootfs\";
+ ${COMPATIBLE_PROP}
+ data = /incbin/(\"${ROOTFS}.pagesync\");
+ type = \"filesystem\";
+ arch = \"${ARCH}\";
+ compression = \"none\";
+ hash@1 {
+ algo = \"crc32\";
+ };
+ hash@2 {
+ algo = \"${HASH}\";
+ };
+ };
+"
+ ROOTFS_PROP="loadables = \"rootfs@${ROOTFSNUM}\";"
+fi
+
# Create a default, fully populated DTS file
DATA="/dts-v1/;
@@ -103,18 +137,21 @@ DATA="/dts-v1/;
algo = \"crc32\";
};
hash@2 {
- algo = \"sha1\";
+ algo = \"$HASH\";
};
};
${FDT_NODE}
+${ROOTFS_NODE}
};
configurations {
default = \"${CONFIG}\";
${CONFIG} {
- description = \"OpenWrt\";
+ description = \"OpenWrt ${DEVICE}\";
kernel = \"kernel@1\";
${FDT_PROP}
+ ${ROOTFS_PROP}
+ ${COMPATIBLE_PROP}
};
};
};"
diff --git a/target/linux/generic/config-5.10 b/target/linux/generic/config-5.10
index f7cc6c8561..ba6317e35f 100644
--- a/target/linux/generic/config-5.10
+++ b/target/linux/generic/config-5.10
@@ -1859,6 +1859,7 @@ CONFIG_FIB_RULES=y
# CONFIG_FIELDBUS_DEV is not set
CONFIG_FILE_LOCKING=y
# CONFIG_FIND_BIT_BENCHMARK is not set
+# CONFIG_FIT_PARTITION is not set
# CONFIG_FIREWIRE is not set
# CONFIG_FIREWIRE_NOSY is not set
# CONFIG_FIREWIRE_SERIAL is not set
diff --git a/target/linux/generic/files/block/partitions/fit.c b/target/linux/generic/files/block/partitions/fit.c
new file mode 100644
index 0000000000..3694a22667
--- /dev/null
+++ b/target/linux/generic/files/block/partitions/fit.c
@@ -0,0 +1,234 @@
+// SPvDX-License-Identifier: GPL-2.0
+/*
+ * fs/partitions/fit.c
+ * Copyright (C) 2021 Daniel Golle
+ *
+ * headers extracted from U-Boot mkimage sources
+ * (C) Copyright 2008 Semihalf
+ * (C) Copyright 2000-2005
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * based on existing partition parsers
+ * Copyright (C) 1991-1998 Linus Torvalds
+ * Re-organised Feb 1998 Russell King
+ */
+
+#define pr_fmt(fmt) fmt
+
+#include <linux/types.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_fdt.h>
+#include <linux/libfdt.h>
+
+#include "check.h"
+
+#define FIT_IMAGES_PATH "/images"
+#define FIT_CONFS_PATH "/configurations"
+
+/* hash/signature/key node */
+#define FIT_HASH_NODENAME "hash"
+#define FIT_ALGO_PROP "algo"
+#define FIT_VALUE_PROP "value"
+#define FIT_IGNORE_PROP "uboot-ignore"
+#define FIT_SIG_NODENAME "signature"
+#define FIT_KEY_REQUIRED "required"
+#define FIT_KEY_HINT "key-name-hint"
+
+/* cipher node */
+#define FIT_CIPHER_NODENAME "cipher"
+#define FIT_ALGO_PROP "algo"
+
+/* image node */
+#define FIT_DATA_PROP "data"
+#define FIT_DATA_POSITION_PROP "data-position"
+#define FIT_DATA_OFFSET_PROP "data-offset"
+#define FIT_DATA_SIZE_PROP "data-size"
+#define FIT_TIMESTAMP_PROP "timestamp"
+#define FIT_DESC_PROP "description"
+#define FIT_ARCH_PROP "arch"
+#define FIT_TYPE_PROP "type"
+#define FIT_OS_PROP "os"
+#define FIT_COMP_PROP "compression"
+#define FIT_ENTRY_PROP "entry"
+#define FIT_LOAD_PROP "load"
+
+/* configuration node */
+#define FIT_KERNEL_PROP "kernel"
+#define FIT_FILESYSTEM_PROP "filesystem"
+#define FIT_RAMDISK_PROP "ramdisk"
+#define FIT_FDT_PROP "fdt"
+#define FIT_LOADABLE_PROP "loadables"
+#define FIT_DEFAULT_PROP "default"
+#define FIT_SETUP_PROP "setup"
+#define FIT_FPGA_PROP "fpga"
+#define FIT_FIRMWARE_PROP "firmware"
+#define FIT_STANDALONE_PROP "standalone"
+
+#define FIT_MAX_HASH_LEN HASH_MAX_DIGEST_SIZE
+
+int fit_partition(struct parsed_partitions *state)
+{
+ struct address_space *mapping = state->bdev->bd_inode->i_mapping;
+ struct page *page = read_mapping_page(mapping, 0, NULL);
+ void *fit, *init_fit;
+ struct partition_meta_info *info;
+ char tmp[sizeof(info->volname)];
+ u64 dsize, dsectors, isectors;
+ u32 size, image_pos, image_len;
+ const u32 *image_offset_be, *image_len_be, *image_pos_be;
+ int ret = 1, node, images, config, slot;
+ const char *image_name, *image_type, *image_description, *config_default,
+ *config_description, *config_loadables;
+ int image_name_len, image_type_len, image_description_len, config_default_len,
+ config_description_len, config_loadables_len;
+ sector_t start_sect, nr_sects;
+ size_t label_min;
+
+ if (!page)
+ return -ENOMEM;
+
+ init_fit = page_address(page);
+
+ if (!init_fit) {
+ put_page(page);
+ return -EFAULT;
+ }
+
+ if (fdt_check_header(init_fit)) {
+ put_page(page);
+ return 0;
+ }
+
+ dsectors = get_capacity(state->bdev->bd_disk);
+ dsize = dsectors << SECTOR_SHIFT;
+
+ printk(KERN_INFO "FIT: volume size: %llu sectors (%llu bytes)\n", dsectors, dsize);
+
+ size = fdt_totalsize(init_fit);
+ isectors = size >> SECTOR_SHIFT;
+ if ((isectors << SECTOR_SHIFT) < size)
+ ++isectors;
+
+ printk(KERN_INFO "FIT: FDT structure size: %llu sectors (%u bytes)\n", isectors, size);
+
+ if (size >= dsize || size > PAGE_SIZE)
+ {
+ put_page(page);
+ state->access_beyond_eod = (size >= dsize);
+ return 0;
+ }
+
+ fit = kmemdup(init_fit, size, GFP_KERNEL);
+ put_page(page);
+ if (!fit)
+ return -ENOMEM;
+
+ config = fdt_path_offset(fit, FIT_CONFS_PATH);
+ if (config < 0) {
+ printk(KERN_INFO "FIT: Cannot find %s node: %d\n", FIT_CONFS_PATH, images);
+ ret = -ENOENT;
+ goto ret_out;
+ }
+
+ config_default = fdt_getprop(fit, config, FIT_DEFAULT_PROP, &config_default_len);
+
+ if (!config_default) {
+ printk(KERN_INFO "FIT: Cannot find default configuration\n");
+ ret = -ENOENT;
+ goto ret_out;
+ }
+
+ node = fdt_subnode_offset(fit, config, config_default);
+ if (node < 0) {
+ printk(KERN_INFO "FIT: Cannot find %s node: %d\n", config_default, node);
+ ret = -ENOENT;
+ goto ret_out;
+ }
+
+ config_description = fdt_getprop(fit, node, FIT_DESC_PROP, &config_description_len);
+ config_loadables = fdt_getprop(fit, node, FIT_LOADABLE_PROP, &config_loadables_len);
+
+ printk(KERN_INFO "FIT: Default configuration: %s%s%s%s\n", config_default,
+ config_description?" (":"", config_description?:"", config_description?")":"");
+
+ images = fdt_path_offset(fit, FIT_IMAGES_PATH);
+ if (images < 0) {
+ printk(KERN_INFO "FIT: Cannot find %s node: %d\n", FIT_IMAGES_PATH, images);
+ ret = -EINVAL;
+ goto ret_out;
+ }
+
+ slot = 1;
+ fdt_for_each_subnode(node, fit, images) {
+ image_name = fdt_get_name(fit, node, &image_name_len);
+ image_type = fdt_getprop(fit, node, FIT_TYPE_PROP, &image_type_len);
+ image_offset_be = fdt_getprop(fit, node, FIT_DATA_OFFSET_PROP, NULL);
+ image_pos_be = fdt_getprop(fit, node, FIT_DATA_POSITION_PROP, NULL);
+ image_len_be = fdt_getprop(fit, node, FIT_DATA_SIZE_PROP, NULL);
+ if (!image_name || !image_type || !image_len_be)
+ continue;
+
+ image_len = be32_to_cpu(*image_len_be);
+ if (!image_len)
+ continue;
+
+ if (image_offset_be)
+ image_pos = be32_to_cpu(*image_offset_be) + size;
+ else if (image_pos_be)
+ image_pos = be32_to_cpu(*image_pos_be);
+ else
+ continue;
+
+ image_description = fdt_getprop(fit, node, FIT_DESC_PROP, &image_description_len);
+
+ printk(KERN_INFO "FIT: %16s sub-image 0x%08x - 0x%08x '%s' %s%s%s\n",
+ image_type, image_pos, image_pos + image_len, image_name,
+ image_description?"(":"", image_description?:"", image_description?") ":"");
+
+ if (strcmp(image_type, FIT_FILESYSTEM_PROP))
+ continue;
+
+ if (image_pos & ((1 << PAGE_SHIFT)-1)) {
+ printk(KERN_INFO "FIT: image %s start not aligned to page boundaries, skipping\n", image_name);
+ continue;
+ }
+
+ if (image_len & ((1 << PAGE_SHIFT)-1)) {
+ printk(KERN_INFO "FIT: sub-image %s end not aligned to page boundaries, skipping\n", image_name);
+ continue;
+ }
+
+ start_sect = image_pos >> SECTOR_SHIFT;
+ nr_sects = image_len >> SECTOR_SHIFT;
+
+ if (start_sect + nr_sects > dsectors) {
+ state->access_beyond_eod = 1;
+ continue;
+ }
+
+ put_partition(state, slot, start_sect, nr_sects);
+ state->parts[slot].flags = 0;
+ info = &state->parts[slot].info;
+
+ label_min = min_t(int, sizeof(info->volname) - 1, image_name_len);
+ strncpy(info->volname, image_name, label_min);
+ info->volname[label_min] = '\0';
+
+ snprintf(tmp, sizeof(tmp), "(%s)", info->volname);
+ strlcat(state->pp_buf, tmp, PAGE_SIZE);
+
+ state->parts[slot].has_info = true;
+
+ if (config_loadables && !strcmp(image_name, config_loadables)) {
+ printk(KERN_INFO "FIT: selecting configured loadable %s to be root filesystem\n", image_name);
+ state->parts[slot].flags |= ADDPART_FLAG_ROOTDEV;
+ }
+
+ ++slot;
+ }
+
+ret_out:
+ kfree(fit);
+ return ret;
+}
diff --git a/target/linux/generic/hack-5.10/400-block-fit-partition-parser.patch b/target/linux/generic/hack-5.10/400-block-fit-partition-parser.patch
new file mode 100644
index 0000000000..9eaf8637d0
--- /dev/null
+++ b/target/linux/generic/hack-5.10/400-block-fit-partition-parser.patch
@@ -0,0 +1,96 @@
+--- a/block/blk.h
++++ b/block/blk.h
+@@ -357,6 +357,7 @@ char *disk_name(struct gendisk *hd, int
+ #define ADDPART_FLAG_NONE 0
+ #define ADDPART_FLAG_RAID 1
+ #define ADDPART_FLAG_WHOLEDISK 2
++#define ADDPART_FLAG_ROOTDEV 4
+ void delete_partition(struct hd_struct *part);
+ int bdev_add_partition(struct block_device *bdev, int partno,
+ sector_t start, sector_t length);
+--- a/block/partitions/Kconfig
++++ b/block/partitions/Kconfig
+@@ -101,6 +101,13 @@ config ATARI_PARTITION
+ Say Y here if you would like to use hard disks under Linux which
+ were partitioned under the Atari OS.
+
++config FIT_PARTITION
++ bool "Flattened-Image-Tree (FIT) partition support" if PARTITION_ADVANCED
++ default n
++ help
++ Say Y here if your system needs to mount the filesystem part of
++ a Flattened-Image-Tree (FIT) image commonly used with Das U-Boot.
++
+ config IBM_PARTITION
+ bool "IBM disk label and partition support"
+ depends on PARTITION_ADVANCED && S390
+--- a/block/partitions/Makefile
++++ b/block/partitions/Makefile
+@@ -8,6 +8,7 @@ obj-$(CONFIG_ACORN_PARTITION) += acorn.o
+ obj-$(CONFIG_AMIGA_PARTITION) += amiga.o
+ obj-$(CONFIG_ATARI_PARTITION) += atari.o
+ obj-$(CONFIG_AIX_PARTITION) += aix.o
++obj-$(CONFIG_FIT_PARTITION) += fit.o
+ obj-$(CONFIG_CMDLINE_PARTITION) += cmdline.o
+ obj-$(CONFIG_MAC_PARTITION) += mac.o
+ obj-$(CONFIG_LDM_PARTITION) += ldm.o
+--- a/block/partitions/check.h
++++ b/block/partitions/check.h
+@@ -58,6 +58,7 @@ int amiga_partition(struct parsed_partit
+ int atari_partition(struct parsed_partitions *state);
+ int cmdline_partition(struct parsed_partitions *state);
+ int efi_partition(struct parsed_partitions *state);
++int fit_partition(struct parsed_partitions *state);
+ int ibm_partition(struct parsed_partitions *);
+ int karma_partition(struct parsed_partitions *state);
+ int ldm_partition(struct parsed_partitions *state);
+--- a/block/partitions/core.c
++++ b/block/partitions/core.c
+@@ -10,6 +10,8 @@
+ #include <linux/vmalloc.h>
+ #include <linux/blktrace_api.h>
+ #include <linux/raid/detect.h>
++#include <linux/root_dev.h>
++
+ #include "check.h"
+
+ static int (*check_part[])(struct parsed_partitions *) = {
+@@ -46,6 +48,9 @@ static int (*check_part[])(struct parsed
+ #ifdef CONFIG_EFI_PARTITION
+ efi_partition, /* this must come before msdos */
+ #endif
++#ifdef CONFIG_FIT_PARTITION
++ fit_partition,
++#endif
+ #ifdef CONFIG_SGI_PARTITION
+ sgi_partition,
+ #endif
+@@ -694,6 +699,9 @@ static bool blk_add_partition(struct gen
+ (state->parts[p].flags & ADDPART_FLAG_RAID))
+ md_autodetect_dev(part_to_dev(part)->devt);
+
++ if ((state->parts[p].flags & ADDPART_FLAG_ROOTDEV) && ROOT_DEV == 0)
++ ROOT_DEV = part_to_dev(part)->devt;
++
+ return true;
+ }
+
+--- a/drivers/mtd/ubi/block.c
++++ b/drivers/mtd/ubi/block.c
+@@ -396,7 +396,7 @@ int ubiblock_create(struct ubi_volume_in
+ dev->leb_size = vi->usable_leb_size;
+
+ /* Initialize the gendisk of this ubiblock device */
+- gd = alloc_disk(1);
++ gd = alloc_disk(0);
+ if (!gd) {
+ pr_err("UBI: block: alloc_disk failed\n");
+ ret = -ENODEV;
+@@ -413,6 +413,7 @@ int ubiblock_create(struct ubi_volume_in
+ goto out_put_disk;
+ }
+ gd->private_data = dev;
++ gd->flags |= GENHD_FL_EXT_DEVT;
+ sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id);
+ set_capacity(gd, disk_capacity);
+ dev->gd = gd;
diff --git a/target/linux/generic/pending-5.10/491-ubi-auto-create-ubiblock-device-for-rootfs.patch b/target/linux/generic/pending-5.10/491-ubi-auto-create-ubiblock-device-for-rootfs.patch
index e5ee2c8656..a2b48fd4fc 100644
--- a/target/linux/generic/pending-5.10/491-ubi-auto-create-ubiblock-device-for-rootfs.patch
+++ b/target/linux/generic/pending-5.10/491-ubi-auto-create-ubiblock-device-for-rootfs.patch
@@ -8,7 +8,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
--- a/drivers/mtd/ubi/block.c
+++ b/drivers/mtd/ubi/block.c
-@@ -652,6 +652,44 @@ static void __init ubiblock_create_from_
+@@ -652,6 +652,47 @@ static void __init ubiblock_create_from_
}
}
@@ -33,6 +33,9 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
+ for (ubi_num = 0; ubi_num < UBI_MAX_DEVICES; ubi_num++) {
+ desc = ubi_open_volume_nm(ubi_num, "rootfs", UBI_READONLY);
+ if (IS_ERR(desc))
++ desc = ubi_open_volume_nm(ubi_num, "fit", UBI_READONLY);;
++
++ if (IS_ERR(desc))
+ continue;
+
+ ubi_get_volume_info(desc, &vi);
--
2.25.1

View File

@@ -1,6 +1,6 @@
repo: https://github.com/openwrt/openwrt.git
branch: openwrt-21.02
revision: fdc0342704b692c46ccb65c6372a853ff89094c4
revision: 64ddac2c1cdf068e66a1325eb4c4d6972a6a8b4f
output_dir: ./output
patch_folders:

View File

@@ -0,0 +1,87 @@
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=opennds
PKG_FIXUP:=autoreconf
PKG_VERSION:=8.1.1
PKG_RELEASE:=1
PKG_SOURCE_URL:=https://codeload.github.com/opennds/opennds/tar.gz/v$(PKG_VERSION)?
PKG_SOURCE:=opennds-$(PKG_VERSION).tar.gz
PKG_HASH:=9e0ede334755dc95a4133a94304f4294b956d4849c48c5521f12b4ed295e356f
PKG_BUILD_DIR:=$(BUILD_DIR)/openNDS-$(PKG_VERSION)
PKG_MAINTAINER:=Rob White <rob@blue-wave.net>
PKG_BUILD_PARALLEL:=1
PKG_LICENSE:=GPL-2.0+
include $(INCLUDE_DIR)/package.mk
define Package/opennds
SUBMENU:=Captive Portals
SECTION:=net
CATEGORY:=Network
DEPENDS:=+libpthread +iptables-mod-ipopt +libmicrohttpd-no-ssl
TITLE:=Open public network gateway daemon
URL:=https://github.com/opennds/opennds
CONFLICTS:=nodogsplash nodogsplash2
endef
define Package/opennds/description
openNDS is a Captive Portal solution that offers an instant way to provide restricted access to the Internet.
With little or no configuration, a dynamically generated and adaptive splash page sequence is automatically served.
Internet access is granted by either a click to continue button, or after credential verification.
The package incorporates the FAS API allowing many flexible customisation options.
The creation of sophisticated third party authentication applications is fully supported.
Internet hosted https portals can be utilised to inspire maximum user confidence.
endef
define Package/opennds/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/opennds $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ndsctl $(1)/usr/bin/
$(INSTALL_DIR) $(1)/etc/opennds/htdocs/images
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_DIR) $(1)/usr/lib/opennds
$(CP) $(PKG_BUILD_DIR)/resources/splash.html $(1)/etc/opennds/htdocs/
$(CP) $(PKG_BUILD_DIR)/resources/splash.css $(1)/etc/opennds/htdocs/
$(CP) $(PKG_BUILD_DIR)/resources/status.html $(1)/etc/opennds/htdocs/
$(CP) $(PKG_BUILD_DIR)/resources/splash.jpg $(1)/etc/opennds/htdocs/images/
$(CP) $(PKG_BUILD_DIR)/linux_openwrt/opennds/files/etc/config/opennds $(1)/etc/config/
$(CP) $(PKG_BUILD_DIR)/linux_openwrt/opennds/files/etc/init.d/opennds $(1)/etc/init.d/
$(CP) $(PKG_BUILD_DIR)/linux_openwrt/opennds/files/etc/uci-defaults/40_opennds $(1)/etc/uci-defaults/
$(CP) $(PKG_BUILD_DIR)/linux_openwrt/opennds/files/usr/lib/opennds/restart.sh $(1)/usr/lib/opennds/
$(CP) $(PKG_BUILD_DIR)/forward_authentication_service/binauth/binauth_log.sh $(1)/usr/lib/opennds/
$(CP) $(PKG_BUILD_DIR)/forward_authentication_service/PreAuth/login.sh $(1)/usr/lib/opennds/
$(CP) $(PKG_BUILD_DIR)/forward_authentication_service/libs/get_client_interface.sh $(1)/usr/lib/opennds/
$(CP) $(PKG_BUILD_DIR)/forward_authentication_service/libs/get_client_token.sh $(1)/usr/lib/opennds/
$(CP) $(PKG_BUILD_DIR)/forward_authentication_service/libs/client_params.sh $(1)/usr/lib/opennds/
$(CP) $(PKG_BUILD_DIR)/forward_authentication_service/libs/unescape.sh $(1)/usr/lib/opennds/
$(CP) $(PKG_BUILD_DIR)/forward_authentication_service/libs/authmon.sh $(1)/usr/lib/opennds/
$(CP) $(PKG_BUILD_DIR)/forward_authentication_service/libs/dnsconfig.sh $(1)/usr/lib/opennds/
$(CP) $(PKG_BUILD_DIR)/forward_authentication_service/libs/post-request.php $(1)/usr/lib/opennds/
$(CP) $(PKG_BUILD_DIR)/forward_authentication_service/fas-aes/fas-aes.php $(1)/etc/opennds/
$(CP) $(PKG_BUILD_DIR)/forward_authentication_service/fas-hid/fas-hid.php $(1)/etc/opennds/
$(CP) $(PKG_BUILD_DIR)/forward_authentication_service/fas-aes/fas-aes-https.php $(1)/etc/opennds/
endef
define Package/opennds/postrm
#!/bin/sh
uci delete firewall.opennds
uci commit firewall
endef
define Package/opennds/conffiles
/etc/config/opennds
endef
$(eval $(call BuildPackage,opennds))

View File

@@ -0,0 +1,16 @@
Index: openNDS-8.1.1/linux_openwrt/opennds/files/etc/init.d/opennds
===================================================================
--- openNDS-8.1.1.orig/linux_openwrt/opennds/files/etc/init.d/opennds
+++ openNDS-8.1.1/linux_openwrt/opennds/files/etc/init.d/opennds
@@ -183,6 +183,11 @@ start_service() {
config_foreach create_instance opennds
}
+service_triggers()
+{
+ procd_add_reload_trigger "opennds"
+}
+
stop_service() {
# When procd terminates opennds, it does not exit fast enough.
# Otherwise procd will restart opennds twice. First time starting

View File

@@ -2,26 +2,6 @@
[ -d /etc/config-shadow/ ] && exit 0
hname=$(cat /sys/class/net/eth0/address | tr -d : | awk '{print tolower($0)}')
uci set system.@system[-1].hostname=$hname
uci set ucentral.config.serial=$hname
uci set network.wan6.ifname=@wan
uci set network.wan.type=bridge
uci rename opennds.@opennds[-1]=opennds
uci set opennds.opennds.enabled=0
uci commit
cp -r /etc/config/ /etc/config-shadow/
. /lib/functions.sh
UCI_CONFIG_DIR=/etc/config-shadow
iface_del() {
uci -c $UCI_CONFIG_DIR delete wireless.$1
}
config_load wireless
config_foreach iface_del wifi-iface
uci -c $UCI_CONFIG_DIR commit

View File

@@ -0,0 +1,2 @@
vm.panic_on_oom = 1
kernel.panic = 10

View File

@@ -0,0 +1,5 @@
#!/bin.sh
hname=$(cat /sys/class/net/eth0/address | tr -d : | awk '{print tolower($0)}')
uci set system.@system[-1].hostname=$hname
uci set ucentral.config.serial=$hname

View File

@@ -0,0 +1,4 @@
#!/bin/sh
uci set network.wan6.ifname=@wan
uci set network.wan.type=bridge

View File

@@ -0,0 +1,3 @@
#!/bin/sh
uci set opennds.@opennds[-1].enabled=0

View File

@@ -0,0 +1,3 @@
#!/bin/sh
uci delete umdns.@umdns[0].network

View File

@@ -0,0 +1,10 @@
#!/bin/sh
. /lib/functions.sh
iface_del() {
uci delete wireless.$1
}
config_load wireless
config_foreach iface_del wifi-iface

View File

@@ -6,7 +6,7 @@ PKG_RELEASE:=1
PKG_SOURCE_URL=https://github.com/blogic/ucentral-schema.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_DATE:=2021-02-15
PKG_SOURCE_VERSION:=9e65a86cd998d87415cf8325895a64e4d8e2e425
PKG_SOURCE_VERSION:=af642bae596fb127dfd897ef093be6f4363759fc
PKG_MAINTAINER:=John Crispin <john@phrozen.org>
PKG_LICENSE:=BSD-3-Clause

View File

@@ -13,7 +13,7 @@ PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=https://github.com/jow-/ucode.git
PKG_SOURCE_DATE:=2021-03-15
PKG_SOURCE_VERSION:=aa9621db401e881ffcdea03be272c94149484ccf
PKG_SOURCE_VERSION:=7f0ff9143159cfa76408ed3dfedb2d730b17fb46
PKG_MIRROR_HASH:=
PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
PKG_LICENSE:=ISC

View File

@@ -9,7 +9,6 @@ Signed-off-by: John Crispin <john@phrozen.org>
---
config/Config-images.in | 1 +
include/image.mk | 2 ++
include/kernel-version.mk | 2 ++
include/kernel.mk | 7 +++--
include/netfilter.mk | 30 +++++++++++++++---
include/package.mk | 8 ++---
@@ -62,22 +61,6 @@ index 2530108211..10e7063f41 100644
define Image/pad-to
dd if=$(1) of=$(1).new bs=$(2) conv=sync
diff --git a/include/kernel-version.mk b/include/kernel-version.mk
index 26f24bae42..70eb3a6d08 100644
--- a/include/kernel-version.mk
+++ b/include/kernel-version.mk
@@ -6,9 +6,11 @@ ifdef CONFIG_TESTING_KERNEL
KERNEL_PATCHVER:=$(KERNEL_TESTING_PATCHVER)
endif
+LINUX_VERSION-4.4 = .60
LINUX_VERSION-5.4 = .105
LINUX_VERSION-5.10 = .16
+LINUX_KERNEL_HASH-4.4.60 = 2cd8df6f1ac6a5329c5a286ec9b5956215977221a1b731597ed169fff74a9659
LINUX_KERNEL_HASH-5.4.105 = 244e4cd16184285df55ec5a9501daba011aa8b85c5527ee05eab4592e70fb8b6
LINUX_KERNEL_HASH-5.10.16 = 536fe3ea273bfcc72b3571d3b3a7ff0a5bcdc16068efd22e42c4f9d03c200a37
diff --git a/include/kernel.mk b/include/kernel.mk
index d2a5b42138..4e9561c93c 100644
--- a/include/kernel.mk

View File

@@ -1,22 +0,0 @@
From cd1f76355a70ff394db64ac1f947c2704ed6c305 Mon Sep 17 00:00:00 2001
From: John Crispin <john@phrozen.org>
Date: Thu, 25 Mar 2021 08:03:28 +0100
Subject: [PATCH 22/23] base-files: add sysctl to reboot upon OOM
Signed-off-by: John Crispin <john@phrozen.org>
---
package/base-files/files/etc/sysctl.d/20-oom-reboot.conf | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 package/base-files/files/etc/sysctl.d/20-oom-reboot.conf
diff --git a/package/base-files/files/etc/sysctl.d/20-oom-reboot.conf b/package/base-files/files/etc/sysctl.d/20-oom-reboot.conf
new file mode 100644
index 0000000000..6c161611c8
--- /dev/null
+++ b/package/base-files/files/etc/sysctl.d/20-oom-reboot.conf
@@ -0,0 +1,2 @@
+vm.panic_on_oom = 1
+kernel.panic = 10
--
2.25.1

View File

@@ -1,7 +1,7 @@
From b4b632ac77e22d2522c3cb2cccf24b1dfae379f4 Mon Sep 17 00:00:00 2001
From 4cbb46d6f0fbf451439f9bcb96ffdcd32529c20d Mon Sep 17 00:00:00 2001
From: John Crispin <john@phrozen.org>
Date: Mon, 29 Mar 2021 16:05:14 +0200
Subject: [PATCH] target: enable vlan-filtering on various targets
Subject: [PATCH 33/37] target: enable vlan-filtering on various targets
Signed-off-by: John Crispin <john@phrozen.org>
---
@@ -22,17 +22,17 @@ index fe21dc8035..8b7364ff33 100755
ipq40xx_setup_macs $board
board_config_flush
diff --git a/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network b/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network
index 82dba44587..d8a90e507e 100755
index f1daa2fae1..fa48c4008c 100644
--- a/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network
+++ b/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network
@@ -43,6 +43,7 @@ mediatek_setup_macs()
@@ -30,6 +30,7 @@ mediatek_setup_interfaces()
board_config_update
board=$(board_name)
+ucidef_set_bridge_device bridge
mediatek_setup_interfaces $board
mediatek_setup_macs $board
board_config_flush
--
2.25.1

View File

@@ -1,15 +1,44 @@
From 7f2bd477546246bb6fab92873b6a2d27ba2b978a Mon Sep 17 00:00:00 2001
From e0ff8f29f0c0c147b34fe943698e8f95dfa6c688 Mon Sep 17 00:00:00 2001
From: John Crispin <john@phrozen.org>
Date: Tue, 30 Mar 2021 19:03:43 +0200
Subject: [PATCH] target: add pstore support
Subject: [PATCH 1/6] target: add pstore support
Signed-off-by: John Crispin <john@phrozen.org>
---
target/linux/generic/config-5.10 | 15 ++++++++++++++-
target/linux/generic/config-5.4 | 14 +++++++++++++-
.../linux/ipq40xx/patches-5.4/903-pstore.patch | 17 +++++++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)
.../patches-5.10/160-add-pstore-support.patch | 17 +++++++++++++++++
4 files changed, 61 insertions(+), 2 deletions(-)
create mode 100644 target/linux/ipq40xx/patches-5.4/903-pstore.patch
create mode 100644 target/linux/mediatek/patches-5.10/160-add-pstore-support.patch
diff --git a/target/linux/generic/config-5.10 b/target/linux/generic/config-5.10
index ba6317e35f..3e911a2619 100644
--- a/target/linux/generic/config-5.10
+++ b/target/linux/generic/config-5.10
@@ -4424,7 +4424,20 @@ CONFIG_PROC_SYSCTL=y
# CONFIG_PSAMPLE is not set
# CONFIG_PSB6970_PHY is not set
# CONFIG_PSI is not set
-# CONFIG_PSTORE is not set
+CONFIG_PSTORE=y
+# CONFIG_PSTORE_842_COMPRESS is not set
+# CONFIG_PSTORE_BLK is not set
+CONFIG_PSTORE_COMPRESS=y
+CONFIG_PSTORE_COMPRESS_DEFAULT="deflate"
+# CONFIG_PSTORE_CONSOLE is not set
+CONFIG_PSTORE_DEFLATE_COMPRESS=y
+CONFIG_PSTORE_DEFLATE_COMPRESS_DEFAULT=y
+# CONFIG_PSTORE_LZ4HC_COMPRESS is not set
+# CONFIG_PSTORE_LZ4_COMPRESS is not set
+# CONFIG_PSTORE_LZO_COMPRESS is not set
+# CONFIG_PSTORE_PMSG is not set
+CONFIG_PSTORE_RAM=y
+# CONFIG_PSTORE_ZSTD_COMPRESS is not set
# CONFIG_PTDUMP_DEBUGFS is not set
# CONFIG_PTP_1588_CLOCK is not set
# CONFIG_PTP_1588_CLOCK_IDT82P33 is not set
diff --git a/target/linux/generic/config-5.4 b/target/linux/generic/config-5.4
index a0193ca718..da2cc8db65 100644
--- a/target/linux/generic/config-5.4
@@ -58,6 +87,29 @@ index 0000000000..89ea4a438e
+ };
+
+ aliases {
diff --git a/target/linux/mediatek/patches-5.10/160-add-pstore-support.patch b/target/linux/mediatek/patches-5.10/160-add-pstore-support.patch
new file mode 100644
index 0000000000..6959fc09b3
--- /dev/null
+++ b/target/linux/mediatek/patches-5.10/160-add-pstore-support.patch
@@ -0,0 +1,17 @@
+Index: linux-5.10.16/arch/arm64/boot/dts/mediatek/mt7622.dtsi
+===================================================================
+--- linux-5.10.16.orig/arch/arm64/boot/dts/mediatek/mt7622.dtsi
++++ linux-5.10.16/arch/arm64/boot/dts/mediatek/mt7622.dtsi
+@@ -132,6 +132,12 @@
+ reg = <0 0x43000000 0 0x30000>;
+ no-map;
+ };
++
++ ramoops@50000000 {
++ compatible = "ramoops";
++ reg = <0 0x50000000 0 0x10000>;
++ record-size = <0x1000>;
++ };
+ };
+
+ thermal-zones {
--
2.25.1

View File

@@ -0,0 +1,257 @@
From 0bdafa77ec675b81d9254cb4ce429e76ca84fcea Mon Sep 17 00:00:00 2001
From: John Crispin <john@phrozen.org>
Date: Thu, 1 Apr 2021 09:31:19 +0200
Subject: [PATCH 1/2] hostapd: add a pile of new options
Signed-off-by: John Crispin <john@phrozen.org>
---
.../network/services/hostapd/files/hostapd.sh | 84 +++++++++++++------
1 file changed, 60 insertions(+), 24 deletions(-)
diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh
index 45a49b8faa..05b901fb6b 100644
--- a/package/network/services/hostapd/files/hostapd.sh
+++ b/package/network/services/hostapd/files/hostapd.sh
@@ -311,12 +311,12 @@ hostapd_common_add_bss_config() {
config_add_string 'owe_transition_bssid:macaddr' 'owe_transition_ssid:string'
- config_add_boolean iw_enabled iw_internet iw_asra iw_esr iw_uesa
+ config_add_boolean interworking iw_internet iw_asra iw_esr iw_uesa
config_add_int iw_access_network_type iw_venue_group iw_venue_type
config_add_int iw_ipaddr_type_availability iw_gas_address3
config_add_string iw_hessid iw_network_auth_type iw_qos_map_set
config_add_array iw_roaming_consortium iw_domain_name iw_anqp_3gpp_cell_net iw_nai_realm
- config_add_array iw_anqp_elem
+ config_add_array iw_anqp_elem iw_venue_name iw_venue_url
config_add_boolean hs20 disable_dgaf osen
config_add_int anqp_domain_id
@@ -327,12 +327,20 @@ hostapd_common_add_bss_config() {
config_add_array hs20_conn_capab
config_add_string osu_ssid hs20_wan_metrics hs20_operating_class hs20_t_c_filename hs20_t_c_timestamp
+ config_add_boolean interworking
+ config_add_string hs20_t_c_server_url
+
config_add_array airtime_sta_weight
config_add_int airtime_bss_weight airtime_bss_limit
config_add_boolean multicast_to_unicast per_sta_vif
config_add_array hostapd_bss_options
+
+ config_add_boolean request_cui
+ config_add_array radius_auth_req_attr
+ config_add_array radius_acct_req_attr
+ config_add_int rts_threshold
}
hostapd_set_vlan_file() {
@@ -396,12 +404,20 @@ append_iw_nai_realm() {
[ -n "$1" ] && append bss_conf "nai_realm=$1" "$N"
}
+append_iw_venue_name() {
+ [ -n "$1" ] && append bss_conf "venue_name=$1" "$N"
+}
+
+append_iw_venue_url() {
+ [ -n "$1" ] && append bss_conf "venue_url=$1" "$N"
+}
+
append_hs20_oper_friendly_name() {
- append bss_conf "hs20_oper_friendly_name=$1" "$N"
+ [ -n "$1" ] && append bss_conf "hs20_oper_friendly_name=$1" "$N"
}
append_osu_provider_service_desc() {
- append bss_conf "osu_service_desc=$1" "$N"
+ [ -n "$1" ] && append bss_conf "osu_service_desc=$1" "$N"
}
append_hs20_icon() {
@@ -421,15 +437,15 @@ append_hs20_icons() {
}
append_operator_icon() {
- append bss_conf "operator_icon=$1" "$N"
+ [ -n "$1" ] && append bss_conf "operator_icon=$1" "$N"
}
append_osu_icon() {
- append bss_conf "osu_icon=$1" "$N"
+ [ -n "$1" ] && append bss_conf "osu_icon=$1" "$N"
}
append_osu_provider() {
- local cfgtype osu_server_uri osu_friendly_name osu_nai osu_nai2 osu_method_list
+ local cfgtype osu_server_uri osu_nai osu_nai2 osu_method_list
config_load wireless
config_get cfgtype "$1" TYPE
@@ -441,12 +457,13 @@ append_osu_provider() {
config_get osu_nai2 "$1" osu_nai2
config_get osu_method_list "$1" osu_method
- append bss_conf "osu_server_uri=$osu_server_uri" "$N"
- append bss_conf "osu_nai=$osu_nai" "$N"
- append bss_conf "osu_nai2=$osu_nai2" "$N"
- append bss_conf "osu_method_list=$osu_method_list" "$N"
+ [ -n "$osu_server_uri" ] && append bss_conf "osu_server_uri=$osu_server_uri" "$N"
+ [ -n "$osu_nai" ] && append bss_conf "osu_nai=$osu_nai" "$N"
+ [ -n "$osu_nai2" ] && append bss_conf "osu_nai2=$osu_nai2" "$N"
+ [ -n "$osu_method_list" ] && append bss_conf "osu_method_list=$osu_method_list" "$N"
config_list_foreach "$1" osu_service_desc append_osu_provider_service_desc
+ config_list_foreach "$1" osu_friendly_name append_osu_friendly_name
config_list_foreach "$1" osu_icon append_osu_icon
append bss_conf "$N"
@@ -456,6 +473,14 @@ append_hs20_conn_capab() {
[ -n "$1" ] && append bss_conf "hs20_conn_capab=$1" "$N"
}
+append_radius_acct_req_attr() {
+ [ -n "$1" ] && append bss_conf "radius_acct_req_attr=$1" "$N"
+}
+
+append_radius_auth_req_attr() {
+ [ -n "$1" ] && append bss_conf "radius_auth_req_attr=$1" "$N"
+}
+
append_airtime_sta_weight() {
[ -n "$1" ] && append bss_conf "airtime_sta_weight=$1" "$N"
}
@@ -482,7 +507,7 @@ hostapd_set_bss_options() {
bss_load_update_period chan_util_avg_period sae_require_mfp \
multi_ap multi_ap_backhaul_ssid multi_ap_backhaul_key skip_inactivity_poll \
airtime_bss_weight airtime_bss_limit airtime_sta_weight \
- multicast_to_unicast per_sta_vif
+ multicast_to_unicast per_sta_vif rts_threshold
set_default isolate 0
set_default maxassoc 0
@@ -503,6 +528,7 @@ hostapd_set_bss_options() {
set_default multi_ap 0
set_default airtime_bss_weight 0
set_default airtime_bss_limit 0
+ set_default rts_threshold -1
append bss_conf "ctrl_interface=/var/run/hostapd"
if [ "$isolate" -gt 0 ]; then
@@ -529,6 +555,7 @@ hostapd_set_bss_options() {
append bss_conf "uapsd_advertisement_enabled=$uapsd" "$N"
append bss_conf "utf8_ssid=$utf8_ssid" "$N"
append bss_conf "multi_ap=$multi_ap" "$N"
+ append bss_conf "rts_threshold=$rts_threshold" "$N"
[ "$tdls_prohibit" -gt 0 ] && append bss_conf "tdls_prohibit=$tdls_prohibit" "$N"
@@ -547,6 +574,7 @@ hostapd_set_bss_options() {
append bss_conf "acct_server_shared_secret=$acct_secret" "$N"
[ -n "$acct_interval" ] && \
append bss_conf "radius_acct_interim_interval=$acct_interval" "$N"
+ json_for_each_item append_radius_acct_req_attr radius_acct_req_attr
}
case "$auth_type" in
@@ -601,7 +629,7 @@ hostapd_set_bss_options() {
auth_server auth_secret auth_port \
dae_client dae_secret dae_port \
ownip radius_client_addr \
- eap_reauth_period
+ eap_reauth_period request_cui
# radius can provide VLAN ID for clients
vlan_possible=1
@@ -613,18 +641,20 @@ hostapd_set_bss_options() {
set_default auth_port 1812
set_default dae_port 3799
-
+ set_default request_cui 0
append bss_conf "auth_server_addr=$auth_server" "$N"
append bss_conf "auth_server_port=$auth_port" "$N"
append bss_conf "auth_server_shared_secret=$auth_secret" "$N"
+ [ "$request_cui" -gt 0 ] && append bss_conf "radius_request_cui=$request_cui" "$N"
[ -n "$eap_reauth_period" ] && append bss_conf "eap_reauth_period=$eap_reauth_period" "$N"
[ -n "$dae_client" -a -n "$dae_secret" ] && {
append bss_conf "radius_das_port=$dae_port" "$N"
append bss_conf "radius_das_client=$dae_client $dae_secret" "$N"
}
+ json_for_each_item append_radius_auth_req_attr radius_auth_req_attr
[ -n "$ownip" ] && append bss_conf "own_ip_addr=$ownip" "$N"
[ -n "$radius_client_addr" ] && append bss_conf "radius_client_addr=$radius_client_addr" "$N"
@@ -871,13 +901,14 @@ hostapd_set_bss_options() {
}
}
- json_get_vars iw_enabled iw_internet iw_asra iw_esr iw_uesa iw_access_network_type
+ json_get_vars interworking iw_internet iw_asra iw_esr iw_uesa iw_access_network_type
json_get_vars iw_hessid iw_venue_group iw_venue_type iw_network_auth_type
json_get_vars iw_roaming_consortium iw_domain_name iw_anqp_3gpp_cell_net iw_nai_realm
json_get_vars iw_anqp_elem iw_qos_map_set iw_ipaddr_type_availability iw_gas_address3
+ json_get_vars iw_venue_name iw_venue_url
- set_default iw_enabled 0
- if [ "$iw_enabled" = "1" ]; then
+ set_default interworking 0
+ if [ "$interworking" = "1" ]; then
append bss_conf "interworking=1" "$N"
set_default iw_internet 1
set_default iw_asra 0
@@ -903,6 +934,8 @@ hostapd_set_bss_options() {
json_for_each_item append_iw_roaming_consortium iw_roaming_consortium
json_for_each_item append_iw_anqp_elem iw_anqp_elem
json_for_each_item append_iw_nai_realm iw_nai_realm
+ json_for_each_item append_iw_venue_name iw_venue_name
+ json_for_each_item append_iw_venue_url iw_venue_url
iw_domain_name_conf=
json_for_each_item append_iw_domain_name iw_domain_name
@@ -917,9 +950,11 @@ hostapd_set_bss_options() {
local hs20 disable_dgaf osen anqp_domain_id hs20_deauth_req_timeout \
- osu_ssid hs20_wan_metrics hs20_operating_class hs20_t_c_filename hs20_t_c_timestamp
+ osu_ssid hs20_wan_metrics hs20_operating_class hs20_t_c_filename hs20_t_c_timestamp \
+ hs20_t_c_server_url
json_get_vars hs20 disable_dgaf osen anqp_domain_id hs20_deauth_req_timeout \
- osu_ssid hs20_wan_metrics hs20_operating_class hs20_t_c_filename hs20_t_c_timestamp
+ osu_ssid hs20_wan_metrics hs20_operating_class hs20_t_c_filename hs20_t_c_timestamp \
+ hs20_t_c_server_url
set_default hs20 0
set_default disable_dgaf $hs20
@@ -929,17 +964,18 @@ hostapd_set_bss_options() {
if [ "$hs20" = "1" ]; then
append bss_conf "hs20=1" "$N"
append_hs20_icons
- append bss_conf "disable_dgaf=$disable_dgaf" "$N"
- append bss_conf "osen=$osen" "$N"
- append bss_conf "anqp_domain_id=$anqp_domain_id" "$N"
- append bss_conf "hs20_deauth_req_timeout=$hs20_deauth_req_timeout" "$N"
+ [ -n "$disable_dgaf"] && append bss_conf "disable_dgaf=$disable_dgaf" "$N"
+ [ -n "$osen"] && append bss_conf "osen=$osen" "$N"
+ [ "$anqp_domain_id" -gt 0 ] && append bss_conf "anqp_domain_id=$anqp_domain_id" "$N"
+ [ -n "$hs20_deauth_req_timeout"] && append bss_conf "hs20_deauth_req_timeout=$hs20_deauth_req_timeout" "$N"
[ -n "$osu_ssid" ] && append bss_conf "osu_ssid=$osu_ssid" "$N"
[ -n "$hs20_wan_metrics" ] && append bss_conf "hs20_wan_metrics=$hs20_wan_metrics" "$N"
[ -n "$hs20_operating_class" ] && append bss_conf "hs20_operating_class=$hs20_operating_class" "$N"
[ -n "$hs20_t_c_filename" ] && append bss_conf "hs20_t_c_filename=$hs20_t_c_filename" "$N"
[ -n "$hs20_t_c_timestamp" ] && append bss_conf "hs20_t_c_timestamp=$hs20_t_c_timestamp" "$N"
- json_for_each_item append_hs20_conn_capab hs20_conn_capab
+ [ -n "$hs20_t_c_server_url" ] && append bss_conf "hs20_t_c_server_url=$hs20_t_c_server_url" "$N"
json_for_each_item append_hs20_oper_friendly_name hs20_oper_friendly_name
+ json_for_each_item append_hs20_conn_capab hs20_conn_capab
json_for_each_item append_osu_provider osu_provider
json_for_each_item append_operator_icon operator_icon
fi
--
2.25.1

View File

@@ -0,0 +1,26 @@
From f1bb66dbeb148d3da6481a98433cff5b5ee3ef96 Mon Sep 17 00:00:00 2001
From: John Crispin <john@phrozen.org>
Date: Tue, 6 Apr 2021 13:24:43 +0200
Subject: [PATCH] hostapd: fix civic location option
Signed-off-by: John Crispin <john@phrozen.org>
---
package/network/services/hostapd/files/hostapd.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh
index 05b901fb6b..e391aae13b 100644
--- a/package/network/services/hostapd/files/hostapd.sh
+++ b/package/network/services/hostapd/files/hostapd.sh
@@ -763,7 +763,7 @@ hostapd_set_bss_options() {
append bss_conf "ftm_responder=1" "$N"
[ "$stationary_ap" -eq "1" ] && append bss_conf "stationary_ap=1" "$N"
[ -n "$lci" ] && append bss_conf "lci=$lci" "$N"
- [ -n "$civic" ] && append bss_conf "lci=$civic" "$N"
+ [ -n "$civic" ] && append bss_conf "civic=$civic" "$N"
}
fi
--
2.25.1

View File

@@ -0,0 +1,77 @@
From 99cffd423352bceb3c2826b4262b575478b0a712 Mon Sep 17 00:00:00 2001
From: John Crispin <john@phrozen.org>
Date: Tue, 6 Apr 2021 14:59:41 +0200
Subject: [PATCH] hostapd: add eap_server support
Signed-off-by: John Crispin <john@phrozen.org>
---
.../network/services/hostapd/files/hostapd.sh | 25 ++++++++++++++++---
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh
index e391aae13b..a3263ed036 100644
--- a/package/network/services/hostapd/files/hostapd.sh
+++ b/package/network/services/hostapd/files/hostapd.sh
@@ -341,6 +341,9 @@ hostapd_common_add_bss_config() {
config_add_array radius_auth_req_attr
config_add_array radius_acct_req_attr
config_add_int rts_threshold
+
+ config_add_int eap_server
+ config_add_string eap_user_file ca_cert server_cert private_key private_key_passwd server_id
}
hostapd_set_vlan_file() {
@@ -507,7 +510,8 @@ hostapd_set_bss_options() {
bss_load_update_period chan_util_avg_period sae_require_mfp \
multi_ap multi_ap_backhaul_ssid multi_ap_backhaul_key skip_inactivity_poll \
airtime_bss_weight airtime_bss_limit airtime_sta_weight \
- multicast_to_unicast per_sta_vif rts_threshold
+ multicast_to_unicast per_sta_vif rts_threshold \
+ eap_server eap_user_file ca_cert server_cert private_key private_key_passwd server_id
set_default isolate 0
set_default maxassoc 0
@@ -529,6 +533,7 @@ hostapd_set_bss_options() {
set_default airtime_bss_weight 0
set_default airtime_bss_limit 0
set_default rts_threshold -1
+ set_default eap_server 0
append bss_conf "ctrl_interface=/var/run/hostapd"
if [ "$isolate" -gt 0 ]; then
@@ -643,9 +648,11 @@ hostapd_set_bss_options() {
set_default dae_port 3799
set_default request_cui 0
- append bss_conf "auth_server_addr=$auth_server" "$N"
- append bss_conf "auth_server_port=$auth_port" "$N"
- append bss_conf "auth_server_shared_secret=$auth_secret" "$N"
+ [ "$eap_server" -eq 0 ] && {
+ append bss_conf "auth_server_addr=$auth_server" "$N"
+ append bss_conf "auth_server_port=$auth_port" "$N"
+ append bss_conf "auth_server_shared_secret=$auth_secret" "$N"
+ }
[ "$request_cui" -gt 0 ] && append bss_conf "radius_request_cui=$request_cui" "$N"
[ -n "$eap_reauth_period" ] && append bss_conf "eap_reauth_period=$eap_reauth_period" "$N"
@@ -980,6 +987,16 @@ hostapd_set_bss_options() {
json_for_each_item append_operator_icon operator_icon
fi
+ if [ "$eap_server" = "1" ]; then
+ append bss_conf "eap_server=1" "$N"
+ [ -n "$eap_user_file" ] && append bss_conf "eap_user_file=$eap_user_file" "$N"
+ [ -n "$ca_cert" ] && append bss_conf "ca_cert=$ca_cert" "$N"
+ [ -n "$server_cert" ] && append bss_conf "server_cert=$server_cert" "$N"
+ [ -n "$private_key" ] && append bss_conf "private_key=$private_key" "$N"
+ [ -n "$private_key_passwd" ] && append bss_conf "private_key_passwd=$private_key_passwd" "$N"
+ [ -n "$server_id" ] && append bss_conf "server_id=$server_id" "$N"
+ fi
+
set_default multicast_to_unicast 0
if [ "$multicast_to_unicast" -gt 0 ]; then
append bss_conf "multicast_to_unicast=$multicast_to_unicast" "$N"
--
2.25.1

View File

@@ -0,0 +1,15 @@
---
profile: edgecore_ecw5211
target: ipq40xx
subtarget: generic
description: Build image for the Edgecore ECW5211
include:
- ucentral-ap
packages:
- ath10k-firmware-qca4019-ct-htt
- ath10k-firmware-qca9888-ct-htt
- ath10k-firmware-qca9984-ct-htt
diffconfig: |
# CONFIG_PACKAGE_ath10k-firmware-qca4019-ct is not set
# CONFIG_PACKAGE_ath10k-firmware-qca9888-ct is not set
# CONFIG_PACKAGE_ath10k-firmware-qca9984-ct is not set

View File

@@ -1,5 +1,5 @@
---
profile: linksys_e8450_ubi
profile: linksys_e8450-ubi
target: mediatek
subtarget: mt7622
description: Build image for the Linksys E8450

View File

@@ -12,14 +12,19 @@ packages:
- batmand
- cJSON
- curl
- dnsmasq-full
- igmpproxy
- ip-bridge
- iw-full
- libmosquitto-ssl
- lldpd
- wlan-ap-config
- wpad-mesh-openssl
- ip-bridge
- dnsmasq-full
- firstcontact
- gre
- tmate
- opennds
- ratelimit
- rtty-openssl
- tcpdump
- ucentral-client
- ucentral-jsonschema
- ucentral-schema
@@ -30,12 +35,9 @@ packages:
- uledd
- usteer
- udevmand
- opennds
- ratelimit
- rtty-openssl
- sqm-scripts
- tcpdump
- umdns
- vxlan
- wpad-mesh-openssl
diffconfig: |
CONFIG_OPENSSL_ENGINE=y
CONFIG_OPENSSL_PREFER_CHACHA_OVER_GCM=y
@@ -54,3 +56,4 @@ diffconfig: |
CONFIG_TARGET_PREINIT_SUPPRESS_STDERR=y
CONFIG_TARGET_PREINIT_DISABLE_FAILSAFE=y
# CONFIG_BATMAN_ADV_BATMAN_V is not set
# CONFIG_PACKAGE_iw is not set