Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bsp: armbian-install: fix the search for eMMC and SD card devices #7017

Merged
merged 2 commits into from
Aug 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 26 additions & 14 deletions packages/bsp/common/usr/sbin/armbian-install
Original file line number Diff line number Diff line change
Expand Up @@ -807,12 +807,23 @@ main()
[ -f $logfile ] && echo -e '\n\n\n' >> $logfile
LANG=C echo -e "$(date): Start ${0##*/}.\n" >> $logfile

# find real mmcblk device numbered 0, 1, 2 for eMMC, SD
for ret in $(find /dev -name 'mmcblk[0-2]' -and -type b)
do
if [ -b ${ret}boot0 ];then
emmc_dev=$ret
else
sd_dev=$ret
fi
done

IFS="'"
options=()

if [[ -n $emmccheck ]]; then
if [[ "${emmccheck#*mmcblk}" == "0" ]]; then
if [[ "${emmccheck}" == "$sd_dev" ]]; then
ichip='SD card'
else
elif [[ "${emmccheck}" == "$emmc_dev" ]]; then
ichip='eMMC'
fi
dest_boot=$emmccheck'p1'
Expand All @@ -838,22 +849,23 @@ main()
[[ -n $mtdcheck ]] && options+=(4 'Boot from MTD Flash - system on SATA, USB or NVMe')

if [[ -n ${root_partition_device} && ${DEVICE_TYPE} != "uefi" ]]; then
if [ "${root_partition_device#*mmcblk}" == "0" ]; then
if [ "${root_partition_device}" == "$sd_dev" ]; then
rootchip='SD card'
else
elif [ "${root_partition_device}" == "$emmc_dev" ]; then
rootchip='eMMC'
fi
options+=(5 "Install/Update the bootloader on $rootchip (${root_partition_device})")
fi

BOOTPART=$(find /dev -name 'mmcblk*boot0' -and -type b)
if [ "${BOOTPART/boot0}" != "${root_partition_device}" ]; then
if [ -n "${emmc_dev}" ] && [ "${emmc_dev}" != "${root_partition_device}" ]; then

options+=(6 "Install/Update the bootloader on eMMC (${emmc_dev})")
BOOTPART=${emmc_dev}

options+=(6 "Install/Update the bootloader on eMMC (${BOOTPART/boot0/})")
elif [ -n "${sd_dev}" ] && [ "${sd_dev}" != "${root_partition_device}" ]; then

elif [ -b /dev/mmcblk0 ]; then
BOOTPART=/dev/mmcblk0
options+=(6 "Install/Update the bootloader on SD card (${BOOTPART/boot0/})")
options+=(6 "Install/Update the bootloader on SD card (${sd_dev})")
BOOTPART=${sd_dev}
fi

[[ -n $mtdcheck && \
Expand All @@ -862,7 +874,7 @@ main()

[[ ${#options[@]} -eq 0 || "$root_uuid" == "$emmcuuid" || "$root_uuid" == "/dev/nand2" ]] && \
dialog --ok-label 'Cancel' --title ' Warning ' --backtitle "$backtitle" --colors --no-collapse --msgbox '\n\Z1There are no targets. Please check your drives.\Zn' 7 52
cmd=(dialog --title 'Choose an option:' --backtitle "$backtitle" --menu "\nCurrent root: $root_uuid \n \n" 14 60 7)
cmd=(dialog --title 'Choose an option:' --backtitle "$backtitle" --menu "\nCurrent root: $root_uuid \n $rootchip (${root_partition_device})\n" 14 75 7)
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
[[ $? -ne 0 ]] && exit 16

Expand Down Expand Up @@ -927,15 +939,15 @@ main()
fi
;;
5)
show_warning 'This script will update the bootloader on ${root_partition_device}.\n\n Continue?'
show_warning "This script will update the bootloader on ${root_partition_device}.\n\n Continue?"
write_uboot_platform "$DIR" "${root_partition_device}"
update_bootscript
dialog --backtitle "$backtitle" --title 'Writing bootloader' --msgbox '\n Done.' 7 30
return
;;
6)
show_warning "This script will update the bootloader on ${BOOTPART/boot0/}.\n\n Continue?"
write_uboot_platform "$DIR" ${BOOTPART/boot0/}
show_warning "This script will update the bootloader on ${BOOTPART}.\n\n Continue?"
write_uboot_platform "$DIR" ${BOOTPART}
echo 'Done'
return
;;
Expand Down