diff options
author | Eric Woudstra | 2023-03-21 16:14:03 +0100 |
---|---|---|
committer | Eric Woudstra | 2023-03-21 16:21:01 +0100 |
commit | 49ab34c0167e5b3781c3e361aa3f7b6954a62e75 (patch) | |
tree | 101b74aee96830e30c6455f0ff91520b572df281 | |
parent | 4d519e08a630e8b6a85f35325cb82ec12987d381 (diff) | |
download | aur-49ab34c0167e5b3781c3e361aa3f7b6954a62e75.tar.gz |
Add R64 to flash script
-rw-r--r-- | .SRCINFO | 4 | ||||
-rw-r--r-- | PKGBUILD | 8 | ||||
-rwxr-xr-x | bpir-flash2emmc (renamed from bpir3-flash2emmc) | 72 | ||||
-rw-r--r-- | mkinitcpio.conf | 2 | ||||
-rw-r--r-- | mkinitcpio.hook | 9 |
5 files changed, 55 insertions, 40 deletions
@@ -1,6 +1,6 @@ pkgbase = linux-bpir64-git pkgver = 6.2.7.bpir - pkgrel = 1 + pkgrel = 2 url = http://www.kernel.org/ arch = aarch64 license = GPL2 @@ -16,7 +16,7 @@ pkgbase = linux-bpir64-git source = mkinitcpio.conf source = mkinitcpio.hook source = mkinitcpio.build - source = bpir3-flash2emmc + source = bpir-flash2emmc source = src/configfs.c::https://github.com/Xilinx/linux-xlnx/raw/master/drivers/of/configfs.c source = src/mt7986a-bananapi-bpi-r3.dts::https://github.com/torvalds/linux/raw/master/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts source = src/mt7986a.dtsi::https://github.com/torvalds/linux/raw/master/arch/arm64/boot/dts/mediatek/mt7986a.dtsi @@ -11,7 +11,7 @@ _kernelname=${pkgbase#linux} _desc="AArch64 kernel for BPI-R64 and BPI-R3" #_lto="true" # Uncomment this line to enable CLANG-LTO pkgver=6.2.7.bpir -pkgrel=1 +pkgrel=2 arch=('aarch64') url="http://www.kernel.org/" license=('GPL2') @@ -25,7 +25,7 @@ source=('defconfig' 'mkinitcpio.conf' 'mkinitcpio.hook' 'mkinitcpio.build' - 'bpir3-flash2emmc' + 'bpir-flash2emmc' "src/configfs.c::https://github.com/Xilinx/linux-xlnx/raw/master/drivers/of/configfs.c" "src/mt7986a-bananapi-bpi-r3.dts::https://github.com/torvalds/linux/raw/master/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts" "src/mt7986a.dtsi::https://github.com/torvalds/linux/raw/master/arch/arm64/boot/dts/mediatek/mt7986a.dtsi" @@ -161,8 +161,8 @@ _package() { install -Dm644 /dev/stdin "${pkgdir}/etc/initcpio/install/${pkgbase}" # install R3 EMMC flash script - sed "${_subst}" ../bpir3-flash2emmc | - install -Dm755 /dev/stdin "${pkgdir}/usr/bin/bpir3-flash2emmc" + sed "${_subst}" ../bpir-flash2emmc | + install -Dm755 /dev/stdin "${pkgdir}/usr/bin/bpir-flash2emmc" # install pacman hooks sed "${_subst}" ../60-linux.hook | diff --git a/bpir3-flash2emmc b/bpir-flash2emmc index 262fdc2a1784..3dfee43ae523 100755 --- a/bpir3-flash2emmc +++ b/bpir-flash2emmc @@ -3,9 +3,6 @@ # Tool for %PKGBASE% package, needs to run from initrd! # Connect UART and when kernel starts, keep 'x' key pressed. -driver="mtk-msdc" -addr="11230000" - function get_sysmmc { str=$(echo /sys/bus/platform/devices/${addr}.mmc/mmc_host/mmc*/mmc* | head -1) [ -e "$str" ] && echo ${str} || echo "" @@ -20,7 +17,7 @@ function get_mmctype { } function set_sdmmc { -rmdir ${mmcdtbo} + rmdir ${mmcdtbo} } function set_emmc { @@ -54,38 +51,51 @@ function restart_driver { sleep 1.9 done } - -mount -t configfs none /sys/kernel/config - -mmcblk=$(get_mmcblk) -mmcdtbo="/sys/kernel/config/device-tree/overlays/mmc0" - -echo "Device = /dev/${mmcblk}" - -if [[ "$(get_mmctype)" == "SD" ]]; then + +driver="mtk-msdc" +addr="11230000" +compatible="$(tr -d '\0' 2>/dev/null </proc/device-tree/compatible)" + +if [[ "$compatible" == *"bananapi"*"mediatek,mt7622"* ]]; then # BPI-R64 + mmcblk=$(get_mmcblk) + echo "EMMC Device = /dev/${mmcblk}" mkdir -p /tmp/mnt mount --source /dev/disk/by-partlabel/*-sdmmc-root --target /tmp/mnt [ $? -ne 0 ] && exit - echo "Reading file $1 now..." - cp -f "/tmp/mnt$1" "/tmp/tempfile" + echo "Flashing file $1 now..." + dd if="/tmp/mnt$1" of=/dev/${mmcblk} bs=1M conv=fsync,notrunc umount /tmp/mnt - [ $? -ne 0 ] && exit - echo "Switching to EMMC..." - set_emmc - restart_driver "MMC" - mmcblk=$(get_mmcblk) - if [ -e "/tmp/tempfile" ]; then - echo "Setting up EMMC so that ${mmcblk} is the bootdevice." - mmc bootpart enable 7 1 /dev/${mmcblk} - echo "Writing $1 to EMMC now..." - xz -dcv "/tmp/tempfile" | dd of=/dev/${mmcblk} conv=fsync,notrunc - echo "Reboot and enjoy booting from EMMC." -fi -elif [[ "$(get_mmctype)" == "MMC" ]]; then - echo "Switching back to SDMMC..." - set_sdmmc - restart_driver "SD" +elif [[ "$compatible" == *"bananapi"*"mediatek,mt7986"* ]]; then # BPI-R3 + addr="11230000" + mount -t configfs none /sys/kernel/config mmcblk=$(get_mmcblk) + mmcdtbo="/sys/kernel/config/device-tree/overlays/mmc0" + echo "EMMC Device = /dev/${mmcblk}" + if [[ "$(get_mmctype)" == "SD" ]]; then + mkdir -p /tmp/mnt + mount --source /dev/disk/by-partlabel/*-sdmmc-root --target /tmp/mnt + [ $? -ne 0 ] && exit + echo "Reading file $1 now..." + cp -f "/tmp/mnt$1" "/tmp/tempfile" + umount /tmp/mnt + [ $? -ne 0 ] && exit + echo "Switching to EMMC..." + set_emmc + restart_driver "MMC" + mmcblk=$(get_mmcblk) + if [ -e "/tmp/tempfile" ]; then + echo "Setting up EMMC so that ${mmcblk} is the bootdevice." + mmc bootpart enable 7 1 /dev/${mmcblk} + echo "Writing $1 to EMMC now..." + xz -dcv "/tmp/tempfile" | dd of=/dev/${mmcblk} conv=fsync,notrunc + echo "Reboot and enjoy booting from EMMC." + fi + elif [[ "$(get_mmctype)" == "MMC" ]]; then + echo "Switching back to SDMMC..." + set_sdmmc + restart_driver "SD" + mmcblk=$(get_mmcblk) + fi fi #echo "Testing on mmcblk0boot1..." diff --git a/mkinitcpio.conf b/mkinitcpio.conf index 4d7a1f235f40..e00f75ca3c98 100644 --- a/mkinitcpio.conf +++ b/mkinitcpio.conf @@ -1,6 +1,6 @@ # vim:set ft=sh MODULES=() -BINARIES=(bpir3-flash2emmc xz mmc lsblk evtest parted dtc mkfs.f2fs) +BINARIES=(bpir-flash2emmc xz mmc lsblk evtest parted dtc mkfs.f2fs) FILES=() HOOKS=(base udev autodetect modconf block filesystems %PKGBASE%) #MODULES_DECOMPRESS="yes" diff --git a/mkinitcpio.hook b/mkinitcpio.hook index 2dd05098d5ee..7fd3013bfd0d 100644 --- a/mkinitcpio.hook +++ b/mkinitcpio.hook @@ -3,9 +3,14 @@ run_hook() { read -n 1 -t 0.3 char - if [[ "$char" == "x" ]]; then + if [[ "$char" == "E" ]]; then + echo "Executing 'bpir-flash2emmc /tmp/bpir.img.xz' ..." + bpir-flash2emmc /tmp/bpir.img.xz echo "Entering busybox ash shell." - echo "Enter 'bpir3-flash2emmc /tmp/bpir.img.xz' to flash it to the EMMC on th R3." + ash + elif [[ "$char" == "x" ]]; then + echo "Entering busybox ash shell." + echo "Enter 'bpir-flash2emmc /tmp/bpir.img.xz' to flash it to the EMMC on th R3." echo "Enter 'exit' to continue booting." ash fi |