diff options
10 files changed, 182 insertions, 72 deletions
diff --git a/target/linux/mediatek/dts/mt7622-bananapi-bpi-r64-rootdisk.dts b/target/linux/mediatek/dts/mt7622-bananapi-bpi-r64-rootdisk.dts deleted file mode 100644 index 911b3dd5b4..0000000000 --- a/target/linux/mediatek/dts/mt7622-bananapi-bpi-r64-rootdisk.dts +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-License-Identifier: (GPL-2.0-only OR MIT) -/* - * Copyright (c) 2018 MediaTek Inc. - * Author: Ryder Lee <ryder.lee@mediatek.com> - */ - -/dts-v1/; - -#include "mt7622-bananapi-bpi-r64.dts" -/ { - model = "Bananapi BPI-R64"; - compatible = "bananapi,bpi-r64-rootdisk", "mediatek,mt7622"; - - chosen { - stdout-path = "serial0:115200n8"; - bootargs = "earlycon=uart8250,mmio32,0x11002000 console=ttyS0,115200n1 swiotlb=512 root=/dev/mmcblk0p7 rootfstype=squashfs,f2fs"; - }; -}; diff --git a/target/linux/mediatek/image/gen_mt7622_emmc_img.sh b/target/linux/mediatek/image/gen_mt7622_emmc_img.sh deleted file mode 100755 index d74068c7b1..0000000000 --- a/target/linux/mediatek/image/gen_mt7622_emmc_img.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -OUTPUT_FILE=$1 -KERNEL_FILE=$2 -RECOVERY_FILE=$3 -ROOTFS_FILE=$4 - -BS=512 - -#RECOVERY_OFFSET= kernel size / BS = 20M / 512 (blocks) -RECOVERY_OFFSET=40960 - -#ROOTFS_OFFSET = RECOVERY_OFFSET + (RECOVERY_SIZE / BS) -# = 40960 + (10M / 512) (blocks) -ROOTFS_OFFSET=61440 -dd bs="$BS" of="$OUTPUT_FILE" if="$KERNEL_FILE" -dd bs="$BS" of="$OUTPUT_FILE" if="$RECOVERY_FILE" seek="$RECOVERY_OFFSET" -dd bs="$BS" of="$OUTPUT_FILE" if="$ROOTFS_FILE" seek="$ROOTFS_OFFSET" -dd if=/dev/zero of="$OUTPUT_FILE" bs=128k count=1 oflag=append conv=notrunc diff --git a/target/linux/mediatek/image/mt7622.mk b/target/linux/mediatek/image/mt7622.mk index e113939e17..3fe9700ae0 100644 --- a/target/linux/mediatek/image/mt7622.mk +++ b/target/linux/mediatek/image/mt7622.mk @@ -6,35 +6,58 @@ else KERNEL_LOADADDR := 0x44000000 endif +define Build/mmc-header + dd if=$(STAGING_DIR_IMAGE)/mt7622-header_$1.bin bs=512 count=1 of=$@ conv=notrunc +endef + define Build/bl2 - $(CP) $(STAGING_DIR_IMAGE)/mt7622-$1-bl2.img $@ + cat $(STAGING_DIR_IMAGE)/mt7622-$1-bl2.img >> $@ endef define Build/bl31-uboot - $(CP) $(STAGING_DIR_IMAGE)/mt7622_$1-u-boot.fip $@ + cat $(STAGING_DIR_IMAGE)/mt7622_$1-u-boot.fip >> $@ endef -define Device/bpi_bananapi-r64 - DEVICE_VENDOR := Bpi - DEVICE_MODEL := Banana Pi R64 - DEVICE_DTS := mt7622-bananapi-bpi-r64 - SUPPORTED_DEVICES := bananapi,bpi-r64 - DEVICE_PACKAGES := kmod-usb-ohci kmod-usb2 kmod-usb3 kmod-ata-ahci-mtk +define Build/mt7622-gpt + ptgen -g -o $@ -h 4 -s 31 -a 1 -l 1024 -g \ + -t 0xef \ + $(if $(findstring sdmmc,$1), \ + -N bl2 -r -p 512k@512k \ + ) \ + -N fip -r -p 1M@2M \ + -N ubootenv -r -p 1M@4M \ + -N recovery -r -p 32M@6M \ + $(if $(findstring sdmmc,$1), \ + -t 0x2e -N production -p 216M@40M \ + ) \ + $(if $(findstring emmc,$1), \ + -t 0x2e -N production -p 980M@40M \ + ) endef -TARGET_DEVICES += bpi_bananapi-r64 -define Device/bpi_bananapi-r64-rootdisk - DEVICE_VENDOR := Bpi - DEVICE_MODEL := Banana Pi R64 (rootdisk) - DEVICE_DTS := mt7622-bananapi-bpi-r64-rootdisk - DEVICE_DTS_DIR := ../dts - SUPPORTED_DEVICES := bananapi,bpi-r64 - DEVICE_PACKAGES := kmod-fs-vfat kmod-nls-cp437 kmod-nls-iso8859-1 \ - mkf2fs e2fsprogs kmod-usb-ohci kmod-usb2 kmod-usb3 kmod-ata-ahci-mtk - IMAGES := sysupgrade-emmc.bin.gz - IMAGE/sysupgrade-emmc.bin.gz := sysupgrade-emmc | gzip | append-metadata +define Device/bananapi_bpi-r64 + DEVICE_VENDOR := Bananapi + DEVICE_MODEL := BPi-R64 + DEVICE_DTS := mt7622-bananapi-bpi-r64 + DEVICE_PACKAGES := kmod-usb-ohci kmod-usb2 kmod-usb3 kmod-ata-ahci-mtk \ + kmod-mt7615e kmod-mt7615-firmware \ + uboot-mt7622_bananapi_bpi-r64-emmc \ + uboot-mt7622_bananapi_bpi-r64-sdmmc \ + e2fsprogs mkf2fs f2fsck \ + kmod-nls-cp437 kmod-nls-iso8859-1 kmod-vfat blockd + ARTIFACTS := boot-sdcard.img boot-emmc.img bl2-emmc.bin bl31-emmc.bin header-emmc.bin + IMAGES := sysupgrade.itb + KERNEL_INITRAMFS_SUFFIX := -recovery.itb + ARTIFACT/boot-sdcard.img := mt7622-gpt sdmmc | mmc-header sdmmc | pad-to 512k | bl2 sdmmc-2ddr | pad-to 2M | bl31-uboot bananapi_bpi-r64-sdmmc | pad-to 6M + ARTIFACT/boot-emmc.img := mt7622-gpt emmc | mmc-header emmc | pad-to 2M | bl31-uboot bananapi_bpi-r64-emmc | pad-to 6M + ARTIFACT/header-emmc.bin := mt7622-gpt emmc | mmc-header emmc + ARTIFACT/bl31-emmc.bin := bl31-uboot bananapi_bpi-r64-emmc + ARTIFACT/bl2-emmc.bin := bl2 emmc-2ddr + KERNEL := kernel-bin | gzip + KERNEL_INITRAMFS := kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 128k + IMAGE/sysupgrade.itb := append-kernel | fit gzip $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb external-static-with-rootfs | append-metadata endef -TARGET_DEVICES += bpi_bananapi-r64-rootdisk +TARGET_DEVICES += bananapi_bpi-r64 define Device/elecom_wrc-2533gent DEVICE_VENDOR := Elecom diff --git a/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network b/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network index 1e4b1273a1..f0d28c9312 100755 --- a/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network +++ b/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network @@ -9,7 +9,6 @@ mediatek_setup_interfaces() local board="$1" case $board in - bananapi,bpi-r64-rootdisk|\ bananapi,bpi-r64|\ linksys,e8450|\ linksys,e8450-ubi|\ 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 2cea6ce378..07efe13363 100755 --- a/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh @@ -1,15 +1,52 @@ -RAMFS_COPY_BIN='fw_printenv fw_setenv' +RAMFS_COPY_BIN='fw_printenv fw_setenv blockdev' RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock' +get_cmdline_var() { + local var=$1 + local cmdlinevar tmp + local cmdline="$(cat /proc/cmdline)" + + for cmdlinevar in $cmdline; do + tmp=${cmdlinevar##${var}} + [ "=" = "${tmp:0:1}" ] && echo ${tmp:1} + done +} + +get_rootdev() { + local rootvol rootdev + rootvol=$(get_cmdline_var root) + rootvol=$(basename $rootvol) + [ -e /sys/class/block/$rootvol/partition ] || { + echo $rootvol + return + } + rootdev=$(busybox readlink -f /sys/class/block/$rootvol) + rootdev=$(basename ${rootdev%%/${rootvol}}) + [ -e /sys/class/block/$rootdev ] && echo $rootdev +} + +get_partition() { + for partname in /sys/class/block/$1/*/name; do + [ "$(cat ${partname})" = "$2" ] && { + basename ${partname%%/name} + break + } + done +} + platform_do_upgrade() { local board=$(board_name) local file_type=$(identify $1) case "$board" in - bananapi,bpi-r64-rootdisk) - #2097152=0x200000 is the offset in bytes from the start - #of eMMC and to the location of the kernel - get_image "$1" | dd of=/dev/mmcblk0 bs=2097152 seek=1 conv=fsync + bananapi,bpi-r64) + local rootdev=$(get_rootdev) + local fitpart=$(get_partition $rootdev production) + [ "$fitpart" ] || exit 1 + dd if=/dev/zero of=/dev/$fitpart bs=4096 count=1 2>/dev/null + blockdev --rereadpt /dev/$rootdev + get_image "$1" | dd of=/dev/$fitpart + echo $rootdev > /tmp/sysupgrade.rootdev ;; linksys,e8450-ubi|\ mediatek,mt7622,ubi) @@ -51,18 +88,20 @@ platform_check_image() { return 0 } -platform_copy_config_emmc() { - mkdir -p /recovery - mount -o rw,noatime /dev/mmcblk0p6 /recovery - cp -af "$UPGRADE_BACKUP" "/recovery/$BACKUP_FILE" +platform_copy_config_mmc() { + local rootdev=$(cat /tmp/sysupgrade.rootdev) + blockdev --rereadpt /dev/$rootdev + local datadev=$(get_partition $rootdev rootfs_data) + [ "$datadev" ] || echo "no rootfs_data partition, cannot keep configuration." >&2 + dd if="$UPGRADE_BACKUP" of=/dev/$datadev sync - umount /recovery + sleep 4 } platform_copy_config() { case "$(board_name)" in - bananapi,bpi-r64-rootdisk) - platform_copy_config_emmc + bananapi,bpi-r64) + platform_copy_config_mmc ;; esac } diff --git a/target/linux/mediatek/mt7622/config-5.10 b/target/linux/mediatek/mt7622/config-5.10 index e6283c37c9..dbc68ddf52 100644 --- a/target/linux/mediatek/mt7622/config-5.10 +++ b/target/linux/mediatek/mt7622/config-5.10 @@ -155,6 +155,7 @@ CONFIG_DTC=y CONFIG_DYNAMIC_DEBUG=y CONFIG_EDAC_SUPPORT=y CONFIG_EINT_MTK=y +CONFIG_EXT4_FS=y CONFIG_FIT_PARTITION=y CONFIG_FIXED_PHY=y CONFIG_FIX_EARLYCON_MEM=y diff --git a/target/linux/mediatek/mt7622/target.mk b/target/linux/mediatek/mt7622/target.mk index 24f7ee1ac4..f43a6c4bf4 100644 --- a/target/linux/mediatek/mt7622/target.mk +++ b/target/linux/mediatek/mt7622/target.mk @@ -2,7 +2,7 @@ ARCH:=aarch64 SUBTARGET:=mt7622 BOARDNAME:=MT7622 CPU_TYPE:=cortex-a53 -DEFAULT_PACKAGES += kmod-mt7615e kmod-mt7615-firmware wpad-basic-wolfssl +DEFAULT_PACKAGES += kmod-mt7615e kmod-mt7615-firmware wpad-basic-wolfssl blockdev uboot-envtools KERNELNAME:=Image dtbs KERNEL_PATCHVER:=5.10 diff --git a/target/linux/mediatek/patches-5.10/112-dts-fix-bpi64-lan-names.patch b/target/linux/mediatek/patches-5.10/112-dts-fix-bpi64-lan-names.patch new file mode 100644 index 0000000000..55c84812d0 --- /dev/null +++ b/target/linux/mediatek/patches-5.10/112-dts-fix-bpi64-lan-names.patch @@ -0,0 +1,29 @@ +--- a/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts ++++ b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts +@@ -160,22 +160,22 @@ + + port@1 { + reg = <1>; +- label = "lan0"; ++ label = "lan1"; + }; + + port@2 { + reg = <2>; +- label = "lan1"; ++ label = "lan2"; + }; + + port@3 { + reg = <3>; +- label = "lan2"; ++ label = "lan3"; + }; + + port@4 { + reg = <4>; +- label = "lan3"; ++ label = "lan4"; + }; + + port@6 { diff --git a/target/linux/mediatek/patches-5.10/112-dts-fix-bpi64-leds-and-buttons.patch b/target/linux/mediatek/patches-5.10/112-dts-fix-bpi64-leds-and-buttons.patch new file mode 100644 index 0000000000..8b6d3d4934 --- /dev/null +++ b/target/linux/mediatek/patches-5.10/112-dts-fix-bpi64-leds-and-buttons.patch @@ -0,0 +1,56 @@ +--- a/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts ++++ b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts +@@ -18,6 +18,10 @@ + + aliases { + serial0 = &uart0; ++ led-boot = &led_system_green; ++ led-failsafe = &led_system_blue; ++ led-running = &led_system_green; ++ led-upgrade = &led_system_blue; + }; + + chosen { +@@ -41,8 +45,8 @@ + compatible = "gpio-keys"; + + factory { +- label = "factory"; +- linux,code = <BTN_0>; ++ label = "reset"; ++ linux,code = <KEY_RESTART>; + gpios = <&pio 0 GPIO_ACTIVE_HIGH>; + }; + +@@ -56,17 +60,25 @@ + leds { + compatible = "gpio-leds"; + +- green { +- label = "bpi-r64:pio:green"; +- gpios = <&pio 89 GPIO_ACTIVE_HIGH>; ++ led_system_blue: blue { ++ label = "bpi-r64:pio:blue"; ++ gpios = <&pio 85 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + +- red { +- label = "bpi-r64:pio:red"; +- gpios = <&pio 88 GPIO_ACTIVE_HIGH>; ++ led_system_green: green { ++ label = "bpi-r64:pio:green"; ++ gpios = <&pio 89 GPIO_ACTIVE_HIGH>; + default-state = "off"; + }; ++ ++/* ++ * red { ++ * label = "bpi-r64:pio:red"; ++ * gpios = <&pio 88 GPIO_ACTIVE_HIGH>; ++ * default-state = "off"; ++ * }; ++ */ + }; + + memory { diff --git a/target/linux/mediatek/patches-5.10/602-arm64-dts-mediatek-Split-PCIe-node-for-MT2712-MT7622.patch b/target/linux/mediatek/patches-5.10/602-arm64-dts-mediatek-Split-PCIe-node-for-MT2712-MT7622.patch index fa4a6ce2db..a680cf0149 100644 --- a/target/linux/mediatek/patches-5.10/602-arm64-dts-mediatek-Split-PCIe-node-for-MT2712-MT7622.patch +++ b/target/linux/mediatek/patches-5.10/602-arm64-dts-mediatek-Split-PCIe-node-for-MT2712-MT7622.patch @@ -253,7 +253,7 @@ Signed-off-by: chuanjia.liu <Chuanjia.Liu@mediatek.com> #interrupt-cells = <1>; --- a/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts +++ b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts -@@ -257,18 +257,16 @@ +@@ -269,18 +269,16 @@ }; }; |