From 2e46e477e3e3efd8851bfcc2d87504e1b9034cf2 Mon Sep 17 00:00:00 2001 From: Jianhui Zhao Date: Thu, 22 Sep 2022 14:58:08 +0800 Subject: [PATCH] Revert "mt798x: add target mt2500" This reverts commit 88faaa778a24ef9dd556b1d8a7438632beab619b. --- ...atek-add-board-for-GL.iNet-GL-MT2500.patch | 1124 ----------------- 1 file changed, 1124 deletions(-) delete mode 100644 patches-mt798x-7.6.6.1/0102-target-mediatek-add-board-for-GL.iNet-GL-MT2500.patch diff --git a/patches-mt798x-7.6.6.1/0102-target-mediatek-add-board-for-GL.iNet-GL-MT2500.patch b/patches-mt798x-7.6.6.1/0102-target-mediatek-add-board-for-GL.iNet-GL-MT2500.patch deleted file mode 100644 index c6b7b2b..0000000 --- a/patches-mt798x-7.6.6.1/0102-target-mediatek-add-board-for-GL.iNet-GL-MT2500.patch +++ /dev/null @@ -1,1124 +0,0 @@ -From 7c8c67ac88f19a9240b3639deb2fc0acf8e2290f Mon Sep 17 00:00:00 2001 -From: Jianhui Zhao -Date: Thu, 22 Sep 2022 14:44:27 +0800 -Subject: [PATCH] target/mediatek: add board for GL.iNet GL-MT2500 - -Signed-off-by: Jianhui Zhao ---- - include/image.mk | 2 +- - package/system/fstools/Makefile | 26 +- - .../0001-add-support-for-dual-boot.patch | 574 ------------------ - .../patches/0001-support-partlable.patch | 23 + - ...-jffs2-mount-on-mtk-flash-workaround.patch | 14 - - .../mt7981/base-files/etc/board.d/02_network | 4 + - target/linux/mediatek/mt7981/config-5.4 | 5 +- - .../9999-block2mtd-support-partline.patch | 139 +++++ - .../9999-support-partition-split.patch | 186 ++++++ - 9 files changed, 362 insertions(+), 611 deletions(-) - delete mode 100644 package/system/fstools/patches/0001-add-support-for-dual-boot.patch - create mode 100644 package/system/fstools/patches/0001-support-partlable.patch - delete mode 100644 package/system/fstools/patches/0101-jffs2-mount-on-mtk-flash-workaround.patch - create mode 100644 target/linux/mediatek/patches-5.4/9999-block2mtd-support-partline.patch - create mode 100644 target/linux/mediatek/patches-5.4/9999-support-partition-split.patch - -diff --git a/include/image.mk b/include/image.mk -index 6c356d25c9..cae8cf1a87 100644 ---- a/include/image.mk -+++ b/include/image.mk -@@ -226,7 +226,7 @@ $(eval $(foreach S,$(NAND_BLOCKSIZE),$(call Image/mkfs/jffs2-nand/template,$(S)) - - define Image/mkfs/squashfs-common - $(STAGING_DIR_HOST)/bin/mksquashfs4 $(call mkfs_target_dir,$(1)) $@ \ -- -nopad -noappend -root-owned \ -+ -nopad -no-exports -noappend -root-owned \ - -comp $(SQUASHFSCOMP) $(SQUASHFSOPT) \ - -processors 1 - endef -diff --git a/package/system/fstools/Makefile b/package/system/fstools/Makefile -index 35da55b031..709a825227 100644 ---- a/package/system/fstools/Makefile -+++ b/package/system/fstools/Makefile -@@ -8,13 +8,13 @@ - include $(TOPDIR)/rules.mk - - PKG_NAME:=fstools --PKG_RELEASE:=1 -+PKG_RELEASE:=$(AUTORELEASE) - - PKG_SOURCE_PROTO:=git - PKG_SOURCE_URL=$(PROJECT_GIT)/project/fstools.git --PKG_MIRROR_HASH:=a485792d90c71cd4fb396ce97f42a57ee4d2a3d78e5f3fd0748270ffb14209e6 --PKG_SOURCE_DATE:=2021-01-04 --PKG_SOURCE_VERSION:=c53b18820756f6f32ad0782d3bf489422b7c4ad3 -+PKG_MIRROR_HASH:=1b16e5ef533c7b30b3ccc4b7001c18b23c44890021aa4ae54850dbec56e7dc7c -+PKG_SOURCE_DATE:=2022-06-02 -+PKG_SOURCE_VERSION:=93369be040612c906bcbb1631f44a92fa4122d24 - CMAKE_INSTALL:=1 - - PKG_LICENSE:=GPL-2.0 -@@ -32,21 +32,14 @@ include $(INCLUDE_DIR)/package.mk - include $(INCLUDE_DIR)/cmake.mk - - TARGET_LDFLAGS += $(if $(CONFIG_USE_GLIBC),-lrt) --TARGET_LDFLAGS += $(if $(CONFIG_USE_GLIBC),-ldl) - CMAKE_OPTIONS += $(if $(CONFIG_FSTOOLS_UBIFS_EXTROOT),-DCMAKE_UBIFS_EXTROOT=y) - CMAKE_OPTIONS += $(if $(CONFIG_FSTOOLS_OVL_MOUNT_FULL_ACCESS_TIME),-DCMAKE_OVL_MOUNT_FULL_ACCESS_TIME=y) - CMAKE_OPTIONS += $(if $(CONFIG_FSTOOLS_OVL_MOUNT_COMPRESS_ZLIB),-DCMAKE_OVL_MOUNT_COMPRESS_ZLIB=y) - --define Package/libfstools-bootparam -- SECTION:=libs -- CATEGORY:=Libraries -- TITLE:=Boot parameter library for OpenWrt filesystem tools --endef -- - define Package/fstools - SECTION:=base - CATEGORY:=Base system -- DEPENDS:=+ubox +USE_GLIBC:librt +NAND_SUPPORT:ubi-utils +libfstools-bootparam -+ DEPENDS:=+ubox +USE_GLIBC:librt +NAND_SUPPORT:ubi-utils - TITLE:=OpenWrt filesystem tools - MENU:=1 - endef -@@ -86,7 +79,7 @@ define Package/block-mount - SECTION:=base - CATEGORY:=Base system - TITLE:=Block device mounting and checking -- DEPENDS:=+ubox +libubox +libuci +libblobmsg-json +libjson-c +libfstools-bootparam -+ DEPENDS:=+ubox +libubox +libuci +libblobmsg-json +libjson-c - endef - - define Package/blockd -@@ -96,12 +89,6 @@ define Package/blockd - DEPENDS:=+block-mount +fstools +libubus +kmod-fs-autofs4 +libblobmsg-json +libjson-c - endef - --define Package/libfstools-bootparam/install -- $(INSTALL_DIR) $(1)/lib -- -- $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libfstools-bootparam.so $(1)/lib/ --endef -- - define Package/fstools/install - $(INSTALL_DIR) $(1)/sbin $(1)/lib - -@@ -145,7 +132,6 @@ define Build/InstallDev - $(CP) $(PKG_INSTALL_DIR)/usr/lib/libubi-utils.a $(1)/usr/lib/ - endef - --$(eval $(call BuildPackage,libfstools-bootparam)) - $(eval $(call BuildPackage,fstools)) - $(eval $(call BuildPackage,snapshot-tool)) - $(eval $(call BuildPackage,block-mount)) -diff --git a/package/system/fstools/patches/0001-add-support-for-dual-boot.patch b/package/system/fstools/patches/0001-add-support-for-dual-boot.patch -deleted file mode 100644 -index a4a9d6c117..0000000000 ---- a/package/system/fstools/patches/0001-add-support-for-dual-boot.patch -+++ /dev/null -@@ -1,574 +0,0 @@ ----- a/CMakeLists.txt --+++ b/CMakeLists.txt --@@ -5,6 +5,10 @@ ADD_DEFINITIONS(-Os -ggdb -Wall -Werror -- -- SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") -- --+ADD_LIBRARY(fstools-bootparam SHARED --+ boot_param.c) --+INSTALL(TARGETS fstools-bootparam LIBRARY DESTINATION lib) --+ -- ADD_LIBRARY(fstools SHARED -- libfstools/snapshot.c -- libfstools/extroot.c --@@ -15,7 +19,7 @@ ADD_LIBRARY(fstools SHARED -- libfstools/ubi.c -- libfstools/rootdisk.c -- libfstools/find.c) ---TARGET_LINK_LIBRARIES(fstools ubox) --+TARGET_LINK_LIBRARIES(fstools ubox fstools-bootparam) -- INSTALL(TARGETS fstools LIBRARY DESTINATION lib) -- -- ADD_LIBRARY(blkid-tiny SHARED --@@ -75,9 +79,9 @@ INSTALL(TARGETS blockd RUNTIME DESTINATI -- ADD_EXECUTABLE(block block.c probe.c probe-libblkid.c) -- IF(DEFINED CMAKE_UBIFS_EXTROOT) -- ADD_DEFINITIONS(-DUBIFS_EXTROOT) --- TARGET_LINK_LIBRARIES(block blkid-tiny dl uci ubox ubus blobmsg_json ubi-utils ${json}) --+ TARGET_LINK_LIBRARIES(block blkid-tiny fstools-bootparam dl uci ubox ubus blobmsg_json ubi-utils ${json}) -- ELSE(DEFINED CMAKE_UBIFS_EXTROOT) --- TARGET_LINK_LIBRARIES(block blkid-tiny dl uci ubox ubus blobmsg_json ${json}) --+ TARGET_LINK_LIBRARIES(block blkid-tiny fstools-bootparam dl uci ubox ubus blobmsg_json ${json}) -- ENDIF(DEFINED CMAKE_UBIFS_EXTROOT) -- INSTALL(TARGETS block RUNTIME DESTINATION sbin) -- ----- a/block.c --+++ b/block.c --@@ -47,6 +47,7 @@ -- #include -- -- #include "probe.h" --+#include "boot_param.h" -- -- #define AUTOFS_MOUNT_PATH "/tmp/run/blockd/" -- --@@ -89,6 +90,9 @@ static LIST_HEAD(devices); -- static int anon_mount, anon_swap, auto_mount, auto_swap, check_fs; -- static unsigned int delay_root; -- --+static char *hide_block_devs[3]; --+static uint32_t num_hide_block_devs; --+ -- enum { -- CFG_ANON_MOUNT, -- CFG_ANON_SWAP, --@@ -498,9 +502,12 @@ static struct probe_info* _probe_path(ch -- return probe_path(path); -- } -- --+static char* find_mount_point(char *block); --+ -- static int _cache_load(const char *path) -- { -- int gl_flags = GLOB_NOESCAPE | GLOB_MARK; --+ uint32_t i; -- int j; -- glob_t gl; -- --@@ -509,8 +516,30 @@ static int _cache_load(const char *path) -- -- for (j = 0; j < gl.gl_pathc; j++) { -- struct probe_info *pr = _probe_path(gl.gl_pathv[j]); --- if (pr) --+ bool skip_curr = false; --+ --+ if (pr) { --+ char *mp = find_mount_point(pr->dev); --+ if (mp) { --+ /* Skip blocks mounted as root or overlay */ --+ if (!strcmp(mp, "/rom") || --+ !strcmp(mp, "/overlay")) --+ continue; --+ } --+ --+ for (i = 0; i < num_hide_block_devs; i++) { --+ /* Skip blocks used for dual boot */ --+ if (!strcmp(hide_block_devs[i], pr->dev)) { --+ skip_curr = true; --+ break; --+ } --+ } --+ --+ if (skip_curr) --+ continue; --+ -- list_add_tail(&pr->list, &devices); --+ } -- } -- -- globfree(&gl); --@@ -1801,6 +1830,26 @@ static int main_swapoff(int argc, char * -- return 0; -- } -- --+static bool add_hide_block_dev(char *path) --+{ --+ if (num_hide_block_devs >= ARRAY_SIZE(hide_block_devs)) --+ return false; --+ --+ hide_block_devs[num_hide_block_devs++] = path; --+ return true; --+} --+ --+static void hide_boot_param_dev(const char *name) --+{ --+ char *path; --+ --+ path = boot_param_get_dev(name); --+ if (path) { --+ if (!add_hide_block_dev(path)) --+ free(path); --+ } --+} --+ -- int main(int argc, char **argv) -- { -- char *base = basename(*argv); --@@ -1810,6 +1859,10 @@ int main(int argc, char **argv) -- ulog_open(-1, -1, "block"); -- ulog_threshold(LOG_NOTICE); -- --+ hide_boot_param_dev("rootfs_data_part"); --+ hide_boot_param_dev("boot_rootfs_part"); --+ hide_boot_param_dev("upgrade_rootfs_part"); --+ -- if (!strcmp(base, "swapon")) -- return main_swapon(argc, argv); -- ----- a/boot_param.c --+++ b/boot_param.c --@@ -0,0 +1,270 @@ --+/* SPDX-License-Identifier: BSD-3-Clause */ --+/* --+ * Copyright (C) 2022 MediaTek Inc. All rights reserved. --+ * --+ * Author: Weijie Gao --+ */ --+ --+#include --+#include --+#include --+#include --+#include --+#include --+#include --+#include --+#include --+ --+#include --+#include --+#include "boot_param.h" --+ --+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) --+ --+#define BOOT_PARAM_STR_MAX_LEN 256 --+ --+static struct { --+ bool loaded; --+ blkid_probe (*new_probe_from_filename)(const char *); --+ int (*do_safeprobe)(blkid_probe); --+ int (*probe_lookup_value)(blkid_probe, const char *, const char **, size_t *); --+ void (*free_probe)(blkid_probe); --+ int (*probe_enable_partitions)(blkid_probe, int); --+ int (*probe_set_partitions_flags)(blkid_probe, int); --+} libblkid = {}; --+ --+bool read_boot_param_bool(const char *name) --+{ --+ char path[BOOT_PARAM_STR_MAX_LEN], val; --+ size_t len; --+ FILE *f; --+ --+ snprintf(path, sizeof(path), "/sys/module/boot_param/parameters/%s", --+ name); --+ --+ f = fopen(path, "rb"); --+ if (!f) --+ return false; --+ --+ len = fread(&val, 1, 1, f); --+ fclose(f); --+ --+ if (len != 1) --+ return false; --+ --+ return val == 'Y'; --+} --+ --+int read_boot_param_string(const char *name, char *val, size_t maxsize) --+{ --+ char path[BOOT_PARAM_STR_MAX_LEN]; --+ size_t len; --+ FILE *f; --+ --+ snprintf(path, sizeof(path), "/sys/module/boot_param/parameters/%s", --+ name); --+ --+ f = fopen(path, "rb"); --+ if (!f) { --+ val[0] = 0; --+ return -1; --+ } --+ --+ len = fread(val, 1, maxsize, f); --+ fclose(f); --+ --+ while (len > 0) { --+ if (val[len - 1] != '\n' && val[len - 1] != '\r') --+ break; --+ --+ len--; --+ } --+ --+ if (len < maxsize) --+ val[len] = 0; --+ --+ return len; --+} --+ --+int write_boot_param_string(const char *name, const char *val) --+{ --+ size_t wlen, len = strlen(val); --+ char path[BOOT_PARAM_STR_MAX_LEN]; --+ FILE *f; --+ --+ if (len >= BOOT_PARAM_STR_MAX_LEN) --+ return -1; --+ --+ snprintf(path, sizeof(path), "/sys/module/boot_param/parameters/%s", --+ name); --+ --+ f = fopen(path, "wb"); --+ if (!f) --+ return -1; --+ --+ wlen = fwrite(val, 1, len, f); --+ fclose(f); --+ --+ return wlen; --+} --+ --+static bool load_libblkid(void) --+{ --+ void *lib; --+ --+ if (libblkid.loaded) --+ return true; --+ --+ lib = dlopen("libblkid.so", RTLD_GLOBAL); --+ --+ if (!lib) --+ lib = dlopen("libblkid.so.1", RTLD_GLOBAL); --+ --+ if (!lib) --+ return false; --+ --+ libblkid.new_probe_from_filename = dlsym(lib, "blkid_new_probe_from_filename"); --+ if (!libblkid.new_probe_from_filename) --+ return false; --+ --+ libblkid.do_safeprobe = dlsym(lib, "blkid_do_safeprobe"); --+ if (!libblkid.do_safeprobe) --+ return false; --+ --+ libblkid.probe_lookup_value = dlsym(lib, "blkid_probe_lookup_value"); --+ if (!libblkid.probe_lookup_value) --+ return false; --+ --+ libblkid.free_probe = dlsym(lib, "blkid_free_probe"); --+ if (!libblkid.free_probe) --+ return false; --+ --+ libblkid.probe_enable_partitions = dlsym(lib, "blkid_probe_enable_partitions"); --+ if (!libblkid.probe_enable_partitions) --+ return false; --+ --+ libblkid.probe_set_partitions_flags = dlsym(lib, "blkid_probe_set_partitions_flags"); --+ if (!libblkid.probe_set_partitions_flags) --+ return false; --+ --+ libblkid.loaded = true; --+ return true; --+} --+ --+static char *lookup_block_dev(const char *path, const char *key, bool is_uuid) --+{ --+ int gl_flags = GLOB_NOESCAPE | GLOB_MARK; --+ const char *type, *value; --+ char *result = NULL; --+ size_t len; --+ glob_t gl; --+ int i; --+ --+ if (glob(path, gl_flags, NULL, &gl) < 0) --+ return NULL; --+ --+ type = is_uuid ? "PART_ENTRY_UUID" : "PART_ENTRY_NAME"; --+ --+ for (i = 0; i < gl.gl_pathc; i++) { --+ blkid_probe pr = libblkid.new_probe_from_filename(gl.gl_pathv[i]); --+ if (!pr) --+ continue; --+ --+ libblkid.probe_enable_partitions(pr, 1); --+ libblkid.probe_set_partitions_flags(pr, BLKID_PARTS_ENTRY_DETAILS); --+ --+ if (libblkid.do_safeprobe(pr)) --+ goto free_pr; --+ --+ if (!libblkid.probe_lookup_value(pr, type, &value, &len)) { --+ if (!strcmp(value, key)) --+ result = strdup(gl.gl_pathv[i]); --+ } --+ --+ free_pr: --+ libblkid.free_probe(pr); --+ --+ if (result) --+ break; --+ } --+ --+ globfree(&gl); --+ --+ return result; --+} --+ --+static char *find_block_dev(const char *key, bool is_uuid) --+{ --+ char *devpath = NULL; --+ int i; --+ --+ static const char *block_pats[] = { --+ "/dev/loop*", --+ "/dev/mmcblk*", --+ "/dev/sd*", --+ "/dev/hd*", --+ "/dev/md*", --+ "/dev/nvme*", --+ "/dev/vd*", --+ "/dev/xvd*", --+ "/dev/mapper/*", --+ }; --+ --+ if (!load_libblkid()) --+ return NULL; --+ --+ for (i = 0; i < ARRAY_SIZE(block_pats); i++) { --+ devpath = lookup_block_dev(block_pats[i], key, is_uuid); --+ if (devpath) --+ break; --+ } --+ --+ return devpath; --+} --+ --+char *blockdev_parse(const char *name) --+{ --+ char *e, *part_dev_path; --+ struct stat st; --+ --+ if (!name) --+ return NULL; --+ --+ e = strchr(name, '='); --+ if (e) { --+ *e = 0; --+ e++; --+ } --+ --+ if (!e) { --+ if (stat(name, &st)) --+ return NULL; --+ --+ if (!S_ISBLK(st.st_mode)) --+ return NULL; --+ --+ part_dev_path = strdup(name); --+ } else if (!strcmp(name, "PARTLABEL")) { --+ part_dev_path = find_block_dev(e, false); --+ } else if (!strcmp(name, "PARTUUID")) { --+ if (strlen(e) != 36) --+ return NULL; --+ part_dev_path = find_block_dev(e, true); --+ } else { --+ return NULL; --+ } --+ --+ return part_dev_path; --+} --+ --+char *boot_param_get_dev(const char *name) --+{ --+ char partkey[BOOT_PARAM_STR_MAX_LEN]; --+ --+ read_boot_param_string(name, partkey, sizeof(partkey)); --+ --+ if (!partkey[0]) --+ return NULL; --+ --+ return blockdev_parse(partkey); --+} ----- a/boot_param.h --+++ b/boot_param.h --@@ -0,0 +1,21 @@ --+// SPDX-License-Identifier: BSD-3-Clause --+/* --+ * Copyright (C) 2022 MediaTek Inc. All rights reserved. --+ * --+ * Author: Weijie Gao --+ */ --+ --+#ifndef _BOOT_PARAM_H_ --+#define _BOOT_PARAM_H_ --+ --+#include --+#include --+ --+bool read_boot_param_bool(const char *name); --+int read_boot_param_string(const char *name, char *val, size_t maxsize); --+int write_boot_param_string(const char *name, const char *val); --+ --+char *blockdev_parse(const char *name); --+char *boot_param_get_dev(const char *name); --+ --+#endif /* _BOOT_PARAM_H_ */ ----- a/libfstools/rootdisk.c --+++ b/libfstools/rootdisk.c --@@ -26,6 +26,7 @@ -- -- #include "libfstools.h" -- #include "volume.h" --+#include "../boot_param.h" -- -- #include -- --@@ -42,6 +43,7 @@ struct rootdev_volume { -- struct volume v; -- uint64_t offset; -- char loop_name[32]; --+ char *dev_path; -- }; -- -- static const char *rootdev; --@@ -109,11 +111,15 @@ static int get_squashfs(struct squashfs_ -- -- static bool rootdisk_use_f2fs(struct rootdev_volume *p) -- { --+ const char *dev = rootdev; -- uint64_t size = 0; -- bool ret = false; -- int fd; -- --- fd = open(rootdev, O_RDONLY); --+ if (p->dev_path) --+ dev = p->dev_path; --+ --+ fd = open(dev, O_RDONLY); -- if (ioctl(fd, BLKGETSIZE64, &size) == 0) -- ret = size - p->offset > F2FS_MINSIZE; -- close(fd); --@@ -121,6 +127,30 @@ static bool rootdisk_use_f2fs(struct roo -- return ret; -- } -- --+static struct volume *find_existed_rootfs_data(void) --+{ --+ struct rootdev_volume *p; --+ char *rootfs_data_dev; --+ --+ rootfs_data_dev = boot_param_get_dev("rootfs_data_part"); --+ --+ if (!rootfs_data_dev) --+ return NULL; --+ --+ ULOG_NOTE("Using existed rootfs_data device %s\n", rootfs_data_dev); --+ --+ write_boot_param_string("rootfs_data_part", rootfs_data_dev); --+ --+ p = calloc(1, sizeof(*p)); --+ p->v.drv = &rootdisk_driver; --+ p->v.name = "rootfs_data"; --+ --+ p->offset = 0; --+ p->dev_path = rootfs_data_dev; --+ --+ return &p->v; --+} --+ -- static struct volume *rootdisk_volume_find(char *name) -- { -- struct squashfs_super_block sb; --@@ -129,6 +159,9 @@ static struct volume *rootdisk_volume_fi -- if (strcmp(name, "rootfs_data") != 0) -- return NULL; -- --+ if (read_boot_param_bool("no_split_rootfs_data")) --+ return find_existed_rootfs_data(); --+ -- if (!rootdev) -- rootdev = get_rootdev("/"); -- if (!rootdev) --@@ -160,12 +193,16 @@ static struct volume *rootdisk_volume_fi -- static int rootdisk_volume_identify(struct volume *v) -- { -- struct rootdev_volume *p = container_of(v, struct rootdev_volume, v); --+ const char *dev = rootdev; -- int ret = FS_NONE; -- uint32_t magic = 0; -- size_t n; -- FILE *f; -- --- f = fopen(rootdev, "r"); --+ if (p->dev_path) --+ dev = p->dev_path; --+ --+ f = fopen(dev, "r"); -- if (!f) -- return ret; -- --@@ -265,6 +302,13 @@ static int rootdisk_volume_init(struct v -- char str[128]; -- int ret = 0; -- --+ if (p->dev_path) { --+ /* Do not create loop device with no_split_rootfs_data set */ --+ v->type = BLOCKDEV; --+ v->blk = p->dev_path; --+ goto do_format; --+ } --+ -- if (!p->loop_name[0] && rootdisk_create_loop(p) != 0) { -- ULOG_ERR("unable to create loop device\n"); -- return -1; --@@ -273,6 +317,7 @@ static int rootdisk_volume_init(struct v -- v->type = BLOCKDEV; -- v->blk = p->loop_name; -- --+do_format: -- switch (rootdisk_volume_identify(v)) { -- case FS_NONE: -- ULOG_INFO("rootdisk overlay filesystem has not been formatted yet\n"); ----- a/mount_root.c --+++ b/mount_root.c --@@ -23,6 +23,8 @@ -- #include "libfstools/libfstools.h" -- #include "libfstools/volume.h" -- --+#include "boot_param.h" --+ -- /* -- * Called in the early (PREINIT) stage, when we immediately need some writable -- * filesystem. --@@ -58,6 +60,12 @@ start(int argc, char *argv[1]) -- /* There isn't extroot, so just try to mount "rootfs_data" */ -- volume_init(data); -- switch (volume_identify(data)) { --+ case -1: --+ /* Use ramoverlay if no "rootfs_data" device found with no_split_rootfs_data set */ --+ if (!read_boot_param_bool("no_split_rootfs_data")) --+ break; --+ --+ /* fall through */ -- case FS_NONE: -- ULOG_WARN("no usable overlay filesystem found, using tmpfs overlay\n"); -- return ramoverlay(); -diff --git a/package/system/fstools/patches/0001-support-partlable.patch b/package/system/fstools/patches/0001-support-partlable.patch -new file mode 100644 -index 0000000000..35ede912e3 ---- /dev/null -+++ b/package/system/fstools/patches/0001-support-partlable.patch -@@ -0,0 +1,23 @@ -+Index: fstools-2022-06-02-93369be0/libfstools/partname.c -+=================================================================== -+--- fstools-2022-06-02-93369be0.orig/libfstools/partname.c -++++ fstools-2022-06-02-93369be0/libfstools/partname.c -+@@ -128,12 +128,13 @@ static struct volume *partname_volume_fi -+ return NULL; -+ } -+ -+- if (get_var_from_file("/proc/cmdline", "root", rootparam, sizeof(rootparam))) { -+- rootdev = rootdevname(rootparam); -+- /* find partition on same device as rootfs */ -+- snprintf(ueventgstr, sizeof(ueventgstr), "%s/%s/*/uevent", block_dir_name, rootdev); -++ if (get_var_from_file("/proc/cmdline", "root", rootparam, sizeof(rootparam)) && -++ strncmp(rootparam, "PARTLABEL=", 10)) { -++ rootdev = rootdevname(rootparam); -++ /* root= is not PARTLABEL, find partition on same device as rootfs */ -++ snprintf(ueventgstr, sizeof(ueventgstr), "%s/%s/*/uevent", block_dir_name, rootdev); -+ } else { -+- /* no 'root=' kernel cmdline parameter, find on any block device */ -++ /* PARTLABEL or no 'root=' kernel cmdline parameter, find on any block device */ -+ snprintf(ueventgstr, sizeof(ueventgstr), "%s/*/uevent", block_dir_name); -+ } -+ -diff --git a/package/system/fstools/patches/0101-jffs2-mount-on-mtk-flash-workaround.patch b/package/system/fstools/patches/0101-jffs2-mount-on-mtk-flash-workaround.patch -deleted file mode 100644 -index 4db38994d0..0000000000 ---- a/package/system/fstools/patches/0101-jffs2-mount-on-mtk-flash-workaround.patch -+++ /dev/null -@@ -1,14 +0,0 @@ --Index: fstools-2016-12-04-84b530a7/libfstools/mtd.c --=================================================================== ----- fstools-2016-12-04-84b530a7.orig/libfstools/mtd.c 2017-08-29 15:00:46.824333000 +0800 --+++ fstools-2016-12-04-84b530a7/libfstools/mtd.c 2017-08-29 15:02:52.848520000 +0800 --@@ -218,6 +218,9 @@ -- if (v->type == UBIVOLUME && deadc0de == 0xffffffff) { -- return FS_JFFS2; -- } --+ if (v->type == NANDFLASH && deadc0de == 0xffffffff) { --+ return FS_JFFS2; --+ } -- -- return FS_NONE; -- } -diff --git a/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network b/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network -index d9d4871cf1..fdb25296f4 100755 ---- a/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network -+++ b/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network -@@ -46,6 +46,10 @@ mediatek_setup_macs() - wan_mac=$(mtd_get_mac_binary $part_name 0x0a) - lan_mac=$(macaddr_add "$wan_mac" 1) - ;; -+ *mt2500*) -+ wan_mac=$(get_mac_binary /dev/mmcblk0boot1 0x0a) -+ lan_mac=$(macaddr_add "$wan_mac" 1) -+ ;; - esac - - [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" "$wan_mac" -diff --git a/target/linux/mediatek/mt7981/config-5.4 b/target/linux/mediatek/mt7981/config-5.4 -index 219c62fca8..7ee7a7609c 100644 ---- a/target/linux/mediatek/mt7981/config-5.4 -+++ b/target/linux/mediatek/mt7981/config-5.4 -@@ -264,6 +264,8 @@ CONFIG_MMC_MTK=y - CONFIG_MODULES_TREE_LOOKUP=y - CONFIG_MODULES_USE_ELF_RELA=y - CONFIG_MT753X_GSW=y -+CONFIG_MTD_BLOCK2MTD=y -+CONFIG_MTD_CMDLINE_PARTS=y - CONFIG_MTD_NAND_CORE=y - CONFIG_MTD_NAND_ECC_SW_HAMMING=y - CONFIG_MTD_NAND_MTK=y -@@ -325,6 +327,7 @@ CONFIG_OF_NET=y - CONFIG_OLD_SIGSUSPEND3=y - CONFIG_PADATA=y - CONFIG_PARTITION_PERCPU=y -+CONFIG_PARTITION_SPLIT=y - CONFIG_PCI=y - # CONFIG_PCIE_MEDIATEK is not set - CONFIG_PCIE_MEDIATEK_GEN3=y -@@ -467,7 +470,5 @@ CONFIG_XPS=y - CONFIG_ZLIB_DEFLATE=y - CONFIG_ZLIB_INFLATE=y - CONFIG_ZONE_DMA32=y --CONFIG_NVMEM=y --CONFIG_MTK_EFUSE=y - # CONFIG_MTD_SPI_NAND_W25N01KV is not set - # CONFIG_MAXLINEAR_GPHY is not set -diff --git a/target/linux/mediatek/patches-5.4/9999-block2mtd-support-partline.patch b/target/linux/mediatek/patches-5.4/9999-block2mtd-support-partline.patch -new file mode 100644 -index 0000000000..2e4c2555da ---- /dev/null -+++ b/target/linux/mediatek/patches-5.4/9999-block2mtd-support-partline.patch -@@ -0,0 +1,139 @@ -+Index: linux-5.4.188/drivers/mtd/devices/block2mtd.c -+=================================================================== -+--- linux-5.4.188.orig/drivers/mtd/devices/block2mtd.c -++++ linux-5.4.188/drivers/mtd/devices/block2mtd.c -+@@ -26,11 +26,14 @@ -+ #include -+ #include -+ #include -++#include -+ #include -+ #include -+ #include -+ #include -+ -++static const char * const block2mtd_probe_types[] = { "ofpart","cmdlinepart", NULL }; -++ -+ /* Info for the block device */ -+ struct block2mtd_dev { -+ struct list_head list; -+@@ -183,10 +186,9 @@ static int block2mtd_write(struct mtd_in -+ mutex_unlock(&dev->write_mutex); -+ if (err > 0) -+ err = 0; -++ sync_blockdev(dev->blkdev); -+ return err; -+ } -+- -+- -+ /* sync the device - wait until the write queue is empty */ -+ static void block2mtd_sync(struct mtd_info *mtd) -+ { -+@@ -214,12 +216,13 @@ static void block2mtd_free_device(struct -+ -+ -+ static struct block2mtd_dev *add_device(char *devname, int erase_size, -+- int timeout) -++ const char *mtdname, int timeout) -+ { -+ #ifndef MODULE -+ int i; -+ #endif -+ const fmode_t mode = FMODE_READ | FMODE_WRITE | FMODE_EXCL; -++ struct mtd_part_parser_data ppdata; -+ struct block_device *bdev; -+ struct block2mtd_dev *dev; -+ char *name; -+@@ -278,10 +281,13 @@ static struct block2mtd_dev *add_device( -+ -+ /* Setup the MTD structure */ -+ /* make the name contain the block device in */ -+- name = kasprintf(GFP_KERNEL, "block2mtd: %s", devname); -++ if (!mtdname) -++ mtdname = devname; -++ name = kmalloc(strlen(mtdname) + 1, GFP_KERNEL); -+ if (!name) -+ goto err_destroy_mutex; -+ -++ strcpy(name, mtdname); -+ dev->mtd.name = name; -+ -+ dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK; -+@@ -292,12 +298,14 @@ static struct block2mtd_dev *add_device( -+ dev->mtd.flags = MTD_CAP_RAM; -+ dev->mtd._erase = block2mtd_erase; -+ dev->mtd._write = block2mtd_write; -++ dev->mtd._panic_write = block2mtd_write; -+ dev->mtd._sync = block2mtd_sync; -+ dev->mtd._read = block2mtd_read; -+ dev->mtd.priv = dev; -+ dev->mtd.owner = THIS_MODULE; -+ -+- if (mtd_device_register(&dev->mtd, NULL, 0)) { -++ memset(&ppdata, '\0', sizeof(ppdata)); -++ if (mtd_device_parse_register(&dev->mtd, block2mtd_probe_types, &ppdata, NULL, 0)) { -+ /* Device didn't get added, so free the entry */ -+ goto err_destroy_mutex; -+ } -+@@ -305,7 +313,7 @@ static struct block2mtd_dev *add_device( -+ list_add(&dev->list, &blkmtd_device_list); -+ pr_info("mtd%d: [%s] erase_size = %dKiB [%d]\n", -+ dev->mtd.index, -+- dev->mtd.name + strlen("block2mtd: "), -++ dev->mtd.name, -+ dev->mtd.erasesize >> 10, dev->mtd.erasesize); -+ return dev; -+ -+@@ -381,7 +389,7 @@ static int block2mtd_setup2(const char * -+ /* 80 for device, 12 for erase size, 80 for name, 8 for timeout */ -+ char buf[80 + 12 + 80 + 8]; -+ char *str = buf; -+- char *token[2]; -++ char *token[4]; -+ char *name; -+ size_t erase_size = PAGE_SIZE; -+ unsigned long timeout = MTD_DEFAULT_TIMEOUT; -+@@ -395,7 +403,7 @@ static int block2mtd_setup2(const char * -+ strcpy(str, val); -+ kill_final_newline(str); -+ -+- for (i = 0; i < 2; i++) -++ for (i = 0; i < 4; i++) -+ token[i] = strsep(&str, ","); -+ -+ if (str) { -+@@ -421,8 +429,13 @@ static int block2mtd_setup2(const char * -+ return 0; -+ } -+ } -++ if (token[2] && (strlen(token[2]) + 1 > 80)) -++ pr_err("mtd device name too long\n"); -++ -++ if (token[3] && kstrtoul(token[3], 0, &timeout)) -++ pr_err("invalid timeout\n"); -+ -+- add_device(name, erase_size, timeout); -++ add_device(name, erase_size, token[2], timeout); -+ -+ return 0; -+ } -+@@ -454,9 +467,8 @@ static int block2mtd_setup(const char *v -+ #endif -+ } -+ -+- -+ module_param_call(block2mtd, block2mtd_setup, NULL, NULL, 0200); -+-MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=[,]\""); -++MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=[,[,[,]]]\""); -+ -+ static int __init block2mtd_init(void) -+ { -+@@ -484,7 +496,7 @@ static void block2mtd_exit(void) -+ mutex_destroy(&dev->write_mutex); -+ pr_info("mtd%d: [%s] removed\n", -+ dev->mtd.index, -+- dev->mtd.name + strlen("block2mtd: ")); -++ dev->mtd.name); -+ list_del(&dev->list); -+ block2mtd_free_device(dev); -+ } -diff --git a/target/linux/mediatek/patches-5.4/9999-support-partition-split.patch b/target/linux/mediatek/patches-5.4/9999-support-partition-split.patch -new file mode 100644 -index 0000000000..8e0026c216 ---- /dev/null -+++ b/target/linux/mediatek/patches-5.4/9999-support-partition-split.patch -@@ -0,0 +1,186 @@ -+Index: linux-5.4.188/block/Kconfig -+=================================================================== -+--- linux-5.4.188.orig/block/Kconfig -++++ linux-5.4.188/block/Kconfig -+@@ -105,6 +105,9 @@ config BLK_DEV_THROTTLING_LOW -+ -+ Note, this is an experimental interface and could be changed someday. -+ -++config PARTITION_SPLIT -++ bool "Openwrt Block device partition rootfs split" -++ -+ config BLK_CMDLINE_PARSER -+ bool "Block device command line partition parser" -+ ---help--- -+Index: linux-5.4.188/block/Makefile -+=================================================================== -+--- linux-5.4.188.orig/block/Makefile -++++ linux-5.4.188/block/Makefile -+@@ -36,3 +36,4 @@ obj-$(CONFIG_BLK_DEBUG_FS) += blk-mq-deb -+ obj-$(CONFIG_BLK_DEBUG_FS_ZONED)+= blk-mq-debugfs-zoned.o -+ obj-$(CONFIG_BLK_SED_OPAL) += sed-opal.o -+ obj-$(CONFIG_BLK_PM) += blk-pm.o -++obj-$(CONFIG_PARTITION_SPLIT) += partition-split.o -+Index: linux-5.4.188/block/partition-generic.c -+=================================================================== -+--- linux-5.4.188.orig/block/partition-generic.c -++++ linux-5.4.188/block/partition-generic.c -+@@ -21,6 +21,10 @@ -+ -+ #include "partitions/check.h" -+ -++#ifdef CONFIG_PARTITION_SPLIT -++#include "partition-split.h" -++#endif -++ -+ #ifdef CONFIG_BLK_DEV_MD -+ extern void md_autodetect_dev(dev_t dev); -+ #endif -+@@ -569,6 +573,9 @@ rescan: -+ highest = p; -+ -+ disk_expand_part_tbl(disk, highest); -++#ifdef CONFIG_PARTITION_SPLIT -++ partition_split(bdev, state); -++#endif -+ -+ /* add partitions */ -+ for (p = 1; p < state->limit; p++) { -+Index: linux-5.4.188/block/partition-split.c -+=================================================================== -+--- /dev/null -++++ linux-5.4.188/block/partition-split.c -+@@ -0,0 +1,111 @@ -++#include -++#include -++#include -++#include "partitions/check.h" -++#include "partition-split.h" -++ -++void print_sblock_value(char *buf) -++{ -++ int i, j; -++ for (i = 0; i < sizeof(struct squashfs_sblock);) { -++ for (j = 0; j < 16; j++) { -++ printk("%02x ", buf[i]); -++ i++; -++ } -++ printk("\n"); -++ } -++} -++ -++unsigned char *fs_read_super_block(struct block_device *bdev, sector_t from, Sector *sector) -++{ -++ if (from >= get_capacity(bdev->bd_disk)) { -++ return NULL; -++ } -++ return read_dev_sector(bdev, from, sector); -++} -++ -++ -++int get_squashfs_len(struct block_device *bdev, sector_t from, size_t *squashfs_len) -++{ -++ struct squashfs_sblock sb; -++ unsigned char *buf; -++ Sector sector; -++ size_t retlen; -++ -++ buf = fs_read_super_block(bdev, from, §or); -++ if (!buf) { -++ printk("failed to get super\n"); -++ return -EIO; -++ } -++ memcpy((void *)&sb, buf, sizeof(sb)); -++ put_dev_sector(sector); -++ -++ if (le32_to_cpu(sb.s_magic) != SQUASHFS_MAGIC) { -++ printk("no squashfs found in\n"); -++ //print_sblock_value((char *)&sb); -++ return -EINVAL; -++ } -++ -++ retlen = le64_to_cpu(sb.bytes_used); -++ if (retlen <= 0) { -++ printk("squashfs is empty in \n"); -++ return -ENODEV; -++ } -++ -++ *squashfs_len = retlen; -++ return 0; -++} -++ -++static int find_part_by_lable(struct parsed_partitions *state, const char *lable) -++{ -++ int p; -++ /* add partitions */ -++ for (p = 1; p < state->limit; p++) { -++ if (!strcmp(state->parts[p].info.volname, lable)) -++ return p; -++ } -++ return 0; -++} -++ -++int partition_split(struct block_device *bdev, struct parsed_partitions *state) -++{ -++ int p, insert; -++ size_t sqfs_size; -++ sector_t new_size, new_from; -++ struct partition_meta_info *info; -++ char tmp[sizeof(info->volname) + 4]; -++ -++ p = find_part_by_lable(state, ROOTFS_PART); -++ if (p == 0) -++ return 0; -++ if (get_squashfs_len(bdev, state->parts[p].from, &sqfs_size)) -++ return 0; -++ -++ sqfs_size = (sqfs_size + (ALING_SQFS - 1)) & ~(ALING_SQFS - 1); //squashfs 64k对齐 -++ -++ //计算新分区大小和起始位置 -++ -++ new_size = state->parts[p].size - (sqfs_size >> 9); -++ new_from = state->parts[p].from + (sqfs_size >> 9); -++ -++ for (insert = 1; insert < state->limit; insert++) { -++ if (!state->parts[insert].size) -++ break; -++ } -++ -++ if (insert >= state->limit) -++ return 0; -++ -++ //追加一个新分区并设置相关信息 -++ put_partition(state, insert, new_from, new_size); -++ -++ info = &state->parts[insert].info; -++ -++ strncpy(info->volname, ROOTFS_PART_DATA, strlen(ROOTFS_PART_DATA) + 1); -++ snprintf(tmp, sizeof(tmp), "(%s)", info->volname); -++ strlcat(state->pp_buf, tmp, PAGE_SIZE); -++ -++ state->parts[insert].has_info = true; -++ return 0; -++ -++} -+Index: linux-5.4.188/block/partition-split.h -+=================================================================== -+--- /dev/null -++++ linux-5.4.188/block/partition-split.h -+@@ -0,0 +1,17 @@ -++#ifndef __PARTITION_SPLIT_H -++#define __PARTITION_SPLIT_H -++ -++#define ROOTFS_PART "rootfs" -++#define ROOTFS_PART_DATA "rootfs_data" -++ -++#define ALING_SQFS 0X10000 -++ -++struct squashfs_sblock { -++ __le32 s_magic; -++ __le32 pad0[9]; -++ __le64 bytes_used; -++}; -++ -++extern int partition_split(struct block_device *bdev, struct parsed_partitions *state); -++ -++#endif --- -2.25.1 -