diff --git a/package/boot/uboot-mediatek/patches/314-mt7981-select-rootdisk.patch b/package/boot/uboot-mediatek/patches/314-mt7981-select-rootdisk.patch new file mode 100644 index 0000000000..c53e4a8752 --- /dev/null +++ b/package/boot/uboot-mediatek/patches/314-mt7981-select-rootdisk.patch @@ -0,0 +1,102 @@ +--- a/board/mediatek/mt7981/mt7981_rfb.c ++++ b/board/mediatek/mt7981/mt7981_rfb.c +@@ -11,7 +11,9 @@ + #include + #include + #include ++#include + #include ++#include + + #ifndef CONFIG_RESET_BUTTON_LABEL + #define CONFIG_RESET_BUTTON_LABEL "reset" +@@ -81,3 +83,54 @@ int board_nmbm_init(void) + + return 0; + } ++ ++#define MT7981_BOOT_NOR 0 ++#define MT7981_BOOT_SPIM_NAND 1 /* ToDo: fallback to SD */ ++#define MT7981_BOOT_EMMC 2 ++#define MT7981_BOOT_SNFI_NAND 3 /* ToDo (treated as SD) */ ++ ++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; ++ ++ switch ((readl(0x11d006f0) & 0xc0) >> 6) { ++ case MT7981_BOOT_NOR: ++ media = "rootdisk-nor"; ++ break ++ ;; ++ case MT7981_BOOT_SPIM_NAND: ++ media = "rootdisk-spim-nand"; ++ break ++ ;; ++ case MT7981_BOOT_EMMC: ++ media = "rootdisk-emmc"; ++ break ++ ;; ++ case MT7981_BOOT_SNFI_NAND: ++ 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)); ++ ++ return 0; ++} +--- a/configs/mt7981_emmc_rfb_defconfig ++++ b/configs/mt7981_emmc_rfb_defconfig +@@ -114,3 +114,4 @@ CONFIG_FAT_WRITE=y + CONFIG_HEXDUMP=y + # CONFIG_EFI_LOADER is not set + CONFIG_LMB_MAX_REGIONS=64 ++CONFIG_OF_SYSTEM_SETUP=y +--- a/configs/mt7981_nor_rfb_defconfig ++++ b/configs/mt7981_nor_rfb_defconfig +@@ -126,3 +126,4 @@ CONFIG_DM_SPI=y + CONFIG_MTK_SPIM=y + CONFIG_HEXDUMP=y + CONFIG_LMB_MAX_REGIONS=64 ++CONFIG_OF_SYSTEM_SETUP=y +--- a/configs/mt7981_rfb_defconfig ++++ b/configs/mt7981_rfb_defconfig +@@ -135,3 +135,4 @@ CONFIG_DM_SPI=y + CONFIG_MTK_SPIM=y + CONFIG_HEXDUMP=y + CONFIG_LMB_MAX_REGIONS=64 ++CONFIG_OF_SYSTEM_SETUP=y +--- a/configs/mt7981_sd_rfb_defconfig ++++ b/configs/mt7981_sd_rfb_defconfig +@@ -114,3 +114,4 @@ CONFIG_FAT_WRITE=y + CONFIG_HEXDUMP=y + # CONFIG_EFI_LOADER is not set + CONFIG_LMB_MAX_REGIONS=64 ++CONFIG_OF_SYSTEM_SETUP=y +--- a/configs/mt7981_snfi_nand_rfb_defconfig ++++ b/configs/mt7981_snfi_nand_rfb_defconfig +@@ -120,3 +120,4 @@ CONFIG_DM_SERIAL=y + CONFIG_MTK_SERIAL=y + CONFIG_HEXDUMP=y + CONFIG_LMB_MAX_REGIONS=64 ++CONFIG_OF_SYSTEM_SETUP=y diff --git a/package/network/config/wifi-scripts/files/lib/netifd/hostapd.sh b/package/network/config/wifi-scripts/files/lib/netifd/hostapd.sh index 6da01128a2..4f16c20382 100644 --- a/package/network/config/wifi-scripts/files/lib/netifd/hostapd.sh +++ b/package/network/config/wifi-scripts/files/lib/netifd/hostapd.sh @@ -439,7 +439,7 @@ append_iw_anqp_3gpp_cell_net() { if [ -z "$iw_anqp_3gpp_cell_net_conf" ]; then iw_anqp_3gpp_cell_net_conf="$1" else - iw_anqp_3gpp_cell_net_conf="$iw_anqp_3gpp_cell_net_conf:$1" + iw_anqp_3gpp_cell_net_conf="$iw_anqp_3gpp_cell_net_conf;$1" fi } diff --git a/target/linux/generic/hack-5.15/911-kobject_add_broadcast_uevent.patch b/target/linux/generic/hack-5.15/911-kobject_add_broadcast_uevent.patch index a487d55193..dd93e0be42 100644 --- a/target/linux/generic/hack-5.15/911-kobject_add_broadcast_uevent.patch +++ b/target/linux/generic/hack-5.15/911-kobject_add_broadcast_uevent.patch @@ -1,7 +1,7 @@ From 0d37e6edc09c99e683dd91ca0e83bbc0df8477b3 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sun, 16 Jul 2017 16:56:10 +0200 -Subject: lib: add uevent_next_seqnum() +Subject: lib: add broadcast_uevent() Signed-off-by: Felix Fietkau --- diff --git a/target/linux/generic/hack-6.1/911-kobject_add_broadcast_uevent.patch b/target/linux/generic/hack-6.1/911-kobject_add_broadcast_uevent.patch index c828ecd450..99e95ce352 100644 --- a/target/linux/generic/hack-6.1/911-kobject_add_broadcast_uevent.patch +++ b/target/linux/generic/hack-6.1/911-kobject_add_broadcast_uevent.patch @@ -1,7 +1,7 @@ From 0d37e6edc09c99e683dd91ca0e83bbc0df8477b3 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sun, 16 Jul 2017 16:56:10 +0200 -Subject: lib: add uevent_next_seqnum() +Subject: lib: add broadcast_uevent() Signed-off-by: Felix Fietkau --- diff --git a/target/linux/generic/hack-6.6/911-kobject_add_broadcast_uevent.patch b/target/linux/generic/hack-6.6/911-kobject_add_broadcast_uevent.patch index 56cd696e18..372ac6fa7d 100644 --- a/target/linux/generic/hack-6.6/911-kobject_add_broadcast_uevent.patch +++ b/target/linux/generic/hack-6.6/911-kobject_add_broadcast_uevent.patch @@ -1,7 +1,7 @@ From 0d37e6edc09c99e683dd91ca0e83bbc0df8477b3 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sun, 16 Jul 2017 16:56:10 +0200 -Subject: lib: add uevent_next_seqnum() +Subject: lib: add broadcast_uevent() Signed-off-by: Felix Fietkau --- diff --git a/target/linux/mediatek/dts/mt7981b-h3c-magic-nx30-pro.dts b/target/linux/mediatek/dts/mt7981b-h3c-magic-nx30-pro.dts index 7410369ed7..90d11e9514 100644 --- a/target/linux/mediatek/dts/mt7981b-h3c-magic-nx30-pro.dts +++ b/target/linux/mediatek/dts/mt7981b-h3c-magic-nx30-pro.dts @@ -20,6 +20,8 @@ }; chosen { + bootargs-append = " root=/dev/fit0 rootwait"; + rootdisk = <&ubi_rootdisk>; stdout-path = "serial0:115200n8"; }; @@ -141,6 +143,13 @@ partition@580000 { label = "ubi"; reg = <0x0580000 0x4000000>; + compatible = "linux,ubi"; + + volumes { + ubi_rootdisk: ubi-volume-fit { + volname = "fit"; + }; + }; }; /* yaffs partition */ diff --git a/target/linux/mediatek/dts/mt7981b-jcg-q30-pro.dts b/target/linux/mediatek/dts/mt7981b-jcg-q30-pro.dts index 97fad50725..e5ce69f87b 100644 --- a/target/linux/mediatek/dts/mt7981b-jcg-q30-pro.dts +++ b/target/linux/mediatek/dts/mt7981b-jcg-q30-pro.dts @@ -21,6 +21,8 @@ }; chosen { + bootargs-append = " root=/dev/fit0 rootwait"; + rootdisk = <&ubi_rootdisk>; stdout-path = "serial0:115200n8"; }; @@ -156,7 +158,14 @@ ubi: partition@580000 { label = "ubi"; - reg = <0x580000 0x7000000>; + reg = <0x0580000 0x7000000>; + compatible = "linux,ubi"; + + volumes { + ubi_rootdisk: ubi-volume-fit { + volname = "fit"; + }; + }; }; }; }; diff --git a/target/linux/mediatek/dts/mt7981b-qihoo-360t7.dts b/target/linux/mediatek/dts/mt7981b-qihoo-360t7.dts index 3925f80ba3..f167600f30 100644 --- a/target/linux/mediatek/dts/mt7981b-qihoo-360t7.dts +++ b/target/linux/mediatek/dts/mt7981b-qihoo-360t7.dts @@ -20,6 +20,8 @@ }; chosen { + bootargs-append = " root=/dev/fit0 rootwait"; + rootdisk = <&ubi_rootdisk>; stdout-path = "serial0:115200n8"; }; @@ -134,6 +136,13 @@ partition@580000 { label = "ubi"; reg = <0x0580000 0x6c00000>; + compatible = "linux,ubi"; + + volumes { + ubi_rootdisk: ubi-volume-fit { + volname = "fit"; + }; + }; }; partition@7180000 { diff --git a/target/linux/mediatek/dts/mt7981b-xiaomi-mi-router-ax3000t-ubootmod.dts b/target/linux/mediatek/dts/mt7981b-xiaomi-mi-router-ax3000t-ubootmod.dts index 809e625ce1..7466b8f7c6 100644 --- a/target/linux/mediatek/dts/mt7981b-xiaomi-mi-router-ax3000t-ubootmod.dts +++ b/target/linux/mediatek/dts/mt7981b-xiaomi-mi-router-ax3000t-ubootmod.dts @@ -6,11 +6,23 @@ / { model = "Xiaomi Mi Router AX3000T (OpenWrt U-Boot layout)"; compatible = "xiaomi,mi-router-ax3000t-ubootmod", "mediatek,mt7981"; + + chosen { + bootargs-append = " root=/dev/fit0 rootwait"; + rootdisk = <&ubi_rootdisk>; + }; }; &partitions { partition@600000 { label = "ubi"; reg = <0x600000 0x7000000>; + compatible = "linux,ubi"; + + volumes { + ubi_rootdisk: ubi-volume-fit { + volname = "fit"; + }; + }; }; }; diff --git a/target/linux/mediatek/dts/mt7981b-xiaomi-mi-router-wr30u-ubootmod.dts b/target/linux/mediatek/dts/mt7981b-xiaomi-mi-router-wr30u-ubootmod.dts index 6d0f3feb45..b22bbed379 100644 --- a/target/linux/mediatek/dts/mt7981b-xiaomi-mi-router-wr30u-ubootmod.dts +++ b/target/linux/mediatek/dts/mt7981b-xiaomi-mi-router-wr30u-ubootmod.dts @@ -6,11 +6,23 @@ / { model = "Xiaomi Mi Router WR30U (OpenWrt U-Boot layout)"; compatible = "xiaomi,mi-router-wr30u-ubootmod", "mediatek,mt7981"; + + chosen { + bootargs-append = " root=/dev/fit0 rootwait"; + rootdisk = <&ubi_rootdisk>; + }; }; &partitions { partition@600000 { label = "ubi"; reg = <0x600000 0x7000000>; + compatible = "linux,ubi"; + + volumes { + ubi_rootdisk: ubi-volume-fit { + volname = "fit"; + }; + }; }; }; diff --git a/target/linux/mediatek/dts/mt7986a-netcore-n60.dts b/target/linux/mediatek/dts/mt7986a-netcore-n60.dts index b96b1e2ec0..2c129acbba 100644 --- a/target/linux/mediatek/dts/mt7986a-netcore-n60.dts +++ b/target/linux/mediatek/dts/mt7986a-netcore-n60.dts @@ -21,6 +21,8 @@ }; chosen { + bootargs-append = " root=/dev/fit0 rootwait"; + rootdisk = <&ubi_rootdisk>; stdout-path = "serial0:115200n8"; }; @@ -206,6 +208,13 @@ partition@580000 { label = "ubi"; reg = <0x0580000 0x7280000>; + compatible = "linux,ubi"; + + volumes { + ubi_rootdisk: ubi-volume-fit { + volname = "fit"; + }; + }; }; }; }; diff --git a/target/linux/mediatek/dts/mt7986a-zyxel-ex5601-t0-ubootmod.dts b/target/linux/mediatek/dts/mt7986a-zyxel-ex5601-t0-ubootmod.dts index 7422a10aef..88010f6c5d 100644 --- a/target/linux/mediatek/dts/mt7986a-zyxel-ex5601-t0-ubootmod.dts +++ b/target/linux/mediatek/dts/mt7986a-zyxel-ex5601-t0-ubootmod.dts @@ -13,10 +13,16 @@ / { model = "Zyxel EX5601-T0 ubootmod"; compatible = "zyxel,ex5601-t0-ubootmod", "mediatek,mt7986a"; + memory@40000000 { device_type = "memory"; reg = <0x40000000 0x20000000>; }; + + chosen { + bootargs-append = " root=/dev/fit0 rootwait"; + rootdisk = <&ubi_rootdisk>; + }; }; &nand_partitions { @@ -82,6 +88,13 @@ partition@580000 { label = "ubi"; reg = <0x580000 0x1da80000>; + compatible = "linux,ubi"; + + volumes { + ubi_rootdisk: ubi-volume-fit { + volname = "fit"; + }; + }; }; }; diff --git a/target/linux/mediatek/files-6.6/arch/arm64/boot/dts/mediatek/mt7981-rfb-spim-nand.dtso b/target/linux/mediatek/files-6.6/arch/arm64/boot/dts/mediatek/mt7981-rfb-spim-nand.dtso index 5b51dfd671..ab53f96cde 100644 --- a/target/linux/mediatek/files-6.6/arch/arm64/boot/dts/mediatek/mt7981-rfb-spim-nand.dtso +++ b/target/linux/mediatek/files-6.6/arch/arm64/boot/dts/mediatek/mt7981-rfb-spim-nand.dtso @@ -6,6 +6,11 @@ compatible = "mediatek,mt7981-rfb", "mediatek,mt7981"; fragment@0 { + target = <&chosen>; + rootdisk-spim-nand = <&ubi_rootdisk>; + }; + + fragment@1 { target = <&spi0>; __overlay__ { status = "okay"; @@ -50,13 +55,20 @@ partition@580000 { label = "ubi"; reg = <0x580000 0x4000000>; + compatible = "linux,ubi"; + + volumes { + ubi_rootdisk: ubi-volume-fit { + volname = "fit"; + }; + }; }; }; }; }; }; - fragment@1 { + fragment@2 { target = <&wifi>; __overlay__ { mediatek,mtd-eeprom = <&factory 0x0>; diff --git a/target/linux/mediatek/files-6.6/arch/arm64/boot/dts/mediatek/mt7981-rfb.dts b/target/linux/mediatek/files-6.6/arch/arm64/boot/dts/mediatek/mt7981-rfb.dts index b2bb692956..791b56113a 100644 --- a/target/linux/mediatek/files-6.6/arch/arm64/boot/dts/mediatek/mt7981-rfb.dts +++ b/target/linux/mediatek/files-6.6/arch/arm64/boot/dts/mediatek/mt7981-rfb.dts @@ -15,8 +15,9 @@ serial0 = &uart0; }; - chosen { + chosen: chosen { stdout-path = "serial0:115200n8"; + bootargs-append = " root=/dev/fit0 rootwait"; }; memory { diff --git a/target/linux/mediatek/files/block/partitions/fit.c b/target/linux/mediatek/files/block/partitions/fit.c deleted file mode 100644 index 01b0f42c7c..0000000000 --- a/target/linux/mediatek/files/block/partitions/fit.c +++ /dev/null @@ -1,307 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * fs/partitions/fit.c - * Copyright (C) 2021 Daniel Golle - * - * headers extracted from U-Boot mkimage sources - * (C) Copyright 2008 Semihalf - * (C) Copyright 2000-2005 - * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - * - * based on existing partition parsers - * Copyright (C) 1991-1998 Linus Torvalds - * Re-organised Feb 1998 Russell King - */ - -#define pr_fmt(fmt) fmt - -#include -#include -#include -#include -#include -#include - -#include "check.h" - -#define FIT_IMAGES_PATH "/images" -#define FIT_CONFS_PATH "/configurations" - -/* hash/signature/key node */ -#define FIT_HASH_NODENAME "hash" -#define FIT_ALGO_PROP "algo" -#define FIT_VALUE_PROP "value" -#define FIT_IGNORE_PROP "uboot-ignore" -#define FIT_SIG_NODENAME "signature" -#define FIT_KEY_REQUIRED "required" -#define FIT_KEY_HINT "key-name-hint" - -/* cipher node */ -#define FIT_CIPHER_NODENAME "cipher" -#define FIT_ALGO_PROP "algo" - -/* image node */ -#define FIT_DATA_PROP "data" -#define FIT_DATA_POSITION_PROP "data-position" -#define FIT_DATA_OFFSET_PROP "data-offset" -#define FIT_DATA_SIZE_PROP "data-size" -#define FIT_TIMESTAMP_PROP "timestamp" -#define FIT_DESC_PROP "description" -#define FIT_ARCH_PROP "arch" -#define FIT_TYPE_PROP "type" -#define FIT_OS_PROP "os" -#define FIT_COMP_PROP "compression" -#define FIT_ENTRY_PROP "entry" -#define FIT_LOAD_PROP "load" - -/* configuration node */ -#define FIT_KERNEL_PROP "kernel" -#define FIT_FILESYSTEM_PROP "filesystem" -#define FIT_RAMDISK_PROP "ramdisk" -#define FIT_FDT_PROP "fdt" -#define FIT_LOADABLE_PROP "loadables" -#define FIT_DEFAULT_PROP "default" -#define FIT_SETUP_PROP "setup" -#define FIT_FPGA_PROP "fpga" -#define FIT_FIRMWARE_PROP "firmware" -#define FIT_STANDALONE_PROP "standalone" - -#define FIT_MAX_HASH_LEN HASH_MAX_DIGEST_SIZE - -#define MIN_FREE_SECT 16 -#define REMAIN_VOLNAME "rootfs_data" - -int parse_fit_partitions(struct parsed_partitions *state, u64 fit_start_sector, u64 sectors, int *slot, int add_remain) -{ - struct block_device *bdev = state->disk->part0; - struct address_space *mapping = bdev->bd_inode->i_mapping; - struct page *page; - void *fit, *init_fit; - struct partition_meta_info *info; - char tmp[sizeof(info->volname)]; - u64 dsize, dsectors, imgmaxsect = 0; - u32 size, image_pos, image_len; - const u32 *image_offset_be, *image_len_be, *image_pos_be; - int ret = 1, node, images, config; - const char *image_name, *image_type, *image_description, *config_default, - *config_description, *config_loadables, *bootconf_c; - int image_name_len, image_type_len, image_description_len, config_default_len, - config_description_len, config_loadables_len, bootconf_len; - sector_t start_sect, nr_sects; - size_t label_min; - struct device_node *np = NULL; - char *bootconf = NULL, *bootconf_term; - const char *loadable; - const char *select_rootfs = NULL; - bool found; - int loadables_rem_len, loadable_len; - - if (fit_start_sector % (1<<(PAGE_SHIFT - SECTOR_SHIFT))) - return -ERANGE; - - page = read_mapping_page(mapping, fit_start_sector >> (PAGE_SHIFT - SECTOR_SHIFT), NULL); - if (IS_ERR(page)) - return -EFAULT; - - if (PageError(page)) - return -EFAULT; - - init_fit = page_address(page); - - if (!init_fit) { - put_page(page); - return -EFAULT; - } - - if (fdt_check_header(init_fit)) { - put_page(page); - return 0; - } - - dsectors = get_capacity(bdev->bd_disk); - if (sectors) - dsectors = (dsectors>sectors)?sectors:dsectors; - - dsize = dsectors << SECTOR_SHIFT; - size = fdt_totalsize(init_fit); - - /* silently skip non-external-data legacy FIT images */ - if (size > PAGE_SIZE) { - put_page(page); - return 0; - } - - if (size >= dsize) { - state->access_beyond_eod = 1; - put_page(page); - return -EFBIG; - } - - fit = kmemdup(init_fit, size, GFP_KERNEL); - put_page(page); - if (!fit) - return -ENOMEM; - - np = of_find_node_by_path("/chosen"); - if (np) { - /* new fitblk driver should take over if /chosen/rootdisk is defined */ - if (of_get_property(np, "rootdisk", NULL)) - return 0; - - bootconf_c = of_get_property(np, "u-boot,bootconf", &bootconf_len); - if (bootconf_c && bootconf_len) - bootconf = kmemdup_nul(bootconf_c, bootconf_len, GFP_KERNEL); - } - - if (bootconf) { - bootconf_term = strchr(bootconf, '#'); - if (bootconf_term) - *bootconf_term = '\0'; - } - - config = fdt_path_offset(fit, FIT_CONFS_PATH); - if (config < 0) { - printk(KERN_ERR "FIT: Cannot find %s node: %d\n", FIT_CONFS_PATH, config); - ret = -ENOENT; - goto ret_out; - } - - config_default = fdt_getprop(fit, config, FIT_DEFAULT_PROP, &config_default_len); - - if (!config_default && !bootconf) { - printk(KERN_ERR "FIT: Cannot find default configuration\n"); - ret = -ENOENT; - goto ret_out; - } - - node = fdt_subnode_offset(fit, config, bootconf?:config_default); - if (node < 0) { - printk(KERN_ERR "FIT: Cannot find %s node: %d\n", bootconf?:config_default, node); - ret = -ENOENT; - goto ret_out; - } - - config_description = fdt_getprop(fit, node, FIT_DESC_PROP, &config_description_len); - config_loadables = fdt_getprop(fit, node, FIT_LOADABLE_PROP, &config_loadables_len); - - printk(KERN_DEBUG "FIT: %s configuration: \"%s\"%s%s%s\n", - bootconf?"Selected":"Default", bootconf?:config_default, - config_description?" (":"", config_description?:"", config_description?")":""); - - if (!config_loadables || !config_loadables_len) { - printk(KERN_ERR "FIT: No loadables configured in \"%s\"\n", bootconf?:config_default); - ret = -ENOENT; - goto ret_out; - } - - images = fdt_path_offset(fit, FIT_IMAGES_PATH); - if (images < 0) { - printk(KERN_ERR "FIT: Cannot find %s node: %d\n", FIT_IMAGES_PATH, images); - ret = -EINVAL; - goto ret_out; - } - - fdt_for_each_subnode(node, fit, images) { - image_name = fdt_get_name(fit, node, &image_name_len); - image_type = fdt_getprop(fit, node, FIT_TYPE_PROP, &image_type_len); - image_offset_be = fdt_getprop(fit, node, FIT_DATA_OFFSET_PROP, NULL); - image_pos_be = fdt_getprop(fit, node, FIT_DATA_POSITION_PROP, NULL); - image_len_be = fdt_getprop(fit, node, FIT_DATA_SIZE_PROP, NULL); - if (!image_name || !image_type || !image_len_be) - continue; - - image_len = be32_to_cpu(*image_len_be); - if (!image_len) - continue; - - if (image_offset_be) - image_pos = be32_to_cpu(*image_offset_be) + size; - else if (image_pos_be) - image_pos = be32_to_cpu(*image_pos_be); - else - continue; - - image_description = fdt_getprop(fit, node, FIT_DESC_PROP, &image_description_len); - - printk(KERN_DEBUG "FIT: %16s sub-image 0x%08x..0x%08x \"%s\" %s%s%s\n", - image_type, image_pos, image_pos + image_len - 1, image_name, - image_description?"(":"", image_description?:"", image_description?") ":""); - - if (strcmp(image_type, FIT_FILESYSTEM_PROP)) - continue; - - /* check if sub-image is part of configured loadables */ - found = false; - loadable = config_loadables; - loadables_rem_len = config_loadables_len; - while (loadables_rem_len > 1) { - loadable_len = strnlen(loadable, loadables_rem_len - 1) + 1; - loadables_rem_len -= loadable_len; - if (!strncmp(image_name, loadable, loadable_len)) { - found = true; - break; - } - loadable += loadable_len; - } - if (!found) - continue; - - if (image_pos & ((1 << PAGE_SHIFT)-1)) { - printk(KERN_ERR "FIT: image %s start not aligned to page boundaries, skipping\n", image_name); - continue; - } - - if (image_len & ((1 << PAGE_SHIFT)-1)) { - printk(KERN_ERR "FIT: sub-image %s end not aligned to page boundaries, skipping\n", image_name); - continue; - } - - start_sect = image_pos >> SECTOR_SHIFT; - nr_sects = image_len >> SECTOR_SHIFT; - imgmaxsect = (imgmaxsect < (start_sect + nr_sects))?(start_sect + nr_sects):imgmaxsect; - - if (start_sect + nr_sects > dsectors) { - state->access_beyond_eod = 1; - continue; - } - - put_partition(state, ++(*slot), fit_start_sector + start_sect, nr_sects); - state->parts[*slot].flags = ADDPART_FLAG_READONLY; - state->parts[*slot].has_info = true; - info = &state->parts[*slot].info; - - label_min = min_t(int, sizeof(info->volname) - 1, image_name_len); - strncpy(info->volname, image_name, label_min); - info->volname[label_min] = '\0'; - - snprintf(tmp, sizeof(tmp), "(%s)", info->volname); - strlcat(state->pp_buf, tmp, PAGE_SIZE); - - /* Mark first loadable listed to be mounted as rootfs */ - if (!strcmp(image_name, config_loadables)) { - select_rootfs = image_name; - state->parts[*slot].flags |= ADDPART_FLAG_ROOTDEV; - } - } - - if (select_rootfs) - printk(KERN_DEBUG "FIT: selecting configured loadable \"%s\" to be root filesystem\n", select_rootfs); - - if (add_remain && (imgmaxsect + MIN_FREE_SECT) < dsectors) { - put_partition(state, ++(*slot), fit_start_sector + imgmaxsect, dsectors - imgmaxsect); - state->parts[*slot].flags = 0; - info = &state->parts[*slot].info; - strcpy(info->volname, REMAIN_VOLNAME); - snprintf(tmp, sizeof(tmp), "(%s)", REMAIN_VOLNAME); - strlcat(state->pp_buf, tmp, PAGE_SIZE); - } -ret_out: - kfree(bootconf); - kfree(fit); - return ret; -} - -int fit_partition(struct parsed_partitions *state) { - int slot = 0; - return parse_fit_partitions(state, 0, 0, &slot, 0); -} diff --git a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh index 3fbe9649b5..07e53c8e83 100755 --- a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh @@ -70,15 +70,23 @@ platform_do_upgrade() { bananapi,bpi-r4|\ bananapi,bpi-r4-poe|\ cmcc,rax3000m|\ + h3c,magic-nx30-pro|\ + jcg,q30-pro|\ jdcloud,re-cp-03|\ + mediatek,mt7981-rfb|\ mediatek,mt7988a-rfb|\ nokia,ea0326gmp|\ openwrt,one|\ + netcore,n60|\ + qihoo,360t7|\ tplink,tl-xdr4288|\ tplink,tl-xdr6086|\ tplink,tl-xdr6088|\ tplink,tl-xtr8488|\ - xiaomi,redmi-router-ax6000-ubootmod) + xiaomi,mi-router-ax3000t-ubootmod|\ + xiaomi,redmi-router-ax6000-ubootmod|\ + xiaomi,mi-router-wr30u-ubootmod|\ + zyxel,ex5601-t0-ubootmod) fit_do_upgrade "$1" ;; acer,predator-w6|\ @@ -112,16 +120,6 @@ platform_do_upgrade() { CI_ROOTPART="rootfs" emmc_do_upgrade "$1" ;; - h3c,magic-nx30-pro|\ - jcg,q30-pro|\ - mediatek,mt7981-rfb|\ - netcore,n60|\ - qihoo,360t7|\ - xiaomi,mi-router-ax3000t-ubootmod|\ - xiaomi,mi-router-wr30u-ubootmod) - CI_KERNPART="fit" - nand_do_upgrade "$1" - ;; mercusys,mr90x-v1|\ tplink,re6000xd) CI_UBIPART="ubi0" @@ -139,11 +137,6 @@ platform_do_upgrade() { CI_ROOT_UBIPART=ubi nand_do_upgrade "$1" ;; - zyxel,ex5601-t0-ubootmod) - CI_KERNPART="fit" - CI_ROOTPART="ubi_rootfs" - nand_do_upgrade "$1" - ;; unielec,u7981-01*) local rootdev="$(cmdline_get_var root)" rootdev="${rootdev##*/}" diff --git a/target/linux/mediatek/filogic/config-6.6 b/target/linux/mediatek/filogic/config-6.6 index cb36d74e1d..818bcfa081 100644 --- a/target/linux/mediatek/filogic/config-6.6 +++ b/target/linux/mediatek/filogic/config-6.6 @@ -158,7 +158,6 @@ CONFIG_EINT_MTK=y CONFIG_EXCLUSIVE_SYSTEM_RAM=y CONFIG_EXT4_FS=y CONFIG_F2FS_FS=y -CONFIG_FIT_PARTITION=y CONFIG_FIXED_PHY=y CONFIG_FIX_EARLYCON_MEM=y CONFIG_FRAME_POINTER=y diff --git a/target/linux/mediatek/mt7622/config-6.6 b/target/linux/mediatek/mt7622/config-6.6 index fab9c7dbe6..cf445b2b71 100644 --- a/target/linux/mediatek/mt7622/config-6.6 +++ b/target/linux/mediatek/mt7622/config-6.6 @@ -164,7 +164,6 @@ CONFIG_EINT_MTK=y CONFIG_EXCLUSIVE_SYSTEM_RAM=y CONFIG_EXT4_FS=y CONFIG_F2FS_FS=y -# CONFIG_FIT_PARTITION is not set CONFIG_FIXED_PHY=y CONFIG_FIX_EARLYCON_MEM=y CONFIG_FRAME_POINTER=y diff --git a/target/linux/mediatek/mt7623/config-6.6 b/target/linux/mediatek/mt7623/config-6.6 index 9d6c5eed96..bb00bee8f3 100644 --- a/target/linux/mediatek/mt7623/config-6.6 +++ b/target/linux/mediatek/mt7623/config-6.6 @@ -224,7 +224,6 @@ CONFIG_FB_SYS_COPYAREA=y CONFIG_FB_SYS_FILLRECT=y CONFIG_FB_SYS_FOPS=y CONFIG_FB_SYS_IMAGEBLIT=y -# CONFIG_FIT_PARTITION is not set CONFIG_FIXED_PHY=y CONFIG_FIX_EARLYCON_MEM=y CONFIG_FONT_8x16=y diff --git a/target/linux/mediatek/mt7629/config-6.6 b/target/linux/mediatek/mt7629/config-6.6 index ec029de2fe..1748efab77 100644 --- a/target/linux/mediatek/mt7629/config-6.6 +++ b/target/linux/mediatek/mt7629/config-6.6 @@ -106,7 +106,6 @@ CONFIG_EDAC_ATOMIC_SCRUB=y CONFIG_EDAC_SUPPORT=y CONFIG_EINT_MTK=y CONFIG_EXCLUSIVE_SYSTEM_RAM=y -# CONFIG_FIT_PARTITION is not set CONFIG_FIXED_PHY=y CONFIG_FIX_EARLYCON_MEM=y CONFIG_FS_IOMAP=y diff --git a/target/linux/mediatek/patches-6.6/041-block-fit-partition-parser.patch b/target/linux/mediatek/patches-6.6/041-block-fit-partition-parser.patch deleted file mode 100644 index de91497a85..0000000000 --- a/target/linux/mediatek/patches-6.6/041-block-fit-partition-parser.patch +++ /dev/null @@ -1,216 +0,0 @@ -From 69357074558daf6ff24c9f58714935e9e095a865 Mon Sep 17 00:00:00 2001 -From: OpenWrt community -Date: Wed, 13 Jul 2022 13:37:33 +0200 -Subject: [PATCH] kernel: add block fit partition parser - ---- - block/blk.h | 2 ++ - block/partitions/Kconfig | 7 +++++++ - block/partitions/Makefile | 1 + - block/partitions/check.h | 3 +++ - block/partitions/core.c | 17 +++++++++++++++++ - block/partitions/efi.c | 8 ++++++++ - block/partitions/efi.h | 3 +++ - block/partitions/msdos.c | 10 ++++++++++ - drivers/mtd/mtd_blkdevs.c | 2 ++ - drivers/mtd/ubi/block.c | 3 +++ - include/linux/msdos_partition.h | 1 + - 11 files changed, 57 insertions(+) - ---- a/block/blk.h -+++ b/block/blk.h -@@ -424,6 +424,8 @@ void blk_free_ext_minor(unsigned int min - #define ADDPART_FLAG_NONE 0 - #define ADDPART_FLAG_RAID 1 - #define ADDPART_FLAG_WHOLEDISK 2 -+#define ADDPART_FLAG_READONLY 4 -+#define ADDPART_FLAG_ROOTDEV 8 - int bdev_add_partition(struct gendisk *disk, int partno, sector_t start, - sector_t length); - int bdev_del_partition(struct gendisk *disk, int partno); ---- a/block/partitions/Kconfig -+++ b/block/partitions/Kconfig -@@ -103,6 +103,13 @@ config ATARI_PARTITION - Say Y here if you would like to use hard disks under Linux which - were partitioned under the Atari OS. - -+config FIT_PARTITION -+ bool "Flattened-Image-Tree (FIT) partition support" if PARTITION_ADVANCED -+ default n -+ help -+ Say Y here if your system needs to mount the filesystem part of -+ a Flattened-Image-Tree (FIT) image commonly used with Das U-Boot. -+ - config IBM_PARTITION - bool "IBM disk label and partition support" - depends on PARTITION_ADVANCED && S390 ---- a/block/partitions/Makefile -+++ b/block/partitions/Makefile -@@ -8,6 +8,7 @@ obj-$(CONFIG_ACORN_PARTITION) += acorn.o - obj-$(CONFIG_AMIGA_PARTITION) += amiga.o - obj-$(CONFIG_ATARI_PARTITION) += atari.o - obj-$(CONFIG_AIX_PARTITION) += aix.o -+obj-$(CONFIG_FIT_PARTITION) += fit.o - obj-$(CONFIG_CMDLINE_PARTITION) += cmdline.o - obj-$(CONFIG_MAC_PARTITION) += mac.o - obj-$(CONFIG_LDM_PARTITION) += ldm.o ---- a/block/partitions/check.h -+++ b/block/partitions/check.h -@@ -57,6 +57,7 @@ int amiga_partition(struct parsed_partit - int atari_partition(struct parsed_partitions *state); - int cmdline_partition(struct parsed_partitions *state); - int efi_partition(struct parsed_partitions *state); -+int fit_partition(struct parsed_partitions *state); - int ibm_partition(struct parsed_partitions *); - int karma_partition(struct parsed_partitions *state); - int ldm_partition(struct parsed_partitions *state); -@@ -67,3 +68,5 @@ int sgi_partition(struct parsed_partitio - int sun_partition(struct parsed_partitions *state); - int sysv68_partition(struct parsed_partitions *state); - int ultrix_partition(struct parsed_partitions *state); -+ -+int parse_fit_partitions(struct parsed_partitions *state, u64 start_sector, u64 nr_sectors, int *slot, int add_remain); ---- a/block/partitions/core.c -+++ b/block/partitions/core.c -@@ -11,6 +11,9 @@ - #include - #include - #include -+#ifdef CONFIG_FIT_PARTITION -+#include -+#endif - - #include "check.h" - -@@ -48,6 +51,9 @@ static int (*const check_part[])(struct - #ifdef CONFIG_EFI_PARTITION - efi_partition, /* this must come before msdos */ - #endif -+#ifdef CONFIG_FIT_PARTITION -+ fit_partition, -+#endif - #ifdef CONFIG_SGI_PARTITION - sgi_partition, - #endif -@@ -464,6 +470,11 @@ static struct block_device *add_partitio - goto out_del; - } - -+#ifdef CONFIG_FIT_PARTITION -+ if (flags & ADDPART_FLAG_READONLY) -+ bdev->bd_read_only = true; -+#endif -+ - /* everything is up and running, commence */ - err = xa_insert(&disk->part_tbl, partno, bdev, GFP_KERNEL); - if (err) -@@ -656,6 +667,11 @@ static bool blk_add_partition(struct gen - (state->parts[p].flags & ADDPART_FLAG_RAID)) - md_autodetect_dev(part->bd_dev); - -+#ifdef CONFIG_FIT_PARTITION -+ if ((state->parts[p].flags & ADDPART_FLAG_ROOTDEV) && ROOT_DEV == 0) -+ ROOT_DEV = part->bd_dev; -+#endif -+ - return true; - } - ---- a/block/partitions/efi.c -+++ b/block/partitions/efi.c -@@ -716,6 +716,9 @@ int efi_partition(struct parsed_partitio - gpt_entry *ptes = NULL; - u32 i; - unsigned ssz = queue_logical_block_size(state->disk->queue) / 512; -+#ifdef CONFIG_FIT_PARTITION -+ u32 extra_slot = 64; -+#endif - - if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) { - kfree(gpt); -@@ -749,6 +752,11 @@ int efi_partition(struct parsed_partitio - ARRAY_SIZE(ptes[i].partition_name)); - utf16_le_to_7bit(ptes[i].partition_name, label_max, info->volname); - state->parts[i + 1].has_info = true; -+#ifdef CONFIG_FIT_PARTITION -+ /* If this is a U-Boot FIT volume it may have subpartitions */ -+ if (!efi_guidcmp(ptes[i].partition_type_guid, PARTITION_LINUX_FIT_GUID)) -+ (void) parse_fit_partitions(state, start * ssz, size * ssz, &extra_slot, 1); -+#endif - } - kfree(ptes); - kfree(gpt); ---- a/block/partitions/efi.h -+++ b/block/partitions/efi.h -@@ -51,6 +51,9 @@ - #define PARTITION_LINUX_LVM_GUID \ - EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \ - 0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28) -+#define PARTITION_LINUX_FIT_GUID \ -+ EFI_GUID( 0xcae9be83, 0xb15f, 0x49cc, \ -+ 0x86, 0x3f, 0x08, 0x1b, 0x74, 0x4a, 0x2d, 0x93) - - typedef struct _gpt_header { - __le64 signature; ---- a/block/partitions/msdos.c -+++ b/block/partitions/msdos.c -@@ -564,6 +564,15 @@ static void parse_minix(struct parsed_pa - #endif /* CONFIG_MINIX_SUBPARTITION */ - } - -+static void parse_fit_mbr(struct parsed_partitions *state, -+ sector_t offset, sector_t size, int origin) -+{ -+#ifdef CONFIG_FIT_PARTITION -+ u32 extra_slot = 64; -+ (void) parse_fit_partitions(state, offset, size, &extra_slot, 1); -+#endif /* CONFIG_FIT_PARTITION */ -+} -+ - static struct { - unsigned char id; - void (*parse)(struct parsed_partitions *, sector_t, sector_t, int); -@@ -575,6 +584,7 @@ static struct { - {UNIXWARE_PARTITION, parse_unixware}, - {SOLARIS_X86_PARTITION, parse_solaris_x86}, - {NEW_SOLARIS_X86_PARTITION, parse_solaris_x86}, -+ {FIT_PARTITION, parse_fit_mbr}, - {0, NULL}, - }; - ---- a/drivers/mtd/mtd_blkdevs.c -+++ b/drivers/mtd/mtd_blkdevs.c -@@ -359,7 +359,9 @@ int add_mtd_blktrans_dev(struct mtd_blkt - } else { - snprintf(gd->disk_name, sizeof(gd->disk_name), - "%s%d", tr->name, new->devnum); -- gd->flags |= GENHD_FL_NO_PART; -+ -+ if (!IS_ENABLED(CONFIG_FIT_PARTITION) || mtd_type_is_nand(new->mtd)) -+ gd->flags |= GENHD_FL_NO_PART; - } - - set_capacity(gd, ((u64)new->size * tr->blksize) >> 9); ---- a/drivers/mtd/ubi/block.c -+++ b/drivers/mtd/ubi/block.c -@@ -410,7 +410,9 @@ int ubiblock_create(struct ubi_volume_in - ret = -ENODEV; - goto out_cleanup_disk; - } -- gd->flags |= GENHD_FL_NO_PART; -+ if (!IS_ENABLED(CONFIG_FIT_PARTITION)) -+ gd->flags |= GENHD_FL_NO_PART; -+ - gd->private_data = dev; - sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id); - set_capacity(gd, disk_capacity); ---- a/include/linux/msdos_partition.h -+++ b/include/linux/msdos_partition.h -@@ -31,6 +31,7 @@ enum msdos_sys_ind { - LINUX_LVM_PARTITION = 0x8e, - LINUX_RAID_PARTITION = 0xfd, /* autodetect RAID partition */ - -+ FIT_PARTITION = 0x2e, /* U-Boot uImage.FIT */ - SOLARIS_X86_PARTITION = 0x82, /* also Linux swap partitions */ - NEW_SOLARIS_X86_PARTITION = 0xbf, -