diff options
author | Daniel Golle <daniel@makrotopia.org> | 2021-02-27 14:17:09 +0000 |
---|---|---|
committer | Daniel Golle <daniel@makrotopia.org> | 2021-02-28 04:15:44 +0000 |
commit | dfa0a38d1f4d5bbac768569e3769ae4438a57e73 (patch) | |
tree | 04d8c630c07e74bc94db6f429a861dda1a9806ec /target/linux/mediatek/mt7622 | |
parent | b102e281a4de8f177adcabbff07072a3c926c367 (diff) | |
download | upstream-dfa0a38d1f4d5bbac768569e3769ae4438a57e73.tar.gz upstream-dfa0a38d1f4d5bbac768569e3769ae4438a57e73.tar.bz2 upstream-dfa0a38d1f4d5bbac768569e3769ae4438a57e73.zip |
mediatek: rework support for BananaPi BPi-R64
**What's new**
* Bring support for the Bananapi BPi-R64 to the level desirable for
a nice hackable routerboard.
* Use ARM Trusted Firmware A from source. (goodbye binary preloader)
* Use Das U-Boot from source. (see previous commit)
* Assemble SD-card image using OpenWrt image-commands.
(no gen_sd_cruz_foo.sh added, this is not Raspbian)
* Updated kernel options to support root filesystem.
* Updated DTS to match OpenWrt LAN ports, known LEDs, buttons, ...
* Detect root device, handle sysupgrade, config restore, ...
* Wire up (known) LEDs and buttons in OpenWrt-fashion.
* Build one set of images from SD-card and eMMC.
* Hopefully provide a good example of how things can be done right
from scratch.
**Installation and images**
* Have an empty SD-card at hand
* Write stuff to the card, as root (card device is /dev/mmcblkX)
- write header, gpt, bl2, atf, u-boot and recovery kernel:
`cat *bpi-r64-boot-sdcard.img *bpi-r64-initramfs-recovery.fit > /dev/mmcblkX`
- rescan partitions:
`blockdev --rereadpt /dev/mmcblkX`
- write main system to production partition:
`cat *bpi-r64-squashfs-sysupgrade.fit > /dev/mmcblkXp5`
* Installation to eMMC works using SD-card bootloader via TFTP
When running OpenWrt of SD-card, issue this to trigger installation
to eMMC:
`fw_setenv bootcmd run emmc_init`
Be prepared to serve the content of bin/targets/mediatek/mt7622 on
TFTP server address 192.168.1.254.
**What's missing**
* The red LED is always on, probably a hardware bug.
* AHCI (probably needs DTS changes)
* Ship SD-card image ready with every needed for eMMC install.
* The eMMC has a second, currently unused boot partition. This would
be ideal to store the WiFi EEPROM and Ethernet MAC address(es).
@sinovoip ideas?
Thanks to Thomas Hühn @thuehn for providing the hardware!
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'target/linux/mediatek/mt7622')
4 files changed, 53 insertions, 14 deletions
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 |