fix the patch quality

This commit is contained in:
Luo Chongjun 2023-01-19 14:31:44 +08:00
parent ae3d1608e1
commit 6760446957
8 changed files with 2156 additions and 0 deletions

View File

@ -0,0 +1,25 @@
From 1944b5065a88da93ec59ac36a50d8512fcc4c3ef Mon Sep 17 00:00:00 2001
From: Luo Chongjun <luochongjun@gl-inet.com>
Date: Thu, 19 Jan 2023 10:02:53 +0800
Subject: [PATCH] mksquashfs4 add root-owned option
---
include/image.mk | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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
--
2.25.1

View File

@ -0,0 +1,722 @@
From 3e2ea19af2de4ef58c667dfada79976b7862ef35 Mon Sep 17 00:00:00 2001
From: Luo Chongjun <luochongjun@gl-inet.com>
Date: Thu, 19 Jan 2023 09:53:28 +0800
Subject: [PATCH] fstool support emmc part name
---
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 -
4 files changed, 29 insertions(+), 608 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
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 <libubus.h>
-
- #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 <weijie.gao@mediatek.com>
-+ */
-+
-+#include <sys/types.h>
-+#include <sys/stat.h>
-+#include <stdio.h>
-+#include <string.h>
-+#include <dirent.h>
-+#include <fcntl.h>
-+#include <unistd.h>
-+#include <glob.h>
-+#include <dlfcn.h>
-+
-+#include <blkid/blkid.h>
-+#include <libubox/ulog.h>
-+#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 <weijie.gao@mediatek.com>
-+ */
-+
-+#ifndef _BOOT_PARAM_H_
-+#define _BOOT_PARAM_H_
-+
-+#include <stddef.h>
-+#include <stdbool.h>
-+
-+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 <linux/loop.h>
-
-@@ -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;
- }
--
2.25.1

View File

@ -0,0 +1,40 @@
From e50477baeb6edb590fce64cb505988fd5b4b49ef Mon Sep 17 00:00:00 2001
From: Luo Chongjun <luochongjun@gl-inet.com>
Date: Thu, 19 Jan 2023 12:17:10 +0800
Subject: [PATCH 1/2] mt7981 adjust 01_leds
---
.../mt7981/base-files/etc/board.d/01_leds | 21 +++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100755 target/linux/mediatek/mt7981/base-files/etc/board.d/01_leds
diff --git a/target/linux/mediatek/mt7981/base-files/etc/board.d/01_leds b/target/linux/mediatek/mt7981/base-files/etc/board.d/01_leds
new file mode 100755
index 0000000000..e5e5aca029
--- /dev/null
+++ b/target/linux/mediatek/mt7981/base-files/etc/board.d/01_leds
@@ -0,0 +1,21 @@
+
+. /lib/functions/uci-defaults.sh
+
+board_config_update
+
+board=$(board_name)
+
+case "$board" in
+glinet,xe3000-emmc |\
+glinet,x3000-emmc)
+ ucidef_set_led_netdev "wlan2g" "WLAN2G" "wifi:2g" "ra0"
+ ucidef_set_led_netdev "wlan5g" "WLAN5G" "wifi:5g" "rax0"
+ ucidef_set_led_netdev "wan" "WAN" "internet" "eth0"
+ ucidef_set_led_default "power" "POWER" "power" "1"
+ ;;
+esac
+
+board_config_flush
+
+exit 0
+
--
2.25.1

View File

@ -0,0 +1,44 @@
From 7e13024b85dc4c07521e4a4ccf71a93ee8b3c89b Mon Sep 17 00:00:00 2001
From: Luo Chongjun <luochongjun@gl-inet.com>
Date: Thu, 19 Jan 2023 12:16:26 +0800
Subject: [PATCH] mt7981 adjust 02_network
---
.../mt7981/base-files/etc/board.d/02_network | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
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 6865f52bb8..c2a22e425b 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
@@ -22,7 +22,10 @@ mediatek_setup_interfaces()
*2500wan-p5*)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" wan
;;
- *mt3000*)
+ *mt3000*|\
+ *x3000*|\
+ *xe3000*|\
+ *mt2500*)
ucidef_set_interfaces_lan_wan eth1 eth0
;;
*)
@@ -43,6 +46,15 @@ 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)
+ ;;
+ *xe3000*|\
+ *x3000*)
+ wan_mac=$(get_mac_binary /dev/mmcblk0p3 0x0a)
+ lan_mac=$(macaddr_add "$wan_mac" 1)
+ ;;
esac
[ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" "$wan_mac"
--
2.25.1

View File

@ -0,0 +1,53 @@
From f1d953f946c496b60469f9d36244f9c8c502f50a Mon Sep 17 00:00:00 2001
From: Luo Chongjun <luochongjun@gl-inet.com>
Date: Thu, 19 Jan 2023 12:19:11 +0800
Subject: [PATCH 2/2] mt7981 adjust mt7981.mk
---
target/linux/mediatek/image/mt7981.mk | 33 +++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/target/linux/mediatek/image/mt7981.mk b/target/linux/mediatek/image/mt7981.mk
index a798034da9..b7f1f6d437 100755
--- a/target/linux/mediatek/image/mt7981.mk
+++ b/target/linux/mediatek/image/mt7981.mk
@@ -189,3 +189,36 @@ define Device/glinet_gl-mt3000
IMAGE/sysupgrade.tar := sysupgrade-tar | append-gl-metadata
endef
TARGET_DEVICES += glinet_gl-mt3000
+
+define Device/glinet_gl-x3000
+ DEVICE_VENDOR := GL.iNet
+ DEVICE_MODEL := GL-X3000
+ DEVICE_DTS := mt7981-gl-x3000
+ DEVICE_DTS_DIR := $(DTS_DIR)/mediatek
+ SUPPORTED_DEVICES := glinet,x3000-emmc
+ DEVICE_PACKAGES := kmod-hwmon-pwmfan mkf2fs kmod-mmc kmod-fs-f2fs gdisk
+ IMAGE/sysupgrade.bin := sysupgrade-tar | append-gl-metadata
+endef
+TARGET_DEVICES += glinet_gl-x3000
+
+define Device/glinet_gl-xe3000
+ DEVICE_VENDOR := GL.iNet
+ DEVICE_MODEL := GL-XE3000
+ DEVICE_DTS := mt7981-gl-xe3000
+ DEVICE_DTS_DIR := $(DTS_DIR)/mediatek
+ SUPPORTED_DEVICES := glinet,xe3000-emmc
+ DEVICE_PACKAGES := kmod-hwmon-pwmfan mkf2fs kmod-mmc kmod-fs-f2fs gdisk
+ IMAGE/sysupgrade.bin := sysupgrade-tar | append-gl-metadata
+endef
+TARGET_DEVICES += glinet_gl-xe3000
+
+define Device/glinet_gl-mt2500
+ DEVICE_VENDOR := GL.iNet
+ DEVICE_MODEL := GL-MT2500
+ DEVICE_DTS := mt7981-gl-mt2500
+ SUPPORTED_DEVICES := glinet,mt2500-emmc
+ DEVICE_DTS_DIR := $(DTS_DIR)/mediatek
+ DEVICE_PACKAGES := mkf2fs kmod-mmc kmod-fs-f2fs gdisk
+ IMAGE/sysupgrade.bin := sysupgrade-tar | append-gl-metadata
+endef
+TARGET_DEVICES += glinet_gl-mt2500
--
2.25.1

View File

@ -0,0 +1,573 @@
From 9a5d2a1d630b6311d3ad1dc15ec9547f82e2cfb3 Mon Sep 17 00:00:00 2001
From: Luo Chongjun <luochongjun@gl-inet.com>
Date: Thu, 19 Jan 2023 10:37:12 +0800
Subject: [PATCH] support MT2500 target
---
.../boot/dts/mediatek/mt7981-gl-mt2500.dts | 183 +++++++++++++++++
target/linux/mediatek/mt7981/config-5.4 | 5 +-
.../9999-block2mtd-support-partline.patch | 139 +++++++++++++
.../9999-support-partition-split.patch | 186 ++++++++++++++++++
4 files changed, 511 insertions(+), 2 deletions(-)
create mode 100755 target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-mt2500.dts
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/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-mt2500.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-mt2500.dts
new file mode 100755
index 0000000000..e5d793cd1f
--- /dev/null
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-mt2500.dts
@@ -0,0 +1,183 @@
+/dts-v1/;
+#include "mt7981.dtsi"
+/ {
+ model = "GL.iNet GL-MT2500";
+ compatible = "glinet,mt2500-emmc", "mediatek,mt7981";
+
+ chosen {
+ bootargs = "console=ttyS0,115200n1 loglevel=8 \
+ earlycon=uart8250,mmio32,0x11002000 \
+ root=PARTLABEL=rootfs rootwait rootfstype=squashfs,f2fs \
+ block2mtd.block2mtd=/dev/mmcblk0p1,65536,log";
+ };
+
+ reg_3p3v: regulator-3p3v {
+ compatible = "regulator-fixed";
+ regulator-name = "fixed-3.3V";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-boot-on;
+ regulator-always-on;
+ };
+
+ gl-hw {
+ compatible = "gl-hw-info";
+ model = "mt2500";
+ wan = "eth0";
+ lan = "eth1";
+ usb-port = "1-1";
+ flash_size = <8192>;
+ temperature = "/sys/devices/virtual/thermal/thermal_zone0/temp";
+ factory_data {
+ device_mac = "/dev/mmcblk0boot1", "0x0a";
+ device_ddns = "/dev/mmcblk0boot1", "0x10";
+ device_sn_bak = "/dev/mmcblk0boot1", "0x20";
+ device_sn = "/dev/mmcblk0boot1", "0x30";
+ };
+ };
+
+ gpio-keys {
+ compatible = "gpio-keys";
+
+ reset {
+ label = "reset";
+ linux,code = <KEY_RESTART>;
+ gpios = <&pio 1 GPIO_ACTIVE_LOW>;
+ };
+ };
+
+ gpio-export {
+ compatible = "gpio-export";
+
+ usb_power {
+ gpio-export,name = "usb_power";
+ gpio-export,output = <1>;
+ gpios = <&pio 12 GPIO_ACTIVE_HIGH>;
+ };
+ };
+
+ leds {
+ compatible = "gpio-leds";
+
+ led@0 {
+ label = "vpn";
+ gpios = <&pio 31 GPIO_ACTIVE_LOW>;
+ };
+
+ led@1 {
+ label = "white:system";
+ gpios = <&pio 30 GPIO_ACTIVE_LOW>;
+ };
+
+ led@2 {
+ label = "blue:system";
+ gpios = <&pio 29 GPIO_ACTIVE_LOW>;
+ default-state = "on";
+ };
+ };
+};
+
+&uart0 {
+ status = "okay";
+};
+
+&watchdog {
+ status = "okay";
+};
+
+&mmc0 {
+ pinctrl-names = "default", "state_uhs";
+ pinctrl-0 = <&mmc0_pins_default>;
+ pinctrl-1 = <&mmc0_pins_uhs>;
+ bus-width = <8>;
+ max-frequency = <52000000>;
+ cap-mmc-highspeed;
+ vmmc-supply = <&reg_3p3v>;
+ non-removable;
+ status = "okay";
+};
+
+&eth {
+ status = "okay";
+
+ gmac0: mac@0 {
+ compatible = "mediatek,eth-mac";
+ reg = <0>;
+ phy-mode = "2500base-x";
+ fixed-link {
+ speed = <2500>;
+ full-duplex;
+ pause;
+ };
+ };
+
+ gmac1: mac@1 {
+ compatible = "mediatek,eth-mac";
+ reg = <1>;
+ phy-mode = "gmii";
+ phy-handle = <&phy0>;
+ };
+
+ mdio: mdio-bus {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ phy0: ethernet-phy@0 {
+ compatible = "ethernet-phy-id03a2.9461";
+ reg = <0>;
+ phy-mode = "gmii";
+ nvmem-cells = <&phy_calibration>;
+ nvmem-cell-names = "phy-cal-data";
+ };
+
+ phy5: phy@5 {
+ compatible = "ethernet-phy-id67c9.de0a";
+ reg = <5>;
+ reset-gpios = <&pio 14 1>;
+ reset-assert-us = <600>;
+ reset-deassert-us = <20000>;
+ };
+ };
+};
+
+&hnat {
+ mtketh-wan = "eth0";
+ mtketh-lan = "eth1";
+ mtketh-ppd = "eth1";
+ mtketh-max-gmac = <2>;
+ status = "okay";
+};
+
+&spi1 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&spic_pins>;
+ status = "disabled";
+};
+
+&pio {
+ spic_pins: spi1-pins {
+ mux {
+ function = "spi";
+ groups = "spi1_1";
+ };
+ };
+ mmc0_pins_default: mmc0-pins-default {
+ mux {
+ function = "flash";
+ groups = "emmc_45";
+ };
+ };
+ mmc0_pins_uhs: mmc0-pins-uhs {
+ mux {
+ function = "flash";
+ groups = "emmc_45";
+ };
+ };
+};
+
+&xhci {
+ mediatek,u3p-dis-msk = <0x0>;
+ phys = <&u2port0 PHY_TYPE_USB2>,
+ <&u3port0 PHY_TYPE_USB3>;
+ status = "okay";
+};
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 <linux/list.h>
+ #include <linux/init.h>
+ #include <linux/mtd/mtd.h>
++#include <linux/mtd/partitions.h>
+ #include <linux/mutex.h>
+ #include <linux/mount.h>
+ #include <linux/slab.h>
+ #include <linux/major.h>
+
++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=<dev>[,<erasesize>]\"");
++MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>[,<name>[,<timeout>]]]\"");
+
+ 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 <linux/blkdev.h>
++#include <linux/magic.h>
++#include <linux/module.h>
++#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, &sector);
++ 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

View File

@ -0,0 +1,371 @@
From 12482b59735bff2e48ae427eb166db22b45118d3 Mon Sep 17 00:00:00 2001
From: Luo Chongjun <luochongjun@gl-inet.com>
Date: Thu, 19 Jan 2023 11:51:21 +0800
Subject: [PATCH] support X3000 target
---
.../boot/dts/mediatek/mt7981-gl-x3000.dts | 314 ++++++++++++++++++
.../patches-5.4/403-support-x3000-emmc.patch | 30 ++
2 files changed, 344 insertions(+)
create mode 100755 target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-x3000.dts
create mode 100644 target/linux/mediatek/patches-5.4/403-support-x3000-emmc.patch
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-x3000.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-x3000.dts
new file mode 100755
index 0000000000..457b67fc7d
--- /dev/null
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-x3000.dts
@@ -0,0 +1,314 @@
+/dts-v1/;
+#include "mt7981.dtsi"
+/ {
+ model = "GL.iNet GL-X3000";
+ compatible = "glinet,x3000-emmc", "mediatek,mt7981";
+
+ chosen {
+ bootargs = "console=ttyS0,115200n1 loglevel=8 \
+ earlycon=uart8250,mmio32,0x11002000 \
+ root=PARTLABEL=rootfs rootwait rootfstype=squashfs,f2fs \
+ block2mtd.block2mtd=/dev/mmcblk0p1,65536,log;/dev/mmcblk0p5,65536,custom";
+ };
+
+ reg_3p3v: regulator-3p3v {
+ compatible = "regulator-fixed";
+ regulator-name = "fixed-3.3V";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-boot-on;
+ regulator-always-on;
+ };
+
+ gl-hw {
+ compatible = "gl-hw-info";
+ model = "x3000";
+ wan = "eth0";
+ lan = "eth1";
+ build-in-modem = "0001:01:00.0";
+ pcie-bus = "0001:01:00.0";
+ usb-port = "1-1.3";
+ fan = "pwmchip0";
+ flash_size = <7456>;
+ temperature = "/sys/devices/virtual/thermal/thermal_zone0/temp";
+ reset-button = "gpio-456";
+ radio = "mt798111 mt798112";
+ cfg-partition = "/dev/mmcblk0p5";
+ dfs;
+ factory_data {
+ device_mac = "/dev/mmcblk0p3", "0x0a";
+ device_ddns = "/dev/mmcblk0p3", "0x10";
+ device_sn_bak = "/dev/mmcblk0p3", "0x20";
+ device_sn = "/dev/mmcblk0p3", "0x30";
+ country_code = "/dev/mmcblk0p3", "0x88";
+ };
+ };
+
+ gpio-keys {
+ compatible = "gpio-keys";
+
+ reset {
+ label = "reset";
+ linux,code = <KEY_RESTART>;
+ gpios = <&pio 1 GPIO_ACTIVE_LOW>;
+ };
+
+ };
+
+ gpio-export {
+ compatible = "gpio-export";
+
+ usb_power {
+ gpio-export,name = "usb_power";
+ gpio-export,output = <1>;
+ gpios = <&pio 12 GPIO_ACTIVE_HIGH>;
+ };
+
+ hub_power {
+ gpio-export,name = "hub_power";
+ gpio-export,output = <1>;
+ gpios = <&pio 5 GPIO_ACTIVE_HIGH>;
+ };
+
+ 5G_power {
+ gpio-export,name = "5G_power";
+ gpio-export,output = <1>;
+ gpios = <&pio 11 GPIO_ACTIVE_HIGH>;
+ };
+
+ 5G_control {
+ gpio-export,name = "5G_control";
+ gpio-export,output = <1>;
+ gpios = <&pio 9 GPIO_ACTIVE_HIGH>;
+ };
+
+ 5G_reset {
+ gpio-export,name = "5G_reset";
+ gpio-export,output = <1>;
+ gpios = <&pio 10 GPIO_ACTIVE_HIGH>;
+ };
+
+ thread_reset {
+ gpio-export,name = "gpio26";
+ gpio-export,output = <1>;
+ gpios = <&pio 26 GPIO_ACTIVE_HIGH>;
+ };
+
+ thread_dfu {
+ gpio-export,name = "gpio27";
+ gpio-export,output = <1>;
+ gpios = <&pio 27 GPIO_ACTIVE_HIGH>;
+ };
+
+ fan_power {
+ gpio-export,name = "fan_power";
+ gpio-export,output = <1>;
+ gpios = <&pio 28 GPIO_ACTIVE_HIGH>;
+ };
+ };
+
+ leds {
+ compatible = "gpio-leds";
+
+ led@0 {
+ label = "wifi:2g";
+ gpios = <&pio 30 GPIO_ACTIVE_LOW>;
+ default-state = "off";
+ };
+
+ led@1 {
+ label = "wifi:5g";
+ gpios = <&pio 38 GPIO_ACTIVE_LOW>;
+ default-state = "off";
+ };
+
+ led@2 {
+ label = "5G:signal:led1";
+ gpios = <&pio 6 GPIO_ACTIVE_LOW>;
+ default-state = "off";
+ };
+
+ led@3 {
+ label = "5G:signal:led2";
+ gpios = <&pio 7 GPIO_ACTIVE_LOW>;
+ default-state = "off";
+ };
+
+ led@4 {
+ label = "5G:signal:led3";
+ gpios = <&pio 8 GPIO_ACTIVE_LOW>;
+ default-state = "off";
+ };
+
+ led@5 {
+ label = "5G:signal:led4";
+ gpios = <&pio 4 GPIO_ACTIVE_HIGH>;
+ default-state = "off";
+ };
+
+ led@6 {
+ label = "power";
+ gpios = <&pio 39 GPIO_ACTIVE_LOW>;
+ default-state = "on";
+ };
+
+ led@7 {
+ label = "internet";
+ gpios = <&pio 31 GPIO_ACTIVE_LOW>;
+ default-state = "off";
+ };
+ };
+
+ gl_fan {
+ compatible = "gl-fan";
+ interrupt-parent = <&pio>;
+ interrupts = <29 IRQ_TYPE_EDGE_RISING>;
+ };
+
+ pwm-fan {
+ compatible = "pwm-fan";
+ cooling-min-state = <0>;
+ cooling-max-state = <255>;
+ #cooling-cells = <2>;
+ pwms = <&pwm 0 40000 0>;
+ cooling-levels = <0 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
+ 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 37 38 39
+ 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
+ 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
+ 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
+ 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
+ 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
+ 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
+ 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
+ 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
+ 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
+ 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255>;
+ };
+};
+
+&uart0 {
+ status = "okay";
+};
+
+&watchdog {
+ status = "okay";
+};
+
+&mmc0 {
+ pinctrl-names = "default", "state_uhs";
+ pinctrl-0 = <&mmc0_pins_default>;
+ pinctrl-1 = <&mmc0_pins_uhs>;
+ bus-width = <8>;
+ max-frequency = <52000000>;
+ cap-mmc-highspeed;
+ vmmc-supply = <&reg_3p3v>;
+ non-removable;
+ status = "okay";
+};
+
+&eth {
+ status = "okay";
+
+ gmac0: mac@0 {
+ compatible = "mediatek,eth-mac";
+ reg = <0>;
+ phy-mode = "2500base-x";
+ fixed-link {
+ speed = <2500>;
+ full-duplex;
+ pause;
+ };
+ };
+
+ gmac1: mac@1 {
+ compatible = "mediatek,eth-mac";
+ reg = <1>;
+ phy-mode = "gmii";
+ phy-handle = <&phy0>;
+ };
+
+ mdio: mdio-bus {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ phy0: ethernet-phy@0 {
+ compatible = "ethernet-phy-id03a2.9461";
+ reg = <0>;
+ phy-mode = "gmii";
+ nvmem-cells = <&phy_calibration>;
+ nvmem-cell-names = "phy-cal-data";
+ };
+
+ phy5: phy@5 {
+ compatible = "ethernet-phy-id67c9.de0a";
+ reg = <5>;
+ reset-gpios = <&pio 14 1>;
+ reset-assert-us = <600>;
+ reset-deassert-us = <20000>;
+ };
+ };
+};
+
+&hnat {
+ mtketh-wan = "eth0";
+ mtketh-lan = "eth1";
+ mtketh-ppd = "eth1";
+ mtketh-max-gmac = <2>;
+ status = "okay";
+};
+
+&spi1 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&spic_pins>;
+ status = "disabled";
+};
+
+&pio {
+ spic_pins: spi1-pins {
+ mux {
+ function = "spi";
+ groups = "spi1_1";
+ };
+ };
+ mmc0_pins_default: mmc0-pins-default {
+ mux {
+ function = "flash";
+ groups = "emmc";
+ };
+ };
+ mmc0_pins_uhs: mmc0-pins-uhs {
+ mux {
+ function = "flash";
+ groups = "emmc";
+ };
+ };
+ pcie_pins: pcie-pins {
+ mux {
+ function = "pcie";
+ groups = "pcie_pereset", "pcie_clk", "pcie_wake";
+ };
+ };
+ pwm0_pin: pwm0-pin-g0 {
+ mux {
+ function = "pwm";
+ groups = "pwm0_1";
+ };
+ };
+};
+
+&xhci {
+ phys = <&u2port0 PHY_TYPE_USB2>;
+ status = "okay";
+};
+
+&pcie {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pcie_pins>;
+ status = "okay";
+};
+
+&pwm {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pwm0_pin>;
+};
diff --git a/target/linux/mediatek/patches-5.4/403-support-x3000-emmc.patch b/target/linux/mediatek/patches-5.4/403-support-x3000-emmc.patch
new file mode 100644
index 0000000000..afa8309b2a
--- /dev/null
+++ b/target/linux/mediatek/patches-5.4/403-support-x3000-emmc.patch
@@ -0,0 +1,30 @@
+--- linux-origin/drivers/pinctrl/mediatek/pinctrl-mt7981.c 2022-12-02 16:58:14.809104549 +0800
++++ linux/drivers/pinctrl/mediatek/pinctrl-mt7981.c 2022-12-05 19:42:57.559519783 +0800
+@@ -668,6 +668,9 @@
+ static int mt7981_emmc_45_pins[] = { 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, };
+ static int mt7981_emmc_45_funcs[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, };
+
++static int mt7981_emmc_pins[] = { 0, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, };
++static int mt7981_emmc_funcs[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, };
++
+ /* SNFI */
+ static int mt7981_snfi_pins[] = { 16, 17, 18, 19, 20, 21, };
+ static int mt7981_snfi_funcs[] = { 3, 3, 3, 3, 3, 3, };
+@@ -813,6 +816,8 @@
+ PINCTRL_PIN_GROUP("drv_vbus", mt7981_drv_vbus),
+ /* @GPIO(15,25): EMMC(2) */
+ PINCTRL_PIN_GROUP("emmc_45", mt7981_emmc_45),
++ /* @GPIO(0.16,25): EMMC(2) */
++ PINCTRL_PIN_GROUP("emmc", mt7981_emmc),
+ /* @GPIO(16,21): SNFI(3) */
+ PINCTRL_PIN_GROUP("snfi", mt7981_snfi),
+ /* @GPIO(16,19): SPI0(1) */
+@@ -910,7 +915,7 @@
+ static const char *mt7981_pcm_groups[] = { "pcm", };
+ static const char *mt7981_udi_groups[] = { "udi", };
+ static const char *mt7981_usb_groups[] = { "drv_vbus", };
+-static const char *mt7981_flash_groups[] = { "emmc_45", "snfi", };
++static const char *mt7981_flash_groups[] = { "emmc_45", "emmc", "snfi", };
+ static const char *mt7981_ethernet_groups[] = { "smi_mdc_mdio", "gbe_ext_mdc_mdio",
+ "wf0_mode1", "wf0_mode3", "mt7531_int", };
+ static const char *mt7981_ant_groups[] = { "ant_sel", };
--
2.25.1

View File

@ -0,0 +1,328 @@
From fca1366343c83ce58628a2d0a1199b84b222d1a3 Mon Sep 17 00:00:00 2001
From: Luo Chongjun <luochongjun@gl-inet.com>
Date: Thu, 19 Jan 2023 12:09:45 +0800
Subject: [PATCH] support XE3000 target
---
.../boot/dts/mediatek/mt7981-gl-xe3000.dts | 309 ++++++++++++++++++
1 file changed, 309 insertions(+)
create mode 100755 target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-xe3000.dts
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-xe3000.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-xe3000.dts
new file mode 100755
index 0000000000..8d3902d418
--- /dev/null
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-gl-xe3000.dts
@@ -0,0 +1,309 @@
+/dts-v1/;
+#include "mt7981.dtsi"
+/ {
+ model = "GL.iNet GL-XE3000";
+ compatible = "glinet,xe3000-emmc", "mediatek,mt7981";
+
+ chosen {
+ bootargs = "console=ttyS0,115200n1 loglevel=8 \
+ earlycon=uart8250,mmio32,0x11002000 \
+ root=PARTLABEL=rootfs rootwait rootfstype=squashfs,f2fs \
+ block2mtd.block2mtd=/dev/mmcblk0p1,65536,log";
+ };
+
+ reg_3p3v: regulator-3p3v {
+ compatible = "regulator-fixed";
+ regulator-name = "fixed-3.3V";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-boot-on;
+ regulator-always-on;
+ };
+
+ gl-hw {
+ compatible = "gl-hw-info";
+ model = "xe3000";
+ wan = "eth0";
+ lan = "eth1";
+ build-in-modem = "0001:01:00.0";
+ pcie-bus = "0001:01:00.0";
+ usb-port = "1-1.3";
+ fan = "pwmchip0";
+ flash_size = <7456>;
+ temperature = "/sys/devices/virtual/thermal/thermal_zone0/temp";
+ reset-button = "gpio-456";
+ radio = "mt798111 mt798112";
+ cfg-partition = "/dev/mmcblk0p5";
+ dfs;
+ factory_data {
+ device_mac = "/dev/mmcblk0p3", "0x0a";
+ device_ddns = "/dev/mmcblk0p3", "0x10";
+ device_sn_bak = "/dev/mmcblk0p3", "0x20";
+ device_sn = "/dev/mmcblk0p3", "0x30";
+ country_code = "/dev/mmcblk0p3", "0x88";
+ };
+ };
+
+ gpio-keys {
+ compatible = "gpio-keys";
+
+ reset {
+ label = "reset";
+ linux,code = <KEY_RESTART>;
+ gpios = <&pio 1 GPIO_ACTIVE_LOW>;
+ };
+
+ };
+
+ gpio-export {
+ compatible = "gpio-export";
+
+ hub_power {
+ gpio-export,name = "hub_power";
+ gpio-export,output = <1>;
+ gpios = <&pio 5 GPIO_ACTIVE_HIGH>;
+ };
+
+ 5G_power {
+ gpio-export,name = "5G_power";
+ gpio-export,output = <1>;
+ gpios = <&pio 11 GPIO_ACTIVE_HIGH>;
+ };
+
+ 5G_control {
+ gpio-export,name = "5G_control";
+ gpio-export,output = <1>;
+ gpios = <&pio 9 GPIO_ACTIVE_HIGH>;
+ };
+
+ 5G_reset {
+ gpio-export,name = "5G_reset";
+ gpio-export,output = <1>;
+ gpios = <&pio 10 GPIO_ACTIVE_HIGH>;
+ };
+
+ fan_power {
+ gpio-export,name = "fan_power";
+ gpio-export,output = <1>;
+ gpios = <&pio 28 GPIO_ACTIVE_HIGH>;
+ };
+ };
+
+ leds {
+ compatible = "gpio-leds";
+
+ led@0 {
+ label = "wifi:2g";
+ gpios = <&pio 30 GPIO_ACTIVE_LOW>;
+ default-state = "off";
+ };
+
+ led@1 {
+ label = "wifi:5g";
+ gpios = <&pio 38 GPIO_ACTIVE_LOW>;
+ default-state = "off";
+ };
+
+ led@2 {
+ label = "5G:signal:led1";
+ gpios = <&pio 6 GPIO_ACTIVE_LOW>;
+ default-state = "off";
+ };
+
+ led@3 {
+ label = "5G:signal:led2";
+ gpios = <&pio 7 GPIO_ACTIVE_LOW>;
+ default-state = "off";
+ };
+
+ led@4 {
+ label = "5G:signal:led3";
+ gpios = <&pio 8 GPIO_ACTIVE_LOW>;
+ default-state = "off";
+ };
+
+ led@5 {
+ label = "5G:signal:led4";
+ gpios = <&pio 4 GPIO_ACTIVE_HIGH>;
+ default-state = "off";
+ };
+
+ led@6 {
+ label = "power";
+ gpios = <&pio 39 GPIO_ACTIVE_LOW>;
+ default-state = "on";
+ };
+
+ led@7 {
+ label = "internet";
+ gpios = <&pio 31 GPIO_ACTIVE_LOW>;
+ default-state = "off";
+ };
+ };
+
+ gl_fan {
+ compatible = "gl-fan";
+ interrupt-parent = <&pio>;
+ interrupts = <29 IRQ_TYPE_EDGE_RISING>;
+ };
+
+ pwm-fan {
+ compatible = "pwm-fan";
+ cooling-min-state = <0>;
+ cooling-max-state = <255>;
+ #cooling-cells = <2>;
+ pwms = <&pwm 0 40000 0>;
+ cooling-levels = <0 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
+ 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 37 38 39
+ 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
+ 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
+ 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
+ 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
+ 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
+ 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
+ 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
+ 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
+ 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
+ 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
+ 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255>;
+ };
+};
+
+&uart0 {
+ status = "okay";
+};
+
+&uart1 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart1_pins>;
+ status = "okay";
+};
+
+&watchdog {
+ status = "okay";
+};
+
+&mmc0 {
+ pinctrl-names = "default", "state_uhs";
+ pinctrl-0 = <&mmc0_pins_default>;
+ pinctrl-1 = <&mmc0_pins_uhs>;
+ bus-width = <8>;
+ max-frequency = <52000000>;
+ cap-mmc-highspeed;
+ vmmc-supply = <&reg_3p3v>;
+ non-removable;
+ status = "okay";
+};
+
+&eth {
+ status = "okay";
+
+ gmac0: mac@0 {
+ compatible = "mediatek,eth-mac";
+ reg = <0>;
+ phy-mode = "2500base-x";
+ fixed-link {
+ speed = <2500>;
+ full-duplex;
+ pause;
+ };
+ };
+
+ gmac1: mac@1 {
+ compatible = "mediatek,eth-mac";
+ reg = <1>;
+ phy-mode = "gmii";
+ phy-handle = <&phy0>;
+ };
+
+ mdio: mdio-bus {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ phy0: ethernet-phy@0 {
+ compatible = "ethernet-phy-id03a2.9461";
+ reg = <0>;
+ phy-mode = "gmii";
+ nvmem-cells = <&phy_calibration>;
+ nvmem-cell-names = "phy-cal-data";
+ };
+
+ phy5: phy@5 {
+ compatible = "ethernet-phy-id67c9.de0a";
+ reg = <5>;
+ reset-gpios = <&pio 14 1>;
+ reset-assert-us = <600>;
+ reset-deassert-us = <20000>;
+ };
+ };
+};
+
+&hnat {
+ mtketh-wan = "eth0";
+ mtketh-lan = "eth1";
+ mtketh-ppd = "eth1";
+ mtketh-max-gmac = <2>;
+ status = "okay";
+};
+
+&spi1 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&spic_pins>;
+ status = "disabled";
+};
+
+&pio {
+ spic_pins: spi1-pins {
+ mux {
+ function = "spi";
+ groups = "spi1_1";
+ };
+ };
+ mmc0_pins_default: mmc0-pins-default {
+ mux {
+ function = "flash";
+ groups = "emmc";
+ };
+ };
+ mmc0_pins_uhs: mmc0-pins-uhs {
+ mux {
+ function = "flash";
+ groups = "emmc";
+ };
+ };
+ pcie_pins: pcie-pins {
+ mux {
+ function = "pcie";
+ groups = "pcie_pereset", "pcie_clk", "pcie_wake";
+ };
+ };
+ pwm0_pin: pwm0-pin-g0 {
+ mux {
+ function = "pwm";
+ groups = "pwm0_1";
+ };
+ };
+
+ uart1_pins: uart1-pins-g1 {
+ mux {
+ function = "uart";
+ groups = "uart1_1";
+ };
+ };
+};
+
+&xhci {
+ phys = <&u2port0 PHY_TYPE_USB2>;
+ status = "okay";
+};
+
+&pcie {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pcie_pins>;
+ status = "okay";
+};
+
+&pwm {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pwm0_pin>;
+};
--
2.25.1