From c85348d9abf4b89d37a7fa134cf6424bdf16787f Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Tue, 16 Jul 2024 19:00:29 +0200 Subject: [PATCH 01/13] imagebuilder: remove initramfs image files Initramfs images are not supported by imagebuilder. With recent changes to support Per Device Rootfs, we now generate an image and a vmlinux for each Rootfs and these additional files are all shipped in the imagebuilder tar. Drop these new file and any vmlinux-initramfs as they are not used and increase the final size of the imagebuilder archive. Signed-off-by: Christian Marangi --- target/imagebuilder/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/imagebuilder/Makefile b/target/imagebuilder/Makefile index 7fd2aa0920..7127df5ebc 100644 --- a/target/imagebuilder/Makefile +++ b/target/imagebuilder/Makefile @@ -112,6 +112,9 @@ endif -cp $(LINUX_DIR)/.config $(IB_LDIR)/ rm -f $(IB_KDIR)/root.* rm -f $(IB_KDIR)/vmlinux.debug + # remove any file for initramfs and Per Device Rootfs initramfs files + rm -f $(IB_KDIR)/vmlinux-initramfs* + rm -f $(IB_KDIR)/Image-initramfs* if [ -x $(LINUX_DIR)/scripts/dtc/dtc ]; then \ $(INSTALL_DIR) $(IB_LDIR)/scripts/dtc; \ $(INSTALL_BIN) $(LINUX_DIR)/scripts/dtc/dtc $(IB_LDIR)/scripts/dtc/dtc; \ From c46ce8307c217ff22182ce2a4cbf8bc63dd5d367 Mon Sep 17 00:00:00 2001 From: Zxl hhyccc Date: Tue, 16 Jul 2024 14:14:08 +0800 Subject: [PATCH 02/13] kernel: bump 6.1 to 6.1.99 https://cdn.kernel.org/pub/linux/kernel/v6.x/ChangeLog-6.1.99 All patches automatically rebased. Build system: Kirkwood bcm53xx Signed-off-by: Zxl hhyccc --- include/kernel-6.1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/kernel-6.1 b/include/kernel-6.1 index 1f97e8f301..dcdebfc6cb 100644 --- a/include/kernel-6.1 +++ b/include/kernel-6.1 @@ -1,2 +1,2 @@ -LINUX_VERSION-6.1 = .98 -LINUX_KERNEL_HASH-6.1.98 = 97cdc9127c7700556ea0891267a0c24cf372f4b81636fb8203a914f3a69f3406 +LINUX_VERSION-6.1 = .99 +LINUX_KERNEL_HASH-6.1.99 = c086ee9ce2b1eeba6e085d569bc97ae764a5d15f6322847f0ebc9f787ae34dd3 From 0641967458a587033390c7d33dbaf715125b2242 Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Sat, 13 Jul 2024 14:49:08 +0200 Subject: [PATCH 03/13] omap: switch back to old cpsw ethernet driver The new cpsw-switch driver reserves VLAN 1 for internal use, which conflicts with the default network configuration of OpenWrt. Switch back to the older cpsw driver to make the network connection on the affected devices (BeagleBone Black and AM335x EVM) usable again. Signed-off-by: Jan Hoffmann --- .../900-use-cpsw-ethernet-driver.patch | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 target/linux/omap/patches/900-use-cpsw-ethernet-driver.patch diff --git a/target/linux/omap/patches/900-use-cpsw-ethernet-driver.patch b/target/linux/omap/patches/900-use-cpsw-ethernet-driver.patch new file mode 100644 index 0000000000..17c07fbdfb --- /dev/null +++ b/target/linux/omap/patches/900-use-cpsw-ethernet-driver.patch @@ -0,0 +1,93 @@ +From: Jan Hoffmann +Date: Sat, 27 Apr 2024 20:41:43 +0200 +Subject: ARM: dts: Use cpsw ethernet driver for some am335x devices + +The new cpsw-switch driver requires a vid for every port which is +reserved for internal usage (defaulting to 1 and 2). As a result, some +network configurations are impossible, such as a bridge with +default_pvid of 1 (even if it is not vlan aware). + +As a simple workaround, the ti,dual-emac-pvid property could be changed +to another value, but that would just shift the problem. Instead, switch +some devices back to the older cpsw ethernet driver. + +(This patch is not suitable for upstreaming, it just makes the affected +devices in OpenWrt usable again with the default network config.) + +Signed-off-by: Jan Hoffmann +--- + +--- a/arch/arm/boot/dts/am335x-bone-common.dtsi ++++ b/arch/arm/boot/dts/am335x-bone-common.dtsi +@@ -353,27 +353,24 @@ + }; + }; + +-&cpsw_port1 { ++&cpsw_emac0 { + phy-handle = <ðphy0>; + phy-mode = "mii"; +- ti,dual-emac-pvid = <1>; + }; + +-&cpsw_port2 { +- status = "disabled"; +-}; +- +-&mac_sw { ++&mac { ++ slaves = <1>; + pinctrl-names = "default", "sleep"; + pinctrl-0 = <&cpsw_default>; + pinctrl-1 = <&cpsw_sleep>; + status = "okay"; + }; + +-&davinci_mdio_sw { ++&davinci_mdio { + pinctrl-names = "default", "sleep"; + pinctrl-0 = <&davinci_mdio_default>; + pinctrl-1 = <&davinci_mdio_sleep>; ++ status = "okay"; + + ethphy0: ethernet-phy@0 { + reg = <0>; +--- a/arch/arm/boot/dts/am335x-evm.dts ++++ b/arch/arm/boot/dts/am335x-evm.dts +@@ -682,31 +682,28 @@ + }; + }; + +-&mac_sw { ++&mac { ++ slaves = <1>; + pinctrl-names = "default", "sleep"; + pinctrl-0 = <&cpsw_default>; + pinctrl-1 = <&cpsw_sleep>; + status = "okay"; + }; + +-&davinci_mdio_sw { ++&davinci_mdio { + pinctrl-names = "default", "sleep"; + pinctrl-0 = <&davinci_mdio_default>; + pinctrl-1 = <&davinci_mdio_sleep>; ++ status = "okay"; + + ethphy0: ethernet-phy@0 { + reg = <0>; + }; + }; + +-&cpsw_port1 { ++&cpsw_emac0 { + phy-handle = <ðphy0>; + phy-mode = "rgmii-id"; +- ti,dual-emac-pvid = <1>; +-}; +- +-&cpsw_port2 { +- status = "disabled"; + }; + + &tscadc { From 9d8d0509bf2a630464e050de21e21110748e4f27 Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Sat, 13 Jul 2024 14:49:09 +0200 Subject: [PATCH 04/13] omap: re-enable target The target was marked source-only due do the broken Ethernet port on some devices. With that fixed, it can be enabled again. Signed-off-by: Jan Hoffmann --- target/linux/omap/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/omap/Makefile b/target/linux/omap/Makefile index fc0842d056..a3c61efc9a 100644 --- a/target/linux/omap/Makefile +++ b/target/linux/omap/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk ARCH:=arm BOARD:=omap BOARDNAME:=TI OMAP3/4/AM33xx -FEATURES:=usb usbgadget ext4 targz fpu audio display nand rootfs-part squashfs source-only +FEATURES:=usb usbgadget ext4 targz fpu audio display nand rootfs-part squashfs CPU_TYPE:=cortex-a8 CPU_SUBTYPE:=vfpv3 SUBTARGETS:=generic From ec2dc60d575f6ef4ace4aa36d4940b7e13034778 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Wed, 17 Jul 2024 16:22:10 +0100 Subject: [PATCH 05/13] fitblk: move shell functions to common file Move shell functions used for sysupgrade into /lib/upgrade/fit.sh. Introduce improved fitblk boot device detection function which works also in case ubiblock devices have not yet been created or even UBI itself not yet being attached. Signed-off-by: Daniel Golle --- package/utils/fitblk/Makefile | 4 +- package/utils/fitblk/files/fit.sh | 63 +++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 package/utils/fitblk/files/fit.sh diff --git a/package/utils/fitblk/Makefile b/package/utils/fitblk/Makefile index 4da4dc46f1..8fb6e14c7e 100644 --- a/package/utils/fitblk/Makefile +++ b/package/utils/fitblk/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=fitblk -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_LICENSE:=GPL-2.0-only PKG_MAINTAINER:=Daniel Golle @@ -36,6 +36,8 @@ endef define Package/fitblk/install $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_BIN) $(PKG_BUILD_DIR)/fitblk $(1)/usr/sbin/ + $(INSTALL_DIR) $(1)/lib/upgrade + $(INSTALL_DATA) ./files/fit.sh $(1)/lib/upgrade endef $(eval $(call BuildPackage,fitblk)) diff --git a/package/utils/fitblk/files/fit.sh b/package/utils/fitblk/files/fit.sh new file mode 100644 index 0000000000..b715a15ddf --- /dev/null +++ b/package/utils/fitblk/files/fit.sh @@ -0,0 +1,63 @@ +export_fitblk_bootdev() { + [ -e /sys/firmware/devicetree/base/chosen/rootdisk ] || return + + local rootdisk="$(cat /sys/firmware/devicetree/base/chosen/rootdisk)" + local handle bootdev + + for handle in /sys/class/mtd/mtd*/of_node/volumes/*/phandle; do + [ ! -e "$handle" ] && continue + if [ "$rootdisk" = "$(cat "$handle")" ]; then + if [ -e "${handle%/phandle}/volname" ]; then + export CI_KERNPART="$(cat "${handle%/phandle}/volname")" + elif [ -e "${handle%/phandle}/volid" ]; then + export CI_KERNVOLID="$(cat "${handle%/phandle}/volid")" + else + return + fi + export CI_UBIPART="$(cat "${handle%%/of_node*}/name")" + export CI_METHOD="ubi" + return + fi + done + + for handle in /sys/class/mtd/mtd*/of_node/phandle; do + [ ! -e "$handle" ] && continue + if [ "$rootdisk" = "$(cat $handle)" ]; then + bootdev="${handle%/of_node/phandle}" + bootdev="${bootdev#/sys/class/mtd/}" + export PART_NAME="/dev/$bootdev" + export CI_METHOD="default" + return + fi + done + + for handle in /sys/class/block/*/of_node/phandle; do + [ ! -e "$handle" ] && continue + if [ "$rootdisk" = "$(cat $handle)" ]; then + bootdev="${handle%/of_node/phandle}" + bootdev="${bootdev#/sys/class/block/}" + export EMMC_KERN_DEV="/dev/$bootdev" + export CI_METHOD="emmc" + return + fi + done +} + +fit_do_upgrade() { + export_fitblk_bootdev + [ -n "$CI_METHOD" ] || return 1 + [ -e /dev/fit0 ] && fitblk /dev/fit0 + [ -e /dev/fitrw ] && fitblk /dev/fitrw + + case "$CI_METHOD" in + emmc) + emmc_do_upgrade "$1" + ;; + default) + default_do_upgrade "$1" + ;; + ubi) + nand_do_upgrade "$1" + ;; + esac +} From 4448d6325fcd9393c1019dca07d5a75ea74eccf5 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Wed, 17 Jul 2024 16:24:03 +0100 Subject: [PATCH 06/13] mediatek: make use of common uImage.FIT upgrade functions Use newly introduced fit_do_upgrade() function in /lib/upgrade/platform.sh. Signed-off-by: Daniel Golle --- .../base-files/lib/upgrade/platform.sh | 35 ++++--------------- .../mt7622/base-files/lib/upgrade/platform.sh | 19 +--------- 2 files changed, 8 insertions(+), 46 deletions(-) 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 2fed8a0ab5..eb11a3b551 100755 --- a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh @@ -88,24 +88,13 @@ platform_do_upgrade() { bananapi,bpi-r4-poe|\ jdcloud,re-cp-03|\ mediatek,mt7988a-rfb|\ - openwrt,one) - [ -e /dev/fit0 ] && fitblk /dev/fit0 - [ -e /dev/fitrw ] && fitblk /dev/fitrw - bootdev="$(fitblk_get_bootdev)" - case "$bootdev" in - mmcblk*) - EMMC_KERN_DEV="/dev/$bootdev" - emmc_do_upgrade "$1" - ;; - mtdblock*) - PART_NAME="/dev/mtd${bootdev:8}" - default_do_upgrade "$1" - ;; - ubiblock*) - CI_KERNPART="fit" - nand_do_upgrade "$1" - ;; - esac + nokia,ea0326gmp|\ + openwrt,one|\ + tplink,tl-xdr4288|\ + tplink,tl-xdr6086|\ + tplink,tl-xdr6088|\ + xiaomi,redmi-router-ax6000-ubootmod) + fit_do_upgrade "$1" ;; cmcc,rax3000m) case "$(cmdline_get_var root)" in @@ -147,16 +136,6 @@ platform_do_upgrade() { CI_UBIPART="ubi0" nand_do_upgrade "$1" ;; - nokia,ea0326gmp|\ - tplink,tl-xdr4288|\ - tplink,tl-xdr6086|\ - tplink,tl-xdr6088|\ - xiaomi,redmi-router-ax6000-ubootmod) - [ -e /dev/fit0 ] && fitblk /dev/fit0 - [ -e /dev/fitrw ] && fitblk /dev/fitrw - CI_KERNPART="fit" - nand_do_upgrade "$1" - ;; ubnt,unifi-6-plus) CI_KERNPART="kernel0" EMMC_ROOT_DEV="$(cmdline_get_var root)" diff --git a/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh index 59375ccd9b..a9a39f8e83 100755 --- a/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh @@ -12,25 +12,8 @@ platform_do_upgrade() { ubnt,unifi-6-lr-v2-ubootmod|\ ubnt,unifi-6-lr-v3-ubootmod|\ xiaomi,redmi-router-ax6s) - [ -e /dev/fit0 ] && fitblk /dev/fit0 - [ -e /dev/fitrw ] && fitblk /dev/fitrw - bootdev="$(fitblk_get_bootdev)" - case "$bootdev" in - mmcblk*) - EMMC_KERN_DEV="/dev/$bootdev" - emmc_do_upgrade "$1" - ;; - mtdblock*) - PART_NAME="/dev/mtd${bootdev:8}" - default_do_upgrade "$1" - ;; - ubiblock*) - CI_KERNPART="fit" - nand_do_upgrade "$1" - ;; - esac + fit_do_upgrade "$1" ;; - buffalo,wsr-2533dhp2|\ buffalo,wsr-3200ax4s) local magic="$(get_magic_long "$1")" From 386855dca80be0caae434412fc8373c15f72684d Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Wed, 17 Jul 2024 16:25:05 +0100 Subject: [PATCH 07/13] uboot-envtools: use /lib/upgrade/fit.sh Use export_fitblk_bootdev() in /lib/upgrade/fit.sh instead of now deprecated fitblk_get_bootdev() function. Include /lib/upgrade/fit.sh instead of /lib/upgrade/common.sh to allow removing the function there. Signed-off-by: Daniel Golle --- .../boot/uboot-envtools/files/mediatek_filogic | 16 ++++++++-------- .../boot/uboot-envtools/files/mediatek_mt7622 | 17 ++++++++--------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/package/boot/uboot-envtools/files/mediatek_filogic b/package/boot/uboot-envtools/files/mediatek_filogic index 0e30c489c9..4d1016d412 100644 --- a/package/boot/uboot-envtools/files/mediatek_filogic +++ b/package/boot/uboot-envtools/files/mediatek_filogic @@ -41,17 +41,17 @@ bananapi,bpi-r3-mini|\ bananapi,bpi-r4|\ bananapi,bpi-r4-poe|\ jdcloud,re-cp-03) - . /lib/upgrade/common.sh - - bootdev="$(fitblk_get_bootdev)" - case "$bootdev" in - ubi*) + . /lib/upgrade/fit.sh + export_fitblk_bootdev + case "$CI_METHOD" in + ubi) ubootenv_add_ubi_default ;; - mmc*) - ubootenv_add_mmc_default "${bootdev%%p[0-9]*}" + emmc) + bootdev=${EMMC_KERN_DEV%%p[0-9]*} + ubootenv_add_mmc_default "${bootdev#/dev/}" ;; - mtd*) + default) ubootenv_add_nor_default ;; esac diff --git a/package/boot/uboot-envtools/files/mediatek_mt7622 b/package/boot/uboot-envtools/files/mediatek_mt7622 index 6698e06ee3..ae173fad61 100644 --- a/package/boot/uboot-envtools/files/mediatek_mt7622 +++ b/package/boot/uboot-envtools/files/mediatek_mt7622 @@ -31,17 +31,16 @@ dlink,eagle-pro-ai-m32-a1|\ dlink,eagle-pro-ai-r32-a1) ubootenv_add_uci_config "/dev/mtd3" "0x0" "0x2000" "0x2000" ;; +bananapi,bpi-r64|\ linksys,e8450-ubi) - ubootenv_add_ubi_default - ;; -bananapi,bpi-r64) - . /lib/upgrade/common.sh - bootdev="$(fitblk_get_bootdev)" - case "$bootdev" in - mmc*) - ubootenv_add_mmc_default "${bootdev%p[0-9]*}" + . /lib/upgrade/fit.sh + export_fitblk_bootdev + case "$CI_METHOD" in + emmc) + bootdev=${EMMC_KERN_DEV%%p[0-9]*} + ubootenv_add_mmc_default "${bootdev#/dev/}" ;; - ubi*) + ubi) ubootenv_add_ubi_default ;; esac From de2df0f2c5b767b74c07e450c408ffc35a657aee Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Wed, 17 Jul 2024 16:25:59 +0100 Subject: [PATCH 08/13] base-files: remove fitblk_get_bootdev() from /lib/upgrade/common.sh The function was moved to /lib/upgrade/fit.sh which is part of the fitblk package. Remove it from /lib/upgrade/common.sh to safe space on boards not using unified uImage.FIT images. Signed-off-by: Daniel Golle --- package/base-files/files/lib/upgrade/common.sh | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh index ef8d01e168..718907a711 100644 --- a/package/base-files/files/lib/upgrade/common.sh +++ b/package/base-files/files/lib/upgrade/common.sh @@ -165,23 +165,6 @@ part_magic_fat() { [ "$magic" = "FAT" ] || [ "$magic_fat32" = "FAT32" ] } -fitblk_get_bootdev() { - [ -e /sys/firmware/devicetree/base/chosen/rootdisk ] || return - - local rootdisk="$(cat /sys/firmware/devicetree/base/chosen/rootdisk)" - local handle bootdev - for handle in /sys/class/block/*/of_node/phandle /sys/class/block/*/device/of_node/phandle; do - [ ! -e "$handle" ] && continue - if [ "$rootdisk" = "$(cat $handle)" ]; then - bootdev="${handle%/of_node/phandle}" - bootdev="${bootdev%/device}" - bootdev="${bootdev#/sys/class/block/}" - echo "$bootdev" - break - fi - done -} - export_bootdevice() { local cmdline uuid blockdev uevent line class local MAJOR MINOR DEVNAME DEVTYPE From b39375ae4cab359553e681fc3aacdf516cacf5ea Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Thu, 18 Jul 2024 11:56:13 +0100 Subject: [PATCH 09/13] mediatek: fix platform_copy_config() Also use env variables exported by export_fitblk_rootdev() in platform_copy_config(). Fixes: 4448d6325f ("mediatek: make use of common uImage.FIT upgrade functions") Signed-off-by: Daniel Golle --- .../mediatek/filogic/base-files/lib/upgrade/platform.sh | 6 ++---- .../mediatek/mt7622/base-files/lib/upgrade/platform.sh | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) 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 eb11a3b551..e059048d12 100755 --- a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh @@ -218,11 +218,9 @@ platform_copy_config() { bananapi,bpi-r3-mini|\ bananapi,bpi-r4|\ bananapi,bpi-r4-poe) - case "$(fitblk_get_bootdev)" in - mmcblk*) + if [ "$CI_METHOD" = "emmc" ]; then emmc_copy_config - ;; - esac + fi ;; acer,predator-w6|\ glinet,gl-mt2500|\ diff --git a/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh index a9a39f8e83..61025fb380 100755 --- a/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh @@ -86,7 +86,7 @@ platform_check_image() { platform_copy_config() { case "$(board_name)" in bananapi,bpi-r64) - if fitblk_get_bootdev | grep -q mmc; then + if [ "$CI_METHOD" = "emmc" ]; then emmc_copy_config fi ;; From ed14add1efcac7491b46cf6628cacc6e9b6a1398 Mon Sep 17 00:00:00 2001 From: Martin Schiller Date: Wed, 17 Jul 2024 13:00:38 +0200 Subject: [PATCH 10/13] target.mk: further improve handling of default enabled SECCOMP The fix in commit 847fad476f3d ("target.mk: improve handling of default enabled SECCOMP") unfortunately does not work for targets where the ARCH variable is set in ./$(SUBTARGET)/target.mk. To get this working, the ./$(SUBTARGET)/target.mk must be included before the check. Fixes: 847fad476f3d ("target.mk: improve handling of default enabled SECCOMP") Signed-off-by: Martin Schiller --- include/target.mk | 83 ++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/include/target.mk b/include/target.mk index c9ff3cbb7c..48536b5dd9 100644 --- a/include/target.mk +++ b/include/target.mk @@ -6,25 +6,6 @@ ifneq ($(__target_inc),1) __target_inc=1 -ifneq ($(DUMP),) - # Parse generic config that might be set before a .config is generated to modify the - # default package configuration - # Keep DYNAMIC_DEF_PKG_CONF in sync with toplevel.mk to reflect the same configs - DYNAMIC_DEF_PKG_CONF := CONFIG_USE_APK CONFIG_SELINUX CONFIG_SMALL_FLASH CONFIG_SECCOMP - ifneq ($(wildcard $(TOPDIR)/.config),) - $(foreach config, $(DYNAMIC_DEF_PKG_CONF), \ - $(eval $(config) := $(shell grep "$(config)=y" $(TOPDIR)/.config 2>/dev/null)) \ - ) - # Init config that are enabled by default. Dependency are checked matching the one in - # the config. - else - ifeq ($(filter $(BOARD), uml),) - ifneq ($(filter $(ARCH), aarch64 arm armeb mips mipsel mips64 mips64el i386 powerpc x86_64),) - CONFIG_SECCOMP := y - endif - endif - endif -endif # default device type DEVICE_TYPE?=router @@ -46,28 +27,6 @@ DEFAULT_PACKAGES:=\ urandom-seed \ urngd -ifneq ($(CONFIG_USE_APK),) -DEFAULT_PACKAGES+=apk-mbedtls -else -DEFAULT_PACKAGES+=opkg -endif - -ifneq ($(CONFIG_SELINUX),) -DEFAULT_PACKAGES+=busybox-selinux procd-selinux -else -DEFAULT_PACKAGES+=busybox procd -endif - -# include ujail on systems with enough storage -ifeq ($(CONFIG_SMALL_FLASH),) -DEFAULT_PACKAGES+=procd-ujail -endif - -# include seccomp ld-preload hooks if kernel supports it -ifneq ($(CONFIG_SECCOMP),) -DEFAULT_PACKAGES+=procd-seccomp -endif - # For the basic set DEFAULT_PACKAGES.basic:= # For nas targets @@ -118,6 +77,48 @@ else endif endif +ifneq ($(DUMP),) + # Parse generic config that might be set before a .config is generated to modify the + # default package configuration + # Keep DYNAMIC_DEF_PKG_CONF in sync with toplevel.mk to reflect the same configs + DYNAMIC_DEF_PKG_CONF := CONFIG_USE_APK CONFIG_SELINUX CONFIG_SMALL_FLASH CONFIG_SECCOMP + ifneq ($(wildcard $(TOPDIR)/.config),) + $(foreach config, $(DYNAMIC_DEF_PKG_CONF), \ + $(eval $(config) := $(shell grep "$(config)=y" $(TOPDIR)/.config 2>/dev/null)) \ + ) + # Init config that are enabled by default. Dependency are checked matching the one in + # the config. + else + ifeq ($(filter $(BOARD), uml),) + ifneq ($(filter $(ARCH), aarch64 arm armeb mips mipsel mips64 mips64el i386 powerpc x86_64),) + CONFIG_SECCOMP := y + endif + endif + endif +endif + +ifneq ($(CONFIG_USE_APK),) +DEFAULT_PACKAGES+=apk-mbedtls +else +DEFAULT_PACKAGES+=opkg +endif + +ifneq ($(CONFIG_SELINUX),) +DEFAULT_PACKAGES+=busybox-selinux procd-selinux +else +DEFAULT_PACKAGES+=busybox procd +endif + +# include ujail on systems with enough storage +ifeq ($(CONFIG_SMALL_FLASH),) +DEFAULT_PACKAGES+=procd-ujail +endif + +# include seccomp ld-preload hooks if kernel supports it +ifneq ($(CONFIG_SECCOMP),) +DEFAULT_PACKAGES+=procd-seccomp +endif + # Add device specific packages (here below to allow device type set from subtarget) DEFAULT_PACKAGES += $(DEFAULT_PACKAGES.$(DEVICE_TYPE)) From 02488176b7995721d4e8288f0bd9a00428dbb991 Mon Sep 17 00:00:00 2001 From: Martin Schiller Date: Thu, 18 Jul 2024 13:53:37 +0200 Subject: [PATCH 11/13] target.mk: init default configs if they are missing in the .config The config options that are enabled by default and where other default packages depends on should not only be set if there is no .config file, but also if the .config exists but the config option (e.g. CONFIG_SECCOMP) is missing in the file. This is relevant, for example, if you are working with .config templates and then want to complete the configuration using make defconfig. Signed-off-by: Martin Schiller --- include/target.mk | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/include/target.mk b/include/target.mk index 48536b5dd9..d13902ad6e 100644 --- a/include/target.mk +++ b/include/target.mk @@ -82,13 +82,12 @@ ifneq ($(DUMP),) # default package configuration # Keep DYNAMIC_DEF_PKG_CONF in sync with toplevel.mk to reflect the same configs DYNAMIC_DEF_PKG_CONF := CONFIG_USE_APK CONFIG_SELINUX CONFIG_SMALL_FLASH CONFIG_SECCOMP - ifneq ($(wildcard $(TOPDIR)/.config),) - $(foreach config, $(DYNAMIC_DEF_PKG_CONF), \ - $(eval $(config) := $(shell grep "$(config)=y" $(TOPDIR)/.config 2>/dev/null)) \ - ) - # Init config that are enabled by default. Dependency are checked matching the one in - # the config. - else + $(foreach config, $(DYNAMIC_DEF_PKG_CONF), \ + $(eval $(config) := $(shell grep "$(config)=y" $(TOPDIR)/.config 2>/dev/null)) \ + ) + # The config options that are enabled by default and where other default + # packages depends on needs to be set if they are missing in the .config. + ifeq ($(shell grep "CONFIG_SECCOMP" $(TOPDIR)/.config 2>/dev/null),) ifeq ($(filter $(BOARD), uml),) ifneq ($(filter $(ARCH), aarch64 arm armeb mips mipsel mips64 mips64el i386 powerpc x86_64),) CONFIG_SECCOMP := y From eb510d21588cfa48cb70e696469be03f2d7404e1 Mon Sep 17 00:00:00 2001 From: Tianling Shen Date: Tue, 2 Apr 2024 20:26:45 +0800 Subject: [PATCH 12/13] mediatek: convert eeprom/macaddr to nvmem format for cmcc rax3000m Switch to new nvmem binding. Also fixes a issue that the MAC address assigned to lan/wan was reversed on eMMC boards. Signed-off-by: Tianling Shen --- .../dts/mt7981b-cmcc-rax3000m-emmc.dtso | 63 ++++++++++++++++++- .../dts/mt7981b-cmcc-rax3000m-nand.dtso | 9 ++- .../filogic/base-files/etc/board.d/02_network | 9 --- .../etc/hotplug.d/firmware/11-mt76-caldata | 7 --- .../etc/hotplug.d/ieee80211/11_fix_wifi_mac | 11 +--- 5 files changed, 71 insertions(+), 28 deletions(-) diff --git a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-emmc.dtso b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-emmc.dtso index c1c9c75c27..bfccc923a4 100644 --- a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-emmc.dtso +++ b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-emmc.dtso @@ -7,6 +7,22 @@ compatible = "cmcc,rax3000m", "mediatek,mt7981"; fragment@0 { + target = <&gmac0>; + __overlay__ { + nvmem-cells = <&macaddr_factory_2a 0>; + nvmem-cell-names = "mac-address"; + }; + }; + + fragment@1 { + target = <&gmac1>; + __overlay__ { + nvmem-cells = <&macaddr_factory_24 0>; + nvmem-cell-names = "mac-address"; + }; + }; + + fragment@2 { target = <&mmc0>; __overlay__ { bus-width = <8>; @@ -19,10 +35,47 @@ pinctrl-1 = <&mmc0_pins_uhs>; vmmc-supply = <®_3p3v>; status = "okay"; + + card@0 { + compatible = "mmc-card"; + reg = <0>; + + block { + compatible = "block-device"; + + partitions { + block-partition-factory { + partname = "factory"; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + eeprom_factory_0: eeprom@0 { + reg = <0x0 0x1000>; + }; + + macaddr_factory_24: macaddr@24 { + compatible = "mac-base"; + reg = <0x24 0x6>; + #nvmem-cell-cells = <1>; + }; + + macaddr_factory_2a: macaddr@2a { + compatible = "mac-base"; + reg = <0x2a 0x6>; + #nvmem-cell-cells = <1>; + }; + }; + }; + }; + }; + }; }; }; - fragment@1 { + fragment@3 { target = <&pio>; __overlay__ { mmc0_pins_default: mmc0-pins { @@ -40,4 +93,12 @@ }; }; }; + + fragment@4 { + target = <&wifi>; + __overlay__ { + nvmem-cells = <&eeprom_factory_0>; + nvmem-cell-names = "eeprom"; + }; + }; }; diff --git a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-nand.dtso b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-nand.dtso index 4d2b01cb63..3f401b53d3 100644 --- a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-nand.dtso +++ b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-nand.dtso @@ -79,7 +79,7 @@ reg = <0x100000 0x80000>; }; - factory: partition@180000 { + partition@180000 { label = "factory"; reg = <0x180000 0x200000>; read-only; @@ -89,6 +89,10 @@ #address-cells = <1>; #size-cells = <1>; + eeprom_factory_0: eeprom@0 { + reg = <0x0 0x1000>; + }; + macaddr_factory_24: macaddr@24 { compatible = "mac-base"; reg = <0x24 0x6>; @@ -121,7 +125,8 @@ fragment@4 { target = <&wifi>; __overlay__ { - mediatek,mtd-eeprom = <&factory 0x0>; + nvmem-cells = <&eeprom_factory_0>; + nvmem-cell-names = "eeprom"; }; }; }; diff --git a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network index 1a210810bc..c9c8a87f54 100644 --- a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network +++ b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network @@ -134,15 +134,6 @@ mediatek_setup_macs() bananapi,bpi-r4) wan_mac=$(macaddr_add $(cat /sys/class/net/eth0/address) 1) ;; - cmcc,rax3000m) - case "$(cmdline_get_var root)" in - /dev/mmc*) - wan_mac=$(mmc_get_mac_binary factory 0x2a) - lan_mac=$(mmc_get_mac_binary factory 0x24) - label_mac=$wan_mac - ;; - esac - ;; h3c,magic-nx30-pro) wan_mac=$(mtd_get_mac_ascii pdt_data_1 ethaddr) lan_mac=$(macaddr_add "$wan_mac" 1) diff --git a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata index 920a16d05d..c6900e6ebd 100644 --- a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata +++ b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata @@ -24,13 +24,6 @@ case "$FIRMWARE" in ;; "mediatek/mt7981_eeprom_mt7976_dbdc.bin") case "$board" in - cmcc,rax3000m) - case "$(cmdline_get_var root)" in - /dev/mmc*) - caldata_extract_mmc "factory" 0x0 0x1000 - ;; - esac - ;; ubnt,unifi-6-plus) caldata_extract_mmc "factory" 0x0 0x1000 ;; diff --git a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac index 942facee87..98b1023e3e 100644 --- a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac +++ b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac @@ -55,15 +55,8 @@ case "$board" in [ "$PHYNBR" = "1" ] && macaddr_setbit_la $(macaddr_add $addr 2) > /sys${DEVPATH}/macaddress ;; cmcc,rax3000m) - case "$(cmdline_get_var root)" in - /dev/mmc*) - addr=$(mmc_get_mac_binary factory 0xa) - ;; - *) - addr=$(mtd_get_mac_binary factory 0xa) - ;; - esac - [ "$PHYNBR" = "1" ] && echo "$addr" > /sys${DEVPATH}/macaddress + addr=$(cat /sys/class/net/eth0/address) + [ "$PHYNBR" = "1" ] && macaddr_add $addr -1 > /sys${DEVPATH}/macaddress ;; comfast,cf-e393ax) addr=$(mtd_get_mac_binary "Factory" 0x8000) From 39c824f846ceca5281ee5f3ddbf92627076bdb5e Mon Sep 17 00:00:00 2001 From: Tianling Shen Date: Tue, 2 Apr 2024 20:26:45 +0800 Subject: [PATCH 13/13] mediatek: switch to fitblk for cmcc rax3000m Use the new fitblk driver. Tested-by: Yangyu Chen Signed-off-by: Tianling Shen --- .../uboot-envtools/files/mediatek_filogic | 11 +-------- .../patches/437-add-cmcc_rax3000m.patch | 2 +- .../dts/mt7981b-cmcc-rax3000m-emmc.dtso | 19 +++++++++++---- .../dts/mt7981b-cmcc-rax3000m-nand.dtso | 22 ++++++++++++++---- .../mediatek/dts/mt7981b-cmcc-rax3000m.dts | 3 ++- .../base-files/lib/upgrade/platform.sh | 23 +++---------------- 6 files changed, 40 insertions(+), 40 deletions(-) diff --git a/package/boot/uboot-envtools/files/mediatek_filogic b/package/boot/uboot-envtools/files/mediatek_filogic index 4d1016d412..67d37931c2 100644 --- a/package/boot/uboot-envtools/files/mediatek_filogic +++ b/package/boot/uboot-envtools/files/mediatek_filogic @@ -40,6 +40,7 @@ bananapi,bpi-r3|\ bananapi,bpi-r3-mini|\ bananapi,bpi-r4|\ bananapi,bpi-r4-poe|\ +cmcc,rax3000m|\ jdcloud,re-cp-03) . /lib/upgrade/fit.sh export_fitblk_bootdev @@ -56,16 +57,6 @@ jdcloud,re-cp-03) ;; esac ;; -cmcc,rax3000m) - case "$(cmdline_get_var root)" in - /dev/mmc*) - ubootenv_add_mmc_default - ;; - *) - ubootenv_add_ubi_default - ;; - esac - ;; comfast,cf-e393ax) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x80000" ;; diff --git a/package/boot/uboot-mediatek/patches/437-add-cmcc_rax3000m.patch b/package/boot/uboot-mediatek/patches/437-add-cmcc_rax3000m.patch index 972581fce7..f056cbf377 100644 --- a/package/boot/uboot-mediatek/patches/437-add-cmcc_rax3000m.patch +++ b/package/boot/uboot-mediatek/patches/437-add-cmcc_rax3000m.patch @@ -485,7 +485,7 @@ +serverip=192.168.1.254 +loadaddr=0x46000000 +console=earlycon=uart8250,mmio32,0x11002000 console=ttyS0 -+bootargs=root=/dev/mmcblk0p65 ++bootargs=root=/dev/fit0 rootwait +bootcmd=if pstore check ; then run boot_recovery ; else run boot_emmc ; fi +bootconf=config-1#mt7981b-cmcc-rax3000m-emmc +bootdelay=0 diff --git a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-emmc.dtso b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-emmc.dtso index bfccc923a4..e6b140bfad 100644 --- a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-emmc.dtso +++ b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-emmc.dtso @@ -7,6 +7,13 @@ compatible = "cmcc,rax3000m", "mediatek,mt7981"; fragment@0 { + target = <&chosen>; + __overlay__ { + rootdisk = <&emmc_rootdisk>; + }; + }; + + fragment@1 { target = <&gmac0>; __overlay__ { nvmem-cells = <&macaddr_factory_2a 0>; @@ -14,7 +21,7 @@ }; }; - fragment@1 { + fragment@2 { target = <&gmac1>; __overlay__ { nvmem-cells = <&macaddr_factory_24 0>; @@ -22,7 +29,7 @@ }; }; - fragment@2 { + fragment@3 { target = <&mmc0>; __overlay__ { bus-width = <8>; @@ -69,13 +76,17 @@ }; }; }; + + emmc_rootdisk: block-partition-production { + partname = "production"; + }; }; }; }; }; }; - fragment@3 { + fragment@4 { target = <&pio>; __overlay__ { mmc0_pins_default: mmc0-pins { @@ -94,7 +105,7 @@ }; }; - fragment@4 { + fragment@5 { target = <&wifi>; __overlay__ { nvmem-cells = <&eeprom_factory_0>; diff --git a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-nand.dtso b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-nand.dtso index 3f401b53d3..fded878332 100644 --- a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-nand.dtso +++ b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-nand.dtso @@ -7,6 +7,13 @@ compatible = "cmcc,rax3000m", "mediatek,mt7981"; fragment@0 { + target = <&chosen>; + __overlay__ { + rootdisk = <&ubi_rootdisk>; + }; + }; + + fragment@1 { target = <&gmac0>; __overlay__ { nvmem-cells = <&macaddr_factory_2a 0>; @@ -14,7 +21,7 @@ }; }; - fragment@1 { + fragment@2 { target = <&gmac1>; __overlay__ { nvmem-cells = <&macaddr_factory_24 0>; @@ -22,7 +29,7 @@ }; }; - fragment@2 { + fragment@3 { target = <&pio>; __overlay__ { spi0_flash_pins: spi0-pins { @@ -46,7 +53,7 @@ }; }; - fragment@3 { + fragment@4 { target = <&spi0>; __overlay__ { pinctrl-names = "default"; @@ -114,15 +121,22 @@ }; partition@580000 { + compatible = "linux,ubi"; label = "ubi"; reg = <0x580000 0x7200000>; + + volumes { + ubi_rootdisk: ubi-volume-fit { + volname = "fit"; + }; + }; }; }; }; }; }; - fragment@4 { + fragment@5 { target = <&wifi>; __overlay__ { nvmem-cells = <&eeprom_factory_0>; diff --git a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m.dts b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m.dts index c8db5b58f5..977a613333 100644 --- a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m.dts +++ b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m.dts @@ -22,7 +22,8 @@ serial0 = &uart0; }; - chosen { + chosen: chosen { + bootargs-override = "root=/dev/fit0 rootwait"; stdout-path = "serial0:115200n8"; }; 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 e059048d12..3b1b2f7fa6 100755 --- a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh @@ -86,6 +86,7 @@ platform_do_upgrade() { bananapi,bpi-r3-mini|\ bananapi,bpi-r4|\ bananapi,bpi-r4-poe|\ + cmcc,rax3000m|\ jdcloud,re-cp-03|\ mediatek,mt7988a-rfb|\ nokia,ea0326gmp|\ @@ -96,18 +97,6 @@ platform_do_upgrade() { xiaomi,redmi-router-ax6000-ubootmod) fit_do_upgrade "$1" ;; - cmcc,rax3000m) - case "$(cmdline_get_var root)" in - /dev/mmc*) - CI_KERNPART="production" - emmc_do_upgrade "$1" - ;; - *) - CI_KERNPART="fit" - nand_do_upgrade "$1" - ;; - esac - ;; cudy,re3000-v1|\ cudy,wr3000-v1|\ yuncore,ax835) @@ -207,17 +196,11 @@ platform_check_image() { platform_copy_config() { case "$(board_name)" in - cmcc,rax3000m) - case "$(cmdline_get_var root)" in - /dev/mmc*) - emmc_copy_config - ;; - esac - ;; bananapi,bpi-r3|\ bananapi,bpi-r3-mini|\ bananapi,bpi-r4|\ - bananapi,bpi-r4-poe) + bananapi,bpi-r4-poe|\ + cmcc,rax3000m) if [ "$CI_METHOD" = "emmc" ]; then emmc_copy_config fi