Merge Official Source

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
Tianling Shen 2024-09-20 13:06:31 +08:00
commit 9022262539
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
28 changed files with 329 additions and 456 deletions

View File

@ -1,2 +1,2 @@
LINUX_VERSION-6.6 = .51 LINUX_VERSION-6.6 = .52
LINUX_KERNEL_HASH-6.6.51 = 1c0c9a14650879c4913efdbac428ba31a540c3d987155ddf34d33e11eca008b3 LINUX_KERNEL_HASH-6.6.52 = 1591ab348399d4aa53121158525056a69c8cf0fe0e90935b0095e9a58e37b4b8

View File

@ -81,6 +81,7 @@ jcg,q20-pb-boot|\
linksys,e7350|\ linksys,e7350|\
netgear,eax12|\ netgear,eax12|\
netgear,wax202|\ netgear,wax202|\
netis,n6|\
zyxel,wsm20) zyxel,wsm20)
ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000" ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
;; ;;

View File

@ -469,7 +469,8 @@
+CONFIG_LMB_MAX_REGIONS=64 +CONFIG_LMB_MAX_REGIONS=64
--- /dev/null --- /dev/null
+++ b/openwrt-one-nor_env +++ b/openwrt-one-nor_env
@@ -0,0 +1,46 @@ @@ -0,0 +1,47 @@
+ethaddr_factory=mtd read factory 0x46000000 0x0 0x20000 && env readmem -b ethaddr 0x4600002a 0x6 ; setenv ethaddr_factory
+bl2_mtd_write=mtd erase bl2-nor && mtd write bl2-nor $loadaddr 0x0 0x40000 +bl2_mtd_write=mtd erase bl2-nor && mtd write bl2-nor $loadaddr 0x0 0x40000
+bl2_tftp_write=tftpboot $loadaddr $bootfile_bl2_nor && run bl2_mtd_write +bl2_tftp_write=tftpboot $loadaddr $bootfile_bl2_nor && run bl2_mtd_write
+bootcmd=run check_button ; run led_start ; mtd read recovery ${loadaddr} ; bootm ; run led_loop_error +bootcmd=run check_button ; run led_start ; mtd read recovery ${loadaddr} ; bootm ; run led_loop_error
@ -512,13 +513,14 @@
+usb_recovery=run led_start ; usb start && run usb_recovery_bl2 && run usb_recovery_ubi && run led_loop_done +usb_recovery=run led_start ; usb start && run usb_recovery_bl2 && run usb_recovery_ubi && run led_loop_done
+usb_recovery_bl2=fatload usb 0:1 ${loadaddr} ${recoverfile_bl2} && run recovery_write_bl2 +usb_recovery_bl2=fatload usb 0:1 ${loadaddr} ${recoverfile_bl2} && run recovery_write_bl2
+usb_recovery_ubi=fatload usb 0:1 ${loadaddr} ${recoverfile_ubi} && run recovery_write_ubi +usb_recovery_ubi=fatload usb 0:1 ${loadaddr} ${recoverfile_ubi} && run recovery_write_ubi
+_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title $ver" +_firstboot=setenv _firstboot ; run ethaddr_factory ; run _switch_to_menu ; run _init_env ; bootmenu
+_firstboot=setenv _firstboot ; run _switch_to_menu ; run _init_env ; bootmenu
+_init_env=setenv _init_env ; echo Initialize Env ; run ubi_create_env ; saveenv +_init_env=setenv _init_env ; echo Initialize Env ; run ubi_create_env ; saveenv
+_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title +_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title
+_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title $ver"
--- /dev/null --- /dev/null
+++ b/openwrt-one-spi-nand_env +++ b/openwrt-one-spi-nand_env
@@ -0,0 +1,59 @@ @@ -0,0 +1,60 @@
+ethaddr_factory=mtd read factory 0x46000000 0x0 0x20000 && env readmem -b ethaddr 0x4600002a 0x6 ; setenv ethaddr_factory
+ipaddr=192.168.11.11 +ipaddr=192.168.11.11
+serverip=192.168.11.23 +serverip=192.168.11.23
+loadaddr=0x46000000 +loadaddr=0x46000000
@ -575,6 +577,6 @@
+ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic && ubi write $loadaddr fit $filesize +ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic && ubi write $loadaddr fit $filesize
+ubi_write_recovery=ubi check recovery && ubi remove recovery ; run ubi_remove_rootfs ; ubi create recovery $filesize dynamic && ubi write $loadaddr recovery $filesize +ubi_write_recovery=ubi check recovery && ubi remove recovery ; run ubi_remove_rootfs ; ubi create recovery $filesize dynamic && ubi write $loadaddr recovery $filesize
+_init_env=setenv _init_env ; run ubi_create_env ; saveenv ; saveenv +_init_env=setenv _init_env ; run ubi_create_env ; saveenv ; saveenv
+_firstboot=setenv _firstboot ; run _switch_to_menu ; run _init_env ; bootmenu +_firstboot=setenv _firstboot ; run ethaddr_factory ; run _switch_to_menu ; run _init_env ; bootmenu
+_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title +_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title
+_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title $ver" +_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title $ver"

View File

@ -5,11 +5,11 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=dtc PKG_NAME:=dtc
PKG_VERSION:=1.7.0 PKG_VERSION:=1.7.1
PKG_RELEASE:=3 PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_HASH:=29edce3d302a15563d8663198bbc398c5a0554765c83830d0d4c0409d21a16c4 PKG_HASH:=9532f10098455711a4da37816fd567dfc8523bb01f59ad6c44887a112e553d9e
PKG_SOURCE_URL:=@KERNEL/software/utils/dtc PKG_SOURCE_URL:=@KERNEL/software/utils/dtc
PKG_MAINTAINER:=Yousong Zhou <yszhou4tech@gmail.com> PKG_MAINTAINER:=Yousong Zhou <yszhou4tech@gmail.com>
@ -88,6 +88,7 @@ define Package/libfdt/install
endef endef
MESON_ARGS += \ MESON_ARGS += \
-Dtests=false \
-Dtools=true \ -Dtools=true \
-Dyaml=disabled \ -Dyaml=disabled \
-Dvalgrind=disabled \ -Dvalgrind=disabled \

View File

@ -1,48 +0,0 @@
From da39ee0e68b6d9293133a7c41c6cf73354dce337 Mon Sep 17 00:00:00 2001
From: Rosen Penev <rosenp@gmail.com>
Date: Wed, 21 Feb 2024 13:57:56 -0800
Subject: [PATCH] libfdt: rework shared/static libraries
Instead of creating 2 libraries manualy, just call both_libraries and
link to the appropriate one as requested.
Fixes compilation when passing -Ddefault_libraries=both as the
static_library name is duplicated.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
libfdt/meson.build | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
--- a/libfdt/meson.build
+++ b/libfdt/meson.build
@@ -16,7 +16,7 @@ sources = files(
'fdt_wip.c',
)
-libfdt = library(
+libfdt = both_libraries(
'fdt', sources,
version: '1.6.0',
link_args: ['-Wl,--no-undefined', version_script],
@@ -24,17 +24,12 @@ libfdt = library(
install: true,
)
-libfdt_a = static_library(
- 'fdt', sources,
- install: true,
-)
-
libfdt_inc = include_directories('.')
if static_build
- link_with = libfdt_a
+ link_with = libfdt.get_static_lib()
else
- link_with = libfdt
+ link_with = libfdt.get_shared_lib()
endif
libfdt_dep = declare_dependency(

View File

@ -506,6 +506,9 @@ CONFIG_VFPv3=y
CONFIG_VIDEOMODE_HELPERS=y CONFIG_VIDEOMODE_HELPERS=y
CONFIG_VIDEO_CMDLINE=y CONFIG_VIDEO_CMDLINE=y
CONFIG_VIDEO_DEV=y CONFIG_VIDEO_DEV=y
# CONFIG_VIDEO_MICROCHIP_CSI2DC is not set
# CONFIG_VIDEO_MICROCHIP_ISC is not set
# CONFIG_VIDEO_MICROCHIP_XISC is not set
CONFIG_VIDEO_NOMODESET=y CONFIG_VIDEO_NOMODESET=y
CONFIG_VIDEO_V4L2_I2C=y CONFIG_VIDEO_V4L2_I2C=y
CONFIG_VM_EVENT_COUNTERS=y CONFIG_VM_EVENT_COUNTERS=y

View File

@ -417,6 +417,9 @@ CONFIG_VFAT_FS=y
CONFIG_VFP=y CONFIG_VFP=y
CONFIG_VFPv3=y CONFIG_VFPv3=y
CONFIG_VIDEO_DEV=y CONFIG_VIDEO_DEV=y
# CONFIG_VIDEO_MICROCHIP_CSI2DC is not set
# CONFIG_VIDEO_MICROCHIP_ISC is not set
# CONFIG_VIDEO_MICROCHIP_XISC is not set
CONFIG_VIDEO_V4L2_I2C=y CONFIG_VIDEO_V4L2_I2C=y
CONFIG_VT=y CONFIG_VT=y
CONFIG_VT_CONSOLE=y CONFIG_VT_CONSOLE=y

View File

@ -33,7 +33,7 @@ Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
#define USB_VENDOR_ID_BELKIN 0x050d #define USB_VENDOR_ID_BELKIN 0x050d
#define USB_DEVICE_ID_FLIP_KVM 0x3201 #define USB_DEVICE_ID_FLIP_KVM 0x3201
@@ -1407,6 +1410,9 @@ @@ -1409,6 +1412,9 @@
#define USB_VENDOR_ID_XIAOMI 0x2717 #define USB_VENDOR_ID_XIAOMI 0x2717
#define USB_DEVICE_ID_MI_SILENT_MOUSE 0x5014 #define USB_DEVICE_ID_MI_SILENT_MOUSE 0x5014

View File

@ -42,7 +42,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
return of_get_child_by_name(nvmem->dev.of_node, "nvmem-layout"); return of_get_child_by_name(nvmem->dev.of_node, "nvmem-layout");
--- a/include/linux/nvmem-consumer.h --- a/include/linux/nvmem-consumer.h
+++ b/include/linux/nvmem-consumer.h +++ b/include/linux/nvmem-consumer.h
@@ -241,7 +241,6 @@ struct nvmem_cell *of_nvmem_cell_get(str @@ -242,7 +242,6 @@ struct nvmem_cell *of_nvmem_cell_get(str
const char *id); const char *id);
struct nvmem_device *of_nvmem_device_get(struct device_node *np, struct nvmem_device *of_nvmem_device_get(struct device_node *np,
const char *name); const char *name);
@ -50,7 +50,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
#else #else
static inline struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, static inline struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
const char *id) const char *id)
@@ -254,12 +253,6 @@ static inline struct nvmem_device *of_nv @@ -255,12 +254,6 @@ static inline struct nvmem_device *of_nv
{ {
return ERR_PTR(-EOPNOTSUPP); return ERR_PTR(-EOPNOTSUPP);
} }

View File

@ -330,7 +330,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
} }
EXPORT_SYMBOL_GPL(nvmem_cell_put); EXPORT_SYMBOL_GPL(nvmem_cell_put);
@@ -2103,11 +2044,22 @@ EXPORT_SYMBOL_GPL(nvmem_dev_name); @@ -2116,11 +2057,22 @@ EXPORT_SYMBOL_GPL(nvmem_dev_size);
static int __init nvmem_init(void) static int __init nvmem_init(void)
{ {

View File

@ -1,53 +0,0 @@
From 33cf42e68efc8ff529a7eee08a4f0ba8c8d0a207 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
Date: Thu, 21 Dec 2023 18:34:17 +0100
Subject: [PATCH] nvmem: core: add nvmem_dev_size() helper
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This is required by layouts that need to read whole NVMEM content. It's
especially useful for NVMEM devices without hardcoded layout (like
U-Boot environment data block).
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20231221173421.13737-2-zajec5@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/nvmem/core.c | 13 +++++++++++++
include/linux/nvmem-consumer.h | 1 +
2 files changed, 14 insertions(+)
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -2162,6 +2162,19 @@ const char *nvmem_dev_name(struct nvmem_
}
EXPORT_SYMBOL_GPL(nvmem_dev_name);
+/**
+ * nvmem_dev_size() - Get the size of a given nvmem device.
+ *
+ * @nvmem: nvmem device.
+ *
+ * Return: size of the nvmem device.
+ */
+size_t nvmem_dev_size(struct nvmem_device *nvmem)
+{
+ return nvmem->size;
+}
+EXPORT_SYMBOL_GPL(nvmem_dev_size);
+
static int __init nvmem_init(void)
{
int ret;
--- a/include/linux/nvmem-consumer.h
+++ b/include/linux/nvmem-consumer.h
@@ -81,6 +81,7 @@ int nvmem_device_cell_write(struct nvmem
struct nvmem_cell_info *info, void *buf);
const char *nvmem_dev_name(struct nvmem_device *nvmem);
+size_t nvmem_dev_size(struct nvmem_device *nvmem);
void nvmem_add_cell_lookups(struct nvmem_cell_lookup *entries,
size_t nentries);

View File

@ -1,126 +0,0 @@
From 7c8979b42b1a9c5604f431ba804928e55919263c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
Date: Thu, 21 Dec 2023 18:34:18 +0100
Subject: [PATCH] nvmem: u-boot-env: use nvmem_add_one_cell() nvmem subsystem
helper
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Simplify adding NVMEM cells.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20231221173421.13737-3-zajec5@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/nvmem/u-boot-env.c | 55 +++++++++++++++-----------------------
1 file changed, 21 insertions(+), 34 deletions(-)
--- a/drivers/nvmem/u-boot-env.c
+++ b/drivers/nvmem/u-boot-env.c
@@ -23,13 +23,10 @@ enum u_boot_env_format {
struct u_boot_env {
struct device *dev;
+ struct nvmem_device *nvmem;
enum u_boot_env_format format;
struct mtd_info *mtd;
-
- /* Cells */
- struct nvmem_cell_info *cells;
- int ncells;
};
struct u_boot_env_image_single {
@@ -94,43 +91,36 @@ static int u_boot_env_read_post_process_
static int u_boot_env_add_cells(struct u_boot_env *priv, uint8_t *buf,
size_t data_offset, size_t data_len)
{
+ struct nvmem_device *nvmem = priv->nvmem;
struct device *dev = priv->dev;
char *data = buf + data_offset;
char *var, *value, *eq;
- int idx;
-
- priv->ncells = 0;
- for (var = data; var < data + data_len && *var; var += strlen(var) + 1)
- priv->ncells++;
-
- priv->cells = devm_kcalloc(dev, priv->ncells, sizeof(*priv->cells), GFP_KERNEL);
- if (!priv->cells)
- return -ENOMEM;
- for (var = data, idx = 0;
+ for (var = data;
var < data + data_len && *var;
- var = value + strlen(value) + 1, idx++) {
+ var = value + strlen(value) + 1) {
+ struct nvmem_cell_info info = {};
+
eq = strchr(var, '=');
if (!eq)
break;
*eq = '\0';
value = eq + 1;
- priv->cells[idx].name = devm_kstrdup(dev, var, GFP_KERNEL);
- if (!priv->cells[idx].name)
+ info.name = devm_kstrdup(dev, var, GFP_KERNEL);
+ if (!info.name)
return -ENOMEM;
- priv->cells[idx].offset = data_offset + value - data;
- priv->cells[idx].bytes = strlen(value);
- priv->cells[idx].np = of_get_child_by_name(dev->of_node, priv->cells[idx].name);
+ info.offset = data_offset + value - data;
+ info.bytes = strlen(value);
+ info.np = of_get_child_by_name(dev->of_node, info.name);
if (!strcmp(var, "ethaddr")) {
- priv->cells[idx].raw_len = strlen(value);
- priv->cells[idx].bytes = ETH_ALEN;
- priv->cells[idx].read_post_process = u_boot_env_read_post_process_ethaddr;
+ info.raw_len = strlen(value);
+ info.bytes = ETH_ALEN;
+ info.read_post_process = u_boot_env_read_post_process_ethaddr;
}
- }
- if (WARN_ON(idx != priv->ncells))
- priv->ncells = idx;
+ nvmem_add_one_cell(nvmem, &info);
+ }
return 0;
}
@@ -209,7 +199,6 @@ static int u_boot_env_probe(struct platf
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
struct u_boot_env *priv;
- int err;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
@@ -224,17 +213,15 @@ static int u_boot_env_probe(struct platf
return PTR_ERR(priv->mtd);
}
- err = u_boot_env_parse(priv);
- if (err)
- return err;
-
config.dev = dev;
- config.cells = priv->cells;
- config.ncells = priv->ncells;
config.priv = priv;
config.size = priv->mtd->size;
- return PTR_ERR_OR_ZERO(devm_nvmem_register(dev, &config));
+ priv->nvmem = devm_nvmem_register(dev, &config);
+ if (IS_ERR(priv->nvmem))
+ return PTR_ERR(priv->nvmem);
+
+ return u_boot_env_parse(priv);
}
static const struct of_device_id u_boot_env_of_match_table[] = {

View File

@ -1,81 +0,0 @@
From a832556d23c5a11115f300011a5874d6107a0d62 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
Date: Thu, 21 Dec 2023 18:34:19 +0100
Subject: [PATCH] nvmem: u-boot-env: use nvmem device helpers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Use nvmem_dev_size() and nvmem_device_read() to make this driver less
mtd dependent.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20231221173421.13737-4-zajec5@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/nvmem/u-boot-env.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
--- a/drivers/nvmem/u-boot-env.c
+++ b/drivers/nvmem/u-boot-env.c
@@ -127,27 +127,34 @@ static int u_boot_env_add_cells(struct u
static int u_boot_env_parse(struct u_boot_env *priv)
{
+ struct nvmem_device *nvmem = priv->nvmem;
struct device *dev = priv->dev;
size_t crc32_data_offset;
size_t crc32_data_len;
size_t crc32_offset;
size_t data_offset;
size_t data_len;
+ size_t dev_size;
uint32_t crc32;
uint32_t calc;
- size_t bytes;
uint8_t *buf;
+ int bytes;
int err;
- buf = kcalloc(1, priv->mtd->size, GFP_KERNEL);
+ dev_size = nvmem_dev_size(nvmem);
+
+ buf = kcalloc(1, dev_size, GFP_KERNEL);
if (!buf) {
err = -ENOMEM;
goto err_out;
}
- err = mtd_read(priv->mtd, 0, priv->mtd->size, &bytes, buf);
- if ((err && !mtd_is_bitflip(err)) || bytes != priv->mtd->size) {
- dev_err(dev, "Failed to read from mtd: %d\n", err);
+ bytes = nvmem_device_read(nvmem, 0, dev_size, buf);
+ if (bytes < 0) {
+ err = bytes;
+ goto err_kfree;
+ } else if (bytes != dev_size) {
+ err = -EIO;
goto err_kfree;
}
@@ -169,8 +176,8 @@ static int u_boot_env_parse(struct u_boo
break;
}
crc32 = le32_to_cpu(*(__le32 *)(buf + crc32_offset));
- crc32_data_len = priv->mtd->size - crc32_data_offset;
- data_len = priv->mtd->size - data_offset;
+ crc32_data_len = dev_size - crc32_data_offset;
+ data_len = dev_size - data_offset;
calc = crc32(~0, buf + crc32_data_offset, crc32_data_len) ^ ~0L;
if (calc != crc32) {
@@ -179,7 +186,7 @@ static int u_boot_env_parse(struct u_boo
goto err_kfree;
}
- buf[priv->mtd->size - 1] = '\0';
+ buf[dev_size - 1] = '\0';
err = u_boot_env_add_cells(priv, buf, data_offset, data_len);
if (err)
dev_err(dev, "Failed to add cells: %d\n", err);

View File

@ -1,62 +0,0 @@
From 6bafe07c930676d6430be471310958070816a595 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
Date: Thu, 21 Dec 2023 18:34:20 +0100
Subject: [PATCH] nvmem: u-boot-env: improve coding style
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
1. Prefer kzalloc() over kcalloc()
See memory-allocation.rst which says: "to be on the safe side it's
best to use routines that set memory to zero, like kzalloc()"
2. Drop dev_err() for u_boot_env_add_cells() fail
It can fail only on -ENOMEM. We don't want to print error then.
3. Add extra "crc32_addr" variable
It makes code reading header's crc32 easier to understand / review.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/r/20231221173421.13737-5-zajec5@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/nvmem/u-boot-env.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--- a/drivers/nvmem/u-boot-env.c
+++ b/drivers/nvmem/u-boot-env.c
@@ -132,6 +132,7 @@ static int u_boot_env_parse(struct u_boo
size_t crc32_data_offset;
size_t crc32_data_len;
size_t crc32_offset;
+ __le32 *crc32_addr;
size_t data_offset;
size_t data_len;
size_t dev_size;
@@ -143,7 +144,7 @@ static int u_boot_env_parse(struct u_boo
dev_size = nvmem_dev_size(nvmem);
- buf = kcalloc(1, dev_size, GFP_KERNEL);
+ buf = kzalloc(dev_size, GFP_KERNEL);
if (!buf) {
err = -ENOMEM;
goto err_out;
@@ -175,7 +176,8 @@ static int u_boot_env_parse(struct u_boo
data_offset = offsetof(struct u_boot_env_image_broadcom, data);
break;
}
- crc32 = le32_to_cpu(*(__le32 *)(buf + crc32_offset));
+ crc32_addr = (__le32 *)(buf + crc32_offset);
+ crc32 = le32_to_cpu(*crc32_addr);
crc32_data_len = dev_size - crc32_data_offset;
data_len = dev_size - data_offset;
@@ -188,8 +190,6 @@ static int u_boot_env_parse(struct u_boo
buf[dev_size - 1] = '\0';
err = u_boot_env_add_cells(priv, buf, data_offset, data_len);
- if (err)
- dev_err(dev, "Failed to add cells: %d\n", err);
err_kfree:
kfree(buf);

View File

@ -39,7 +39,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
MODULE_DEVICE_TABLE(of, brcm_nvram_of_match_table); MODULE_DEVICE_TABLE(of, brcm_nvram_of_match_table);
--- a/drivers/nvmem/u-boot-env.c --- a/drivers/nvmem/u-boot-env.c
+++ b/drivers/nvmem/u-boot-env.c +++ b/drivers/nvmem/u-boot-env.c
@@ -249,5 +249,6 @@ static struct platform_driver u_boot_env @@ -256,5 +256,6 @@ static struct platform_driver u_boot_env
module_platform_driver(u_boot_env_driver); module_platform_driver(u_boot_env_driver);
MODULE_AUTHOR("Rafał Miłecki"); MODULE_AUTHOR("Rafał Miłecki");

View File

@ -1,40 +0,0 @@
From 8679e8b4a1ebdb40c4429e49368d29353e07b601 Mon Sep 17 00:00:00 2001
From: John Thomson <git@johnthomson.fastmail.com.au>
Date: Mon, 2 Sep 2024 15:25:08 +0100
Subject: [PATCH] nvmem: u-boot-env: error if NVMEM device is too small
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Verify data size before trying to parse it to avoid reading out of
buffer. This could happen in case of problems at MTD level or invalid DT
bindings.
Signed-off-by: John Thomson <git@johnthomson.fastmail.com.au>
Cc: stable <stable@kernel.org>
Fixes: d5542923f200 ("nvmem: add driver handling U-Boot environment variables")
[rmilecki: simplify commit description & rebase]
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20240902142510.71096-2-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/nvmem/u-boot-env.c | 7 +++++++
1 file changed, 7 insertions(+)
--- a/drivers/nvmem/u-boot-env.c
+++ b/drivers/nvmem/u-boot-env.c
@@ -176,6 +176,13 @@ static int u_boot_env_parse(struct u_boo
data_offset = offsetof(struct u_boot_env_image_broadcom, data);
break;
}
+
+ if (dev_size < data_offset) {
+ dev_err(dev, "Device too small for u-boot-env\n");
+ err = -EIO;
+ goto err_kfree;
+ }
+
crc32_addr = (__le32 *)(buf + crc32_offset);
crc32 = le32_to_cpu(*crc32_addr);
crc32_data_len = dev_size - crc32_data_offset;

View File

@ -8,11 +8,13 @@
compatible = "openwrt,one", "mediatek,mt7981"; compatible = "openwrt,one", "mediatek,mt7981";
aliases { aliases {
serial0 = &uart0; ethernet0 = &gmac1;
label-mac-device = &gmac0;
led-boot = &led_status_white; led-boot = &led_status_white;
led-failsafe = &led_status_red; led-failsafe = &led_status_red;
led-running = &led_status_green; led-running = &led_status_green;
led-upgrade = &led_status_green; led-upgrade = &led_status_green;
serial0 = &uart0;
}; };
chosen { chosen {
@ -146,8 +148,6 @@
reg = <1>; reg = <1>;
phy-mode = "gmii"; phy-mode = "gmii";
phy-handle = <&int_gbe_phy>; phy-handle = <&int_gbe_phy>;
nvmem-cell-names = "mac-address";
nvmem-cells = <&macaddr_factory_2a>;
}; };
}; };
@ -395,11 +395,6 @@
reg = <0x24 0x6>; reg = <0x24 0x6>;
compatible = "mac-base"; compatible = "mac-base";
}; };
macaddr_factory_2a: macaddr@2a {
reg = <0x2a 0x6>;
compatible = "mac-base";
};
}; };
}; };

View File

@ -140,7 +140,7 @@ case "$board" in
[ "$PHYNBR" = "2" ] && macaddr_add $addr 4 > /sys${DEVPATH}/macaddress [ "$PHYNBR" = "2" ] && macaddr_add $addr 4 > /sys${DEVPATH}/macaddress
;; ;;
smartrg,sdg-8733|\ smartrg,sdg-8733|\
smartrg,sdg-8634) smartrg,sdg-8734)
addr=$(mmc_get_mac_ascii mfginfo MFG_MAC) addr=$(mmc_get_mac_ascii mfginfo MFG_MAC)
[ "$PHYNBR" = "0" ] && macaddr_add $addr 4 > /sys${DEVPATH}/macaddress [ "$PHYNBR" = "0" ] && macaddr_add $addr 4 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $addr a > /sys${DEVPATH}/macaddress [ "$PHYNBR" = "1" ] && macaddr_add $addr a > /sys${DEVPATH}/macaddress

View File

@ -0,0 +1,227 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
#include "mt7621.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/leds/common.h>
/ {
compatible = "netis,n6", "mediatek,mt7621-soc";
model = "netis N6";
aliases {
label-mac-device = &gmac0;
led-boot = &led_power_green;
led-failsafe = &led_system_green;
led-running = &led_power_green;
led-upgrade = &led_system_green;
};
chosen {
bootargs = "console=ttyS0,115200";
};
keys {
compatible = "gpio-keys";
key-0 {
label = "wps";
gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
linux,code = <KEY_WPS_BUTTON>;
debounce-interval = <60>;
};
key-1 {
label = "reset";
gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RESTART>;
debounce-interval = <60>;
};
};
leds {
compatible = "gpio-leds";
led-0 {
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_USB;
gpios = <&gpio 4 GPIO_ACTIVE_LOW>;
trigger-sources = <&xhci_ehci_port1>;
linux,default-trigger = "usbport";
};
led-1 {
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_WPS;
gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
};
led_system_green: led-2 {
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_INDICATOR;
gpios = <&gpio 14 GPIO_ACTIVE_LOW>;
};
led-3 {
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_WAN;
gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
};
led_power_green: led-4 {
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_POWER;
gpios = <&gpio 17 GPIO_ACTIVE_HIGH>;
};
};
};
&gmac0 {
nvmem-cells = <&macaddr_factory_7ef20 0>;
nvmem-cell-names = "mac-address";
};
&gmac1 {
status = "okay";
label = "wan";
phy-handle = <&ethphy4>;
nvmem-cells = <&macaddr_factory_7ef26 0>;
nvmem-cell-names = "mac-address";
};
&ethphy4 {
/delete-property/ interrupts;
};
&nand {
status = "okay";
mediatek,nmbm;
mediatek,bmt-remap-range = <0x000000 0x580000>;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "u-boot";
reg = <0x0 0x80000>;
read-only;
};
partition@80000 {
label = "Config";
reg = <0x80000 0x80000>;
};
partition@100000 {
label = "Factory";
reg = <0x100000 0x80000>;
read-only;
nvmem-layout {
compatible = "fixed-layout";
#address-cells = <1>;
#size-cells = <1>;
eeprom_factory_0: eeprom@0 {
reg = <0x0 0xe00>;
};
macaddr_factory_7ef20: macaddr@7ef20 {
reg = <0x7ef20 0x6>;
};
macaddr_factory_7ef26: macaddr@7ef26 {
reg = <0x7ef26 0x6>;
};
};
};
partition@180000 {
label = "firmware";
reg = <0x180000 0x7680000>;
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "kernel";
reg = <0x0 0x400000>;
};
partition@400000 {
label = "ubi";
reg = <0x400000 0x7280000>;
};
};
};
};
&pcie {
status = "okay";
};
&pcie1 {
wifi@0,0 {
compatible = "mediatek,mt76";
reg = <0x0000 0 0 0 0>;
/*
* *** The code block below is commented out ***
* Reason: Probably, original Netis N6 EEPROM has wrong
* MT_EE_WIFI_CONF value 0xd2. As a result 2.4 GHz
* doesn't start with mt76 driver. Other routers
* with the same WLAN chips (e.g., Routerich
* AX1800) have MT_EE_WIFI_CONF = 0x92.
* Workaround: Extract EEPROM to a file at the first time
* boot and change MT_EE_WIFI_CONF (offset
* 0x190) value from 0xd2 to 0x92. See
* /etc/hotplug.d/firmware/11-mt76-caldata for
* details.
*/
/*
nvmem-cells = <&eeprom_factory_0>;
nvmem-cell-names = "eeprom";
*/
mediatek,disable-radar-background;
};
};
&state_default {
gpio {
groups = "i2c", "jtag", "wdt";
function = "gpio";
};
};
&switch0 {
ports {
port@0 {
status = "okay";
label = "lan4";
};
port@1 {
status = "okay";
label = "lan3";
};
port@2 {
status = "okay";
label = "lan2";
};
port@3 {
status = "okay";
label = "lan1";
};
};
};

0
target/linux/ramips/dts/mt7621_openfi_5pro.dts Executable file → Normal file
View File

0
target/linux/ramips/dts/mt7621_winstars_ws-wn536p3.dts Executable file → Normal file
View File

View File

@ -23,6 +23,21 @@ define Build/append-dlink-covr-metadata
rm $@metadata.tmp rm $@metadata.tmp
endef endef
define Build/append-netis-n6-metadata
( echo -ne '{ \
"up_model": "Netis-N6R", \
"supported_devices": ["mt7621-rfb-ax-nand"], \
"version": { \
"dist": "$(call json_quote,$(VERSION_DIST))", \
"version": "$(call json_quote,$(VERSION_NUMBER))", \
"revision": "$(call json_quote,$(REVISION))", \
"board": "$(call json_quote,$(BOARD))" \
} }' \
) > $@.metadata.tmp
fwtool -I $@.metadata.tmp $@
rm $@.metadata.tmp
endef
define Build/arcadyan-trx define Build/arcadyan-trx
echo -ne "hsqs" > $@.hsqs echo -ne "hsqs" > $@.hsqs
$(eval trx_magic=$(word 1,$(1))) $(eval trx_magic=$(word 1,$(1)))
@ -2262,6 +2277,23 @@ define Device/netgear_wndr3700-v5
endef endef
TARGET_DEVICES += netgear_wndr3700-v5 TARGET_DEVICES += netgear_wndr3700-v5
define Device/netis_n6
$(Device/dsa-migration)
$(Device/nand)
IMAGE_SIZE := 121344k
DEVICE_VENDOR := netis
DEVICE_MODEL := N6
KERNEL_LOADADDR := 0x82000000
KERNEL := kernel-bin | relocate-kernel $(loadaddr-y) | lzma | \
fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
IMAGES += factory.bin
IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | \
append-ubi | check-size | append-netis-n6-metadata
DEVICE_PACKAGES += kmod-mt7915-firmware kmod-usb-ledtrig-usbport \
kmod-usb3
endef
TARGET_DEVICES += netis_n6
define Device/netis_wf2881 define Device/netis_wf2881
$(Device/nand) $(Device/nand)
$(Device/uimage-lzma-loader) $(Device/uimage-lzma-loader)
@ -2916,7 +2948,6 @@ define Device/wavlink_ws-wn572hp3-4g
endef endef
TARGET_DEVICES += wavlink_ws-wn572hp3-4g TARGET_DEVICES += wavlink_ws-wn572hp3-4g
define Device/wavlink_wl-wn573hx1 define Device/wavlink_wl-wn573hx1
$(Device/uimage-lzma-loader) $(Device/uimage-lzma-loader)
IMAGE_SIZE := 15808k IMAGE_SIZE := 15808k

View File

@ -187,6 +187,9 @@ netgear,r7450)
netgear,wax202) netgear,wax202)
ucidef_set_led_netdev "internet" "Internet" "green:net" "wan" ucidef_set_led_netdev "internet" "Internet" "green:net" "wan"
;; ;;
netis,n6)
ucidef_set_led_netdev "wan" "wan" "green:wan" "wan" "link tx rx"
;;
oraybox,x3a) oraybox,x3a)
ucidef_set_led_netdev "wan" "wan link" "red:status" "wan" ucidef_set_led_netdev "wan" "wan link" "red:status" "wan"
ucidef_set_led_netdev "lan" "lan link" "green:status" "br-lan" ucidef_set_led_netdev "lan" "lan link" "green:status" "br-lan"

View File

@ -0,0 +1,21 @@
#!/bin/sh
[ -e /lib/firmware/$FIRMWARE ] && exit 0
. /lib/functions/caldata.sh
board=$(board_name)
case "$FIRMWARE" in
"mediatek/mt7915_eeprom_dbdc.bin")
case "$board" in
netis,n6)
EEPROM=/lib/firmware/$FIRMWARE
head -c $((0xe00)) /dev/mtd2 > $EEPROM
printf "\x92" | \
dd of=$EEPROM seek=$((0x190)) bs=1 conv=notrunc \
2>/dev/null
;;
esac
;;
esac

View File

@ -162,6 +162,14 @@ case "$board" in
[ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 3 > /sys${DEVPATH}/macaddress [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 3 > /sys${DEVPATH}/macaddress
;; ;;
netis,n6)
hw_mac_addr="$(mtd_get_mac_binary Factory 0x4)"
hw_mac_addr=$(macaddr_setbit $hw_mac_addr 28)
hw_mac_2g=$(macaddr_unsetbit $hw_mac_addr 26)
hw_mac_5g=$(macaddr_setbit $hw_mac_addr 27)
[ "$PHYNBR" = "0" ] && echo -n "$hw_mac_2g" > /sys${DEVPATH}/macaddress
[ "$PHYNBR" = "1" ] && echo -n "$hw_mac_5g" > /sys${DEVPATH}/macaddress
;;
mercusys,mr70x-v1|\ mercusys,mr70x-v1|\
tplink,archer-ax23-v1) tplink,archer-ax23-v1)
hw_mac_addr="$(mtd_get_mac_binary config 0x8)" hw_mac_addr="$(mtd_get_mac_binary config 0x8)"

View File

@ -124,6 +124,7 @@ platform_do_upgrade() {
netgear,wac124|\ netgear,wac124|\
netgear,wax202|\ netgear,wax202|\
netgear,wax214v2|\ netgear,wax214v2|\
netis,n6|\
netis,wf2881|\ netis,wf2881|\
raisecom,msg1500-x-00|\ raisecom,msg1500-x-00|\
rostelecom,rt-fe-1a|\ rostelecom,rt-fe-1a|\

View File

@ -57,7 +57,7 @@ Signed-off-by: Hal Feng <hal.feng@starfivetech.com>
}; };
&dvp_clk { &dvp_clk {
@@ -202,8 +231,28 @@ @@ -202,6 +231,24 @@
status = "okay"; status = "okay";
}; };
@ -81,21 +81,8 @@ Signed-off-by: Hal Feng <hal.feng@starfivetech.com>
+ +
&mmc0 { &mmc0 {
max-frequency = <100000000>; max-frequency = <100000000>;
+ assigned-clocks = <&syscrg JH7110_SYSCLK_SDIO0_SDCARD>; assigned-clocks = <&syscrg JH7110_SYSCLK_SDIO0_SDCARD>;
+ assigned-clock-rates = <50000000>; @@ -235,6 +282,34 @@
bus-width = <8>;
cap-mmc-highspeed;
mmc-ddr-1_8v;
@@ -220,6 +269,8 @@
&mmc1 {
max-frequency = <100000000>;
+ assigned-clocks = <&syscrg JH7110_SYSCLK_SDIO1_SDCARD>;
+ assigned-clock-rates = <50000000>;
bus-width = <4>;
no-sdio;
no-mmc;
@@ -231,6 +282,34 @@
status = "okay"; status = "okay";
}; };
@ -130,7 +117,7 @@ Signed-off-by: Hal Feng <hal.feng@starfivetech.com>
&qspi { &qspi {
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
@@ -336,6 +415,46 @@ @@ -340,6 +415,46 @@
}; };
}; };
@ -177,7 +164,7 @@ Signed-off-by: Hal Feng <hal.feng@starfivetech.com>
mmc0_pins: mmc0-0 { mmc0_pins: mmc0-0 {
rst-pins { rst-pins {
pinmux = <GPIOMUX(62, GPOUT_SYS_SDIO0_RST, pinmux = <GPIOMUX(62, GPOUT_SYS_SDIO0_RST,
@@ -400,6 +519,86 @@ @@ -404,6 +519,86 @@
slew-rate = <0>; slew-rate = <0>;
}; };
}; };

View File

@ -9,10 +9,10 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=expat PKG_NAME:=expat
PKG_CPE_ID:=cpe:/a:libexpat:libexpat PKG_CPE_ID:=cpe:/a:libexpat:libexpat
PKG_VERSION:=2.6.2 PKG_VERSION:=2.6.3
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_HASH:=d4cf38d26e21a56654ffe4acd9cd5481164619626802328506a2869afab29ab3 PKG_HASH:=17aa6cfc5c4c219c09287abfc10bc13f0c06f30bb654b28bfe6f567ca646eb79
PKG_SOURCE_URL:=https://github.com/libexpat/libexpat/releases/download/R_$(subst .,_,$(PKG_VERSION)) PKG_SOURCE_URL:=https://github.com/libexpat/libexpat/releases/download/R_$(subst .,_,$(PKG_VERSION))
HOST_BUILD_PARALLEL:=1 HOST_BUILD_PARALLEL:=1