[no subject]

2020-11-30 Thread Raylynn Knight via openwrt-devel
The sender domain has a DMARC Reject/Quarantine policy which disallows
sending mailing list messages using the original "From" header.

To mitigate this problem, the original message has been wrapped
automatically by the mailing list software.--- Begin Message ---
The snapshot builds for Octeon are missing the artifacts for the EdgeRouter and 
EdgeRouter Pro devices (artifacts should be identical).  I couldn’t figure out 
exactly what is wrong with the make file, but if I build locally and select:
 
* Target System (Cavium Networks Octeon)
* Target Profile (Multiple Devices)
* Target Devices
(*) Enable all profiles by default

All of the profiles except the Ubiquiti EdgeRouter profile are selected.  So 
whatever mechanism is used to determine all profiles is missing the Ubiquiti 
EdgeRouter profile.

Hoping someone more familiar with the build system constructs can fix this.

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


[PATCH v2 09/10] kernel: mtdsplit_uimage: add "openwrt, offset" and "openwrt, partition-magic"

2020-11-30 Thread Bjørn Mork
Some devices prepend a standard U-Boot Image with a vendor specific
header, having its own magic. Adding two new properties will support
validation of such images, including the additional magic.

Signed-off-by: Bjørn Mork 
---
 .../drivers/mtd/mtdsplit/mtdsplit_uimage.c| 40 +--
 1 file changed, 28 insertions(+), 12 deletions(-)

diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c 
b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
index c29eb6234bc2..7a8ccdf8f59a 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
@@ -70,7 +70,8 @@ read_uimage_header(struct mtd_info *mtd, size_t offset, 
u_char *buf,
 }
 
 static void uimage_parse_dt(struct mtd_info *master, int *extralen,
-   u32 *ih_magic, u32 *ih_type)
+   u32 *ih_magic, u32 *ih_type,
+   u32 *header_offset, u32 *part_magic)
 {
struct device_node *np = mtd_get_of_node(master);
 
@@ -83,6 +84,10 @@ static void uimage_parse_dt(struct mtd_info *master, int 
*extralen,
pr_debug("got openwrt,ih-magic=%08x from device-tree\n", 
*ih_magic);
if (!of_property_read_u32(np, "openwrt,ih-type", ih_type))
pr_debug("got openwrt,ih-type=%08x from device-tree\n", 
*ih_type);
+   if (!of_property_read_u32(np, "openwrt,offset", header_offset))
+   pr_debug("got ih-start=%u from device-tree\n", *header_offset);
+   if (!of_property_read_u32(np, "openwrt,partition-magic", part_magic))
+   pr_debug("got openwrt,partition-magic=%08x from device-tree\n", 
*part_magic);
 }
 
 /**
@@ -92,9 +97,9 @@ static void uimage_parse_dt(struct mtd_info *master, int 
*extralen,
  *  and tail padding length of a valid uImage header if found
  */
 static int __mtdsplit_parse_uimage(struct mtd_info *master,
-  const struct mtd_partition **pparts,
-  struct mtd_part_parser_data *data,
-  ssize_t (*find_header)(u_char *buf, size_t len, u32 
ih_magic, u32 ih_type))
+  const struct mtd_partition **pparts,
+  struct mtd_part_parser_data *data,
+  ssize_t (*find_header)(u_char *buf, size_t 
len, u32 ih_magic, u32 ih_type))
 {
struct mtd_partition *parts;
u_char *buf;
@@ -104,11 +109,14 @@ static int __mtdsplit_parse_uimage(struct mtd_info 
*master,
size_t uimage_size = 0;
size_t rootfs_offset;
size_t rootfs_size = 0;
+   size_t buflen;
int uimage_part, rf_part;
int ret;
int extralen = 0;
u32 ih_magic = IH_MAGIC;
u32 ih_type = IH_TYPE_KERNEL;
+   u32 header_offset = 0;
+   u32 part_magic = 0;
enum mtdsplit_part_type type;
 
nr_parts = 2;
@@ -116,34 +124,42 @@ static int __mtdsplit_parse_uimage(struct mtd_info 
*master,
if (!parts)
return -ENOMEM;
 
-   buf = vmalloc(MAX_HEADER_LEN);
+   uimage_parse_dt(master, , _magic, _type, _offset, 
_magic);
+   buflen = MAX_HEADER_LEN;
+   buf = vmalloc(buflen);
if (!buf) {
ret = -ENOMEM;
goto err_free_parts;
}
 
-   uimage_parse_dt(master, , _magic, _type);
-
/* find uImage on erase block boundaries */
for (offset = 0; offset < master->size; offset += master->erasesize) {
struct uimage_header *header;
 
uimage_size = 0;
 
-   ret = read_uimage_header(master, offset, buf, MAX_HEADER_LEN);
+   ret = read_uimage_header(master, offset, buf, buflen);
if (ret)
continue;
 
-   ret = find_header(buf, MAX_HEADER_LEN, ih_magic, ih_type);
+   /* verify optional partition magic before uimage header */
+   if (header_offset && part_magic && (be32_to_cpu(*(u32 *)buf) != 
part_magic))
+   continue;
+
+   ret = find_header(buf + header_offset, buflen, ih_magic, 
ih_type);
if (ret < 0) {
pr_debug("no valid uImage found in \"%s\" at offset 
%llx\n",
 master->name, (unsigned long long) offset);
continue;
}
-   header = (struct uimage_header *)(buf + ret);
+
+   /* let uimage_find_edimax override the offset */
+   if (ret > 0)
+   header_offset = ret;
+   header = (struct uimage_header *)(buf + header_offset);
 
uimage_size = sizeof(*header) +
-   be32_to_cpu(header->ih_size) + ret + extralen;
+   be32_to_cpu(header->ih_size) + header_offset + 
extralen;
 
if ((offset + uimage_size) > 

[PATCH v2 01/10] dt-bindings: mtd: partitions: add OpenWrt defined U-Boot Image

2020-11-30 Thread Bjørn Mork
Add devicetree bindings for vendor specific variants of U-Boot
Images, as defined by OpenWrt.

Signed-off-by: Bjørn Mork 
---
 .../mtd/partitions/openwrt,uimage.yaml|  91 +
 .../dt-bindings/mtd/partitions/uimage.h   | 191 ++
 2 files changed, 282 insertions(+)
 create mode 100644 
target/linux/generic/files/Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.yaml
 create mode 100644 
target/linux/generic/files/include/dt-bindings/mtd/partitions/uimage.h

diff --git 
a/target/linux/generic/files/Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.yaml
 
b/target/linux/generic/files/Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.yaml
new file mode 100644
index ..789850f0a263
--- /dev/null
+++ 
b/target/linux/generic/files/Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.yaml
@@ -0,0 +1,91 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mtd/partitions/openwrt,uimage.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: OpenWrt variations of U-Boot Image partitions
+
+maintainers:
+  - Bjørn Mork 
+
+description: |
+  The image format defined by the boot loader "Das U-Boot" is often
+  modified or extended by device vendors. This defines a few optional
+  properties which can be used to describe such modifications.
+
+# partition.txt defines common properties, but has not yet been
+# converted to YAML
+#allOf:
+#  - $ref: ../partition.yaml#
+
+properties:
+  compatible:
+items:
+  - enum:
+  - openwrt,uimage
+  - const: denx,uimage
+
+  openwrt,padding:
+description: Number of padding bytes between header and data
+$ref: /schemas/types.yaml#/definitions/uint32
+default: 0
+
+  openwrt,ih-magic:
+description: U-Boot Image Header magic number.
+$ref: /schemas/types.yaml#/definitions/uint32
+default: 0x27051956 # IH_MAGIC
+
+  openwrt,ih-type:
+description: U-Boot Image type
+$ref: /schemas/types.yaml#/definitions/uint32
+default: 2 # IH_TYPE_KERNEL
+
+  openwrt,offset:
+description:
+  Offset between partition start and U-Boot Image in bytes
+$ref: /schemas/types.yaml#/definitions/uint32
+default: 0
+
+  openwrt,partition-magic:
+description:
+  Magic number found at the start of the partition. Will only be
+  validated if both this property and openwrt,offset is non-zero
+$ref: /schemas/types.yaml#/definitions/uint32
+default: 0
+
+required:
+  - compatible
+  - reg
+
+#unevaluatedProperties: false
+additionalProperties: false
+
+examples:
+  - |
+// device with non-default magic
+partition@30 {
+  compatible = "openwrt,uimage", "denx,uimage";
+  reg = <0x0030 0xe8>;
+  label = "firmware";
+  openwrt,ih-magic = <0x4e474520>;
+};
+  - |
+// device with U-Boot Image at an offset, with a partition magic value
+partition@7 {
+  compatible = "openwrt,uimage", "denx,uimage";
+  reg = <0x0007 0x0079>;
+  label = "firmware";
+  openwrt,offset = <20>;
+  openwrt,partition-magic = <0x43535953>;
+};
+  - |
+// device using a non-default image type
+#include "dt-bindings/mtd/partitions/uimage.h"
+partition@6c {
+  compatible = "openwrt,uimage", "denx,uimage";
+  reg = <0x6c 0x190>;
+  label = "firmware";
+  openwrt,ih-magic = <0x33373033>;
+  openwrt,ih-type = ;
+};
diff --git 
a/target/linux/generic/files/include/dt-bindings/mtd/partitions/uimage.h 
b/target/linux/generic/files/include/dt-bindings/mtd/partitions/uimage.h
new file mode 100644
index ..29eec38dd282
--- /dev/null
+++ b/target/linux/generic/files/include/dt-bindings/mtd/partitions/uimage.h
@@ -0,0 +1,191 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ **** IMPORTANT ***
+ * This file is not only included from C-code but also from devicetree source
+ * files. As such this file MUST only contain comments and defines.
+ *
+ * Based on image.h from U-Boot which is
+ * (C) Copyright 2008 Semihalf
+ * (C) Copyright 2000-2005 Wolfgang Denk, DENX Software Engineering, 
w...@denx.de.
+ */
+
+#ifndef __UIMAGE_H__
+#define __UIMAGE_H__
+
+/*
+ * Operating System Codes
+ *
+ * The following are exposed to uImage header.
+ * New IDs *MUST* be appended at the end of the list and *NEVER*
+ * inserted for backward compatibility.
+ */
+#defineIH_OS_INVALID   0   /* Invalid OS   */
+#defineIH_OS_OPENBSD   1   /* OpenBSD  */
+#defineIH_OS_NETBSD2   /* NetBSD   */
+#defineIH_OS_FREEBSD   3   /* FreeBSD  */
+#defineIH_OS_4_4BSD4   /* 4.4BSD   */
+#defineIH_OS_LINUX 5   /* Linux*/
+#defineIH_OS_SVR4  6   /* SVR4 */
+#define

[PATCH v2 10/10] kernel: mtdsplit_uimage: replace "edimax, uimage" parser

2020-11-30 Thread Bjørn Mork
The "edimax,uimage"" parser can be replaced by the generic
parser using device specific openwrt,partition-magic and
openwrt,offset properties.

Signed-off-by: Bjørn Mork 
---
 .../drivers/mtd/mtdsplit/mtdsplit_uimage.c| 129 --
 .../dts/mt7620a_edimax_br-6478ac-v2.dts   |   4 +-
 .../ramips/dts/mt7620a_edimax_ew-7478apc.dts  |   4 +-
 .../linux/ramips/dts/mt7621_edimax_re23s.dts  |   4 +-
 .../ramips/dts/rt3050_edimax_3g-6200n.dts |   4 +-
 .../ramips/dts/rt3050_edimax_3g-6200nl.dts|   4 +-
 .../ramips/dts/rt3662_edimax_br-6475nd.dts|   4 +-
 7 files changed, 48 insertions(+), 105 deletions(-)

diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c 
b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
index 7a8ccdf8f59a..a3e55fb1fe38 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
@@ -23,12 +23,6 @@
 
 #include "mtdsplit.h"
 
-/*
- * uimage_header itself is only 64B, but it may be prepended with another data.
- * Currently the biggest size is for Fon(Foxconn) devices: 64B + 32B
- */
-#define MAX_HEADER_LEN 96
-
 /*
  * Legacy format image header,
  * all data in network byte order (aka natural aka bigendian).
@@ -90,6 +84,32 @@ static void uimage_parse_dt(struct mtd_info *master, int 
*extralen,
pr_debug("got openwrt,partition-magic=%08x from device-tree\n", 
*part_magic);
 }
 
+static ssize_t uimage_verify_default(u_char *buf, u32 ih_magic, u32 ih_type)
+{
+   struct uimage_header *header = (struct uimage_header *)buf;
+
+   /* default sanity checks */
+   if (be32_to_cpu(header->ih_magic) != ih_magic) {
+   pr_debug("invalid uImage magic: %08x != %08x\n",
+be32_to_cpu(header->ih_magic), ih_magic);
+   return -EINVAL;
+   }
+
+   if (header->ih_os != IH_OS_LINUX) {
+   pr_debug("invalid uImage OS: %08x != %08x\n",
+be32_to_cpu(header->ih_os), IH_OS_LINUX);
+   return -EINVAL;
+   }
+
+   if (header->ih_type != ih_type) {
+   pr_debug("invalid uImage type: %08x != %08x\n",
+be32_to_cpu(header->ih_type), ih_type);
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
 /**
  * __mtdsplit_parse_uimage - scan partition and create kernel + rootfs parts
  *
@@ -98,8 +118,7 @@ static void uimage_parse_dt(struct mtd_info *master, int 
*extralen,
  */
 static int __mtdsplit_parse_uimage(struct mtd_info *master,
   const struct mtd_partition **pparts,
-  struct mtd_part_parser_data *data,
-  ssize_t (*find_header)(u_char *buf, size_t 
len, u32 ih_magic, u32 ih_type))
+  struct mtd_part_parser_data *data)
 {
struct mtd_partition *parts;
u_char *buf;
@@ -125,7 +144,7 @@ static int __mtdsplit_parse_uimage(struct mtd_info *master,
return -ENOMEM;
 
uimage_parse_dt(master, , _magic, _type, _offset, 
_magic);
-   buflen = MAX_HEADER_LEN;
+   buflen = sizeof(struct uimage_header) + header_offset;
buf = vmalloc(buflen);
if (!buf) {
ret = -ENOMEM;
@@ -146,16 +165,13 @@ static int __mtdsplit_parse_uimage(struct mtd_info 
*master,
if (header_offset && part_magic && (be32_to_cpu(*(u32 *)buf) != 
part_magic))
continue;
 
-   ret = find_header(buf + header_offset, buflen, ih_magic, 
ih_type);
+   ret = uimage_verify_default(buf + header_offset, ih_magic, 
ih_type);
if (ret < 0) {
pr_debug("no valid uImage found in \"%s\" at offset 
%llx\n",
 master->name, (unsigned long long) offset);
continue;
}
 
-   /* let uimage_find_edimax override the offset */
-   if (ret > 0)
-   header_offset = ret;
header = (struct uimage_header *)(buf + header_offset);
 
uimage_size = sizeof(*header) +
@@ -238,41 +254,6 @@ err_free_parts:
return ret;
 }
 
-static ssize_t uimage_verify_default(u_char *buf, size_t len, u32 ih_magic, 
u32 ih_type)
-{
-   struct uimage_header *header = (struct uimage_header *)buf;
-
-   /* default sanity checks */
-   if (be32_to_cpu(header->ih_magic) != ih_magic) {
-   pr_debug("invalid uImage magic: %08x != %08x\n",
-be32_to_cpu(header->ih_magic), ih_magic);
-   return -EINVAL;
-   }
-
-   if (header->ih_os != IH_OS_LINUX) {
-   pr_debug("invalid uImage OS: %08x != %08x\n",
-be32_to_cpu(header->ih_os), IH_OS_LINUX);
-   return -EINVAL;
-   }
-
-   if (header->ih_type != 

[PATCH v2 08/10] kernel: mtdsplit_uimage: replace "netgear, uimage" parser

2020-11-30 Thread Bjørn Mork
The "netgear,uimage" parser can be replaced by the generic
parser using device specific openwrt,ih-magic and
openwrt,ih-type properties.

Device tree properties for the following devices have not
been set, as they have been dropped from OpenWrt with the
removal of the ar71xx target:

 FW_MAGIC_WNR2000V1 0x32303031
 FW_MAGIC_WNR2000V4 0x32303034
 FW_MAGIC_WNR1000V2_VC  0x31303030
 FW_MAGIC_WPN824N   0x31313030

Signed-off-by: Bjørn Mork 
---
 .../linux/ath79/dts/ar7161_netgear_wndr.dtsi  |  1 +
 .../ath79/dts/ar7161_netgear_wndr3700-v2.dts  |  4 +-
 .../ath79/dts/ar7161_netgear_wndr3700.dts |  4 +-
 .../ath79/dts/ar7161_netgear_wndr3800.dts |  4 +-
 .../ath79/dts/ar7161_netgear_wndr3800ch.dts   |  4 +-
 .../ath79/dts/ar7161_netgear_wndrmac-v1.dts   |  4 +-
 .../ath79/dts/ar7161_netgear_wndrmac-v2.dts   |  4 +-
 .../ath79/dts/ar7240_netgear_wnr1000-v2.dts   |  5 +-
 .../ath79/dts/ar7240_netgear_wnr612-v2.dtsi   |  5 +-
 .../ath79/dts/ar7241_netgear_wnr2000-v3.dts   |  5 +-
 .../ath79/dts/ar7241_netgear_wnr2200-16m.dts  |  4 +-
 .../ath79/dts/ar7241_netgear_wnr2200-8m.dts   |  4 +-
 .../ath79/dts/ar7241_netgear_wnr2200.dtsi |  1 +
 .../linux/ath79/dts/ar9344_netgear_wndr.dtsi  |  5 +-
 .../drivers/mtd/mtdsplit/mtdsplit_uimage.c| 67 ---
 .../dts/rtl8380_netgear_gs110tpp-v1.dts   |  3 +-
 16 files changed, 44 insertions(+), 80 deletions(-)

diff --git a/target/linux/ath79/dts/ar7161_netgear_wndr.dtsi 
b/target/linux/ath79/dts/ar7161_netgear_wndr.dtsi
index 9e41b6135748..b780183cbb57 100644
--- a/target/linux/ath79/dts/ar7161_netgear_wndr.dtsi
+++ b/target/linux/ath79/dts/ar7161_netgear_wndr.dtsi
@@ -4,6 +4,7 @@
 
 #include 
 #include 
+#include 
 
 / {
aliases {
diff --git a/target/linux/ath79/dts/ar7161_netgear_wndr3700-v2.dts 
b/target/linux/ath79/dts/ar7161_netgear_wndr3700-v2.dts
index 0543c471130c..6d78c019dac1 100644
--- a/target/linux/ath79/dts/ar7161_netgear_wndr3700-v2.dts
+++ b/target/linux/ath79/dts/ar7161_netgear_wndr3700-v2.dts
@@ -22,7 +22,9 @@
partition@7 {
label = "firmware";
reg = <0x07 0xf8>;
-   compatible = "netgear,uimage";
+   compatible = "openwrt,uimage", "denx,uimage";
+   openwrt,ih-magic = <0x33373031>;
+   openwrt,ih-type = ;
};
 
art: partition@ff {
diff --git a/target/linux/ath79/dts/ar7161_netgear_wndr3700.dts 
b/target/linux/ath79/dts/ar7161_netgear_wndr3700.dts
index 955dd2edf0f1..ad29d256f6d8 100644
--- a/target/linux/ath79/dts/ar7161_netgear_wndr3700.dts
+++ b/target/linux/ath79/dts/ar7161_netgear_wndr3700.dts
@@ -22,7 +22,9 @@
partition@7 {
label = "firmware";
reg = <0x07 0x78>;
-   compatible = "netgear,uimage";
+   compatible = "openwrt,uimage", "denx,uimage";
+   openwrt,ih-magic = <0x33373030>;
+   openwrt,ih-type = ;
};
 
art: partition@7f {
diff --git a/target/linux/ath79/dts/ar7161_netgear_wndr3800.dts 
b/target/linux/ath79/dts/ar7161_netgear_wndr3800.dts
index 41fe401ddb01..80b25492b1b7 100644
--- a/target/linux/ath79/dts/ar7161_netgear_wndr3800.dts
+++ b/target/linux/ath79/dts/ar7161_netgear_wndr3800.dts
@@ -23,7 +23,9 @@
partition@7 {
label = "firmware";
reg = <0x07 0xf8>;
-   compatible = "netgear,uimage";
+   compatible = "openwrt,uimage", "denx,uimage";
+   openwrt,ih-magic = <0x33373031>;
+   openwrt,ih-type = ;
};
 
art: partition@ff {
diff --git a/target/linux/ath79/dts/ar7161_netgear_wndr3800ch.dts 
b/target/linux/ath79/dts/ar7161_netgear_wndr3800ch.dts
index 79569adba87f..cc51aca8b636 100644
--- a/target/linux/ath79/dts/ar7161_netgear_wndr3800ch.dts
+++ b/target/linux/ath79/dts/ar7161_netgear_wndr3800ch.dts
@@ -23,7 +23,9 @@
partition@7 {
label = "firmware";
reg = <0x07 0xf8>;
-   compatible = "netgear,uimage";
+   compatible = "openwrt,uimage", "denx,uimage";
+   openwrt,ih-magic = <0x33373031>;
+   openwrt,ih-type = ;
};
 
art: partition@ff {
diff --git a/target/linux/ath79/dts/ar7161_netgear_wndrmac-v1.dts 
b/target/linux/ath79/dts/ar7161_netgear_wndrmac-v1.dts
index 65d2393c67a3..8604414d1998 100644
--- a/target/linux/ath79/dts/ar7161_netgear_wndrmac-v1.dts
+++ b/target/linux/ath79/dts/ar7161_netgear_wndrmac-v1.dts
@@ -22,7 +22,9 @@
partition@7 {
label = "firmware";
reg = <0x07 0xf8>;
-   compatible = "netgear,uimage";
+   compatible = "openwrt,uimage", "denx,uimage";
+   openwrt,ih-magic = <0x33373031>;
+   openwrt,ih-type = ;
};
 
art: partition@ff {
diff --git 

[PATCH v2 02/10] kernel: mtdsplit_uimage: read extralen from device tree

2020-11-30 Thread Bjørn Mork
An "openwrt,padding" property in device tree can replace two device
specific parsers.

Signed-off-by: Bjørn Mork 
---
 .../drivers/mtd/mtdsplit/mtdsplit_uimage.c| 24 +++
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c 
b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
index 57d8b9f420d7..f9544ec382e3 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "mtdsplit.h"
 
@@ -28,14 +29,6 @@
  */
 #define MAX_HEADER_LEN 96
 
-#define IH_MAGIC   0x27051956  /* Image Magic Number   */
-#define IH_NMLEN   32  /* Image Name Length*/
-
-#define IH_OS_LINUX5   /* Linux*/
-
-#define IH_TYPE_KERNEL 2   /* OS Kernel Image  */
-#define IH_TYPE_FILESYSTEM 7   /* Filesystem Image */
-
 /*
  * Legacy format image header,
  * all data in network byte order (aka natural aka bigendian).
@@ -76,6 +69,15 @@ read_uimage_header(struct mtd_info *mtd, size_t offset, 
u_char *buf,
return 0;
 }
 
+static void uimage_parse_dt(struct mtd_info *master, int *extralen)
+{
+   struct device_node *np = mtd_get_of_node(master);
+
+   if (!np || !of_device_is_compatible(np, "openwrt,uimage"))
+   return;
+   of_property_read_u32(np, "openwrt,padding", extralen);
+}
+
 /**
  * __mtdsplit_parse_uimage - scan partition and create kernel + rootfs parts
  *
@@ -97,7 +99,7 @@ static int __mtdsplit_parse_uimage(struct mtd_info *master,
size_t rootfs_size = 0;
int uimage_part, rf_part;
int ret;
-   int extralen;
+   int extralen = 0;
enum mtdsplit_part_type type;
 
nr_parts = 2;
@@ -111,6 +113,8 @@ static int __mtdsplit_parse_uimage(struct mtd_info *master,
goto err_free_parts;
}
 
+   uimage_parse_dt(master, );
+
/* find uImage on erase block boundaries */
for (offset = 0; offset < master->size; offset += master->erasesize) {
struct uimage_header *header;
@@ -121,7 +125,6 @@ static int __mtdsplit_parse_uimage(struct mtd_info *master,
if (ret)
continue;
 
-   extralen = 0;
ret = find_header(buf, MAX_HEADER_LEN, );
if (ret < 0) {
pr_debug("no valid uImage found in \"%s\" at offset 
%llx\n",
@@ -247,6 +250,7 @@ mtdsplit_uimage_parse_generic(struct mtd_info *master,
 
 static const struct of_device_id mtdsplit_uimage_of_match_table[] = {
{ .compatible = "denx,uimage" },
+   { .compatible = "openwrt,uimage" },
{},
 };
 
-- 
2.20.1


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


[PATCH v2 06/10] kernel: mtdsplit_uimage: replace "allnet, uimage" parser

2020-11-30 Thread Bjørn Mork
Convert users to the generic "openwrt,uimage" using device specific
"openwrt,ih-magic" properties, and remove "allnet,uimage".

Signed-off-by: Bjørn Mork 
---
 .../drivers/mtd/mtdsplit/mtdsplit_uimage.c| 49 ---
 .../dts/rtl8382_allnet_all-sg8208m.dts|  3 +-
 2 files changed, 2 insertions(+), 50 deletions(-)

diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c 
b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
index 32c027d3e979..55eaca9946a0 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
@@ -333,54 +333,6 @@ static struct mtd_part_parser uimage_netgear_parser = {
 
 };
 
-
-/**
- * ALLNET
- **/
-
-#define FW_MAGIC_SG8208M   0x0006
-#define FW_MAGIC_SG8310PM  0x8306
-
-static ssize_t uimage_verify_allnet(u_char *buf, size_t len, u32 ih_magic)
-{
-   struct uimage_header *header = (struct uimage_header *)buf;
-
-   switch (be32_to_cpu(header->ih_magic)) {
-   case FW_MAGIC_SG8208M:
-   case FW_MAGIC_SG8310PM:
-   break;
-   default:
-   return -EINVAL;
-   }
-
-   if (header->ih_os != IH_OS_LINUX)
-   return -EINVAL;
-
-   return 0;
-}
-
-static int
-mtdsplit_uimage_parse_allnet(struct mtd_info *master,
- const struct mtd_partition **pparts,
- struct mtd_part_parser_data *data)
-{
-   return __mtdsplit_parse_uimage(master, pparts, data,
- uimage_verify_allnet);
-}
-
-static const struct of_device_id mtdsplit_uimage_allnet_of_match_table[] = {
-   { .compatible = "allnet,uimage" },
-   {},
-};
-
-static struct mtd_part_parser uimage_allnet_parser = {
-   .owner = THIS_MODULE,
-   .name = "allnet-fw",
-   .of_match_table = mtdsplit_uimage_allnet_of_match_table,
-   .parse_fn = mtdsplit_uimage_parse_allnet,
-};
-
-
 /**
  * Edimax
  **/
@@ -438,7 +390,6 @@ static int __init mtdsplit_uimage_init(void)
 {
register_mtd_parser(_generic_parser);
register_mtd_parser(_netgear_parser);
-   register_mtd_parser(_allnet_parser);
register_mtd_parser(_edimax_parser);
 
return 0;
diff --git a/target/linux/realtek/dts/rtl8382_allnet_all-sg8208m.dts 
b/target/linux/realtek/dts/rtl8382_allnet_all-sg8208m.dts
index a5dd3be0a4ab..30ff8cd150be 100644
--- a/target/linux/realtek/dts/rtl8382_allnet_all-sg8208m.dts
+++ b/target/linux/realtek/dts/rtl8382_allnet_all-sg8208m.dts
@@ -90,7 +90,8 @@
partition@2a {
label = "firmware";
reg = <0x2a 0xd6>;
-   compatible = "allnet,uimage";
+   compatible = "openwrt,uimage", "denx,uimage";
+   openwrt,ih-magic = <0x0006>;
};
};
};
-- 
2.20.1


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


[PATCH v2 00/10] kernel: mtdsplit_uimage: use device tree properties for non-standard uimage parsing

2020-11-30 Thread Bjørn Mork
OK, another go at this.  The idea is still to replace a number of
device specific variants of the "denx,uimage" partition splitter with
a unified parser, using optional device-tree properties to describe
deviations from the standard U-Boot Image.

Changes in v2:
 - added documentation of the properties, almost upstreamable
 - added a device tree header shared with the driver
 - changed property names to openwrt,foo and tied these to an
   openwrt,uimage compatible string
 - split out the definition of the properties from the deletion of the
   "edimax,uimage" parser

Naming is hard.  And I am still not sure about the "openwrt," thing.
Ref http://lists.openwrt.org/pipermail/openwrt-devel/2018-December/021004.html

But it fealt so wrong trying to define these properties with a "denx,"
prefix.  The way I read
https://www.kernel.org/doc/html/latest/devicetree/bindings/writing-bindings.html
we must use some prefix here.  These properties are not generally
applicable to any partition.  They are very specific to the uimage,
and in particular to the bastard uimage partitions which don't really
qualify as "denx,uimage".

So it ended up as "openwrt,".  I'll change it if you hate it, but I'd
appreciate some hints on what I should change it to..

Yes, and testing. I've build tested all the steps with an assorted set
of affected devices.  And I have run tested this with a new device
which needs the "openwrt,ih-magic" property or similar.  But I have
NOT run tested this on any of the affected existing devices.  Which
means that we don't know if they work at all.  And if they don't then
you will not have a rootfs.  So some care should be taken until this
is verified on those devices.

Might have made the new header too complete.  It makes the diffstat
look worse...  But the real savings are still there in
mtdsplit_uimage.c



Bjørn
---

Bjørn Mork (10):
  dt-bindings: mtd: partitions: add OpenWrt defined U-Boot Image
  kernel: mtdsplit_uimage: read extralen from device tree
  kernel: mtdsplit_uimage: replace "fonfxc" and "sge" parsers
  kernel: mtdsplit_uimage: add "openwrt,ih-magic" device-tree property
  kernel: mtdsplit_uimage: replace "openwrt,okli" parser
  kernel: mtdsplit_uimage: replace "allnet,uimage" parser
  kernel: mtdsplit_uimage: add "openwrt,ih-type" device-tree property
  kernel: mtdsplit_uimage: replace "netgear,uimage" parser
  kernel: mtdsplit_uimage: add "openwrt,offset" and
"openwrt,partition-magic"
  kernel: mtdsplit_uimage: replace "edimax,uimage" parser

 .../linux/ath79/dts/ar7161_netgear_wndr.dtsi  |   1 +
 .../ath79/dts/ar7161_netgear_wndr3700-v2.dts  |   4 +-
 .../ath79/dts/ar7161_netgear_wndr3700.dts |   4 +-
 .../ath79/dts/ar7161_netgear_wndr3800.dts |   4 +-
 .../ath79/dts/ar7161_netgear_wndr3800ch.dts   |   4 +-
 .../ath79/dts/ar7161_netgear_wndrmac-v1.dts   |   4 +-
 .../ath79/dts/ar7161_netgear_wndrmac-v2.dts   |   4 +-
 .../ath79/dts/ar7240_engenius_enh202-v1.dts   |   3 +-
 .../ath79/dts/ar7240_netgear_wnr1000-v2.dts   |   5 +-
 .../ath79/dts/ar7240_netgear_wnr612-v2.dtsi   |   5 +-
 .../ath79/dts/ar7241_netgear_wnr2000-v3.dts   |   5 +-
 .../ath79/dts/ar7241_netgear_wnr2200-16m.dts  |   4 +-
 .../ath79/dts/ar7241_netgear_wnr2200-8m.dts   |   4 +-
 .../ath79/dts/ar7241_netgear_wnr2200.dtsi |   1 +
 .../dts/ar9341_engenius_ens202ext-v1.dts  |   3 +-
 .../linux/ath79/dts/ar9341_pisen_wmb001n.dts  |   3 +-
 .../linux/ath79/dts/ar9344_netgear_wndr.dtsi  |   5 +-
 .../mtd/partitions/openwrt,uimage.yaml|  91 
 .../drivers/mtd/mtdsplit/mtdsplit_uimage.c| 426 +++---
 .../dt-bindings/mtd/partitions/uimage.h   | 191 
 .../dts/mt7620a_edimax_br-6478ac-v2.dts   |   4 +-
 .../ramips/dts/mt7620a_edimax_ew-7478apc.dts  |   4 +-
 .../linux/ramips/dts/mt7620a_fon_fon2601.dts  |   3 +-
 .../ramips/dts/mt7620n_sunvalley_filehub.dtsi |   3 +-
 .../ramips/dts/mt7621_dlink_dir-8xx-a1.dtsi   |   3 +-
 .../ramips/dts/mt7621_dlink_dir-xx60-a1.dtsi  |   6 +-
 .../linux/ramips/dts/mt7621_edimax_re23s.dts  |   4 +-
 .../ramips/dts/rt3050_edimax_3g-6200n.dts |   4 +-
 .../ramips/dts/rt3050_edimax_3g-6200nl.dts|   4 +-
 .../ramips/dts/rt3662_edimax_br-6475nd.dts|   4 +-
 .../dts/rtl8380_netgear_gs110tpp-v1.dts   |   3 +-
 .../dts/rtl8382_allnet_all-sg8208m.dts|   3 +-
 32 files changed, 432 insertions(+), 384 deletions(-)
 create mode 100644 
target/linux/generic/files/Documentation/devicetree/bindings/mtd/partitions/openwrt,uimage.yaml
 create mode 100644 
target/linux/generic/files/include/dt-bindings/mtd/partitions/uimage.h

-- 
2.20.1


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


[PATCH v2 04/10] kernel: mtdsplit_uimage: add "openwrt, ih-magic" device-tree property

2020-11-30 Thread Bjørn Mork
Many devices use uimages with non-standard magic values. Let
device tree override the default magic.

Signed-off-by: Bjørn Mork 
---
 .../drivers/mtd/mtdsplit/mtdsplit_uimage.c| 41 +++
 1 file changed, 23 insertions(+), 18 deletions(-)

diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c 
b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
index f5e48c661e8f..58c40e9ec70b 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
@@ -69,13 +69,17 @@ read_uimage_header(struct mtd_info *mtd, size_t offset, 
u_char *buf,
return 0;
 }
 
-static void uimage_parse_dt(struct mtd_info *master, int *extralen)
+static void uimage_parse_dt(struct mtd_info *master, int *extralen, u32 
*ih_magic)
 {
struct device_node *np = mtd_get_of_node(master);
 
if (!np || !of_device_is_compatible(np, "openwrt,uimage"))
return;
-   of_property_read_u32(np, "openwrt,padding", extralen);
+
+   if (!of_property_read_u32(np, "openwrt,padding", extralen))
+   pr_debug("got openwrt,padding=%d from device-tree\n", 
*extralen);
+   if (!of_property_read_u32(np, "openwrt,ih-magic", ih_magic))
+   pr_debug("got openwrt,ih-magic=%08x from device-tree\n", 
*ih_magic);
 }
 
 /**
@@ -87,7 +91,7 @@ static void uimage_parse_dt(struct mtd_info *master, int 
*extralen)
 static int __mtdsplit_parse_uimage(struct mtd_info *master,
   const struct mtd_partition **pparts,
   struct mtd_part_parser_data *data,
-  ssize_t (*find_header)(u_char *buf, size_t len))
+  ssize_t (*find_header)(u_char *buf, size_t len, u32 
ih_magic))
 {
struct mtd_partition *parts;
u_char *buf;
@@ -100,6 +104,7 @@ static int __mtdsplit_parse_uimage(struct mtd_info *master,
int uimage_part, rf_part;
int ret;
int extralen = 0;
+   u32 ih_magic = IH_MAGIC;
enum mtdsplit_part_type type;
 
nr_parts = 2;
@@ -113,7 +118,7 @@ static int __mtdsplit_parse_uimage(struct mtd_info *master,
goto err_free_parts;
}
 
-   uimage_parse_dt(master, );
+   uimage_parse_dt(master, , _magic);
 
/* find uImage on erase block boundaries */
for (offset = 0; offset < master->size; offset += master->erasesize) {
@@ -125,7 +130,7 @@ static int __mtdsplit_parse_uimage(struct mtd_info *master,
if (ret)
continue;
 
-   ret = find_header(buf, MAX_HEADER_LEN);
+   ret = find_header(buf, MAX_HEADER_LEN, ih_magic);
if (ret < 0) {
pr_debug("no valid uImage found in \"%s\" at offset 
%llx\n",
 master->name, (unsigned long long) offset);
@@ -213,26 +218,26 @@ err_free_parts:
return ret;
 }
 
-static ssize_t uimage_verify_default(u_char *buf, size_t len)
+static ssize_t uimage_verify_default(u_char *buf, size_t len, u32 ih_magic)
 {
struct uimage_header *header = (struct uimage_header *)buf;
 
/* default sanity checks */
-   if (be32_to_cpu(header->ih_magic) != IH_MAGIC) {
-   pr_debug("invalid uImage magic: %08x\n",
-be32_to_cpu(header->ih_magic));
+   if (be32_to_cpu(header->ih_magic) != ih_magic) {
+   pr_debug("invalid uImage magic: %08x != %08x\n",
+be32_to_cpu(header->ih_magic), ih_magic);
return -EINVAL;
}
 
if (header->ih_os != IH_OS_LINUX) {
-   pr_debug("invalid uImage OS: %08x\n",
-be32_to_cpu(header->ih_os));
+   pr_debug("invalid uImage OS: %08x != %08x\n",
+be32_to_cpu(header->ih_os), IH_OS_LINUX);
return -EINVAL;
}
 
if (header->ih_type != IH_TYPE_KERNEL) {
-   pr_debug("invalid uImage type: %08x\n",
-be32_to_cpu(header->ih_type));
+   pr_debug("invalid uImage type: %08x != %08x\n",
+be32_to_cpu(header->ih_type), IH_TYPE_KERNEL);
return -EINVAL;
}
 
@@ -274,7 +279,7 @@ static struct mtd_part_parser uimage_generic_parser = {
 #define FW_MAGIC_WNDR3700V20x33373031
 #define FW_MAGIC_WPN824N   0x31313030
 
-static ssize_t uimage_verify_wndr3700(u_char *buf, size_t len)
+static ssize_t uimage_verify_wndr3700(u_char *buf, size_t len, u32 ih_magic)
 {
struct uimage_header *header = (struct uimage_header *)buf;
uint8_t expected_type = IH_TYPE_FILESYSTEM;
@@ -336,7 +341,7 @@ static struct mtd_part_parser uimage_netgear_parser = {
 #define FW_MAGIC_SG8208M   0x0006
 #define FW_MAGIC_SG8310PM  0x8306
 
-static ssize_t uimage_verify_allnet(u_char *buf, size_t len)
+static ssize_t uimage_verify_allnet(u_char *buf, 

[PATCH v2 07/10] kernel: mtdsplit_uimage: add "openwrt, ih-type" device-tree property

2020-11-30 Thread Bjørn Mork
Some devices use uimage headers with a non-default ih_type. Add
support for overriding this in device tree.

Signed-off-by: Bjørn Mork 
---
 .../drivers/mtd/mtdsplit/mtdsplit_uimage.c| 24 +++
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c 
b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
index 55eaca9946a0..ef2d857abb04 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
@@ -69,7 +69,8 @@ read_uimage_header(struct mtd_info *mtd, size_t offset, 
u_char *buf,
return 0;
 }
 
-static void uimage_parse_dt(struct mtd_info *master, int *extralen, u32 
*ih_magic)
+static void uimage_parse_dt(struct mtd_info *master, int *extralen,
+   u32 *ih_magic, u32 *ih_type)
 {
struct device_node *np = mtd_get_of_node(master);
 
@@ -80,6 +81,8 @@ static void uimage_parse_dt(struct mtd_info *master, int 
*extralen, u32 *ih_magi
pr_debug("got openwrt,padding=%d from device-tree\n", 
*extralen);
if (!of_property_read_u32(np, "openwrt,ih-magic", ih_magic))
pr_debug("got openwrt,ih-magic=%08x from device-tree\n", 
*ih_magic);
+   if (!of_property_read_u32(np, "openwrt,ih-type", ih_type))
+   pr_debug("got openwrt,ih-type=%08x from device-tree\n", 
*ih_type);
 }
 
 /**
@@ -91,7 +94,7 @@ static void uimage_parse_dt(struct mtd_info *master, int 
*extralen, u32 *ih_magi
 static int __mtdsplit_parse_uimage(struct mtd_info *master,
   const struct mtd_partition **pparts,
   struct mtd_part_parser_data *data,
-  ssize_t (*find_header)(u_char *buf, size_t len, u32 
ih_magic))
+  ssize_t (*find_header)(u_char *buf, size_t len, u32 
ih_magic, u32 ih_type))
 {
struct mtd_partition *parts;
u_char *buf;
@@ -105,6 +108,7 @@ static int __mtdsplit_parse_uimage(struct mtd_info *master,
int ret;
int extralen = 0;
u32 ih_magic = IH_MAGIC;
+   u32 ih_type = IH_TYPE_KERNEL;
enum mtdsplit_part_type type;
 
nr_parts = 2;
@@ -118,7 +122,7 @@ static int __mtdsplit_parse_uimage(struct mtd_info *master,
goto err_free_parts;
}
 
-   uimage_parse_dt(master, , _magic);
+   uimage_parse_dt(master, , _magic, _type);
 
/* find uImage on erase block boundaries */
for (offset = 0; offset < master->size; offset += master->erasesize) {
@@ -130,7 +134,7 @@ static int __mtdsplit_parse_uimage(struct mtd_info *master,
if (ret)
continue;
 
-   ret = find_header(buf, MAX_HEADER_LEN, ih_magic);
+   ret = find_header(buf, MAX_HEADER_LEN, ih_magic, ih_type);
if (ret < 0) {
pr_debug("no valid uImage found in \"%s\" at offset 
%llx\n",
 master->name, (unsigned long long) offset);
@@ -218,7 +222,7 @@ err_free_parts:
return ret;
 }
 
-static ssize_t uimage_verify_default(u_char *buf, size_t len, u32 ih_magic)
+static ssize_t uimage_verify_default(u_char *buf, size_t len, u32 ih_magic, 
u32 ih_type)
 {
struct uimage_header *header = (struct uimage_header *)buf;
 
@@ -235,9 +239,9 @@ static ssize_t uimage_verify_default(u_char *buf, size_t 
len, u32 ih_magic)
return -EINVAL;
}
 
-   if (header->ih_type != IH_TYPE_KERNEL) {
+   if (header->ih_type != ih_type) {
pr_debug("invalid uImage type: %08x != %08x\n",
-be32_to_cpu(header->ih_type), IH_TYPE_KERNEL);
+be32_to_cpu(header->ih_type), ih_type);
return -EINVAL;
}
 
@@ -279,7 +283,7 @@ static struct mtd_part_parser uimage_generic_parser = {
 #define FW_MAGIC_WNDR3700V20x33373031
 #define FW_MAGIC_WPN824N   0x31313030
 
-static ssize_t uimage_verify_wndr3700(u_char *buf, size_t len, u32 ih_magic)
+static ssize_t uimage_verify_wndr3700(u_char *buf, size_t len, u32 ih_magic, 
u32 ih_type)
 {
struct uimage_header *header = (struct uimage_header *)buf;
uint8_t expected_type = IH_TYPE_FILESYSTEM;
@@ -340,7 +344,7 @@ static struct mtd_part_parser uimage_netgear_parser = {
 #define FW_EDIMAX_OFFSET   20
 #define FW_MAGIC_EDIMAX0x43535953
 
-static ssize_t uimage_find_edimax(u_char *buf, size_t len, u32 ih_magic)
+static ssize_t uimage_find_edimax(u_char *buf, size_t len, u32 ih_magic, u32 
ih_type)
 {
u32 *magic;
 
@@ -353,7 +357,7 @@ static ssize_t uimage_find_edimax(u_char *buf, size_t len, 
u32 ih_magic)
if (be32_to_cpu(*magic) != FW_MAGIC_EDIMAX)
return -EINVAL;
 
-   if (!uimage_verify_default(buf + FW_EDIMAX_OFFSET, len, ih_magic))
+   if (!uimage_verify_default(buf + FW_EDIMAX_OFFSET, len, ih_magic, 

[PATCH v2 05/10] kernel: mtdsplit_uimage: replace "openwrt, okli" parser

2020-11-30 Thread Bjørn Mork
The only difference between the "openwrt,okli" and the generic
parser is the magic.  Set this in device tree for all affected
devices and  remove the "openwrt,okli" parser.

Signed-off-by: Bjørn Mork 
---
 .../ath79/dts/ar7240_engenius_enh202-v1.dts   |  3 +-
 .../dts/ar9341_engenius_ens202ext-v1.dts  |  3 +-
 .../linux/ath79/dts/ar9341_pisen_wmb001n.dts  |  3 +-
 .../drivers/mtd/mtdsplit/mtdsplit_uimage.c| 53 ---
 .../ramips/dts/mt7620n_sunvalley_filehub.dtsi |  3 +-
 5 files changed, 8 insertions(+), 57 deletions(-)

diff --git a/target/linux/ath79/dts/ar7240_engenius_enh202-v1.dts 
b/target/linux/ath79/dts/ar7240_engenius_enh202-v1.dts
index 4752ad1edd5b..d42f75d31dcc 100644
--- a/target/linux/ath79/dts/ar7240_engenius_enh202-v1.dts
+++ b/target/linux/ath79/dts/ar7240_engenius_enh202-v1.dts
@@ -80,7 +80,8 @@
#size-cells = <1>;
 
partition@0 {
-   compatible = "openwrt,okli";
+   compatible = "openwrt,uimage", "denx,uimage";
+   openwrt,ih-magic = <0x4f4b4c49>;
label = "firmware";
reg = <0x0 0x0>;
};
diff --git a/target/linux/ath79/dts/ar9341_engenius_ens202ext-v1.dts 
b/target/linux/ath79/dts/ar9341_engenius_ens202ext-v1.dts
index da1e59d4c321..e936109351df 100644
--- a/target/linux/ath79/dts/ar9341_engenius_ens202ext-v1.dts
+++ b/target/linux/ath79/dts/ar9341_engenius_ens202ext-v1.dts
@@ -70,7 +70,8 @@
#size-cells = <1>;
 
partition@0 {
-   compatible = "openwrt,okli";
+   compatible = "openwrt,uimage", "denx,uimage";
+   openwrt,ih-magic = <0x4f4b4c49>;
label = "firmware";
reg = <0x0 0x0>;
};
diff --git a/target/linux/ath79/dts/ar9341_pisen_wmb001n.dts 
b/target/linux/ath79/dts/ar9341_pisen_wmb001n.dts
index 7057c3b1adf2..42f2fc22ae00 100644
--- a/target/linux/ath79/dts/ar9341_pisen_wmb001n.dts
+++ b/target/linux/ath79/dts/ar9341_pisen_wmb001n.dts
@@ -106,7 +106,8 @@
partition@0 {
reg = <0x0 0x0>;
label = "firmware";
-   compatible = "openwrt,okli";
+   compatible = "openwrt,uimage", "denx,uimage";
+   openwrt,ih-magic = <0x4f4b4c49>;
};
};
};
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c 
b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
index 58c40e9ec70b..32c027d3e979 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
@@ -429,58 +429,6 @@ static struct mtd_part_parser uimage_edimax_parser = {
.type = MTD_PARSER_TYPE_FIRMWARE,
 };
 
-/**
- * OKLI (OpenWrt Kernel Loader Image)
- **/
-
-#define IH_MAGIC_OKLI  0x4f4b4c49
-
-static ssize_t uimage_verify_okli(u_char *buf, size_t len, u32 ih_magic)
-{
-   struct uimage_header *header = (struct uimage_header *)buf;
-
-   /* default sanity checks */
-   if (be32_to_cpu(header->ih_magic) != IH_MAGIC_OKLI) {
-   pr_debug("invalid uImage magic: %08x\n",
-be32_to_cpu(header->ih_magic));
-   return -EINVAL;
-   }
-
-   if (header->ih_os != IH_OS_LINUX) {
-   pr_debug("invalid uImage OS: %08x\n",
-be32_to_cpu(header->ih_os));
-   return -EINVAL;
-   }
-
-   if (header->ih_type != IH_TYPE_KERNEL) {
-   pr_debug("invalid uImage type: %08x\n",
-be32_to_cpu(header->ih_type));
-   return -EINVAL;
-   }
-
-   return 0;
-}
-
-static int
-mtdsplit_uimage_parse_okli(struct mtd_info *master,
- const struct mtd_partition **pparts,
- struct mtd_part_parser_data *data)
-{
-   return __mtdsplit_parse_uimage(master, pparts, data,
- uimage_verify_okli);
-}
-
-static const struct of_device_id mtdsplit_uimage_okli_of_match_table[] = {
-   { .compatible = "openwrt,okli" },
-   {},
-};
-
-static struct mtd_part_parser uimage_okli_parser = {
-   .owner = THIS_MODULE,
-   .name = "okli-fw",
-   .of_match_table = mtdsplit_uimage_okli_of_match_table,
-   .parse_fn = mtdsplit_uimage_parse_okli,
-};
 
 /**
  * Init
@@ -492,7 +440,6 @@ static int __init mtdsplit_uimage_init(void)
register_mtd_parser(_netgear_parser);
  

[PATCH v2 03/10] kernel: mtdsplit_uimage: replace "fonfxc" and "sge" parsers

2020-11-30 Thread Bjørn Mork
Convert users of the "fonfxc" and "sge" parsers to the generic
"openwrt,uimage", using device specific "openwrt,padding" properties.

Signed-off-by: Bjørn Mork 
---
 .../drivers/mtd/mtdsplit/mtdsplit_uimage.c| 93 ++-
 .../linux/ramips/dts/mt7620a_fon_fon2601.dts  |  3 +-
 .../ramips/dts/mt7621_dlink_dir-8xx-a1.dtsi   |  3 +-
 .../ramips/dts/mt7621_dlink_dir-xx60-a1.dtsi  |  6 +-
 4 files changed, 16 insertions(+), 89 deletions(-)

diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c 
b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
index f9544ec382e3..f5e48c661e8f 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
@@ -87,7 +87,7 @@ static void uimage_parse_dt(struct mtd_info *master, int 
*extralen)
 static int __mtdsplit_parse_uimage(struct mtd_info *master,
   const struct mtd_partition **pparts,
   struct mtd_part_parser_data *data,
-  ssize_t (*find_header)(u_char *buf, size_t len, int 
*extralen))
+  ssize_t (*find_header)(u_char *buf, size_t len))
 {
struct mtd_partition *parts;
u_char *buf;
@@ -125,7 +125,7 @@ static int __mtdsplit_parse_uimage(struct mtd_info *master,
if (ret)
continue;
 
-   ret = find_header(buf, MAX_HEADER_LEN, );
+   ret = find_header(buf, MAX_HEADER_LEN);
if (ret < 0) {
pr_debug("no valid uImage found in \"%s\" at offset 
%llx\n",
 master->name, (unsigned long long) offset);
@@ -213,7 +213,7 @@ err_free_parts:
return ret;
 }
 
-static ssize_t uimage_verify_default(u_char *buf, size_t len, int *extralen)
+static ssize_t uimage_verify_default(u_char *buf, size_t len)
 {
struct uimage_header *header = (struct uimage_header *)buf;
 
@@ -274,7 +274,7 @@ static struct mtd_part_parser uimage_generic_parser = {
 #define FW_MAGIC_WNDR3700V20x33373031
 #define FW_MAGIC_WPN824N   0x31313030
 
-static ssize_t uimage_verify_wndr3700(u_char *buf, size_t len, int *extralen)
+static ssize_t uimage_verify_wndr3700(u_char *buf, size_t len)
 {
struct uimage_header *header = (struct uimage_header *)buf;
uint8_t expected_type = IH_TYPE_FILESYSTEM;
@@ -336,7 +336,7 @@ static struct mtd_part_parser uimage_netgear_parser = {
 #define FW_MAGIC_SG8208M   0x0006
 #define FW_MAGIC_SG8310PM  0x8306
 
-static ssize_t uimage_verify_allnet(u_char *buf, size_t len, int *extralen)
+static ssize_t uimage_verify_allnet(u_char *buf, size_t len)
 {
struct uimage_header *header = (struct uimage_header *)buf;
 
@@ -383,7 +383,7 @@ static struct mtd_part_parser uimage_allnet_parser = {
 #define FW_EDIMAX_OFFSET   20
 #define FW_MAGIC_EDIMAX0x43535953
 
-static ssize_t uimage_find_edimax(u_char *buf, size_t len, int *extralen)
+static ssize_t uimage_find_edimax(u_char *buf, size_t len)
 {
u32 *magic;
 
@@ -396,7 +396,7 @@ static ssize_t uimage_find_edimax(u_char *buf, size_t len, 
int *extralen)
if (be32_to_cpu(*magic) != FW_MAGIC_EDIMAX)
return -EINVAL;
 
-   if (!uimage_verify_default(buf + FW_EDIMAX_OFFSET, len, extralen))
+   if (!uimage_verify_default(buf + FW_EDIMAX_OFFSET, len))
return FW_EDIMAX_OFFSET;
 
return -EINVAL;
@@ -424,88 +424,13 @@ static struct mtd_part_parser uimage_edimax_parser = {
.type = MTD_PARSER_TYPE_FIRMWARE,
 };
 
-
-/**
- * Fon(Foxconn)
- **/
-
-#define FONFXC_PAD_LEN 32
-
-static ssize_t uimage_find_fonfxc(u_char *buf, size_t len, int *extralen)
-{
-   if (uimage_verify_default(buf, len, extralen) < 0)
-   return -EINVAL;
-
-   *extralen = FONFXC_PAD_LEN;
-
-   return 0;
-}
-
-static int
-mtdsplit_uimage_parse_fonfxc(struct mtd_info *master,
- const struct mtd_partition **pparts,
- struct mtd_part_parser_data *data)
-{
-   return __mtdsplit_parse_uimage(master, pparts, data,
-  uimage_find_fonfxc);
-}
-
-static const struct of_device_id mtdsplit_uimage_fonfxc_of_match_table[] = {
-   { .compatible = "fonfxc,uimage" },
-   {},
-};
-
-static struct mtd_part_parser uimage_fonfxc_parser = {
-   .owner = THIS_MODULE,
-   .name = "fonfxc-fw",
-   .of_match_table = mtdsplit_uimage_fonfxc_of_match_table,
-   .parse_fn = mtdsplit_uimage_parse_fonfxc,
-};
-
-/**
- * SGE (T) Shenzhen Gongjin Electronics
- **/
-
-#define SGE_PAD_LEN96
-
-static ssize_t uimage_find_sge(u_char *buf, size_t len, int *extralen)
-{
-   if 

resend my questions - Luci JSON-RPC API question

2020-11-30 Thread Dandi Roland
Hi,

sorry for my new mail, i have just subscribed to the mailing list, so
i am sending it again because i don't know if my previous mail arrived
e. My original letter:

Hi

I would like to ask a question about the OpenWrt Luci JSON-RPC API.
I want to call the class find function of luci.model.ipkg, but I don't
understand how callback works.

Can you explain?

Here is my request that I am submitting, but I don't know how to
specify the callback function or what function it would expect.

curl 
http://192.168.1.1/cgi-bin/luci/rpc/ipkg?auth=d454d28a1dabfde80a591d2f99e25xyz
--data @ipkg_find

ipkg_find
{
  "method": "find",
  "params": [
"luci",

  ]
}

Thank you very much
Roland Dandi


Dandi Roland
dandirol...@gmail.com

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


Re: [PATCH] openvpn: update to 2.5.0

2020-11-30 Thread Jo-Philipp Wich
Hi,

[...]
> @@ -137,6 +143,7 @@ allow_recursive_routing
>  auth_nocache
>  auth_user_pass_optional
>  bind
> +block-ipv6

I suppose this needs to be `block_ipv6` ?

>  ccd_exclusive
>  client
>  client_to_client
> @@ -185,10 +192,13 @@ tls_server
>  up_delay
>  up_restart
>  username_as_common_name
> +vlan_tagging

~ Jo



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


Luci JSON-RPC API question

2020-11-30 Thread Dandi Roland
Hi

I would like to ask a question about the OpenWrt Luci JSON-RPC API.
I want to call the class find function of luci.model.ipkg, but I don't
understand how callback works.

Can you explain?

Here is my request that I am submitting, but I don't know how to
specify the callback function or what function it would expect.

curl 
http://192.168.1.1/cgi-bin/luci/rpc/ipkg?auth=d454d28a1dabfde80a591d2f99e25xyz
--data @ipkg_find

ipkg_find
{
  "method": "find",
  "params": [
"luci",

  ]
}

Thank you very much
Roland Dandi


Dandi Roland
dandirol...@gmail.com

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