From ae2dced6cec71f56432386e49e0150fdaa1e35e0 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Thu, 22 Feb 2024 19:12:03 +0000 Subject: [PATCH 01/18] rpcd: update to latest git HEAD 8ef4c25 sys: use "Auto-Installed" field for packagelist Signed-off-by: Daniel Golle --- package/system/rpcd/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/system/rpcd/Makefile b/package/system/rpcd/Makefile index 977932f9d1..ef360a2c12 100644 --- a/package/system/rpcd/Makefile +++ b/package/system/rpcd/Makefile @@ -12,9 +12,9 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/rpcd.git -PKG_MIRROR_HASH:=76467ff072b50190f93d071b7792ade7c717674397a2547e995a8f819a48954e -PKG_SOURCE_DATE:=2023-07-01 -PKG_SOURCE_VERSION:=c07ab2f91061ad64209e9aaa1fb1b77061a1af25 +PKG_MIRROR_HASH:=cf77c8aca75f893315620e2e3abf7fa02d8c8a21f54808b238973e43c66d0059 +PKG_SOURCE_DATE:=2024-02-22 +PKG_SOURCE_VERSION:=8ef4c2587ac0041049c67befed281a70cf240769 PKG_MAINTAINER:=Jo-Philipp Wich PKG_LICENSE:=ISC From 68968fc981b7804032eba0339a40054f39e0d22f Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Thu, 22 Feb 2024 19:13:34 +0000 Subject: [PATCH 02/18] Revert "build: don't drop 'user' flag when using the ImageBuilder" This reverts commit c42b915af0ea53bc1b65bc72afc9875da08b14d2. Now that rpcd uses the 'Auto-Installed' field to differentiate between deliberately and implicitely installed packages we can remove the hotfix. Signed-off-by: Daniel Golle --- include/rootfs.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/rootfs.mk b/include/rootfs.mk index b07f33d204..2128aefc2a 100644 --- a/include/rootfs.mk +++ b/include/rootfs.mk @@ -87,11 +87,11 @@ define prepare_rootfs fi; \ done || true \ ) - $(if $(IB),,awk -i inplace \ + awk -i inplace \ '/^Status:/ { \ if ($$3 == "user") { $$3 = "ok" } \ else { sub(/,\|\,/, "", $$3) } \ - }1' $(1)/usr/lib/opkg/status) + }1' $(1)/usr/lib/opkg/status $(if $(SOURCE_DATE_EPOCH),sed -i "s/Installed-Time: .*/Installed-Time: $(SOURCE_DATE_EPOCH)/" $(1)/usr/lib/opkg/status) @-find $(1) -name CVS -o -name .svn -o -name .git -o -name '.#*' | $(XARGS) rm -rf rm -rf \ From b2bb4b0f0a4ecd4c3ad58ea42dde14dce87788fc Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Fri, 23 Feb 2024 17:54:52 +0100 Subject: [PATCH 03/18] ipq806x: replace ARM bootloader patch with pending upstream version Replace ARM bootloader patch with pending upstream version. The patch got reviewed upstream and tested on a Netgear R7800. This fix a problem with the ARM decompressor and permits to use AUTO_ZRELADDR without having to hardcode PHYS_OFFSET as the bootloader now correctly parse the memory modes in the appended DTB. Signed-off-by: Christian Marangi --- target/linux/ipq806x/config-6.1 | 2 +- ...RM-mach-qcom-fix-support-for-ipq806x.patch | 60 ---- ...Mangle-bootloader-s-kernel-arguments.patch | 280 ------------------ .../900-arm-add-cmdline-override.patch | 2 +- ...sor-support-memory-start-validation-.patch | 75 +++++ ...essor-add-option-to-ignore-MEM-ATAGs.patch | 54 ++++ ...-support-for-ATAGs-rootblock-parsing.patch | 197 ++++++++++++ 7 files changed, 328 insertions(+), 342 deletions(-) delete mode 100644 target/linux/ipq806x/patches-6.1/0060-ARM-mach-qcom-fix-support-for-ipq806x.patch delete mode 100644 target/linux/ipq806x/patches-6.1/0067-generic-Mangle-bootloader-s-kernel-arguments.patch create mode 100644 target/linux/ipq806x/patches-6.1/901-01-ARM-decompressor-support-memory-start-validation-.patch create mode 100644 target/linux/ipq806x/patches-6.1/901-02-ARM-decompressor-add-option-to-ignore-MEM-ATAGs.patch create mode 100644 target/linux/ipq806x/patches-6.1/902-ARM-decompressor-support-for-ATAGs-rootblock-parsing.patch diff --git a/target/linux/ipq806x/config-6.1 b/target/linux/ipq806x/config-6.1 index e6c9b930a2..598ab305db 100644 --- a/target/linux/ipq806x/config-6.1 +++ b/target/linux/ipq806x/config-6.1 @@ -4,7 +4,6 @@ CONFIG_ALIGNMENT_TRAP=y CONFIG_ARCH_32BIT_OFF_T=y CONFIG_ARCH_HIBERNATION_POSSIBLE=y # CONFIG_ARCH_IPQ40XX is not set -CONFIG_ARCH_IPQ806X=y CONFIG_ARCH_KEEP_MEMBLOCK=y # CONFIG_ARCH_MDM9615 is not set CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y @@ -31,6 +30,7 @@ CONFIG_ARM_ARCH_TIMER_EVTSTREAM=y CONFIG_ARM_ATAG_DTB_COMPAT=y # CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER is not set CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE=y +CONFIG_ARM_ATAG_DTB_COMPAT_IGNORE_MEM=y CONFIG_ARM_CPUIDLE=y CONFIG_ARM_CPU_SUSPEND=y # CONFIG_ARM_CPU_TOPOLOGY is not set diff --git a/target/linux/ipq806x/patches-6.1/0060-ARM-mach-qcom-fix-support-for-ipq806x.patch b/target/linux/ipq806x/patches-6.1/0060-ARM-mach-qcom-fix-support-for-ipq806x.patch deleted file mode 100644 index 47053260bb..0000000000 --- a/target/linux/ipq806x/patches-6.1/0060-ARM-mach-qcom-fix-support-for-ipq806x.patch +++ /dev/null @@ -1,60 +0,0 @@ -From 9c896e9fc2ef1209e4a56d8c9fdd183847c2c814 Mon Sep 17 00:00:00 2001 -From: Christian Marangi -Date: Tue, 18 Oct 2022 22:02:46 +0200 -Subject: [PATCH] ARM: mach-qcom: fix support for ipq806x - -Add a specific config flag for Qcom IPQ806x as this SoC can't use -AUTO_ZRELADDR and require the PHYS_OFFSET set to 0x42000000. - -This is needed as some legacy board (or some wrongly configured -bootloader) pass the wrong memory map and doesn't exclude the first -~20MB of RAM reserved for the hardware network accellerators. - -With this change we can correctly support each board and prevent any -kind of misconfiguration done by the OEM. - -Signed-off-by: Christian Marangi ---- - arch/arm/Kconfig | 3 ++- - arch/arm/mach-qcom/Kconfig | 13 +++++++++++++ - 2 files changed, 15 insertions(+), 1 deletion(-) - ---- a/arch/arm/Kconfig -+++ b/arch/arm/Kconfig -@@ -285,6 +285,7 @@ config PHYS_OFFSET - default 0x30000000 if ARCH_S3C24XX - default 0xa0000000 if ARCH_IOP32X || ARCH_PXA - default 0xc0000000 if ARCH_EP93XX || ARCH_SA1100 -+ default 0x42000000 if ARCH_IPQ806X - default 0 - help - Please provide the physical address corresponding to the -@@ -1704,7 +1705,7 @@ config CRASH_DUMP - - config AUTO_ZRELADDR - bool "Auto calculation of the decompressed kernel image address" if !ARCH_MULTIPLATFORM -- default !(ARCH_FOOTBRIDGE || ARCH_RPC || ARCH_SA1100) -+ default !(ARCH_FOOTBRIDGE || ARCH_RPC || ARCH_SA1100 || ARCH_IPQ806X) - help - ZRELADDR is the physical address where the decompressed kernel - image will be placed. If AUTO_ZRELADDR is selected, the address ---- a/arch/arm/mach-qcom/Kconfig -+++ b/arch/arm/mach-qcom/Kconfig -@@ -46,4 +46,17 @@ config ARCH_MDM9615 - bool "Enable support for MDM9615" - select CLKSRC_QCOM - -+config ARCH_IPQ806X -+ bool "Enable support for IPQ806x" -+ help -+ Enable support for the Qualcomm IPQ806x. -+ -+ IPQ806x require special PHYS_OFFSET and can't use AUTO_ZRELADDR. -+ The first ~20MB of RAM is reserved for the hardware network accelerators, -+ and the bootloader removes this section from the layout passed from the -+ ATAGS (when used by some bootloader doesn't even do that). -+ -+ To support every system and handle legacy systems, hardcode PHYS_OFFSET and -+ disable AUTO_ZRELADDR. -+ - endif diff --git a/target/linux/ipq806x/patches-6.1/0067-generic-Mangle-bootloader-s-kernel-arguments.patch b/target/linux/ipq806x/patches-6.1/0067-generic-Mangle-bootloader-s-kernel-arguments.patch deleted file mode 100644 index 4e47c390a2..0000000000 --- a/target/linux/ipq806x/patches-6.1/0067-generic-Mangle-bootloader-s-kernel-arguments.patch +++ /dev/null @@ -1,280 +0,0 @@ -From 71270226b14733a4b1f2cde58ea9265caa50b38d Mon Sep 17 00:00:00 2001 -From: Adrian Panella -Date: Thu, 9 Mar 2017 09:37:17 +0100 -Subject: [PATCH 67/69] generic: Mangle bootloader's kernel arguments - -The command-line arguments provided by the boot loader will be -appended to a new device tree property: bootloader-args. -If there is a property "append-rootblock" in DT under /chosen -and a root= option in bootloaders command line it will be parsed -and added to DT bootargs with the form: XX. -Only command line ATAG will be processed, the rest of the ATAGs -sent by bootloader will be ignored. -This is usefull in dual boot systems, to get the current root partition -without afecting the rest of the system. - -Signed-off-by: Adrian Panella ---- - arch/arm/Kconfig | 11 +++++ - arch/arm/boot/compressed/atags_to_fdt.c | 72 ++++++++++++++++++++++++++++++++- - init/main.c | 16 ++++++++ - 3 files changed, 98 insertions(+), 1 deletion(-) - ---- a/arch/arm/Kconfig -+++ b/arch/arm/Kconfig -@@ -1588,6 +1588,17 @@ config ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEN - The command-line arguments provided by the boot loader will be - appended to the the device tree bootargs property. - -+config ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE -+ bool "Append rootblock parsing bootloader's kernel arguments" -+ help -+ The command-line arguments provided by the boot loader will be -+ appended to a new device tree property: bootloader-args. -+ If there is a property "append-rootblock" in DT under /chosen -+ and a root= option in bootloaders command line it will be parsed -+ and added to DT bootargs with the form: XX. -+ Only command line ATAG will be processed, the rest of the ATAGs -+ sent by bootloader will be ignored. -+ - endchoice - - config CMDLINE ---- a/arch/arm/boot/compressed/atags_to_fdt.c -+++ b/arch/arm/boot/compressed/atags_to_fdt.c -@@ -5,6 +5,8 @@ - - #if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND) - #define do_extend_cmdline 1 -+#elif defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE) -+#define do_extend_cmdline 1 - #else - #define do_extend_cmdline 0 - #endif -@@ -20,6 +22,7 @@ static int node_offset(void *fdt, const - return offset; - } - -+#ifndef CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE - static int setprop(void *fdt, const char *node_path, const char *property, - void *val_array, int size) - { -@@ -28,6 +31,7 @@ static int setprop(void *fdt, const char - return offset; - return fdt_setprop(fdt, offset, property, val_array, size); - } -+#endif - - static int setprop_string(void *fdt, const char *node_path, - const char *property, const char *string) -@@ -38,6 +42,7 @@ static int setprop_string(void *fdt, con - return fdt_setprop_string(fdt, offset, property, string); - } - -+#ifndef CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE - static int setprop_cell(void *fdt, const char *node_path, - const char *property, uint32_t val) - { -@@ -46,6 +51,7 @@ static int setprop_cell(void *fdt, const - return offset; - return fdt_setprop_cell(fdt, offset, property, val); - } -+#endif - - static const void *getprop(const void *fdt, const char *node_path, - const char *property, int *len) -@@ -58,6 +64,7 @@ static const void *getprop(const void *f - return fdt_getprop(fdt, offset, property, len); - } - -+#ifndef CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE - static uint32_t get_cell_size(const void *fdt) - { - int len; -@@ -68,6 +75,81 @@ static uint32_t get_cell_size(const void - cell_size = fdt32_to_cpu(*size_len); - return cell_size; - } -+#endif -+ -+#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE) -+/** -+ * taken from arch/x86/boot/string.c -+ * local_strstr - Find the first substring in a %NUL terminated string -+ * @s1: The string to be searched -+ * @s2: The string to search for -+ */ -+static char *local_strstr(const char *s1, const char *s2) -+{ -+ size_t l1, l2; -+ -+ l2 = strlen(s2); -+ if (!l2) -+ return (char *)s1; -+ l1 = strlen(s1); -+ while (l1 >= l2) { -+ l1--; -+ if (!memcmp(s1, s2, l2)) -+ return (char *)s1; -+ s1++; -+ } -+ return NULL; -+} -+ -+static char *append_rootblock(char *dest, const char *str, int len, void *fdt) -+{ -+ char *ptr, *end, *tmp; -+ const char *root="root="; -+ const char *find_rootblock; -+ int i, l; -+ const char *rootblock; -+ -+ find_rootblock = getprop(fdt, "/chosen", "find-rootblock", &l); -+ if (!find_rootblock) -+ find_rootblock = root; -+ -+ //ARM doesn't have __HAVE_ARCH_STRSTR, so it was copied from x86 -+ ptr = local_strstr(str, find_rootblock); -+ -+ if(!ptr) -+ return dest; -+ -+ end = strchr(ptr, ' '); -+ end = end ? (end - 1) : (strchr(ptr, 0) - 1); -+ -+ // Some boards ubi.mtd=XX,ZZZZ, so let's check for '," too. -+ tmp = strchr(ptr, ','); -+ -+ if(tmp) -+ end = end < tmp ? end : tmp - 1; -+ -+ //find partition number (assumes format root=/dev/mtdXX | /dev/mtdblockXX | yy:XX | ubi.mtd=XX,ZZZZ ) -+ for( i = 0; end >= ptr && *end >= '0' && *end <= '9'; end--, i++); -+ ptr = end + 1; -+ -+ /* if append-rootblock property is set use it to append to command line */ -+ rootblock = getprop(fdt, "/chosen", "append-rootblock", &l); -+ if(rootblock != NULL) { -+ if(*dest != ' ') { -+ *dest = ' '; -+ dest++; -+ len++; -+ } -+ if (len + l + i <= COMMAND_LINE_SIZE) { -+ memcpy(dest, rootblock, l); -+ dest += l - 1; -+ memcpy(dest, ptr, i); -+ dest += i; -+ } -+ } -+ return dest; -+} -+#endif - - static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline) - { -@@ -88,18 +170,28 @@ static void merge_fdt_bootargs(void *fdt - - /* and append the ATAG_CMDLINE */ - if (fdt_cmdline) { -+ -+#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE) -+ //save original bootloader args -+ //and append ubi.mtd with root partition number to current cmdline -+ setprop_string(fdt, "/chosen", "bootloader-args", fdt_cmdline); -+ ptr = append_rootblock(ptr, fdt_cmdline, len, fdt); -+ -+#else - len = strlen(fdt_cmdline); - if (ptr - cmdline + len + 2 < COMMAND_LINE_SIZE) { - *ptr++ = ' '; - memcpy(ptr, fdt_cmdline, len); - ptr += len; - } -+#endif - } - *ptr = '\0'; - - setprop_string(fdt, "/chosen", "bootargs", cmdline); - } - -+#ifndef CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE - static void hex_str(char *out, uint32_t value) - { - uint32_t digit; -@@ -117,6 +209,7 @@ static void hex_str(char *out, uint32_t - } - *out = '\0'; - } -+#endif - - /* - * Convert and fold provided ATAGs into the provided FDT. -@@ -131,9 +224,11 @@ int atags_to_fdt(void *atag_list, void * - struct tag *atag = atag_list; - /* In the case of 64 bits memory size, need to reserve 2 cells for - * address and size for each bank */ -+#ifndef CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE - __be32 mem_reg_property[2 * 2 * NR_BANKS]; -- int memcount = 0; -- int ret, memsize; -+ int memsize, memcount = 0; -+#endif -+ int ret; - - /* make sure we've got an aligned pointer */ - if ((u32)atag_list & 0x3) -@@ -168,7 +263,9 @@ int atags_to_fdt(void *atag_list, void * - else - setprop_string(fdt, "/chosen", "bootargs", - atag->u.cmdline.cmdline); -- } else if (atag->hdr.tag == ATAG_MEM) { -+ } -+#ifndef CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE -+ else if (atag->hdr.tag == ATAG_MEM) { - if (memcount >= sizeof(mem_reg_property)/4) - continue; - if (!atag->u.mem.size) -@@ -212,6 +309,10 @@ int atags_to_fdt(void *atag_list, void * - setprop(fdt, "/memory", "reg", mem_reg_property, - 4 * memcount * memsize); - } -+#else -+ -+ } -+#endif - - return fdt_pack(fdt); - } ---- a/init/main.c -+++ b/init/main.c -@@ -112,6 +112,10 @@ - - #include - -+#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE) -+#include -+#endif -+ - static int kernel_init(void *); - - extern void init_IRQ(void); -@@ -995,6 +999,18 @@ asmlinkage __visible void __init __no_sa - pr_notice("Kernel command line: %s\n", saved_command_line); - /* parameters may set static keys */ - jump_label_init(); -+ -+#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE) -+ //Show bootloader's original command line for reference -+ if(of_chosen) { -+ const char *prop = of_get_property(of_chosen, "bootloader-args", NULL); -+ if(prop) -+ pr_notice("Bootloader command line (ignored): %s\n", prop); -+ else -+ pr_notice("Bootloader command line not present\n"); -+ } -+#endif -+ - parse_early_param(); - after_dashes = parse_args("Booting kernel", - static_command_line, __start___param, diff --git a/target/linux/ipq806x/patches-6.1/900-arm-add-cmdline-override.patch b/target/linux/ipq806x/patches-6.1/900-arm-add-cmdline-override.patch index 2004632513..c9583549d0 100644 --- a/target/linux/ipq806x/patches-6.1/900-arm-add-cmdline-override.patch +++ b/target/linux/ipq806x/patches-6.1/900-arm-add-cmdline-override.patch @@ -1,6 +1,6 @@ --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig -@@ -1601,6 +1601,14 @@ config ARM_ATAG_DTB_COMPAT_CMDLINE_MANGL +@@ -1589,6 +1589,14 @@ config ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEN endchoice diff --git a/target/linux/ipq806x/patches-6.1/901-01-ARM-decompressor-support-memory-start-validation-.patch b/target/linux/ipq806x/patches-6.1/901-01-ARM-decompressor-support-memory-start-validation-.patch new file mode 100644 index 0000000000..04e2a0c57e --- /dev/null +++ b/target/linux/ipq806x/patches-6.1/901-01-ARM-decompressor-support-memory-start-validation-.patch @@ -0,0 +1,75 @@ +From 2f86b9b71a11f86e3d850214ab781ebb17d7260e Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Fri, 19 Jan 2024 19:48:30 +0100 +Subject: [PATCH v2 1/2] ARM: decompressor: support memory start validation for + appended DTB + +There is currently a problem with a very specific sets of kernel config +and AUTO_ZRELADDR. + +For the most common case AUTO_ZRELADDR check the PC register and +calculate the start of the physical memory. Then fdt_check_mem_start is +called to make sure the detected value makes sense by comparing it with +what is present in DTB in the memory nodes and if additional fixup are +required with the use of linux,usable-memory-range in the chosen node to +hardcode usable memory range in case some reserved space needs to be +addressed. With the help of this function the right address is +calculated and the kernel correctly decompress and loads. + +Things starts to become problematic when in the mix, +CONFIG_ARM_APPENDED_DTB is used. This is a particular kernel config is +used when legacy systems doesn't support passing a DTB directly and a +DTB is appended at the end of the image. + +In such case, fdt_check_mem_start is skipped in AUTO_ZRELADDR iteration +as the appended DTB can be augumented later with ATAGS passed from the +bootloader (if CONFIG_ARM_ATAG_DTB_COMPAT is enabled). + +The main problem and what this patch address is the fact that +fdt_check_mem_start is never called later when the appended DTB is +augumented, hence any fixup and validation is not done making AUTO_ZRELADDR +detection inconsistent and most of the time wrong. + +Add support in head.S for this by checking if AUTO_ZRELADDR is enabled +and calling fdt_check_mem_start with the appended DTB and the augumented +values permitting legacy device to provide info in DTB instead of +disabling AUTO_ZRELADDR and hardcoding the physical address offsets. + +Signed-off-by: Christian Marangi +Reviewed-by: Geert Uytterhoeven +Reviewed-by: Linus Walleij +--- + arch/arm/boot/compressed/head.S | 22 ++++++++++++++++++++++ + 1 file changed, 22 insertions(+) + +--- a/arch/arm/boot/compressed/head.S ++++ b/arch/arm/boot/compressed/head.S +@@ -443,6 +443,28 @@ restart: adr r0, LC1 + add r6, r6, r5 + add r10, r10, r5 + add sp, sp, r5 ++ ++#ifdef CONFIG_AUTO_ZRELADDR ++ /* ++ * Validate calculated start of physical memory with appended DTB. ++ * In the first iteration for physical memory start calculation, ++ * we skipped validating it as it could have been augumented by ++ * ATAGS stored at an offset from the same start of physical memory. ++ * ++ * We now have parsed them and augumented the appended DTB if asked ++ * so we can finally validate the start of physical memory. ++ * ++ * This is needed to apply additional fixup with ++ * linux,usable-memory-range or to make sure AUTO_ZRELADDR detected ++ * the correct value. ++ */ ++ sub r0, r4, #TEXT_OFFSET @ revert to base address ++ mov r1, r8 @ use appended DTB ++ bl fdt_check_mem_start ++ ++ /* Determine final kernel image address. */ ++ add r4, r0, #TEXT_OFFSET ++#endif + dtb_check_done: + #endif + diff --git a/target/linux/ipq806x/patches-6.1/901-02-ARM-decompressor-add-option-to-ignore-MEM-ATAGs.patch b/target/linux/ipq806x/patches-6.1/901-02-ARM-decompressor-add-option-to-ignore-MEM-ATAGs.patch new file mode 100644 index 0000000000..2e4c4de545 --- /dev/null +++ b/target/linux/ipq806x/patches-6.1/901-02-ARM-decompressor-add-option-to-ignore-MEM-ATAGs.patch @@ -0,0 +1,54 @@ +From 781d7cd4c3364e9d38fa12a342c5ad4c7e33a5ba Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Fri, 19 Jan 2024 20:33:10 +0100 +Subject: [PATCH v2 2/2] ARM: decompressor: add option to ignore MEM ATAGs + +Some bootloaders can pass broken MEM ATAGs that provide hardcoded +information about mounted RAM size and physical location. +Example booloader provide RAM of size 1.7Gb but actual mounted RAM +size is 512Mb causing kernel panic. + +Add option CONFIG_ARM_ATAG_DTB_COMPAT_IGNORE_MEM to ignore these ATAG +and not augument appended DTB memory node. + +Signed-off-by: Christian Marangi +Acked-by: Linus Walleij +--- + arch/arm/Kconfig | 12 ++++++++++++ + arch/arm/boot/compressed/atags_to_fdt.c | 4 ++++ + 2 files changed, 16 insertions(+) + +--- a/arch/arm/Kconfig ++++ b/arch/arm/Kconfig +@@ -1570,6 +1570,18 @@ config ARM_ATAG_DTB_COMPAT + bootloaders, this option allows zImage to extract the information + from the ATAG list and store it at run time into the appended DTB. + ++config ARM_ATAG_DTB_COMPAT_IGNORE_MEM ++ bool "Ignore MEM ATAG information from bootloader" ++ depends on ARM_ATAG_DTB_COMPAT ++ help ++ Some bootloaders can pass broken MEM ATAGs that provide hardcoded ++ information about mounted RAM size and physical location. ++ Example booloader provide RAM of size 1.7Gb but actual mounted RAM ++ size is 512Mb causing kernel panic. ++ ++ Enable this option if MEM ATAGs should be ignored and the memory ++ node in the appended DTB should NOT be augumented. ++ + choice + prompt "Kernel command line type" if ARM_ATAG_DTB_COMPAT + default ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER +--- a/arch/arm/boot/compressed/atags_to_fdt.c ++++ b/arch/arm/boot/compressed/atags_to_fdt.c +@@ -169,6 +169,10 @@ int atags_to_fdt(void *atag_list, void * + setprop_string(fdt, "/chosen", "bootargs", + atag->u.cmdline.cmdline); + } else if (atag->hdr.tag == ATAG_MEM) { ++ /* Bootloader MEM ATAG are broken and should be ignored */ ++ if (IS_ENABLED(CONFIG_ARM_ATAG_DTB_COMPAT_IGNORE_MEM)) ++ continue; ++ + if (memcount >= sizeof(mem_reg_property)/4) + continue; + if (!atag->u.mem.size) diff --git a/target/linux/ipq806x/patches-6.1/902-ARM-decompressor-support-for-ATAGs-rootblock-parsing.patch b/target/linux/ipq806x/patches-6.1/902-ARM-decompressor-support-for-ATAGs-rootblock-parsing.patch new file mode 100644 index 0000000000..60b80fefe1 --- /dev/null +++ b/target/linux/ipq806x/patches-6.1/902-ARM-decompressor-support-for-ATAGs-rootblock-parsing.patch @@ -0,0 +1,197 @@ +From 13bb6d8dd9138927950a520a288401db82871dc9 Mon Sep 17 00:00:00 2001 +From: Christian Marangi +Date: Sun, 21 Jan 2024 23:36:57 +0100 +Subject: [PATCH] ARM: decompressor: support for ATAGs rootblock parsing + +The command-line arguments provided by the boot loader will be +appended to a new device tree property: bootloader-args. + +If there is a property "append-rootblock" in DT under /chosen +and a root= option in bootloaders command line it will be parsed +and added to DT bootargs with the form: XX. + +This is usefull in dual boot systems, to get the current root partition +without afecting the rest of the system. + +Signed-off-by: Adrian Panella +[ reworked to a cleaner patch ] +Signed-off-by: Christian Marangi +--- + arch/arm/Kconfig | 10 +++ + arch/arm/boot/compressed/atags_to_fdt.c | 102 ++++++++++++++++++++++-- + init/main.c | 12 +++ + 3 files changed, 117 insertions(+), 7 deletions(-) + +--- a/arch/arm/Kconfig ++++ b/arch/arm/Kconfig +@@ -1599,6 +1599,16 @@ config ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEN + The command-line arguments provided by the boot loader will be + appended to the the device tree bootargs property. + ++config ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE ++ bool "Append rootblock parsing bootloader's kernel arguments" ++ help ++ The command-line arguments provided by the boot loader will be ++ appended to a new device tree property: bootloader-args. ++ ++ If there is a property "append-rootblock" in DT under /chosen ++ and a root= option in bootloaders command line it will be parsed ++ and added to DT bootargs with the form: XX. ++ + endchoice + + config CMDLINE_OVERRIDE +--- a/arch/arm/boot/compressed/atags_to_fdt.c ++++ b/arch/arm/boot/compressed/atags_to_fdt.c +@@ -3,7 +3,8 @@ + #include + #include + +-#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND) ++#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND) || \ ++ defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE) + #define do_extend_cmdline 1 + #else + #define do_extend_cmdline 0 +@@ -69,6 +70,83 @@ static uint32_t get_cell_size(const void + return cell_size; + } + ++/** ++ * taken from arch/x86/boot/string.c ++ * local_strstr - Find the first substring in a %NUL terminated string ++ * @s1: The string to be searched ++ * @s2: The string to search for ++ */ ++static char *local_strstr(const char *s1, const char *s2) ++{ ++ size_t l1, l2; ++ ++ l2 = strlen(s2); ++ if (!l2) ++ return (char *)s1; ++ l1 = strlen(s1); ++ while (l1 >= l2) { ++ l1--; ++ if (!memcmp(s1, s2, l2)) ++ return (char *)s1; ++ s1++; ++ } ++ return NULL; ++} ++ ++static char *append_rootblock(char *dest, const char *str, int len, void *fdt) ++{ ++ char *ptr, *end, *tmp; ++ const char *root="root="; ++ const char *find_rootblock; ++ int i, l; ++ const char *rootblock; ++ ++ find_rootblock = getprop(fdt, "/chosen", "find-rootblock", &l); ++ if (!find_rootblock) ++ find_rootblock = root; ++ ++ /* ARM doesn't have __HAVE_ARCH_STRSTR, so it was copied from x86 */ ++ ptr = local_strstr(str, find_rootblock); ++ if (!ptr) ++ return dest; ++ ++ end = strchr(ptr, ' '); ++ end = end ? (end - 1) : (strchr(ptr, 0) - 1); ++ ++ /* Some boards ubi.mtd=XX,ZZZZ, so let's check for '," too. */ ++ tmp = strchr(ptr, ','); ++ if (tmp) ++ end = end < tmp ? end : tmp - 1; ++ ++ /* ++ * find partition number ++ * (assumes format root=/dev/mtdXX | /dev/mtdblockXX | yy:XX | ubi.mtd=XX,ZZZZ ) ++ */ ++ for (i = 0; end >= ptr && *end >= '0' && *end <= '9'; end--, i++); ++ ++ ptr = end + 1; ++ ++ /* if append-rootblock property is set use it to append to command line */ ++ rootblock = getprop(fdt, "/chosen", "append-rootblock", &l); ++ if (rootblock != NULL) { ++ if (*dest != ' ') { ++ *dest = ' '; ++ dest++; ++ len++; ++ } ++ ++ if (len + l + i <= COMMAND_LINE_SIZE) { ++ memcpy(dest, rootblock, l); ++ dest += l - 1; ++ ++ memcpy(dest, ptr, i); ++ dest += i; ++ } ++ } ++ ++ return dest; ++} ++ + static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline) + { + char cmdline[COMMAND_LINE_SIZE]; +@@ -86,13 +164,23 @@ static void merge_fdt_bootargs(void *fdt + ptr += len - 1; + } + +- /* and append the ATAG_CMDLINE */ + if (fdt_cmdline) { +- len = strlen(fdt_cmdline); +- if (ptr - cmdline + len + 2 < COMMAND_LINE_SIZE) { +- *ptr++ = ' '; +- memcpy(ptr, fdt_cmdline, len); +- ptr += len; ++ if (IS_ENABLED(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE)) { ++ /* ++ * save original bootloader args ++ * and append ubi.mtd with root partition number ++ * to current cmdline ++ */ ++ setprop_string(fdt, "/chosen", "bootloader-args", fdt_cmdline); ++ ptr = append_rootblock(ptr, fdt_cmdline, len, fdt); ++ } else { ++ /* and append the ATAG_CMDLINE */ ++ len = strlen(fdt_cmdline); ++ if (ptr - cmdline + len + 2 < COMMAND_LINE_SIZE) { ++ *ptr++ = ' '; ++ memcpy(ptr, fdt_cmdline, len); ++ ptr += len; ++ } + } + } + *ptr = '\0'; +--- a/init/main.c ++++ b/init/main.c +@@ -28,6 +28,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -995,6 +996,17 @@ asmlinkage __visible void __init __no_sa + pr_notice("Kernel command line: %s\n", saved_command_line); + /* parameters may set static keys */ + jump_label_init(); ++ ++ /* Show bootloader's original command line for reference */ ++ if (IS_ENABLED(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE) && of_chosen) { ++ const char *prop = of_get_property(of_chosen, "bootloader-args", NULL); ++ ++ if(prop) ++ pr_notice("Bootloader command line (ignored): %s\n", prop); ++ else ++ pr_notice("Bootloader command line not present\n"); ++ } ++ + parse_early_param(); + after_dashes = parse_args("Booting kernel", + static_command_line, __start___param, From df3d5fd3f212a0c0b5d479ca51dc3e2b0b24e8f5 Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Fri, 23 Feb 2024 18:05:09 +0100 Subject: [PATCH 04/18] ipq806x: refresh Kconfig Refresh Kconfig due to new changes in ARM decompressor with kernel_makemenuconfig. Signed-off-by: Christian Marangi --- target/linux/ipq806x/config-6.1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/target/linux/ipq806x/config-6.1 b/target/linux/ipq806x/config-6.1 index 598ab305db..18325c0346 100644 --- a/target/linux/ipq806x/config-6.1 +++ b/target/linux/ipq806x/config-6.1 @@ -49,6 +49,7 @@ CONFIG_ARM_QCOM_SPM_CPUIDLE=y CONFIG_ARM_THUMB=y CONFIG_ARM_UNWIND=y CONFIG_ARM_VIRT_EXT=y +CONFIG_AUTO_ZRELADDR=y CONFIG_BINFMT_FLAT_ARGVP_ENVP_ON_STACK=y CONFIG_BLK_DEV_LOOP=y CONFIG_BLK_MQ_PCI=y @@ -147,7 +148,6 @@ CONFIG_DWMAC_IPQ806X=y # CONFIG_DWMAC_QCOM_ETHQOS is not set CONFIG_EDAC_ATOMIC_SCRUB=y CONFIG_EDAC_SUPPORT=y -CONFIG_ETHERNET_PACKET_MANGLE=y CONFIG_EXCLUSIVE_SYSTEM_RAM=y CONFIG_FIXED_PHY=y CONFIG_FIX_EARLYCON_MEM=y @@ -313,6 +313,7 @@ CONFIG_NO_HZ_COMMON=y CONFIG_NO_HZ_IDLE=y CONFIG_NR_CPUS=2 CONFIG_NVMEM=y +CONFIG_NVMEM_LAYOUTS=y CONFIG_NVMEM_QCOM_QFPROM=y # CONFIG_NVMEM_QCOM_SEC_QFPROM is not set # CONFIG_NVMEM_SPMI_SDAM is not set @@ -333,6 +334,7 @@ CONFIG_PAGE_OFFSET=0xC0000000 CONFIG_PAGE_POOL=y CONFIG_PAGE_SIZE_LESS_THAN_256KB=y CONFIG_PAGE_SIZE_LESS_THAN_64KB=y +CONFIG_PAHOLE_HAS_LANG_EXCLUDE=y CONFIG_PCI=y CONFIG_PCIEAER=y CONFIG_PCIEPORTBUS=y @@ -349,8 +351,8 @@ CONFIG_PCS_XPCS=y CONFIG_PERF_USE_VMALLOC=y CONFIG_PGTABLE_LEVELS=2 CONFIG_PHYLIB=y +CONFIG_PHYLIB_LEDS=y CONFIG_PHYLINK=y -CONFIG_PHYS_OFFSET=0x42000000 # CONFIG_PHY_QCOM_APQ8064_SATA is not set # CONFIG_PHY_QCOM_EDP is not set # CONFIG_PHY_QCOM_IPQ4019_USB is not set @@ -404,6 +406,7 @@ CONFIG_QCOM_HFPLL=y # CONFIG_QCOM_ICC_BWMON is not set # CONFIG_QCOM_IOMMU is not set # CONFIG_QCOM_LLCC is not set +CONFIG_QCOM_NET_PHYLIB=y # CONFIG_QCOM_OCMEM is not set # CONFIG_QCOM_PDC is not set # CONFIG_QCOM_RMTFS_MEM is not set From 07b9186e88a2e5b2bd842b87d7063645a23e3fcb Mon Sep 17 00:00:00 2001 From: Marcin Gajda Date: Sun, 11 Feb 2024 16:20:21 +0100 Subject: [PATCH 05/18] ipq40xx: Add support Netgear LBR20 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Netgear LBR20** is a router with two gigabit ethernets , three wifi radios and integrated LTE cat.18 modem. SoC Type: Qualcomm IPQ4019 RAM: 512 MiB Flash: 256 MiB , SLC NAND, 2 Gbit (Macronix MX30LF2G18AC) Bootloader: U-Boot Modem: LTE CAT.18 Quectel EG-18EA , Max. 1.2Gbps downlink / 150Mbps uplink WiFi class AC2200: - radio0 : 5G on QCA9888 , WiFi5- 802.11a/n/ac MU-MIMO 2x2 , 887Mbps , 80MHz - limited for low channels - radio1: 2,4G on IPQ4019 ,WiFi4- 802.11b/g/n MIMO2x2 300Mbps 40Mhz - radio2: 5G on IPQ4019 , WiFi5- 802.11a/n/ac MU-MIMO 2x2 , 887Mbps ,80Mhz - limited for high channels (from 100 up to 165) . Becouse of DFS remember to set country before turning on. Ethernet: 2x1GbE (WAN/LAN1, LAN2) LEDs: section power : green and red , section on top (orbi) drived by TLC59208F: red, green ,blue and white USB ports: No Buttons: 2 Reset and SYNC(WPS) Power: 12 VDC, 2,5 A Connector type: Barrel OpenWRT Installation 1. Simplest way is just do upgrade from webpage with *factory.img 2. You can also do it with standard tool for Netgear's debricking - NMPRFlash 3. Most advanced way is to open device , connect to UART console and : - Prepare OpenWrt initramfs image in TFTP server root (server IP 192.168.1.10) - Connect serial console (115200,8n1) to UART connector - Connect TFTP server to RJ-45 port - Stop in u-Boot and run u-Boot command: > setenv serverip 192.168.1.10 > set fdt_high 0x85000000 > tftpboot 0x83000000 openwrt-ipq40xx-generic-netgear_lbr20-initramfs-zImage.itb > bootm 0x83000000 - Login via ssh - upload or download *sysupgrade.bin ( like wget ... or scp transfer) - Install image via "sysupgrade -n" (like “sysupgrade -n /tmp/openwrt-ipq40xx-generic-netgear_lbr20-squashfs-sysupgrade.bin”) Back to Stock - Download firmware from official Netgear's webpage , it will be *.img file after decompressing. - Use NMRPFlash tool ( detailed insructions on project page https://github.com/jclehner/nmrpflash ) Open the case - Unscrew nuts and remove washers from antenna's conectors. - There are two Torx T10 screws under the label next to antenna conectors. You have to unglue this label from left and right corner to get it - Two parts of shell covers will slide out from eachother , you have to unglue two small rubber pads and namplate sticker on bottom to do that. - PCB is screwed with 4Pcs of Torx T10 screws - Before lifting up PCB remove pigtiles for LTE antennas and release them from PCB and radiator (black and white wires) - On other side of PCB ,in left bottom corner there is already soldered with 4 pins UART connector for console. Counting from left it is +3,3V , TX , RX ,GND (reffer to this picture: https://i.ibb.co/Pmrf9KB/20240116-103524.jpg ) BDF's files are in firmware_qca-wireless https://github.com/openwrt/firmware_qca-wireless/ and in parallel sent to ath10k@lists.infradead.org. Signed-off-by: Marcin Gajda --- package/boot/uboot-envtools/files/ipq40xx | 3 +- package/firmware/ipq-wifi/Makefile | 2 + .../ipq40xx/base-files/etc/board.d/02_network | 4 + .../base-files/etc/init.d/modem_switch | 34 ++ .../base-files/lib/upgrade/platform.sh | 1 + .../arch/arm/boot/dts/qcom-ipq4019-lbr20.dts | 516 ++++++++++++++++++ target/linux/ipq40xx/image/generic.mk | 18 + 7 files changed, 577 insertions(+), 1 deletion(-) create mode 100755 target/linux/ipq40xx/base-files/etc/init.d/modem_switch create mode 100644 target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-lbr20.dts diff --git a/package/boot/uboot-envtools/files/ipq40xx b/package/boot/uboot-envtools/files/ipq40xx index 8d993fae36..8cada7334b 100644 --- a/package/boot/uboot-envtools/files/ipq40xx +++ b/package/boot/uboot-envtools/files/ipq40xx @@ -53,7 +53,8 @@ aruba,ap-303) aruba,ap-365) ubootenv_add_uci_config "/dev/mtd8" "0x0" "0x10000" "0x10000" ;; -buffalo,wtr-m2133hp) +buffalo,wtr-m2133hp|\ +netgear,lbr20) ubootenv_add_uci_config "/dev/mtd8" "0x0" "0x40000" "0x20000" ;; linksys,ea6350v3) diff --git a/package/firmware/ipq-wifi/Makefile b/package/firmware/ipq-wifi/Makefile index df1ae5ee7a..150f146672 100644 --- a/package/firmware/ipq-wifi/Makefile +++ b/package/firmware/ipq-wifi/Makefile @@ -38,6 +38,7 @@ ALLWIFIBOARDS:= \ edimax_cax1800 \ linksys_mx4200 \ linksys_mx5300 \ + netgear_lbr20 \ netgear_rax120v2 \ netgear_wax218 \ netgear_wax620 \ @@ -154,6 +155,7 @@ $(eval $(call generate-ipq-wifi-package,edgecore_eap102,Edgecore EAP102)) $(eval $(call generate-ipq-wifi-package,edimax_cax1800,Edimax CAX1800)) $(eval $(call generate-ipq-wifi-package,linksys_mx4200,Linksys MX4200)) $(eval $(call generate-ipq-wifi-package,linksys_mx5300,Linksys MX5300)) +$(eval $(call generate-ipq-wifi-package,netgear_lbr20,Netgear LBR20)) $(eval $(call generate-ipq-wifi-package,netgear_rax120v2,Netgear RAX120v2)) $(eval $(call generate-ipq-wifi-package,netgear_wax218,Netgear WAX218)) $(eval $(call generate-ipq-wifi-package,netgear_wax620,Netgear WAX620)) diff --git a/target/linux/ipq40xx/base-files/etc/board.d/02_network b/target/linux/ipq40xx/base-files/etc/board.d/02_network index babde1b8e2..02059580a1 100644 --- a/target/linux/ipq40xx/base-files/etc/board.d/02_network +++ b/target/linux/ipq40xx/base-files/etc/board.d/02_network @@ -124,6 +124,10 @@ ipq40xx_setup_interfaces() ucidef_set_interface_lan "lan1 lan2 lan3 lan4" ucidef_set_interface "wan" device "/dev/cdc-wdm0" protocol "qmi" ;; + netgear,lbr20) + ucidef_set_interface_lan "lan1 lan2" + ucidef_set_interface "wan" device "/dev/cdc-wdm0" protocol "qmi" + ;; *) echo "Unsupported hardware. Network interfaces not initialized" ;; diff --git a/target/linux/ipq40xx/base-files/etc/init.d/modem_switch b/target/linux/ipq40xx/base-files/etc/init.d/modem_switch new file mode 100755 index 0000000000..9aeeec8dad --- /dev/null +++ b/target/linux/ipq40xx/base-files/etc/init.d/modem_switch @@ -0,0 +1,34 @@ +#!/bin/sh /etc/rc.common + +START=15 +STOP=10 + +boot() { + case $(board_name) in + netgear,lbr20) + echo "0" > /sys/class/gpio/lte_rst/value + echo "0" > /sys/class/gpio/lte_pwrkey/value + echo "0" > /sys/class/gpio/lte_usb_boot/value + echo "0" > /sys/class/gpio/lte_pwm/value + sleep 1 + echo "1" > /sys/class/gpio/lte_pwm/value + echo "1" > /sys/class/gpio/lte_pwrkey/value + echo "1" > /sys/class/gpio/lte_rst/value + sleep 1 + echo "0" > /sys/class/gpio/lte_pwrkey/value + sleep 1 + echo "1" > /sys/class/gpio/lte_pwrkey/value + ;; + esac +} + +shutdown() { + case $(board_name) in + netgear,lbr20) + echo "0" > /sys/class/gpio/lte_pwrkey/value + sleep 1 + echo "1" > /sys/class/gpio/lte_pwrkey/value + sleep 10 + ;; + esac +} diff --git a/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh b/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh index 22f2ee9ccc..e934326849 100644 --- a/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh @@ -120,6 +120,7 @@ platform_do_upgrade() { glinet,gl-ap1300 |\ luma,wrtq-329acn |\ mobipromo,cm520-79f |\ + netgear,lbr20 |\ netgear,wac510 |\ p2w,r619ac-64m |\ p2w,r619ac-128m |\ diff --git a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-lbr20.dts b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-lbr20.dts new file mode 100644 index 0000000000..4e5497cbc3 --- /dev/null +++ b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-lbr20.dts @@ -0,0 +1,516 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "qcom-ipq4019.dtsi" +#include +#include +#include +#include + +/ { + model = "Netgear LBR20"; + compatible = "netgear,lbr20"; + + chosen { + bootargs-append = "ubi.mtd=ubi root=/dev/ubiblock0_0"; + }; + + aliases { + led-boot = &led_backlight_white; + led-failsafe = &led_status_green; + led-running = &led_status_green; + led-upgrade = &led_status_red; + label-mac-device = &gmac; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&tlmm 18 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&tlmm 49 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_status_green: led-status-green { + function = LED_FUNCTION_STATUS; + color = ; + gpios = <&tlmm 22 GPIO_ACTIVE_LOW>; + default-state = "keep"; + }; + + led_status_red: led-status-red { + function = LED_FUNCTION_STATUS; + color = ; + gpios = <&tlmm 23 GPIO_ACTIVE_LOW>; + }; + }; + + gpio_export { + compatible = "gpio-export"; + #size-cells = <0>; + + lte_rst { + gpio-export,name = "lte_rst"; + gpio-export,output = <1>; + gpios = <&tlmm 28 GPIO_ACTIVE_HIGH>; + }; + + lte_pwrkey { + gpio-export,name = "lte_pwrkey"; + gpio-export,output = <1>; + gpios = <&tlmm 29 GPIO_ACTIVE_HIGH>; + }; + + lte_usb_boot { + gpio-export,name = "lte_usb_boot"; + gpio-export,output = <0>; + gpios = <&tlmm 30 GPIO_ACTIVE_HIGH>; + }; + + lte_pwm { + gpio-export,name = "lte_pwm"; + gpio-export,output = <1>; + gpios = <&tlmm 31 GPIO_ACTIVE_HIGH>; + }; + + }; + + soc { + + tcsr@1949000 { + compatible = "qcom,tcsr"; + reg = <0x1949000 0x100>; + qcom,wifi_glb_cfg = ; + }; + + tcsr@194b000 { + status = "okay"; + + compatible = "qcom,tcsr"; + reg = <0x194b000 0x100>; + qcom,usb-hsphy-mode-select = ; + }; + + ess_tcsr@1953000 { + compatible = "qcom,tcsr"; + reg = <0x1953000 0x1000>; + qcom,ess-interface-select = ; + }; + + tcsr@1957000 { + compatible = "qcom,tcsr"; + reg = <0x1957000 0x100>; + qcom,wifi_noc_memtype_m0_m2 = ; + }; + + }; +}; + +&prng { + status = "okay"; +}; + +&mdio { + status = "okay"; + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; +}; + +&crypto { + status = "okay"; +}; + +&watchdog { + status = "okay"; +}; + +&usb2_hs_phy { + status = "okay"; +}; + +&usb2 { + status = "okay"; +}; + +&usb3_ss_phy { + status = "okay"; +}; + +&usb3_hs_phy { + status = "okay"; +}; + +&usb3 { + status = "okay"; +}; + +&blsp_dma { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&tlmm { + mdio_pins: mdio-pinmux { + mux_mdio { + pins = "gpio6"; + function = "mdio"; + bias-pull-up; + }; + + mux_mdc { + pins = "gpio7"; + function = "mdc"; + bias-pull-up; + }; + }; + + serial_pins: serial-pinmux { + function = "blsp_uart0"; + pins = "gpio16", "gpio17"; + bias-disable; + }; + + nand_pins: nand-pins { + pullups { + pins = "gpio52", "gpio53", "gpio58", "gpio59"; + function = "qpic"; + bias-pull-up; + }; + + pulldowns { + pins = "gpio54", "gpio55", "gpio56", + "gpio57", "gpio60", "gpio61", + "gpio62", "gpio63", "gpio64", + "gpio65", "gpio66", "gpio67", + "gpio68", "gpio69"; + function = "qpic"; + bias-pull-down; + }; + }; +}; + +&nand { + pinctrl-0 = <&nand_pins>; + pinctrl-names = "default"; + status = "okay"; + + nand@0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "0:SBL1"; + reg = <0x00000000 0x00100000>; + read-only; + }; + + partition@100000 { + label = "0:MIBIB"; + reg = <0x00100000 0x00100000>; + read-only; + }; + + partition@200000 { + label = "0:BOOTCONFIG"; + reg = <0x00200000 0x00100000>; + read-only; + }; + + partition@300000 { + label = "0:QSEE"; + reg = <0x00300000 0x00100000>; + read-only; + }; + + partition@400000 { + label = "0:QSEE_1"; + reg = <0x00400000 0x00100000>; + read-only; + }; + + partition@500000 { + label = "0:CDT"; + reg = <0x00500000 0x00080000>; + read-only; + }; + + partition@580000 { + label = "0:CDT_1"; + reg = <0x00580000 0x00080000>; + read-only; + }; + + partition@600000 { + label = "0:BOOTCONFIG1"; + reg = <0x00600000 0x00080000>; + read-only; + }; + + partition@680000 { + label = "0:APPSBLENV"; + reg = <0x00680000 0x00080000>; + }; + + partition@700000 { + label = "0:APPSBL"; + reg = <0x00700000 0x00200000>; + read-only; + }; + + partition@900000 { + label = "0:APPSBL_1"; + reg = <0x00900000 0x00200000>; + read-only; + }; + + partition@b00000 { + label = "0:ART"; + reg = <0x00b00000 0x00080000>; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + precal_art_1000: precal@1000 { + reg = <0x1000 0x2f20>; + }; + + precal_art_5000: precal@5000 { + reg = <0x5000 0x2f20>; + }; + + precal_art_9000: precal@9000 { + reg = <0x9000 0x2f20>; + }; + + }; + }; + + partition@b80000 { + label = "0:ART.bak"; + reg = <0x00b80000 0x00080000>; + read-only; + }; + + partition@c00000 { + label = "config"; + reg = <0x00c00000 0x00100000>; + read-only; + }; + + partition@d00000 { + label = "boarddata1"; + reg = <0x00d00000 0x00080000>; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + mac_address_lan: macaddr@0 { + compatible = "mac-base"; + reg = <0x0 0x6>; + #nvmem-cell-cells = <1>; + }; + + mac_address_wan: macaddr@6 { + compatible = "mac-base"; + reg = <0x6 0x6>; + #nvmem-cell-cells = <1>; + }; + + mac_address_wlan_5g: macaddr@c { + compatible = "mac-base"; + reg = <0xc 0x6>; + #nvmem-cell-cells = <1>; + }; + + mac_address_wlan_2nd5g: macaddr@12 { + compatible = "mac-base"; + reg = <0x12 0x6>; + #nvmem-cell-cells = <1>; + }; + + }; + }; + + partition@d80000 { + label = "boarddata2"; + reg = <0x00d80000 0x00040000>; + read-only; + }; + + partition@dc0000 { + label = "pot"; + reg = <0x00dc0000 0x00100000>; + read-only; + }; + + partition@ec0000 { + label = "boarddata1.bak"; + reg = <0x00ec0000 0x00080000>; + read-only; + }; + + partition@f40000 { + label = "boarddata2.bak"; + reg = <0x00f40000 0x00040000>; + read-only; + }; + + partition@f80000 { + label = "language"; + reg = <0x00f80000 0x00300000>; + read-only; + }; + + partition@1280000 { + label = "cert"; + reg = <0x01280000 0x00080000>; + read-only; + }; + + partition@1300000 { + label = "ntgrdata"; + reg = <0x01300000 0x09300000>; + }; + + partition@a600000 { + label = "kernel"; + reg = <0x0a600000 0x00700000>; + }; + + partition@a9c0000 { + label = "ubi"; + reg = <0x0ad00000 0x05300000>; + }; + + }; + }; +}; + +&blsp1_i2c3 { + status = "okay"; + + led-controller { + #address-cells = <1>; + #size-cells = <0>; + compatible = "ti,tlc59108"; /* really is tlc59208f */ + reg = <0x27>; + + led_backlight_green: led-backlight-green { + function = LED_FUNCTION_BACKLIGHT; + color = ; + reg = <0x0>; + linux,default-trigger = "default-off"; + }; + + led_backlight_red: led-backlight-red { + function = LED_FUNCTION_BACKLIGHT; + color = ; + reg = <0x1>; + linux,default-trigger = "default-off"; + }; + + led_backlight_blue: led-backlight-blue { + function = LED_FUNCTION_BACKLIGHT; + color = ; + reg = <0x2>; + linux,default-trigger = "default-off"; + }; + + led_backlight_white: led-backlight-white { + function = LED_FUNCTION_BACKLIGHT; + color = ; + reg = <0x3>; + linux,default-trigger = "default-off"; + }; + + }; +}; + +&blsp1_uart1 { + status = "okay"; + pinctrl-0 = <&serial_pins>; + pinctrl-names = "default"; +}; + +&cryptobam { + status = "okay"; +}; + +&gmac { + status = "okay"; + nvmem-cell-names = "mac-address"; + nvmem-cells = <&mac_address_lan 0>; +}; + +&switch { + status = "okay"; +}; + +&swport4 { + status = "okay"; + label = "lan1"; +}; + +&swport5 { + status = "okay"; + label = "lan2"; +}; + +&pcie0 { + status = "okay"; + perst-gpios = <&tlmm 38 GPIO_ACTIVE_LOW>; + wake-gpios = <&tlmm 50 GPIO_ACTIVE_LOW>; + + bridge@0,0 { + reg = <0x00000000 0 0 0 0>; + #address-cells = <3>; + #size-cells = <2>; + ranges; + + wifi@1,0 { + compatible = "qcom,ath10k"; + status = "okay"; + reg = <0x00010000 0 0 0 0>; + ieee80211-freq-limit = <5170000 5350000>; + nvmem-cell-names = "pre-calibration", "mac-address"; + nvmem-cells = <&precal_art_9000>, <&mac_address_wlan_2nd5g 0>; + qcom,ath10k-calibration-variant = "Netgear-LBR20"; + }; + }; +}; + +&wifi0 { + status = "okay"; + nvmem-cell-names = "pre-calibration", "mac-address"; + nvmem-cells = <&precal_art_1000>, <&mac_address_lan 0>; + qcom,ath10k-calibration-variant = "Netgear-LBR20"; +}; + +&wifi1 { + status = "okay"; + ieee80211-freq-limit = <5470000 5815000>; + nvmem-cell-names = "pre-calibration", "mac-address"; + nvmem-cells = <&precal_art_5000>, <&mac_address_wlan_5g 0>; + qcom,ath10k-calibration-variant = "Netgear-LBR20"; +}; diff --git a/target/linux/ipq40xx/image/generic.mk b/target/linux/ipq40xx/image/generic.mk index f5132cb91f..61bc0ad619 100644 --- a/target/linux/ipq40xx/image/generic.mk +++ b/target/linux/ipq40xx/image/generic.mk @@ -841,6 +841,24 @@ define Device/netgear_orbi DEVICE_PACKAGES := ath10k-firmware-qca9984-ct e2fsprogs kmod-fs-ext4 losetup endef +define Device/netgear_lbr20 + $(call Device/netgear_orbi) + DEVICE_MODEL := LBR20 + NETGEAR_BOARD_ID := LBR20 + NETGEAR_HW_ID := 29766182+0+256+512+2x2+2x2+2x2+1 + KERNEL_SIZE := 7340032 + BLOCKSIZE := 128k + PAGESIZE := 2048 + IMAGE/factory.img := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | \ + append-uImage-fakehdr filesystem | pad-to $$$$(KERNEL_SIZE) | \ + append-ubi | netgear-dni + IMAGE/sysupgrade.bin := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | \ + append-uImage-fakehdr filesystem | sysupgrade-tar kernel=$$$$@ | \ + append-metadata + DEVICE_PACKAGES := ipq-wifi-netgear_lbr20 ath10k-firmware-qca9888-ct kmod-usb-net-qmi-wwan kmod-usb-serial-option uqmi +endef +TARGET_DEVICES += netgear_lbr20 + define Device/netgear_rbx40 $(call Device/netgear_orbi) NETGEAR_HW_ID := 29765515+0+4096+512+2x2+2x2+2x2 From 9b6427e9083fc2baeb67fca977f621d0c93fd6f2 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sat, 24 Feb 2024 03:00:46 +0000 Subject: [PATCH 06/18] uboot-mediatek: fix truncated patch The default environment for the Linksys E8450 and Belkin RT3200 got truncated by one line due to a broken patch. While the impact was luckily only cosmetic, fix it so bootmenu title also shows U-Boot version again. Fixes: 6aec3c7b5b ("mediatek: mt7622: modernize Linksys E8450 / Belkin RT3200 UBI build") Signed-off-by: Daniel Golle --- package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch b/package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch index 08aee125aa..89a6479241 100644 --- a/package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch +++ b/package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch @@ -370,7 +370,7 @@ mt7981-rfb.dtb \ --- /dev/null +++ b/linksys_e8450_env -@@ -0,0 +1,54 @@ +@@ -0,0 +1,55 @@ +ethaddr_factory=ubi read 0x40080000 factory && env readmem -b ethaddr 0x400ffff4 0x6 ; setenv ethaddr_factory +ipaddr=192.168.1.1 +serverip=192.168.1.254 From 6368ed1ae5b628898b33273c8950f7b7575e4414 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sat, 24 Feb 2024 03:00:27 +0000 Subject: [PATCH 07/18] mediatek: mt7623: phase out uImage.FIT partition parser Use the new fitblk driver on the BananaPi R2 as well as UniElec U7623. Introduce boot device selection for fitblk's /chosen/rootdisk handle, similar to how it is already done on MT7622, MT7986 and MT7988. Signed-off-by: Daniel Golle --- .../boot/uboot-envtools/files/mediatek_mt7623 | 7 ++- .../300-mt7623-fix-mmc-get-env-dev.patch | 46 ++++++++++++++++ ...7623-generic-reset-button-ignore-env.patch | 7 +-- .../patches/313-mt7623-select-rootdisk.patch | 46 ++++++++++++++++ .../patches/400-update-bpir2-defconfig.patch | 12 ++--- .../500-board-mt7623-fix-mmc-detect.patch | 21 -------- .../mediatek/dts/mt7623a-unielec-u7623-02.dts | 22 ++++++++ target/linux/mediatek/image/mt7623.mk | 2 + .../mt7623/base-files/lib/upgrade/platform.sh | 23 ++++++-- target/linux/mediatek/mt7623/config-6.1 | 3 +- ...ts-mt7623-bpi-r2-rootdisk-for-fitblk.patch | 53 +++++++++++++++++++ 11 files changed, 203 insertions(+), 39 deletions(-) create mode 100644 package/boot/uboot-mediatek/patches/300-mt7623-fix-mmc-get-env-dev.patch create mode 100644 package/boot/uboot-mediatek/patches/313-mt7623-select-rootdisk.patch delete mode 100644 package/boot/uboot-mediatek/patches/500-board-mt7623-fix-mmc-detect.patch create mode 100644 target/linux/mediatek/patches-6.1/164-dts-mt7623-bpi-r2-rootdisk-for-fitblk.patch diff --git a/package/boot/uboot-envtools/files/mediatek_mt7623 b/package/boot/uboot-envtools/files/mediatek_mt7623 index fd2a01006a..a676e98bd7 100644 --- a/package/boot/uboot-envtools/files/mediatek_mt7623 +++ b/package/boot/uboot-envtools/files/mediatek_mt7623 @@ -13,10 +13,9 @@ board=$(board_name) case "$board" in bananapi,bpi-r2) - . /lib/upgrade/common.sh - export_bootdevice - export_partdevice ubootpart 1 - ubootenv_add_uci_config "/dev/$ubootpart" "0xb0000" "0x10000" "0x10000" "1" + . /lib/upgrade/platform.sh + bootdev="$(platform_get_bootdev)" + ubootenv_add_uci_config "/dev/${bootdev%p[0-9]*}p1" "0xb0000" "0x10000" "0x10000" "1" ;; unielec,u7623-02) ubootenv_add_uci_config "/dev/mmcblk0p1" "0xc0000" "0x10000" "0x10000" "1" diff --git a/package/boot/uboot-mediatek/patches/300-mt7623-fix-mmc-get-env-dev.patch b/package/boot/uboot-mediatek/patches/300-mt7623-fix-mmc-get-env-dev.patch new file mode 100644 index 0000000000..86c48badda --- /dev/null +++ b/package/boot/uboot-mediatek/patches/300-mt7623-fix-mmc-get-env-dev.patch @@ -0,0 +1,46 @@ +--- a/board/mediatek/mt7623/mt7623_rfb.c ++++ b/board/mediatek/mt7623/mt7623_rfb.c +@@ -5,6 +5,7 @@ + + #include + #include ++#include + #include + + DECLARE_GLOBAL_DATA_PTR; +@@ -22,8 +23,9 @@ int mmc_get_boot_dev(void) + { + int g_mmc_devid = -1; + char *uflag = (char *)0x81DFFFF0; ++ struct blk_desc *desc; + +- if (!find_mmc_device(1)) ++ if (blk_get_device_by_str("mmc", "1", &desc) < 0) + return 0; + + if (strncmp(uflag,"eMMC",4)==0) { +@@ -38,6 +40,23 @@ int mmc_get_boot_dev(void) + + int mmc_get_env_dev(void) + { +- return mmc_get_boot_dev(); ++ struct udevice *dev; ++ const char *mmcdev; ++ ++ switch (mmc_get_boot_dev()) { ++ case 0: ++ mmcdev = "mmc@11230000"; ++ break; ++ case 1: ++ mmcdev = "mmc@11240000"; ++ break; ++ default: ++ return -1; ++ } ++ ++ if (uclass_get_device_by_name(UCLASS_MMC, mmcdev, &dev)) ++ return -1; ++ ++ return dev_seq(dev); + } + #endif diff --git a/package/boot/uboot-mediatek/patches/302-mt7623-generic-reset-button-ignore-env.patch b/package/boot/uboot-mediatek/patches/302-mt7623-generic-reset-button-ignore-env.patch index 928dfe8428..b8d89058a2 100644 --- a/package/boot/uboot-mediatek/patches/302-mt7623-generic-reset-button-ignore-env.patch +++ b/package/boot/uboot-mediatek/patches/302-mt7623-generic-reset-button-ignore-env.patch @@ -1,6 +1,6 @@ --- a/board/mediatek/mt7623/mt7623_rfb.c +++ b/board/mediatek/mt7623/mt7623_rfb.c -@@ -4,8 +4,17 @@ +@@ -4,9 +4,18 @@ */ #include @@ -9,6 +9,7 @@ +#include +#include #include + #include #include +#include + @@ -18,8 +19,8 @@ DECLARE_GLOBAL_DATA_PTR; -@@ -41,3 +50,25 @@ int mmc_get_env_dev(void) - return mmc_get_boot_dev(); +@@ -60,3 +69,25 @@ int mmc_get_env_dev(void) + return dev_seq(dev); } #endif + diff --git a/package/boot/uboot-mediatek/patches/313-mt7623-select-rootdisk.patch b/package/boot/uboot-mediatek/patches/313-mt7623-select-rootdisk.patch new file mode 100644 index 0000000000..0089307bbd --- /dev/null +++ b/package/boot/uboot-mediatek/patches/313-mt7623-select-rootdisk.patch @@ -0,0 +1,46 @@ +--- a/board/mediatek/mt7623/mt7623_rfb.c ++++ b/board/mediatek/mt7623/mt7623_rfb.c +@@ -91,3 +91,43 @@ int board_late_init(void) + env_relocate(); + return 0; + } ++ ++int ft_system_setup(void *blob, struct bd_info *bd) ++{ ++ const u32 *media_handle_p; ++ int chosen, len, ret; ++ const char *media; ++ u32 media_handle; ++ ++#ifdef CONFIG_MMC ++ switch (mmc_get_boot_dev()) { ++ case 0: ++ media = "rootdisk-emmc"; ++ break ++ ;; ++ case 1: ++ media = "rootdisk-sd"; ++ break ++ ;; ++ } ++ ++ chosen = fdt_path_offset(blob, "/chosen"); ++ if (chosen <= 0) ++ return 0; ++ ++ media_handle_p = fdt_getprop(blob, chosen, media, &len); ++ if (media_handle_p <= 0 || len != 4) ++ return 0; ++ ++ media_handle = *media_handle_p; ++ ret = fdt_setprop(blob, chosen, "rootdisk", &media_handle, sizeof(media_handle)); ++ if (ret) { ++ printf("cannot set media phandle %s as rootdisk /chosen node\n", media); ++ return ret; ++ } ++ ++ printf("set /chosen/rootdisk to bootrom media: %s (phandle 0x%08x)\n", media, fdt32_to_cpu(media_handle)); ++#endif ++ ++ return 0; ++} diff --git a/package/boot/uboot-mediatek/patches/400-update-bpir2-defconfig.patch b/package/boot/uboot-mediatek/patches/400-update-bpir2-defconfig.patch index ca011aeca9..ab3424e6b5 100644 --- a/package/boot/uboot-mediatek/patches/400-update-bpir2-defconfig.patch +++ b/package/boot/uboot-mediatek/patches/400-update-bpir2-defconfig.patch @@ -1,6 +1,6 @@ --- a/configs/mt7623n_bpir2_defconfig +++ b/configs/mt7623n_bpir2_defconfig -@@ -7,34 +7,105 @@ CONFIG_SYS_MALLOC_F_LEN=0x4000 +@@ -7,34 +7,106 @@ CONFIG_SYS_MALLOC_F_LEN=0x4000 CONFIG_NR_DRAM_BANKS=1 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x81ffff10 @@ -18,6 +18,7 @@ +CONFIG_LED_GPIO=y +CONFIG_LOGLEVEL=7 +CONFIG_LOG=y ++CONFIG_OF_SYSTEM_SETUP=y +CONFIG_AUTOBOOT_KEYED=y +CONFIG_AUTOBOOT_MENU_SHOW=y +CONFIG_BOARD_LATE_INIT=y @@ -110,7 +111,7 @@ CONFIG_USE_IPADDR=y CONFIG_IPADDR="192.168.1.1" CONFIG_USE_SERVERIP=y -@@ -46,6 +117,12 @@ CONFIG_CLK=y +@@ -46,6 +118,12 @@ CONFIG_CLK=y CONFIG_SUPPORT_EMMC_BOOT=y CONFIG_MMC_HS400_SUPPORT=y CONFIG_MMC_MTK=y @@ -123,7 +124,7 @@ CONFIG_PHY_FIXED=y CONFIG_MEDIATEK_ETH=y CONFIG_PINCTRL=y -@@ -55,10 +132,13 @@ CONFIG_POWER_DOMAIN=y +@@ -55,10 +133,13 @@ CONFIG_POWER_DOMAIN=y CONFIG_MTK_POWER_DOMAIN=y CONFIG_DM_SERIAL=y CONFIG_MTK_SERIAL=y @@ -139,7 +140,7 @@ # CONFIG_EFI_GRUB_ARM32_WORKAROUND is not set --- /dev/null +++ b/bananapi_bpi-r2_env -@@ -0,0 +1,70 @@ +@@ -0,0 +1,69 @@ +ipaddr=192.168.1.1 +serverip=192.168.1.254 +loadaddr=0x88000000 @@ -192,14 +193,13 @@ +sdmmc_write_recovery=iminfo $fileaddr && mmc dev 1 && part start mmc 1 $part_recovery part_addr && part size mmc 1 $part_recovery part_size && run mmc_write_vol +_checkbootedfrom=setenv _checkbootedfrom ; if itest.l *81dffff0 == 434d4d65 ; then setenv bootedfrom eMMC ; else setenv bootedfrom SD ; fi +_init_env=setenv _init_env ; setenv _create_env ; saveenv ; saveenv -+_firstboot=setenv _firstboot ; led $bootled_pwr off ;led $bootled_rec on ; run _checkbootedfrom _switch_to_menu _update_bootdev _update_bootcmd _update_bootcmd2 _init_env boot_first ++_firstboot=setenv _firstboot ; led $bootled_pwr off ;led $bootled_rec on ; run _checkbootedfrom _switch_to_menu _update_bootcmd _update_bootcmd2 _init_env boot_first +_set_bootcmd_sdmmc=setenv boot_production "led $bootled_rec off ; led $bootled_pwr on ; run sdmmc_read_production && bootm $loadaddr ; led $bootled_pwr off" +_set_bootcmd_emmc=setenv boot_production "led $bootled_rec off ; led $bootled_pwr on ; run emmc_read_production && bootm $loadaddr ; led $bootled_pwr off" +_update_bootcmd=setenv _update_bootcmd ; if test "$bootedfrom" = "SD" ; then run _set_bootcmd_sdmmc ; else run _set_bootcmd_emmc ; fi ; setenv _set_bootcmd_sdmmc ; setenv _set_bootcmd_emmc +_set_bootcmd2_sdmmc=setenv boot_recovery "led $bootled_pwr off ; led $bootled_rec on ; run sdmmc_read_recovery && bootm $loadaddr ; led $bootled_rec off" +_set_bootcmd2_emmc=setenv boot_recovery "led $bootled_pwr off ; led $bootled_rec on ; run emmc_read_recovery && bootm $loadaddr ; led $bootled_rec off" +_update_bootcmd2=setenv _update_bootcmd2 ; if test "$bootedfrom" = "SD" ; then run _set_bootcmd2_sdmmc ; else run _set_bootcmd2_emmc ; fi ; setenv _set_bootcmd2_sdmmc ; setenv _set_bootcmd2_emmc -+_update_bootdev=setenv _update_bootdev ; if test "$bootedfrom" = "SD" ; then setenv bootargs "$console root=/dev/mmcblk1p65" ; else setenv bootargs "$console root=/dev/mmcblk0p65" ; fi +_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 [$bootedfrom] $ver" ; run _set_bm2 +_set_bm2=setenv _set_bm2 ; setenv bootmenu_2 "Boot production system from $bootedfrom.=run boot_production ; run bootmenu_confirm_return" ; run _set_bm3 diff --git a/package/boot/uboot-mediatek/patches/500-board-mt7623-fix-mmc-detect.patch b/package/boot/uboot-mediatek/patches/500-board-mt7623-fix-mmc-detect.patch deleted file mode 100644 index 2f0ed85e53..0000000000 --- a/package/boot/uboot-mediatek/patches/500-board-mt7623-fix-mmc-detect.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/board/mediatek/mt7623/mt7623_rfb.c -+++ b/board/mediatek/mt7623/mt7623_rfb.c -@@ -9,6 +9,7 @@ - #include - #include - #include -+#include - #include - #include - -@@ -31,8 +32,9 @@ int mmc_get_boot_dev(void) - { - int g_mmc_devid = -1; - char *uflag = (char *)0x81DFFFF0; -+ struct blk_desc *desc; - -- if (!find_mmc_device(1)) -+ if (blk_get_device_by_str("mmc", "1", &desc) < 0) - return 0; - - if (strncmp(uflag,"eMMC",4)==0) { diff --git a/target/linux/mediatek/dts/mt7623a-unielec-u7623-02.dts b/target/linux/mediatek/dts/mt7623a-unielec-u7623-02.dts index bcd81ba6da..75ee0723ec 100644 --- a/target/linux/mediatek/dts/mt7623a-unielec-u7623-02.dts +++ b/target/linux/mediatek/dts/mt7623a-unielec-u7623-02.dts @@ -9,4 +9,26 @@ / { model = "UniElec U7623-02 eMMC"; compatible = "unielec,u7623-02", "mediatek,mt7623"; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs = "earlycon=uart8250,mmio32,0x11004000 root=/dev/fit0"; + rootdisk = <&emmc_rootdisk>; + }; +}; + +&mmc0 { + card@0 { + compatible = "mmc-card"; + reg = <0>; + + block { + compatible = "block-device"; + partitions { + emmc_rootdisk: block-partition-env { + partno = <3>; + }; + }; + }; + }; }; diff --git a/target/linux/mediatek/image/mt7623.mk b/target/linux/mediatek/image/mt7623.mk index 2c4402da66..24663551e0 100644 --- a/target/linux/mediatek/image/mt7623.mk +++ b/target/linux/mediatek/image/mt7623.mk @@ -116,6 +116,8 @@ endif gzip ARTIFACTS := u-boot.bin preloader.bin sdcard.img.gz SUPPORTED_DEVICES := bananapi,bpi-r2 + DEVICE_COMPAT_VERSION := 1.1 + DEVICE_COMPAT_MESSAGE := Bootloader update required for switch to fitblk endef TARGET_DEVICES += bananapi_bpi-r2 diff --git a/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh index 5d12b6989e..98f76ff49f 100755 --- a/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh @@ -1,5 +1,20 @@ REQUIRE_IMAGE_METADATA=1 +platform_get_bootdev() { + local rootdisk="$(cat /sys/firmware/devicetree/base/chosen/rootdisk)" + local handle bootdev + for handle in /sys/class/block/*/of_node/phandle /sys/class/block/*/device/of_node/phandle; do + [ ! -e "$handle" ] && continue + if [ "$rootdisk" = "$(cat $handle)" ]; then + bootdev="${handle%/of_node/phandle}" + bootdev="${bootdev%/device}" + bootdev="${bootdev#/sys/class/block/}" + echo "$bootdev" + break + fi + done +} + # Legacy full system upgrade including preloader for MediaTek SoCs on eMMC or SD legacy_mtk_mmc_full_upgrade() { local diskdev partdev diff oldrecovery @@ -83,10 +98,10 @@ platform_do_upgrade() { case "$board" in bananapi,bpi-r2|\ unielec,u7623-02) - export_bootdevice - export_partdevice fitpart 3 - [ "$fitpart" ] || return 1 - EMMC_KERN_DEV="/dev/$fitpart" + [ -e /dev/fit0 ] && fitblk /dev/fit0 + [ -e /dev/fitrw ] && fitblk /dev/fitrw + bootdev="$(platform_get_bootdev)" + EMMC_KERN_DEV="/dev/$bootdev" emmc_do_upgrade "$1" ;; unielec,u7623-02-emmc-512m) diff --git a/target/linux/mediatek/mt7623/config-6.1 b/target/linux/mediatek/mt7623/config-6.1 index 765f14fe90..a083809e34 100644 --- a/target/linux/mediatek/mt7623/config-6.1 +++ b/target/linux/mediatek/mt7623/config-6.1 @@ -214,7 +214,7 @@ CONFIG_FB_SYS_COPYAREA=y CONFIG_FB_SYS_FILLRECT=y CONFIG_FB_SYS_FOPS=y CONFIG_FB_SYS_IMAGEBLIT=y -CONFIG_FIT_PARTITION=y +# CONFIG_FIT_PARTITION is not set CONFIG_FIXED_PHY=y CONFIG_FIX_EARLYCON_MEM=y CONFIG_FONT_8x16=y @@ -563,6 +563,7 @@ CONFIG_TREE_SRCU=y # CONFIG_UACCE is not set CONFIG_UBIFS_FS=y CONFIG_UEVENT_HELPER_PATH="" +CONFIG_UIMAGE_FIT_BLK=y CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h" CONFIG_UNINLINE_SPIN_UNLOCK=y CONFIG_UNWINDER_ARM=y diff --git a/target/linux/mediatek/patches-6.1/164-dts-mt7623-bpi-r2-rootdisk-for-fitblk.patch b/target/linux/mediatek/patches-6.1/164-dts-mt7623-bpi-r2-rootdisk-for-fitblk.patch new file mode 100644 index 0000000000..06d54ec462 --- /dev/null +++ b/target/linux/mediatek/patches-6.1/164-dts-mt7623-bpi-r2-rootdisk-for-fitblk.patch @@ -0,0 +1,53 @@ +--- a/arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts ++++ b/arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts +@@ -27,6 +27,8 @@ + chosen { + stdout-path = "serial2:115200n8"; + bootargs = "earlycon=uart8250,mmio32,0x11004000 console=ttyS2,115200n8 console=tty1"; ++ rootdisk-emmc = <&emmc_rootdisk>; ++ rootdisk-sd = <&sd_rootdisk>; + }; + + connector { +@@ -315,6 +317,20 @@ + vmmc-supply = <®_3p3v>; + vqmmc-supply = <®_1p8v>; + non-removable; ++ ++ card@0 { ++ compatible = "mmc-card"; ++ reg = <0>; ++ ++ block { ++ compatible = "block-device"; ++ partitions { ++ emmc_rootdisk: block-partition-fit { ++ partno = <3>; ++ }; ++ }; ++ }; ++ }; + }; + + &mmc1 { +@@ -328,6 +344,20 @@ + cd-gpios = <&pio 261 GPIO_ACTIVE_LOW>; + vmmc-supply = <®_3p3v>; + vqmmc-supply = <®_3p3v>; ++ ++ card@0 { ++ compatible = "mmc-card"; ++ reg = <0>; ++ ++ block { ++ compatible = "block-device"; ++ partitions { ++ sd_rootdisk: block-partition-fit { ++ partno = <3>; ++ }; ++ }; ++ }; ++ }; + }; + + &mt6323_leds { From 360d27eb76f09f310a47e81c8d2ef07897255fc1 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sat, 24 Feb 2024 03:32:13 +0000 Subject: [PATCH 08/18] kernel: fix warning when building fitblk on 32-bit platforms Kernel warns about comparision of different types without cast when building the fitblk driver on 32-bit platforms. Fix this by using `min_t(size_t, ...`. Fixes: 8fc5457869 ("kernel: add pending fitblk uImage.FIT sub-image block driver") Signed-off-by: Daniel Golle --- .../510-block-add-uImage.FIT-subimage-block-driver.patch | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/target/linux/generic/pending-6.1/510-block-add-uImage.FIT-subimage-block-driver.patch b/target/linux/generic/pending-6.1/510-block-add-uImage.FIT-subimage-block-driver.patch index 7ee66b318c..54234caf94 100644 --- a/target/linux/generic/pending-6.1/510-block-add-uImage.FIT-subimage-block-driver.patch +++ b/target/linux/generic/pending-6.1/510-block-add-uImage.FIT-subimage-block-driver.patch @@ -81,7 +81,7 @@ Signed-off-by: Daniel Golle swim_mod-y := swim.o swim_asm.o --- /dev/null +++ b/drivers/block/fitblk.c -@@ -0,0 +1,635 @@ +@@ -0,0 +1,636 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * uImage.FIT virtual block device driver. @@ -454,7 +454,8 @@ Signed-off-by: Daniel Golle + bytes_left = size; + fit_c = fit; + while (bytes_left > 0) { -+ bytes_to_copy = min(bytes_left, folio_size(folio) - offset_in_folio(folio, 0)); ++ bytes_to_copy = min_t(size_t, bytes_left, ++ folio_size(folio) - offset_in_folio(folio, 0)); + memcpy(fit_c, pre_fit, bytes_to_copy); + fit_c += bytes_to_copy; + bytes_left -= bytes_to_copy; From c378927ef82aead8753b66180b764eeb8724b8c0 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sat, 24 Feb 2024 03:59:02 +0000 Subject: [PATCH 09/18] procd: update to git HEAD 2f94972 hotplug-dispatch: don't filter empty env variables 1901aba system: break infite loop resolving rootfs type Signed-off-by: Daniel Golle --- package/system/procd/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/system/procd/Makefile b/package/system/procd/Makefile index 0af90c7d4a..5cbc44f0c0 100644 --- a/package/system/procd/Makefile +++ b/package/system/procd/Makefile @@ -12,9 +12,9 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/procd.git -PKG_MIRROR_HASH:=48e5d555b5beb15cf936e1d2433b8e614de64a4eaf25293f0211eeb9ac79d534 -PKG_SOURCE_DATE:=2023-11-28 -PKG_SOURCE_VERSION:=7e6c6efd6fbcc7955801c5e2ac915a90697e1fd9 +PKG_MIRROR_HASH:=fc7ea415ebb1946661c1204a16b2a2b129014d39521da5883524e5ced8c3c9b4 +PKG_SOURCE_DATE:=2024-02-24 +PKG_SOURCE_VERSION:=1901aba90b6841ec1a99a25224a92d2519c603fd CMAKE_INSTALL:=1 PKG_LICENSE:=GPL-2.0 From 79dae141570d9c003e0af7f39c6ee22730590998 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sat, 24 Feb 2024 17:00:46 +0000 Subject: [PATCH 10/18] mediatek: mt7623: bpi-r2: set root=/dev/fit0 in bootargs Set root=/dev/fit0 cmdline parameter as the kernel won't mount rootfs otherwise after the change from the FIT partition parser to the fitblk driver which replaces it. Fixes: 6368ed1ae5 ("mediatek: mt7623: phase out uImage.FIT partition parser") Signed-off-by: Daniel Golle --- .../164-dts-mt7623-bpi-r2-rootdisk-for-fitblk.patch | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/target/linux/mediatek/patches-6.1/164-dts-mt7623-bpi-r2-rootdisk-for-fitblk.patch b/target/linux/mediatek/patches-6.1/164-dts-mt7623-bpi-r2-rootdisk-for-fitblk.patch index 06d54ec462..2675aa2589 100644 --- a/target/linux/mediatek/patches-6.1/164-dts-mt7623-bpi-r2-rootdisk-for-fitblk.patch +++ b/target/linux/mediatek/patches-6.1/164-dts-mt7623-bpi-r2-rootdisk-for-fitblk.patch @@ -1,9 +1,11 @@ --- a/arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts +++ b/arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts -@@ -27,6 +27,8 @@ +@@ -26,7 +26,9 @@ + chosen { stdout-path = "serial2:115200n8"; - bootargs = "earlycon=uart8250,mmio32,0x11004000 console=ttyS2,115200n8 console=tty1"; +- bootargs = "earlycon=uart8250,mmio32,0x11004000 console=ttyS2,115200n8 console=tty1"; ++ bootargs = "root=/dev/fit0 earlycon=uart8250,mmio32,0x11004000 console=ttyS2,115200n8 console=tty1"; + rootdisk-emmc = <&emmc_rootdisk>; + rootdisk-sd = <&sd_rootdisk>; }; From dca146cc778cdab2858b46e4ef3a3073fd02ab50 Mon Sep 17 00:00:00 2001 From: Mieczyslaw Nalewaj Date: Wed, 14 Feb 2024 13:14:10 +0100 Subject: [PATCH 11/18] kernel: rtl8366_smi: explicitly set phy addr for switch By default rtl8366_smi use phy addr 0 at mii-bus to access switch registers. This patch allow to set it explicitly in dts-file: rtl8367 { compatible = "realtek,rtl8367b"; phy-id = <29>; /* switch address at mii-bus */ realtek,extif2 = <1 0 1 1 1 1 1 1 2>; mii-bus = <&mdio>; cpu-port = <7>; } Use default 0 address if not set. Backward compatibility tested on tplink archer c2 v1 (rtl8367rb switch) Signed-off-by: Serge Vasilugin [code style fixes, add explicit phy_id assignment in probe_plat, use phy-id instead of phy_id for of property name] Signed-off-by: Chuanhong Guo [rebase] Signed-off-by: Gaspare Bruno [added phy_id to struct rtl8366_smi] Signed-off-by: Mieczyslaw Nalewaj --- target/linux/generic/files/drivers/net/phy/rtl8366_smi.c | 8 ++++++-- target/linux/generic/files/drivers/net/phy/rtl8366_smi.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c index 028b9916e7..a26fd204cb 100644 --- a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c +++ b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c @@ -256,7 +256,7 @@ static int __rtl8366_smi_read_reg(struct rtl8366_smi *smi, u32 addr, u32 *data) int __rtl8366_mdio_read_reg(struct rtl8366_smi *smi, u32 addr, u32 *data) { - u32 phy_id = MDC_REALTEK_PHY_ADDR; + u32 phy_id = smi->phy_id; struct mii_bus *mbus = smi->ext_mbus; BUG_ON(in_interrupt()); @@ -293,7 +293,7 @@ int __rtl8366_mdio_read_reg(struct rtl8366_smi *smi, u32 addr, u32 *data) static int __rtl8366_mdio_write_reg(struct rtl8366_smi *smi, u32 addr, u32 data) { - u32 phy_id = MDC_REALTEK_PHY_ADDR; + u32 phy_id = smi->phy_id; struct mii_bus *mbus = smi->ext_mbus; BUG_ON(in_interrupt()); @@ -1547,6 +1547,9 @@ int rtl8366_smi_probe_of(struct platform_device *pdev, struct rtl8366_smi *smi) goto try_gpio; } + if (of_property_read_u32(np, "phy-id", &smi->phy_id)) + smi->phy_id = MDC_REALTEK_PHY_ADDR; + return 0; try_gpio: @@ -1586,6 +1589,7 @@ int rtl8366_smi_probe_plat(struct platform_device *pdev, struct rtl8366_smi *smi smi->gpio_sda = pdata->gpio_sda; smi->gpio_sck = pdata->gpio_sck; smi->hw_reset = pdata->hw_reset; + smi->phy_id = MDC_REALTEK_PHY_ADDR; return 0; } diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h index fabc940278..3fcae81fa4 100644 --- a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h +++ b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h @@ -63,6 +63,7 @@ struct rtl8366_smi { u16 dbg_reg; u8 dbg_vlan_4k_page; #endif + u32 phy_id; struct mii_bus *ext_mbus; }; From 4b81eda3c1a9b9ef32640df9402e3650fb48d98b Mon Sep 17 00:00:00 2001 From: Mieczyslaw Nalewaj Date: Wed, 14 Feb 2024 20:27:23 +0100 Subject: [PATCH 12/18] kernel: support for RTL8367C/S switch From driver point of view no differance between rtl8367b and rtl8367s if it connected through EXT2 (rgmii only). So this trivial patch add some identification and initialization only. SGMII/HSGMII mode for EXT1 is not implemented for the sake of patch clairity. Signed-off-by: Serge Vasilugin [Fix code format] Signed-off-by: DENG Qingfang [add flags to separate chip_num/chip_id detection; drop error print in rtl8367b_init_regs, drop unnecessary info prints, code style fixes] Signed-off-by: Chuanhong Guo [rebase; use MII macros] Signed-off-by: Gaspare Bruno [code optimization] Signed-off-by: Mieczyslaw Nalewaj --- .../generic/files/drivers/net/phy/rtl8367b.c | 67 +++++++++++++------ 1 file changed, 47 insertions(+), 20 deletions(-) diff --git a/target/linux/generic/files/drivers/net/phy/rtl8367b.c b/target/linux/generic/files/drivers/net/phy/rtl8367b.c index 3599791a51..cd0d58cbfa 100644 --- a/target/linux/generic/files/drivers/net/phy/rtl8367b.c +++ b/target/linux/generic/files/drivers/net/phy/rtl8367b.c @@ -605,6 +605,20 @@ static const struct rtl8367b_initval rtl8367r_vb_initvals_1[] = { {0x133E, 0x000E}, {0x133F, 0x0010}, }; +static const struct rtl8367b_initval rtl8367c_initvals[] = { + {0x13c2, 0x0000}, {0x0018, 0x0f00}, {0x0038, 0x0f00}, {0x0058, 0x0f00}, + {0x0078, 0x0f00}, {0x0098, 0x0f00}, {0x1d15, 0x0a69}, {0x2000, 0x1340}, + {0x2020, 0x1340}, {0x2040, 0x1340}, {0x2060, 0x1340}, {0x2080, 0x1340}, + {0x13eb, 0x15bb}, {0x1303, 0x06d6}, {0x1304, 0x0700}, {0x13E2, 0x003F}, + {0x13F9, 0x0090}, {0x121e, 0x03CA}, {0x1233, 0x0352}, {0x1237, 0x00a0}, + {0x123a, 0x0030}, {0x1239, 0x0084}, {0x0301, 0x1000}, {0x1349, 0x001F}, + {0x18e0, 0x4004}, {0x122b, 0x641c}, {0x1305, 0xc000}, {0x1200, 0x7fcb}, + {0x0884, 0x0003}, {0x06eb, 0x0001}, {0x00cf, 0xffff}, {0x00d0, 0x0007}, + {0x00ce, 0x48b0}, {0x00ce, 0x48b0}, {0x0398, 0xffff}, {0x0399, 0x0007}, + {0x0300, 0x0001}, {0x03fa, 0x0007}, {0x08c8, 0x00c0}, {0x0a30, 0x020e}, + {0x0800, 0x0000}, {0x0802, 0x0000}, {0x09da, 0x0017}, {0x1d32, 0x0002}, +}; + static int rtl8367b_write_initvals(struct rtl8366_smi *smi, const struct rtl8367b_initval *initvals, int count) @@ -716,31 +730,35 @@ static int rtl8367b_write_phy_reg(struct rtl8366_smi *smi, static int rtl8367b_init_regs(struct rtl8366_smi *smi) { const struct rtl8367b_initval *initvals; + u32 chip_num; u32 chip_ver; u32 rlvid; int count; int err; REG_WR(smi, RTL8367B_RTL_MAGIC_ID_REG, RTL8367B_RTL_MAGIC_ID_VAL); + REG_RD(smi, RTL8367B_CHIP_NUMBER_REG, &chip_num); REG_RD(smi, RTL8367B_CHIP_VER_REG, &chip_ver); - rlvid = (chip_ver >> RTL8367B_CHIP_VER_RLVID_SHIFT) & - RTL8367B_CHIP_VER_RLVID_MASK; - - switch (rlvid) { - case 0: - initvals = rtl8367r_vb_initvals_0; - count = ARRAY_SIZE(rtl8367r_vb_initvals_0); - break; - - case 1: - initvals = rtl8367r_vb_initvals_1; - count = ARRAY_SIZE(rtl8367r_vb_initvals_1); - break; - - default: - dev_err(smi->parent, "unknow rlvid %u\n", rlvid); - return -ENODEV; + if ((chip_ver == 0x0020 || chip_ver == 0x00A0) && chip_num == 0x6367) { + initvals = rtl8367c_initvals; + count = ARRAY_SIZE(rtl8367c_initvals); + } else { + rlvid = (chip_ver >> RTL8367B_CHIP_VER_RLVID_SHIFT) & + RTL8367B_CHIP_VER_RLVID_MASK; + switch (rlvid) { + case 0: + initvals = rtl8367r_vb_initvals_0; + count = ARRAY_SIZE(rtl8367r_vb_initvals_0); + break; + case 1: + initvals = rtl8367r_vb_initvals_1; + count = ARRAY_SIZE(rtl8367r_vb_initvals_1); + break; + default: + dev_err(smi->parent, "unknow rlvid %u\n", rlvid); + return -ENODEV; + } } /* TODO: disable RLTP */ @@ -1509,7 +1527,7 @@ static int rtl8367b_mii_write(struct mii_bus *bus, int addr, int reg, u16 val) static int rtl8367b_detect(struct rtl8366_smi *smi) { - const char *chip_name; + const char *chip_name = NULL; u32 chip_num; u32 chip_ver; u32 chip_mode; @@ -1541,13 +1559,22 @@ static int rtl8367b_detect(struct rtl8366_smi *smi) } switch (chip_ver) { + case 0x0020: + if (chip_num == 0x6367) + chip_name = "8367RB-VB"; + break; + case 0x00A0: + if (chip_num == 0x6367) + chip_name = "8367S"; + break; case 0x1000: chip_name = "8367RB"; break; case 0x1010: chip_name = "8367R-VB"; - break; - default: + } + + if (!chip_name) { dev_err(smi->parent, "unknown chip num:%04x ver:%04x, mode:%04x\n", chip_num, chip_ver, chip_mode); From 9092fa3a539d9e1729f1003813c7c60c27346a3a Mon Sep 17 00:00:00 2001 From: Mieczyslaw Nalewaj Date: Fri, 23 Feb 2024 20:51:12 +0100 Subject: [PATCH 13/18] ramips: fix TP-Link Archer MAC address for ethernet This fixes: [ 0.981884] OF: /ethernet@10100000: #nvmem-cell-cells = 1 found 0 Signed-off-by: Mieczyslaw Nalewaj --- target/linux/ramips/dts/mt7620a_tplink_archer.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/ramips/dts/mt7620a_tplink_archer.dtsi b/target/linux/ramips/dts/mt7620a_tplink_archer.dtsi index 3579d9b53b..4ba19be495 100644 --- a/target/linux/ramips/dts/mt7620a_tplink_archer.dtsi +++ b/target/linux/ramips/dts/mt7620a_tplink_archer.dtsi @@ -118,7 +118,7 @@ ðernet { pinctrl-names = "default"; - nvmem-cells = <&macaddr_rom_f100>; + nvmem-cells = <&macaddr_rom_f100 0>; nvmem-cell-names = "mac-address"; mediatek,portmap = "wllll"; From fdd3a05c407d2d0793ec9434cd31197b15846f8d Mon Sep 17 00:00:00 2001 From: Mieczyslaw Nalewaj Date: Fri, 23 Feb 2024 20:53:37 +0100 Subject: [PATCH 14/18] ramips: add support for TP-Link Archer C5 v4 TP-Link Archer C5 v4 is a dual band router with 5 GbE ports Advertised as AC1200 for its 867Mbps (2x2) 5GHz band and 300 Mbps (2x2) 2.4GHz band. Specs: - SoC: MediaTek MT7620A - Ethernet: 5x GbE ports (Realtek RTL8367S) - Wireless 2.4GHz: MediaTek MT7620A - Wireless 5GHz: MediaTek MT7612E - RAM: 64MiB - ROM: 8MiB (GD25Q64CSIG) - 1 USB 2.0 port - 2 Buttons (WPS and reset) - 8 LEDs Flash instructions: Currently one has to install OpenWrt only via the serial console 1. Rename the factory.bin to to test.bin 2. start a TFTP server from IP address 192.168.0.225 and serve the image named test.bin 3. connect your device to the LAN port 4. power up the router and press 4 on the console to stop the boot process. 5. enter the following commands on the router console tftp 0x80060000 test.bin erase tplink 0x20000 0x7a0000 cp.b 0x80060000 0x20000 0x7a0000 reset Signed-off-by: DENG Qingfang [Update leds, add fast-read] Signed-off-by: Gaspare Bruno [Rebuilt version based on mt7620 tplink_archer.dtsi, support for external LNA, remove bad cell count info] Signed-off-by: Mieczyslaw Nalewaj --- .../dts/mt7620a_tplink_archer-c5-v4.dts | 127 ++++++++++++++++++ target/linux/ramips/image/mt7620.mk | 17 +++ .../mt7620/base-files/etc/board.d/01_leds | 4 + .../mt7620/base-files/etc/board.d/02_network | 7 + 4 files changed, 155 insertions(+) create mode 100644 target/linux/ramips/dts/mt7620a_tplink_archer-c5-v4.dts diff --git a/target/linux/ramips/dts/mt7620a_tplink_archer-c5-v4.dts b/target/linux/ramips/dts/mt7620a_tplink_archer-c5-v4.dts new file mode 100644 index 0000000000..4707bdf1e2 --- /dev/null +++ b/target/linux/ramips/dts/mt7620a_tplink_archer-c5-v4.dts @@ -0,0 +1,127 @@ +#include + +#include "mt7620a_tplink_archer.dtsi" + +/ { + compatible = "tplink,archer-c5-v4", "ralink,mt7620a-soc"; + model = "TP-Link Archer C5 v4"; + + aliases { + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + label-mac-device = ðernet; + }; + + leds { + compatible = "gpio-leds"; + + led_power: led-0 { + function = LED_FUNCTION_POWER; + color = ; + gpios = <&gpio2 2 GPIO_ACTIVE_LOW>; + }; + + led-1 { + function = LED_FUNCTION_WLAN; + color = ; + function-enumerator = <2>; + gpios = <&gpio0 14 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1tpt"; + }; + + led-2 { + function = LED_FUNCTION_WLAN; + color = ; + function-enumerator = <5>; + gpios = <&gpio0 12 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; + }; + + led-3 { + function = LED_FUNCTION_WAN; + color = ; + gpios = <&gpio0 10 GPIO_ACTIVE_LOW>; + }; + + led-4 { + function = LED_FUNCTION_WAN; + color = ; + gpios = <&gpio0 9 GPIO_ACTIVE_LOW>; + }; + + led-5 { + function = LED_FUNCTION_LAN; + color = ; + gpios = <&gpio0 8 GPIO_ACTIVE_HIGH>; + }; + + led-6 { + function = LED_FUNCTION_USB; + color = ; + gpios = <&gpio0 7 GPIO_ACTIVE_LOW>; + trigger-sources = <&ohci_port1>, <&ehci_port1>; + linux,default-trigger = "usbport"; + }; + + led-7 { + function = LED_FUNCTION_WPS; + color = ; + gpios = <&gpio0 1 GPIO_ACTIVE_LOW>; + }; + }; + + rtl8367s { + compatible = "realtek,rtl8367b"; + cpu_port = <7>; + realtek,extif2 = <1 0 1 1 1 1 1 1 2>; + mii-bus = <&mdio0>; + phy-id = <29>; + }; +}; + +&spi0 { + flash@0 { + #address-cells = <1>; + #size-cells = <1>; + }; +}; + +&state_default { + gpio { + groups = "i2c", "uartf", "ephy", "rgmii2"; + function = "gpio"; + }; +}; + +ðernet { + pinctrl-names = "default"; + pinctrl-0 = <&rgmii1_pins &mdio_pins>; + + port@5 { + status = "okay"; + mediatek,fixed-link = <1000 1 1 1>; + phy-mode = "rgmii"; + }; + + mdio0: mdio-bus { + status = "okay"; + reset-gpios = <&gpio2 20 GPIO_ACTIVE_LOW>; + reset-delay-us = <10000>; + }; +}; + +&wmac { + pinctrl-names = "default", "pa_gpio"; + pinctrl-0 = <&pa_pins>; + pinctrl-1 = <&pa_gpio_pins>; + + nvmem-cells = <&eeprom_radio_0>, <&macaddr_rom_f100 0>; + nvmem-cell-names = "eeprom", "mac-address"; +}; + +&wifi { + nvmem-cells = <&eeprom_radio_8000>, <&macaddr_rom_f100 2>; + nvmem-cell-names = "eeprom", "mac-address"; +}; diff --git a/target/linux/ramips/image/mt7620.mk b/target/linux/ramips/image/mt7620.mk index 883aacabe0..4b35cb6f87 100644 --- a/target/linux/ramips/image/mt7620.mk +++ b/target/linux/ramips/image/mt7620.mk @@ -1214,6 +1214,23 @@ define Device/tplink_archer-c2-v1 endef TARGET_DEVICES += tplink_archer-c2-v1 +define Device/tplink_archer-c5-v4 + $(Device/tplink-v2) + SOC := mt7620a + IMAGE_SIZE := 7808k + TPLINK_FLASHLAYOUT := 8Mmtk + TPLINK_HWID := 0x04da857c + TPLINK_HWREV := 0x0c000600 + TPLINK_HWREVADD := 0x04000000 + IMAGES += tftp-recovery.bin + IMAGE/tftp-recovery.bin := pad-extra 128k | $$(IMAGE/factory.bin) + DEVICE_MODEL := Archer C5 + DEVICE_VARIANT := v4 + DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport \ + kmod-mt76x2 kmod-switch-rtl8367b +endef +TARGET_DEVICES += tplink_archer-c5-v4 + define Device/tplink_archer-c50-v1 $(Device/tplink-v2) SOC := mt7620a diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds index c4f7fcbb87..ffc5745e6f 100644 --- a/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds @@ -225,6 +225,10 @@ tplink,archer-c20i) ucidef_set_led_switch "lan" "lan" "blue:lan" "switch0" "0x1e" ucidef_set_led_switch "wan" "wan" "blue:wan" "switch0" "0x01" ;; +tplink,archer-c5-v4) + ucidef_set_led_switch "lan" "lan" "green:lan" "switch1" "0x0f" + ucidef_set_led_switch "wan" "wan" "green:wan" "switch1" "0x10" + ;; tplink,archer-c50-v1) ucidef_set_led_switch "lan" "lan" "green:lan" "switch0" "0x1e" ucidef_set_led_switch "wan" "wan" "green:wan" "switch0" "0x01" diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network index cbfb8a1d86..167bb47b69 100644 --- a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network @@ -235,6 +235,12 @@ ramips_setup_interfaces() ucidef_add_switch "switch0" \ "1:lan:3" "2:lan:4" "3:lan:1" "4:lan:2" "0:wan" "6@eth0" ;; + tplink,archer-c5-v4) + ucidef_add_switch "switch0" + ucidef_add_switch_attr "switch0" "enable" "0" + ucidef_add_switch "switch1" \ + "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "7@eth0" + ;; tplink,archer-mr200) ucidef_add_switch "switch0" \ "0:lan" "1:lan" "2:lan" "3:lan" "6t@eth0" @@ -407,6 +413,7 @@ ramips_setup_macs() tplink,archer-c2-v1|\ tplink,archer-c20-v1|\ tplink,archer-c20i|\ + tplink,archer-c5-v4|\ tplink,archer-c50-v1|\ tplink,archer-mr200) wan_mac=$(macaddr_add "$(mtd_get_mac_binary rom 0xf100)" 1) From 33e72e0b3d3ba90b2eeeab1c61ff8597693c000d Mon Sep 17 00:00:00 2001 From: John Audia Date: Fri, 23 Feb 2024 15:40:12 -0500 Subject: [PATCH 15/18] kernel: bump 6.1 to 6.1.79 Changelog: https://cdn.kernel.org/pub/linux/kernel/v6.x/ChangeLog-6.1.79 Manually rebased: ath79/patches-6.1/900-unaligned_access_hacks.patch All other patches automatically rebased. Build system: x86/64 Build-tested: x86/64/AMD Cezanne, ramips/tplink_archer-a6-v3, flogic/xiaomi_redmi-router-ax6000-ubootmod Run-tested: x86/64/AMD Cezanne, ramips/tplink_archer-a6-v3, flogic/xiaomi_redmi-router-ax6000-ubootmod Signed-off-by: John Audia --- include/kernel-6.1 | 4 ++-- .../patches-6.1/900-unaligned_access_hacks.patch | 5 +++-- .../patches-6.1/950-0106-Add-dwc_otg-driver.patch | 2 +- ...rq-brcmstb-l2-Add-config-for-2711-controlle.patch | 2 +- ...t-stmmac-move-TX-timer-arm-after-DMA-enable.patch | 8 ++++---- ...erty-make-.-cells-optional-for-simple-props.patch | 2 +- ...3-of-property-add-nvmem-cell-cells-property.patch | 2 +- target/linux/generic/hack-6.1/204-module_strip.patch | 12 ++++++------ .../linux/generic/hack-6.1/221-module_exports.patch | 6 +++--- target/linux/generic/hack-6.1/253-ksmbd-config.patch | 2 +- ...vert-Revert-driver-core-Set-fw_devlink-on-b.patch | 2 +- .../pending-6.1/103-kbuild-export-SUBARCH.patch | 2 +- .../pending-6.1/203-kallsyms_uncompressed.patch | 4 ++-- .../generic/pending-6.1/920-mangle_bootargs.patch | 2 +- ...mx6q-apalis-ixora-make-switch3-reset-button.patch | 2 +- ...01-net-dsa-add-out-of-band-tagging-protocol.patch | 4 ++-- .../825-i2c-MIPS-adds-ralink-I2C-driver.patch | 2 +- 17 files changed, 32 insertions(+), 31 deletions(-) diff --git a/include/kernel-6.1 b/include/kernel-6.1 index 95dede372a..6c05ca0236 100644 --- a/include/kernel-6.1 +++ b/include/kernel-6.1 @@ -1,2 +1,2 @@ -LINUX_VERSION-6.1 = .78 -LINUX_KERNEL_HASH-6.1.78 = 65206b969831236849c9906eba267e715734a93808e9909fd9b4f12eea10d689 +LINUX_VERSION-6.1 = .79 +LINUX_KERNEL_HASH-6.1.79 = faa49ca22fb55ed4d5ca2a55e07dd10e4e171cfc3b92568a631453cd2068b39b diff --git a/target/linux/ath79/patches-6.1/900-unaligned_access_hacks.patch b/target/linux/ath79/patches-6.1/900-unaligned_access_hacks.patch index b6f6d63f68..945143867a 100644 --- a/target/linux/ath79/patches-6.1/900-unaligned_access_hacks.patch +++ b/target/linux/ath79/patches-6.1/900-unaligned_access_hacks.patch @@ -86,7 +86,7 @@ SVN-Revision: 35130 } while (word != stop); return csum_fold(csum); -@@ -179,73 +183,6 @@ static inline __sum16 ip_compute_csum(co +@@ -179,74 +183,6 @@ static inline __sum16 ip_compute_csum(co return csum_fold(csum_partial(buff, len, 0)); } @@ -152,7 +152,8 @@ SVN-Revision: 35130 - " .set pop" - : "=&r" (sum), "=&r" (tmp) - : "r" (saddr), "r" (daddr), -- "0" (htonl(len)), "r" (htonl(proto)), "r" (sum)); +- "0" (htonl(len)), "r" (htonl(proto)), "r" (sum) +- : "memory"); - - return csum_fold(sum); -} diff --git a/target/linux/bcm27xx/patches-6.1/950-0106-Add-dwc_otg-driver.patch b/target/linux/bcm27xx/patches-6.1/950-0106-Add-dwc_otg-driver.patch index 02fc0ed49a..f8ab3b04a1 100644 --- a/target/linux/bcm27xx/patches-6.1/950-0106-Add-dwc_otg-driver.patch +++ b/target/linux/bcm27xx/patches-6.1/950-0106-Add-dwc_otg-driver.patch @@ -1185,7 +1185,7 @@ Signed-off-by: Jonathan Bell } --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c -@@ -5669,7 +5669,7 @@ static void port_event(struct usb_hub *h +@@ -5677,7 +5677,7 @@ static void port_event(struct usb_hub *h port_dev->over_current_count++; port_over_current_notify(port_dev); diff --git a/target/linux/bcm27xx/patches-6.1/950-0918-irqchip-irq-brcmstb-l2-Add-config-for-2711-controlle.patch b/target/linux/bcm27xx/patches-6.1/950-0918-irqchip-irq-brcmstb-l2-Add-config-for-2711-controlle.patch index 5ea212d4a7..039c5fd74f 100644 --- a/target/linux/bcm27xx/patches-6.1/950-0918-irqchip-irq-brcmstb-l2-Add-config-for-2711-controlle.patch +++ b/target/linux/bcm27xx/patches-6.1/950-0918-irqchip-irq-brcmstb-l2-Add-config-for-2711-controlle.patch @@ -52,7 +52,7 @@ Signed-off-by: Dom Cobley /* L2 intc private data structure */ struct brcmstb_l2_intc_data { struct irq_domain *domain; -@@ -286,11 +296,18 @@ static int __init brcmstb_l2_lvl_intc_of +@@ -289,11 +299,18 @@ static int __init brcmstb_l2_lvl_intc_of return brcmstb_l2_intc_of_init(np, parent, &l2_lvl_intc_init); } diff --git a/target/linux/generic/backport-6.1/771-v6.7-02-net-stmmac-move-TX-timer-arm-after-DMA-enable.patch b/target/linux/generic/backport-6.1/771-v6.7-02-net-stmmac-move-TX-timer-arm-after-DMA-enable.patch index 4e9e951598..95dd24881b 100644 --- a/target/linux/generic/backport-6.1/771-v6.7-02-net-stmmac-move-TX-timer-arm-after-DMA-enable.patch +++ b/target/linux/generic/backport-6.1/771-v6.7-02-net-stmmac-move-TX-timer-arm-after-DMA-enable.patch @@ -42,7 +42,7 @@ Signed-off-by: Paolo Abeni __netif_tx_unlock_bh(netdev_get_tx_queue(priv->dev, queue)); -@@ -5485,12 +5489,13 @@ static int stmmac_napi_poll_tx(struct na +@@ -5488,12 +5492,13 @@ static int stmmac_napi_poll_tx(struct na struct stmmac_channel *ch = container_of(napi, struct stmmac_channel, tx_napi); struct stmmac_priv *priv = ch->priv_data; @@ -57,7 +57,7 @@ Signed-off-by: Paolo Abeni work_done = min(work_done, budget); if (work_done < budget && napi_complete_done(napi, work_done)) { -@@ -5501,6 +5506,10 @@ static int stmmac_napi_poll_tx(struct na +@@ -5504,6 +5509,10 @@ static int stmmac_napi_poll_tx(struct na spin_unlock_irqrestore(&ch->lock, flags); } @@ -68,7 +68,7 @@ Signed-off-by: Paolo Abeni return work_done; } -@@ -5509,12 +5518,13 @@ static int stmmac_napi_poll_rxtx(struct +@@ -5512,12 +5521,13 @@ static int stmmac_napi_poll_rxtx(struct struct stmmac_channel *ch = container_of(napi, struct stmmac_channel, rxtx_napi); struct stmmac_priv *priv = ch->priv_data; @@ -83,7 +83,7 @@ Signed-off-by: Paolo Abeni tx_done = min(tx_done, budget); rx_done = stmmac_rx_zc(priv, budget, chan); -@@ -5539,6 +5549,10 @@ static int stmmac_napi_poll_rxtx(struct +@@ -5542,6 +5552,10 @@ static int stmmac_napi_poll_rxtx(struct spin_unlock_irqrestore(&ch->lock, flags); } diff --git a/target/linux/generic/backport-6.1/827-v6.3-0002-of-property-make-.-cells-optional-for-simple-props.patch b/target/linux/generic/backport-6.1/827-v6.3-0002-of-property-make-.-cells-optional-for-simple-props.patch index 3af514c42d..66c29126b6 100644 --- a/target/linux/generic/backport-6.1/827-v6.3-0002-of-property-make-.-cells-optional-for-simple-props.patch +++ b/target/linux/generic/backport-6.1/827-v6.3-0002-of-property-make-.-cells-optional-for-simple-props.patch @@ -21,7 +21,7 @@ Signed-off-by: Greg Kroah-Hartman --- a/drivers/of/property.c +++ b/drivers/of/property.c -@@ -1144,8 +1144,8 @@ static struct device_node *parse_prop_ce +@@ -1146,8 +1146,8 @@ static struct device_node *parse_prop_ce if (strcmp(prop_name, list_name)) return NULL; diff --git a/target/linux/generic/backport-6.1/827-v6.3-0003-of-property-add-nvmem-cell-cells-property.patch b/target/linux/generic/backport-6.1/827-v6.3-0003-of-property-add-nvmem-cell-cells-property.patch index 025f094987..07354d7da7 100644 --- a/target/linux/generic/backport-6.1/827-v6.3-0003-of-property-add-nvmem-cell-cells-property.patch +++ b/target/linux/generic/backport-6.1/827-v6.3-0003-of-property-add-nvmem-cell-cells-property.patch @@ -19,7 +19,7 @@ Signed-off-by: Greg Kroah-Hartman --- a/drivers/of/property.c +++ b/drivers/of/property.c -@@ -1249,7 +1249,7 @@ DEFINE_SIMPLE_PROP(dmas, "dmas", "#dma-c +@@ -1251,7 +1251,7 @@ DEFINE_SIMPLE_PROP(dmas, "dmas", "#dma-c DEFINE_SIMPLE_PROP(power_domains, "power-domains", "#power-domain-cells") DEFINE_SIMPLE_PROP(hwlocks, "hwlocks", "#hwlock-cells") DEFINE_SIMPLE_PROP(extcon, "extcon", NULL) diff --git a/target/linux/generic/hack-6.1/204-module_strip.patch b/target/linux/generic/hack-6.1/204-module_strip.patch index bd168649f2..9fefd0bd6e 100644 --- a/target/linux/generic/hack-6.1/204-module_strip.patch +++ b/target/linux/generic/hack-6.1/204-module_strip.patch @@ -141,7 +141,7 @@ Signed-off-by: Felix Fietkau --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c -@@ -1781,7 +1781,9 @@ static void read_symbols(const char *mod +@@ -1785,7 +1785,9 @@ static void read_symbols(const char *mod symname = remove_dot(info.strtab + sym->st_name); handle_symbol(mod, &info, sym, symname); @@ -151,7 +151,7 @@ Signed-off-by: Felix Fietkau } for (sym = info.symtab_start; sym < info.symtab_stop; sym++) { -@@ -1944,8 +1946,10 @@ static void add_header(struct buffer *b, +@@ -1948,8 +1950,10 @@ static void add_header(struct buffer *b, buf_printf(b, "BUILD_SALT;\n"); buf_printf(b, "BUILD_LTO_INFO;\n"); buf_printf(b, "\n"); @@ -162,7 +162,7 @@ Signed-off-by: Felix Fietkau buf_printf(b, "\n"); buf_printf(b, "__visible struct module __this_module\n"); buf_printf(b, "__section(\".gnu.linkonce.this_module\") = {\n"); -@@ -1959,8 +1963,10 @@ static void add_header(struct buffer *b, +@@ -1963,8 +1967,10 @@ static void add_header(struct buffer *b, buf_printf(b, "\t.arch = MODULE_ARCH_INIT,\n"); buf_printf(b, "};\n"); @@ -173,7 +173,7 @@ Signed-off-by: Felix Fietkau buf_printf(b, "\n" -@@ -1968,8 +1974,10 @@ static void add_header(struct buffer *b, +@@ -1972,8 +1978,10 @@ static void add_header(struct buffer *b, "MODULE_INFO(retpoline, \"Y\");\n" "#endif\n"); @@ -184,7 +184,7 @@ Signed-off-by: Felix Fietkau if (strstarts(mod->name, "tools/testing")) buf_printf(b, "\nMODULE_INFO(test, \"Y\");\n"); -@@ -2065,11 +2073,13 @@ static void add_depends(struct buffer *b +@@ -2069,11 +2077,13 @@ static void add_depends(struct buffer *b static void add_srcversion(struct buffer *b, struct module *mod) { @@ -198,7 +198,7 @@ Signed-off-by: Felix Fietkau } static void write_buf(struct buffer *b, const char *fname) -@@ -2155,7 +2165,9 @@ static void write_mod_c_file(struct modu +@@ -2159,7 +2169,9 @@ static void write_mod_c_file(struct modu add_exported_symbols(&buf, mod); add_versions(&buf, mod); add_depends(&buf, mod); diff --git a/target/linux/generic/hack-6.1/221-module_exports.patch b/target/linux/generic/hack-6.1/221-module_exports.patch index d1ff81613a..967510bcb6 100644 --- a/target/linux/generic/hack-6.1/221-module_exports.patch +++ b/target/linux/generic/hack-6.1/221-module_exports.patch @@ -30,7 +30,7 @@ Signed-off-by: Felix Fietkau /* Align . to a 8 byte boundary equals to maximum function alignment. */ #define ALIGN_FUNCTION() . = ALIGN(8) -@@ -512,14 +522,14 @@ +@@ -511,14 +521,14 @@ /* Kernel symbol table: Normal symbols */ \ __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \ __start___ksymtab = .; \ @@ -47,7 +47,7 @@ Signed-off-by: Felix Fietkau __stop___ksymtab_gpl = .; \ } \ \ -@@ -539,7 +549,7 @@ +@@ -538,7 +548,7 @@ \ /* Kernel symbol table: strings */ \ __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \ @@ -56,7 +56,7 @@ Signed-off-by: Felix Fietkau } \ \ /* __*init sections */ \ -@@ -1048,6 +1058,8 @@ +@@ -1042,6 +1052,8 @@ #define COMMON_DISCARDS \ SANITIZER_DISCARDS \ PATCHABLE_DISCARDS \ diff --git a/target/linux/generic/hack-6.1/253-ksmbd-config.patch b/target/linux/generic/hack-6.1/253-ksmbd-config.patch index 4bb5eb9a6c..a57c914180 100644 --- a/target/linux/generic/hack-6.1/253-ksmbd-config.patch +++ b/target/linux/generic/hack-6.1/253-ksmbd-config.patch @@ -10,7 +10,7 @@ Subject: [PATCH] Kconfig: add tristate for OID and ASNI string --- a/init/Kconfig +++ b/init/Kconfig -@@ -2004,7 +2004,7 @@ config PADATA +@@ -2013,7 +2013,7 @@ config PADATA bool config ASN1 diff --git a/target/linux/generic/hack-6.1/930-Revert-Revert-Revert-driver-core-Set-fw_devlink-on-b.patch b/target/linux/generic/hack-6.1/930-Revert-Revert-Revert-driver-core-Set-fw_devlink-on-b.patch index 98081c4b64..04aaab7adf 100644 --- a/target/linux/generic/hack-6.1/930-Revert-Revert-Revert-driver-core-Set-fw_devlink-on-b.patch +++ b/target/linux/generic/hack-6.1/930-Revert-Revert-Revert-driver-core-Set-fw_devlink-on-b.patch @@ -19,7 +19,7 @@ Signed-off-by: Rafał Miłecki --- a/drivers/base/core.c +++ b/drivers/base/core.c -@@ -1700,7 +1700,7 @@ static void device_links_purge(struct de +@@ -1702,7 +1702,7 @@ static void device_links_purge(struct de #define FW_DEVLINK_FLAGS_RPM (FW_DEVLINK_FLAGS_ON | \ DL_FLAG_PM_RUNTIME) diff --git a/target/linux/generic/pending-6.1/103-kbuild-export-SUBARCH.patch b/target/linux/generic/pending-6.1/103-kbuild-export-SUBARCH.patch index e6480ac03e..c8c0efaecf 100644 --- a/target/linux/generic/pending-6.1/103-kbuild-export-SUBARCH.patch +++ b/target/linux/generic/pending-6.1/103-kbuild-export-SUBARCH.patch @@ -10,7 +10,7 @@ Signed-off-by: Felix Fietkau --- a/Makefile +++ b/Makefile -@@ -606,7 +606,7 @@ endif +@@ -605,7 +605,7 @@ endif # Allows the usage of unstable features in stable compilers. export RUSTC_BOOTSTRAP := 1 diff --git a/target/linux/generic/pending-6.1/203-kallsyms_uncompressed.patch b/target/linux/generic/pending-6.1/203-kallsyms_uncompressed.patch index ce93b73af6..78ed262b78 100644 --- a/target/linux/generic/pending-6.1/203-kallsyms_uncompressed.patch +++ b/target/linux/generic/pending-6.1/203-kallsyms_uncompressed.patch @@ -13,7 +13,7 @@ Signed-off-by: Felix Fietkau --- a/init/Kconfig +++ b/init/Kconfig -@@ -1482,6 +1482,17 @@ config SYSCTL_ARCH_UNALIGN_ALLOW +@@ -1491,6 +1491,17 @@ config SYSCTL_ARCH_UNALIGN_ALLOW the unaligned access emulation. see arch/parisc/kernel/unaligned.c for reference @@ -105,7 +105,7 @@ Signed-off-by: Felix Fietkau --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh -@@ -160,6 +160,10 @@ kallsyms() +@@ -165,6 +165,10 @@ kallsyms() kallsymopt="${kallsymopt} --lto-clang" fi diff --git a/target/linux/generic/pending-6.1/920-mangle_bootargs.patch b/target/linux/generic/pending-6.1/920-mangle_bootargs.patch index db7274e7aa..4552b4cd66 100644 --- a/target/linux/generic/pending-6.1/920-mangle_bootargs.patch +++ b/target/linux/generic/pending-6.1/920-mangle_bootargs.patch @@ -13,7 +13,7 @@ Signed-off-by: Imre Kaloz --- a/init/Kconfig +++ b/init/Kconfig -@@ -1827,6 +1827,15 @@ config EMBEDDED +@@ -1836,6 +1836,15 @@ config EMBEDDED an embedded system so certain expert options are available for configuration. diff --git a/target/linux/imx/patches-6.1/301-ARM-dts-imx6q-apalis-ixora-make-switch3-reset-button.patch b/target/linux/imx/patches-6.1/301-ARM-dts-imx6q-apalis-ixora-make-switch3-reset-button.patch index 6f8c7ad727..95f572f35e 100644 --- a/target/linux/imx/patches-6.1/301-ARM-dts-imx6q-apalis-ixora-make-switch3-reset-button.patch +++ b/target/linux/imx/patches-6.1/301-ARM-dts-imx6q-apalis-ixora-make-switch3-reset-button.patch @@ -63,7 +63,7 @@ Signed-off-by: Petr Štetiar reg_3v3_vmmc: regulator-3v3-vmmc { compatible = "regulator-fixed"; enable-active-high; -@@ -260,6 +271,12 @@ +@@ -262,6 +273,12 @@ >; }; diff --git a/target/linux/ipq40xx/patches-6.1/701-net-dsa-add-out-of-band-tagging-protocol.patch b/target/linux/ipq40xx/patches-6.1/701-net-dsa-add-out-of-band-tagging-protocol.patch index ba50d64a76..ab01e6704a 100644 --- a/target/linux/ipq40xx/patches-6.1/701-net-dsa-add-out-of-band-tagging-protocol.patch +++ b/target/linux/ipq40xx/patches-6.1/701-net-dsa-add-out-of-band-tagging-protocol.patch @@ -136,7 +136,7 @@ Signed-off-by: Maxime Chevallier #include #include #include -@@ -4516,6 +4520,9 @@ static const u8 skb_ext_type_len[] = { +@@ -4517,6 +4521,9 @@ static const u8 skb_ext_type_len[] = { #if IS_ENABLED(CONFIG_MCTP_FLOWS) [SKB_EXT_MCTP] = SKB_EXT_CHUNKSIZEOF(struct mctp_flow), #endif @@ -146,7 +146,7 @@ Signed-off-by: Maxime Chevallier }; static __always_inline unsigned int skb_ext_total_length(void) -@@ -4536,6 +4543,9 @@ static __always_inline unsigned int skb_ +@@ -4537,6 +4544,9 @@ static __always_inline unsigned int skb_ #if IS_ENABLED(CONFIG_MCTP_FLOWS) skb_ext_type_len[SKB_EXT_MCTP] + #endif diff --git a/target/linux/ramips/patches-6.1/825-i2c-MIPS-adds-ralink-I2C-driver.patch b/target/linux/ramips/patches-6.1/825-i2c-MIPS-adds-ralink-I2C-driver.patch index 09f62ad51b..461cf6e222 100644 --- a/target/linux/ramips/patches-6.1/825-i2c-MIPS-adds-ralink-I2C-driver.patch +++ b/target/linux/ramips/patches-6.1/825-i2c-MIPS-adds-ralink-I2C-driver.patch @@ -59,7 +59,7 @@ Signed-off-by: John Crispin depends on ARCH_RENESAS || COMPILE_TEST --- a/drivers/i2c/busses/Makefile +++ b/drivers/i2c/busses/Makefile -@@ -97,6 +97,7 @@ obj-$(CONFIG_I2C_PCA_PLATFORM) += i2c-pc +@@ -95,6 +95,7 @@ obj-$(CONFIG_I2C_PCA_PLATFORM) += i2c-pc obj-$(CONFIG_I2C_PNX) += i2c-pnx.o obj-$(CONFIG_I2C_PXA) += i2c-pxa.o obj-$(CONFIG_I2C_PXA_PCI) += i2c-pxa-pci.o From 6d8b36bfd821aecc32a4357062ae83a6b3bcd2a9 Mon Sep 17 00:00:00 2001 From: Marcin Gajda Date: Sat, 24 Feb 2024 17:49:49 +0100 Subject: [PATCH 16/18] ipq40xx: Netgear LBR20 fix for proper img builds Without UBINIZE_OPTS it is possile to have error: "ubi0 error: ubi_attach_mtd_dev: failed to atach mtd23, error -22" This solve this problem. Signed-off-by: Marcin Gajda --- target/linux/ipq40xx/image/generic.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/target/linux/ipq40xx/image/generic.mk b/target/linux/ipq40xx/image/generic.mk index 61bc0ad619..8a83e27f54 100644 --- a/target/linux/ipq40xx/image/generic.mk +++ b/target/linux/ipq40xx/image/generic.mk @@ -849,6 +849,7 @@ define Device/netgear_lbr20 KERNEL_SIZE := 7340032 BLOCKSIZE := 128k PAGESIZE := 2048 + UBINIZE_OPTS := -E 5 IMAGE/factory.img := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | \ append-uImage-fakehdr filesystem | pad-to $$$$(KERNEL_SIZE) | \ append-ubi | netgear-dni From 52cd3c74f1de656f9fdefedc742ad72e2a8695b0 Mon Sep 17 00:00:00 2001 From: Mieczyslaw Nalewaj Date: Sat, 24 Feb 2024 21:59:40 +0100 Subject: [PATCH 17/18] ramips: TP-Link Archer C5 v4: license and file formatting fixes mt7620a_tplink_archer-c5-v4.dts - added missing SPDX-License-Identifier mt7620.mk: added missing tabulator Signed-off-by: Mieczyslaw Nalewaj --- target/linux/ramips/dts/mt7620a_tplink_archer-c5-v4.dts | 2 ++ target/linux/ramips/image/mt7620.mk | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/target/linux/ramips/dts/mt7620a_tplink_archer-c5-v4.dts b/target/linux/ramips/dts/mt7620a_tplink_archer-c5-v4.dts index 4707bdf1e2..c02b341d09 100644 --- a/target/linux/ramips/dts/mt7620a_tplink_archer-c5-v4.dts +++ b/target/linux/ramips/dts/mt7620a_tplink_archer-c5-v4.dts @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + #include #include "mt7620a_tplink_archer.dtsi" diff --git a/target/linux/ramips/image/mt7620.mk b/target/linux/ramips/image/mt7620.mk index 4b35cb6f87..04c3262920 100644 --- a/target/linux/ramips/image/mt7620.mk +++ b/target/linux/ramips/image/mt7620.mk @@ -1227,7 +1227,7 @@ define Device/tplink_archer-c5-v4 DEVICE_MODEL := Archer C5 DEVICE_VARIANT := v4 DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport \ - kmod-mt76x2 kmod-switch-rtl8367b + kmod-mt76x2 kmod-switch-rtl8367b endef TARGET_DEVICES += tplink_archer-c5-v4 From 3e8d2f2439d627e8798191b898628197a5dcd69e Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sun, 25 Feb 2024 01:38:39 +0000 Subject: [PATCH 18/18] mediatek: mt7623: bpi-r2: bump compat version on boot The device booting successfully indicates that bootloader has been updated. Set compat_version to 1.1 on new configs and bump compat_version to 1.1 on first boot after a successful sysupgrade. Fixes: 6368ed1ae5 ("mediatek: mt7623: phase out uImage.FIT partition parser") Signed-off-by: Daniel Golle --- .../base-files/etc/board.d/05_compat-version | 14 ++++++++++++++ .../etc/uci-defaults/05_fix-compat-version | 10 ++++++++++ 2 files changed, 24 insertions(+) create mode 100644 target/linux/mediatek/mt7623/base-files/etc/board.d/05_compat-version create mode 100644 target/linux/mediatek/mt7623/base-files/etc/uci-defaults/05_fix-compat-version diff --git a/target/linux/mediatek/mt7623/base-files/etc/board.d/05_compat-version b/target/linux/mediatek/mt7623/base-files/etc/board.d/05_compat-version new file mode 100644 index 0000000000..a4cf133a69 --- /dev/null +++ b/target/linux/mediatek/mt7623/base-files/etc/board.d/05_compat-version @@ -0,0 +1,14 @@ +. /lib/functions.sh +. /lib/functions/uci-defaults.sh + +board_config_update + +case "$(board_name)" in +bananapi,bpi-r2) + ucidef_set_compat_version "1.1" + ;; +esac + +board_config_flush + +exit 0 diff --git a/target/linux/mediatek/mt7623/base-files/etc/uci-defaults/05_fix-compat-version b/target/linux/mediatek/mt7623/base-files/etc/uci-defaults/05_fix-compat-version new file mode 100644 index 0000000000..ae3f16002f --- /dev/null +++ b/target/linux/mediatek/mt7623/base-files/etc/uci-defaults/05_fix-compat-version @@ -0,0 +1,10 @@ +. /lib/functions.sh + +case "$(board_name)" in +bananapi,bpi-r2) + uci set system.@system[0].compat_version="1.1" + uci commit system + ;; +esac + +exit 0