mirror of
https://github.com/DrHo1y/orangepi-build.git
synced 2026-11-19 00:22:47 +07:00
Bump to next branch
Host: Ubuntu 21.04
This commit is contained in:
@@ -64,11 +64,11 @@ fi
|
||||
mkopts[btrfs]='-f'
|
||||
mkopts[f2fs]='-f'
|
||||
|
||||
mountopts[ext2]='defaults,noatime,nodiratime,commit=600,errors=remount-ro,x-gvfs-hide 0 1'
|
||||
mountopts[ext3]='defaults,noatime,nodiratime,commit=600,errors=remount-ro,x-gvfs-hide 0 1'
|
||||
mountopts[ext4]='defaults,noatime,nodiratime,commit=600,errors=remount-ro,x-gvfs-hide 0 1'
|
||||
mountopts[btrfs]='defaults,noatime,nodiratime,commit=600,compress=lzo,x-gvfs-hide 0 2'
|
||||
mountopts[f2fs]='defaults,noatime,nodiratime,x-gvfs-hide 0 2'
|
||||
mountopts[ext2]='defaults,noatime,commit=600,errors=remount-ro,x-gvfs-hide 0 1'
|
||||
mountopts[ext3]='defaults,noatime,commit=600,errors=remount-ro,x-gvfs-hide 0 1'
|
||||
mountopts[ext4]='defaults,noatime,commit=600,errors=remount-ro,x-gvfs-hide 0 1'
|
||||
mountopts[btrfs]='defaults,noatime,commit=600,compress=lzo,x-gvfs-hide 0 2'
|
||||
mountopts[f2fs]='defaults,noatime,x-gvfs-hide 0 2'
|
||||
|
||||
# Create boot and root file system "$1" = boot, "$2" = root (Example: create_orangepi "/dev/nand1" "/dev/sda3")
|
||||
create_orangepi()
|
||||
@@ -193,7 +193,7 @@ create_orangepi()
|
||||
This will take approximately $(( $((USAGE/300)) * 1 )) minutes to finish. Please wait!\n\n" 11 80
|
||||
|
||||
# run rsync again to silently catch outstanding changes between / and "${TempDir}"/rootfs/
|
||||
dialog --title "$title" --backtitle "$backtitle" --infobox "\n Cleaning up ... Almost done." 5 40
|
||||
dialog --title "$title" --backtitle "$backtitle" --infobox "\n Cleaning up ... Almost done." 5 60
|
||||
rsync -avrltD --delete --exclude-from=$EX_LIST / "${TempDir}"/rootfs >/dev/null 2>&1
|
||||
|
||||
# creating fstab from scratch
|
||||
@@ -211,7 +211,7 @@ create_orangepi()
|
||||
echo "Finishing installation to NAND." >> $logfile
|
||||
REMOVESDTXT="and remove SD to boot from NAND"
|
||||
echo "$1 /boot vfat defaults 0 0" >> "${TempDir}"/rootfs/etc/fstab
|
||||
echo "$2 / ext4 defaults,noatime,nodiratime,commit=600,errors=remount-ro 0 1" >> "${TempDir}"/rootfs/etc/fstab
|
||||
echo "$2 / ext4 defaults,noatime,commit=600,errors=remount-ro 0 1" >> "${TempDir}"/rootfs/etc/fstab
|
||||
dialog --title "$title" --backtitle "$backtitle" --infobox "\nConverting kernel ... few seconds." 5 60
|
||||
mkimage -A arm -O linux -T kernel -C none -a "0x40008000" -e "0x40008000" -n "Linux kernel" -d \
|
||||
/boot/zImage "${TempDir}"/bootfs/uImage >/dev/null 2>&1
|
||||
@@ -278,7 +278,13 @@ create_orangepi()
|
||||
[[ -f "${TempDir}"/bootfs/boot/boot.ini ]] && sed -e 's,^setenv rootdev.*$,setenv rootdev "'"$targetuuid"'",' -i "${TempDir}"/bootfs/boot/boot.ini
|
||||
[[ -f "${TempDir}"/rootfs/boot/boot.ini ]] && sed -e 's,^setenv rootdev.*$,setenv rootdev "'"$targetuuid"'",' -i "${TempDir}"/rootfs/boot/boot.ini
|
||||
fi
|
||||
mkimage -C none -A arm -T script -d "${TempDir}"/bootfs/boot/boot.cmd "${TempDir}"/bootfs/boot/boot.scr >/dev/null 2>&1 || (echo 'Error while creating U-Boot loader image with mkimage' >&2 ; exit 5)
|
||||
|
||||
if [[ -f "${TempDir}"/bootfs/boot/extlinux/extlinux.conf ]]; then
|
||||
sed -e 's,root='"$root_uuid"',root='"$targetuuid"',g' -i "${TempDir}"/bootfs/boot/extlinux/extlinux.conf
|
||||
[[ -f "${TempDir}"/bootfs/boot/boot.cmd ]] && rm "${TempDir}"/bootfs/boot/boot.cmd
|
||||
else
|
||||
mkimage -C none -A arm -T script -d "${TempDir}"/bootfs/boot/boot.cmd "${TempDir}"/bootfs/boot/boot.scr >/dev/null 2>&1 || (echo 'Error while creating U-Boot loader image with mkimage' >&2 ; exit 5)
|
||||
fi
|
||||
|
||||
# fstab adj
|
||||
if [[ "$1" != "$2" ]]; then
|
||||
@@ -327,6 +333,10 @@ create_orangepi()
|
||||
sed -e 's,setenv rootfstype.*,setenv rootfstype '"$FilesystemChoosen"',' -i /boot/boot.cmd
|
||||
sed -e 's,setenv rootfstype.*,setenv rootfstype '"$FilesystemChoosen"',' -i /boot/boot.ini
|
||||
fi
|
||||
if [[ -f /bootfs/boot/extlinux/extlinux.conf ]]; then
|
||||
sed -e 's,root='"$root_uuid"',root='"$satauuid"',g' -i /boot/extlinux/extlinux.conf
|
||||
[[ -f /boot/boot.cmd ]] && rm /boot/boot.cmd
|
||||
fi
|
||||
[[ -f /boot/boot.cmd ]] && mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr >/dev/null 2>&1 || (echo 'Error while creating U-Boot loader image with mkimage' >&2 ; exit 7)
|
||||
mkdir -p "${TempDir}"/rootfs/media/mmc/boot
|
||||
echo "${sduuid} /media/mmcboot ext4 ${mountopts[ext4]}" >> "${TempDir}"/rootfs/etc/fstab
|
||||
@@ -407,7 +417,7 @@ format_nand()
|
||||
|
||||
show_nand_warning
|
||||
|
||||
dialog --title "$title" --backtitle "$backtitle" --infobox "\nFormating ... up to one minute." 5 40
|
||||
dialog --title "$title" --backtitle "$backtitle" --infobox "\n Formatting ... up to one minute." 5 60
|
||||
if [[ $DEVICE_TYPE = a20 ]]; then
|
||||
(echo y;) | sunxi-nand-part -f a20 /dev/nand 65536 'bootloader 65536' 'linux 0' >> $logfile 2>&1
|
||||
else
|
||||
@@ -443,15 +453,21 @@ format_emmc()
|
||||
QUOTED_DEVICE=$(echo "$1" | sed 's:/:\\\/:g')
|
||||
CAPACITY=$(parted "$1" unit s print -sm | awk -F":" "/^${QUOTED_DEVICE}/ {printf (\"%0d\", \$2 / ( 1024 / \$4 ))}")
|
||||
|
||||
# We use 16MiB to align partitions which may overestimate the erase block
|
||||
# size of a NAND device. Overestimating is harmless. (512 byte
|
||||
# sectors, so we use 32768 as divider and substract 1)
|
||||
if [[ $CAPACITY -lt 4000000 ]]; then
|
||||
# Leave 2 percent unpartitioned when eMMC size is less than 4GB (unlikely)
|
||||
LASTSECTOR=$(( 32 * $(parted "$1" unit s print -sm | awk -F":" "/^${QUOTED_DEVICE}/ {printf (\"%0d\", ( \$2 * 98 / 3200))}") -1 ))
|
||||
LASTSECTOR=$(( 32768 * $(parted "$1" unit s print -sm | awk -F":" "/^${QUOTED_DEVICE}/ {printf (\"%0d\", ( \$2 * 98 / 3276800))}") -1 ))
|
||||
else
|
||||
# Leave 1 percent unpartitioned
|
||||
LASTSECTOR=$(( 32 * $(parted "$1" unit s print -sm | awk -F":" "/^${QUOTED_DEVICE}/ {printf (\"%0d\", ( \$2 * 99 / 3200))}") -1 ))
|
||||
LASTSECTOR=$(( 32768 * $(parted "$1" unit s print -sm | awk -F":" "/^${QUOTED_DEVICE}/ {printf (\"%0d\", ( \$2 * 99 / 3276800))}") -1 ))
|
||||
fi
|
||||
|
||||
parted -s "$1" -- mklabel msdos
|
||||
# get target partition table type from the root partition device
|
||||
PART_TABLE_TYPE=$(parted "$root_partition_device" print -sm | awk -F ":" -v pattern="$root_partition_device" '$0 ~ pattern {print $6}')
|
||||
|
||||
parted -s "$1" -- mklabel "$PART_TABLE_TYPE"
|
||||
dialog --title "$title" --backtitle "$backtitle" --infobox "\nFormating $1 to $eMMCFilesystemChoosen ... please wait." 5 60
|
||||
# we can't boot from btrfs or f2fs
|
||||
if [[ $eMMCFilesystemChoosen =~ ^(btrfs|f2fs)$ ]]; then
|
||||
@@ -461,7 +477,7 @@ format_emmc()
|
||||
fi
|
||||
|
||||
# default boot partition size, in MiB
|
||||
DEFAULT_BOOTSIZE=96
|
||||
DEFAULT_BOOTSIZE=256
|
||||
|
||||
# (convert to sectors for partitioning)
|
||||
DEFAULT_BOOTSIZE_SECTORS=$(((${DEFAULT_BOOTSIZE} * 1024 * 1024) / 512))
|
||||
@@ -573,7 +589,7 @@ update_bootscript()
|
||||
# show warning [TEXT]
|
||||
show_warning()
|
||||
{
|
||||
dialog --title "$title" --backtitle "$backtitle" --cr-wrap --colors --yesno " \Z1$(toilet -W -f ascii9 WARNING)\Zn\n$1" 14 53
|
||||
dialog --title "$title" --backtitle "$backtitle" --cr-wrap --colors --yesno " \Z1$(toilet -W -f ascii9 ' WARNING')\Zn\n$1" 16 67
|
||||
[[ $? -ne 0 ]] && exit 13
|
||||
}
|
||||
|
||||
@@ -587,6 +603,20 @@ stop_running_services()
|
||||
done
|
||||
}
|
||||
|
||||
# show warning and write u-boot to SPI flash $1 = spi device name, $2 = u-boot files directory
|
||||
write_uboot_to_spi_flash()
|
||||
{
|
||||
local MTD_BLK="/dev/$1"
|
||||
local DIR="$2"
|
||||
local MESSAGE="This script will update the bootloader on SPI Flash $MTD_BLK. Continue?\nIt will take up to a few minutes."
|
||||
dialog --title "$title" --backtitle "$backtitle" --cr-wrap --colors --yesno " \Z1$(toilet -W -f ascii9 ' WARNING')\Zn\n$MESSAGE" 16 67
|
||||
if [[ $? -eq 0 ]]; then
|
||||
write_uboot_platform_mtd "$DIR" $MTD_BLK
|
||||
update_bootscript
|
||||
echo 'Done'
|
||||
fi
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
@@ -599,15 +629,15 @@ main()
|
||||
|
||||
# Check if we run it from SD card
|
||||
# TODO: Disable/remove this in the future
|
||||
case ${root_partition_device} in
|
||||
/dev/mmcblk*) # mmc device, we can continue
|
||||
:
|
||||
;;
|
||||
*)
|
||||
dialog --title "$title" --backtitle "$backtitle" --colors --infobox '\n\Z1This tool must run from SD-card! \Zn' 5 37
|
||||
exit 15
|
||||
;;
|
||||
esac
|
||||
# case ${root_partition_device} in
|
||||
# /dev/mmcblk*) # mmc device, we can continue
|
||||
# :
|
||||
# ;;
|
||||
# *)
|
||||
# dialog --title "$title" --backtitle "$backtitle" --colors --infobox '\n\Z1 This tool must run from SD-card! \Zn' 5 60
|
||||
# exit 15
|
||||
# ;;
|
||||
# esac
|
||||
|
||||
[ -f $logfile ] && echo -e '\n\n\n' >> $logfile
|
||||
LANG=C echo -e "$(date): Start ${0##*/}.\n" >> $logfile
|
||||
@@ -691,6 +721,15 @@ main()
|
||||
show_warning "This script will erase your device $DISK_ROOT_PART. Continue?"
|
||||
format_disk "$DISK_ROOT_PART"
|
||||
create_orangepi 'spi' "$DISK_ROOT_PART"
|
||||
|
||||
if [[ $(type -t write_uboot_platform_mtd) == function ]]; then
|
||||
dialog --title "$title" --backtitle "$backtitle" --yesno \
|
||||
"Do you want to write the bootloader to SPI flash?\n\nIt is required if you have not done it before or if you have some non-OrangePi bootloader in SPI." 8 60
|
||||
|
||||
if [[ $? -eq 0 ]]; then
|
||||
write_uboot_to_spi_flash $spicheck "$DIR"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
5)
|
||||
show_warning 'This script will update the bootloader on SD/eMMC. Continue?'
|
||||
@@ -711,11 +750,7 @@ main()
|
||||
return
|
||||
;;
|
||||
7)
|
||||
MTD_BLK="/dev/${spicheck}"
|
||||
show_warning "This script will update the bootloader on SPI Flash $MTD_BLK. Continue?"
|
||||
write_uboot_platform_mtd "$DIR" $MTD_BLK
|
||||
update_bootscript
|
||||
echo 'Done'
|
||||
write_uboot_to_spi_flash $spicheck "$DIR"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -36,7 +36,7 @@ fi
|
||||
. /etc/orangepi-release
|
||||
|
||||
case "${LINUXFAMILY}" in
|
||||
sunxi|sunxi64|rockchip64|sun50iw9)
|
||||
sunxi|sunxi64|rockchip64|sun50iw9|rk3399)
|
||||
:;;
|
||||
*)
|
||||
echo >&2 "Overlays are not supported on ${LINUXFAMILY^} based boards."
|
||||
|
||||
Reference in New Issue
Block a user