Some code cleanups in nand-sata-install.sh, Beelink X2 fex fixes

This commit is contained in:
ThomasKaiser
2016-06-05 18:18:43 +02:00
parent dd77b72852
commit 6ecd6da6ba
2 changed files with 1298 additions and 1318 deletions

View File

@@ -350,15 +350,15 @@ standby_led = "gpio_pin_2"
;----------------------------------------------------------------------------------
[ths_para]
ths_used = 1
ths_trip1_count = 5
ths_trip1_0 = 70
ths_trip1_1 = 80
ths_trip1_2 = 90
ths_trip1_3 = 100
ths_trip1_4 = 105
ths_trip1_5 = 0
ths_trip1_6 = 0
ths_trip1_7 = 0
ths_trip1_count = 8
ths_trip1_0 = 65
ths_trip1_1 = 70
ths_trip1_2 = 75
ths_trip1_3 = 80
ths_trip1_4 = 85
ths_trip1_5 = 90
ths_trip1_6 = 95
ths_trip1_7 = 105
ths_trip1_0_min = 0
ths_trip1_0_max = 1
ths_trip1_1_min = 1
@@ -368,24 +368,32 @@ ths_trip1_2_max = 3
ths_trip1_3_min = 3
ths_trip1_3_max = 4
ths_trip1_4_min = 4
ths_trip1_4_max = 4
ths_trip1_5_min = 0
ths_trip1_5_max = 0
ths_trip1_6_min = 0
ths_trip1_6_max = 0
ths_trip1_4_max = 6
ths_trip1_5_min = 6
ths_trip1_5_max = 8
ths_trip1_6_min = 8
ths_trip1_6_max = 10
ths_trip1_7_min = 0
ths_trip1_7_max = 0
ths_trip2_count = 1
ths_trip2_0 = 105
;----------------------------------------------------------------------------------
;cooler_table cooler_count <=32
;----------------------------------------------------------------------------------
[cooler_table]
cooler_count = 5
cooler_count = 11
cooler0 = "1200000 4 4294967295 0"
cooler1 = "1200000 3 4294967295 0"
cooler2 = "1200000 2 4294967295 0"
cooler3 = "1200000 1 4294967295 0"
cooler4 = "504000 1 4294967295 0"
cooler1 = "1008000 4 4294967295 0"
cooler2 = "816000 4 4294967295 0"
cooler3 = "720000 4 4294967295 0"
cooler4 = "648000 4 4294967295 0"
cooler5 = "480000 4 4294967295 0"
cooler6 = "312000 4 4294967295 0"
cooler7 = "240000 4 4294967295 0"
cooler8 = "240000 3 4294967295 0"
cooler9 = "240000 2 4294967295 0"
cooler10 = "240000 1 4294967295 0"
[nand0_para]
nand_support_2ch = 0
@@ -1073,36 +1081,15 @@ ir_tx = port:PH07<2><default><default><default>
pmuic_type = 0
pmu_gpio0 = port:PL06<1><1><2><1>
pmu_level0 = 11300
pmu_level1 = 01100
;extremity_freq = 1344000000
pmu_level1 = 1100
;extremity_freq = 1296000000
max_freq = 1200000000
min_freq = 480000000
boot_freq = 1008000000
LV_count = 8
min_freq = 648000000
LV_count = 2
LV1_freq = 1200000000
LV1_volt = 1300
LV2_freq = 1008000000
LV2_volt = 1200
LV3_freq = 0
LV3_volt = 1100
LV4_freq = 0
LV4_volt = 1100
LV5_freq = 0
LV5_volt = 1100
LV6_freq = 0
LV6_volt = 1100
LV7_freq = 0
LV7_volt = 1100
LV8_freq = 0
LV8_volt = 1100
LV2_freq = 648000000
LV2_volt = 1300
[gpu_dvfs_table]
@@ -1254,3 +1241,15 @@ d7s_used = 0
din_gpio = port:PD00<1><default><default><1>
clk_gpio = port:PD01<1><default><default><1>
stb_gpio = port:PD02<1><default><default><1>
;----------------------------------------------------------------------------------
;mali parameters
;----------------------------------------------------------------------------------
[mali_para]
mali_used = 1
mali_clkdiv = 1
mali_extreme_freq = 600
mali_extreme_vol = 1400
[corekeeper]
corekeeper_enabled = 1

View File

@@ -14,21 +14,18 @@
CWD="/usr/lib/nand-sata-install"
EX_LIST="${CWD}/exclude.txt"
backtitle="Armbian install script, http://www.armbian.com | Author: Igor Pecovnik"
title="NAND, SATA and USB Armbian installer"
title="NAND, eMMC, SATA and USB Armbian installer"
emmcdevice="/dev/mmcblk1"
nanddevice="/dev/nand"
if cat /proc/cpuinfo | grep -q 'sun4i'; then DEVICE_TYPE="a10"; else DEVICE_TYPE="a20"; fi # Determine device
BOOTLOADER="${CWD}/${DEVICE_TYPE}/bootloader" # Define bootloader
nandcheck=$(grep nand /proc/partitions) # check NAND
emmcchech=$(grep mmcblk1 /proc/partitions) # check eMMC
emmccheck=$(grep mmcblk1 /proc/partitions) # check eMMC
satacheck=$(grep sd /proc/partitions) # check SATA/USB
# Create boot and root file system $1 = boot, $2 = root (Example: create_armbian "/dev/nand1" "/dev/sda3")
create_armbian ()
{
create_armbian() {
# create mount points, mount and clean
sync
mkdir -p /mnt/bootfs /mnt/rootfs
@@ -36,7 +33,6 @@ create_armbian ()
[[ -n "$1" && "$1" != "$2" ]] && mount $1 /mnt/bootfs
rm -rf /mnt/bootfs/* /mnt/rootfs/*
# calculate usage and see if it fits on destination
USAGE=$(df -BM | grep ^/dev | head -1 | awk '{print $3}' | tr -cd '[0-9]. \n')
DEST=$(df -BM | grep ^/dev | grep /mnt/rootfs | awk '{print $4}' | tr -cd '[0-9]. \n')
@@ -65,7 +61,6 @@ create_armbian ()
# creating fstab, kernel and boot script for NAND partition
if [[ "$1" == *nand* ]]; then
REMOVESDTXT="and remove SD to boot from NAND"
sed -i '/boot/d' /mnt/rootfs/etc/fstab
echo "$1 /boot vfat defaults 0 0" >> /mnt/rootfs/etc/fstab
@@ -118,7 +113,7 @@ EOF
sed -i "s/data=writeback,//" /mnt/rootfs/etc/fstab
fi
umountdevice "/dev/sda"
}
} # create_armbian
# Accept device as parameter: for example /dev/sda unmounts all their mounts
@@ -133,13 +128,11 @@ umountdevice() {
fi
done
fi
}
} # umountdevice
# Recognize root filesystem
recognize_root() {
local device="/dev/"$(lsblk -idn -o NAME | grep mmcblk0)
local partitions=$(($(fdisk -l $device | grep $device | wc -l)-1))
local device="/dev/"$(lsblk -idn -o NAME | grep mmcblk0)"p"$partitions
@@ -151,13 +144,11 @@ recognize_root (){
break;
fi
done
}
} # recognize_root
# Formatting NAND - no parameters. Fixed solution.
formatnand() {
[[ ! -e /dev/nand ]] && echo "NAND error" && exit 0
dialog --title "$title" --backtitle "$backtitle" --infobox "\nFormating ... up to one minute." 5 40
if [[ "$DEVICE_TYPE" = "a20" ]]; then
@@ -167,14 +158,11 @@ formatnand(){
fi
mkfs.vfat /dev/nand1 >/dev/null 2>&1
mkfs.ext4 /dev/nand2 >/dev/null 2>&1
}
} # formatnand
# Formatting eMMC [device] example /dev/mmcblk1
formatemmc()
{
formatemmc() {
# deletes all partitions
dialog --title "$title" --backtitle "$backtitle" --infobox "\n Formating eMMC ... one moment." 5 40
dd bs=1 seek=446 count=64 if=/dev/zero of=$1 >/dev/null 2>&1
@@ -183,26 +171,21 @@ formatemmc()
partprobe $1
# create fs
mkfs.ext4 -qF $1"p1" >/dev/null 2>&1
}
} # formatemmc
# formatting SATA/USB [device] example /dev/sda3
formatsata() {
dialog --title "$title" --backtitle "$backtitle" --infobox "\nFormating ... up to one minute." 5 40
mkfs.ext4 $1 >/dev/null 2>&1
tune2fs $1 -o journal_data_writeback >/dev/null 2>&1
}
} # formatsata
# choose target SATA/USB partition.
function checksatatarget
{
checksatatarget() {
IFS=" "
SataTargets=$(cat /proc/partitions | grep sd | awk '{print "/dev/"$4}' | grep -E '[0-9]{1,4}' | nl | xargs echo -n)
SataTargets=$(awk '/sd/ {print "/dev/"$4}' </proc/partitions | grep -E '[0-9]{1,4}' | nl | xargs echo -n)
if [[ "$SataTargets" == "" ]]; then
dialog --title "$title" --backtitle "$backtitle" --colors --infobox \
"\n\Z1There are no avaliable partitions. Please create them.\Zn" 5 60
@@ -214,20 +197,16 @@ function checksatatarget
SataChoices=$("${SataCmd[@]}" "${SataOptions[@]}" 2>&1 >/dev/tty)
if [ $? -ne 0 ]; then exit 1; fi
SDA_ROOT_PART=${SataOptions[(2*$SataChoices)-1]}
}
} # checksatatarget
# show warning [TEXT]
function ShowWarning
{
ShowWarning() {
dialog --title "$title" --backtitle "$backtitle" --cr-wrap --colors --yesno " \Z1$(toilet -f mono12 WARNING)\Zn\n$1" 17 74
if [ $? -ne 0 ]; then exit 1; fi
} # ShowWarning
}
main() {
# This tool must run under root
if [[ ${EUID} -ne 0 ]]; then
@@ -249,11 +228,10 @@ function ShowWarning
exit 1
fi
recognize_root
IFS="'"
options=()
if [[ -n "$emmcchech" ]]; then
if [[ -n "$emmccheck" ]]; then
ichip="eMMC";
dest_boot="/dev/mmcblk1p1";
dest_root="/dev/mmcblk1p1";
@@ -263,8 +241,8 @@ function ShowWarning
dest_root="/dev/nand2";
fi
[[ -n "$nandcheck" || -n "$emmcchech" ]] && options=(${options[@]} 1 'Boot from '$ichip' - system on '$ichip)
[[ ( -n "$nandcheck" || -n "$emmcchech" ) && -n "$satacheck" ]] && options=(${options[@]} 2 'Boot from '$ichip' - system on SATA or USB')
[[ -n "$nandcheck" || -n "$emmccheck" ]] && options=(${options[@]} 1 'Boot from '$ichip' - system on '$ichip)
[[ ( -n "$nandcheck" || -n "$emmccheck" ) && -n "$satacheck" ]] && options=(${options[@]} 2 'Boot from '$ichip' - system on SATA or USB')
[[ -n "$satacheck" ]] && options=(${options[@]} 3 'Boot from SD - system on SATA or USB')
[[ ${#options[@]} -eq 0 ]] && dialog --title "$title" --backtitle "$backtitle" --colors --infobox "\n\Z1There are no targets. Please check your drives.\Zn" 5 60 && exit 1
@@ -280,7 +258,7 @@ function ShowWarning
title="$ichip install"
command="Power off"
ShowWarning "This script will erase your $ichip. Continue?"
if [[ -n "$emmcchech" ]]; then
if [[ -n "$emmccheck" ]]; then
umountdevice "/dev/mmcblk1"
formatemmc "/dev/mmcblk1"
else
@@ -294,7 +272,7 @@ function ShowWarning
command="Power off"
checksatatarget
ShowWarning "This script will erase your $ichip and $SDA_ROOT_PART. Continue?"
if [[ -n "$emmcchech" ]]; then
if [[ -n "$emmccheck" ]]; then
umountdevice "/dev/mmcblk1"
formatemmc "/dev/mmcblk1"
else
@@ -318,3 +296,6 @@ function ShowWarning
dialog --title "$title" --backtitle "$backtitle" --yes-label "$command" --no-label "Exit" --yesno "\nAll done. $command $REMOVESDTXT" 7 60
if [ $? -eq 0 ]; then "$(echo ${command,,} | sed 's/ //')"; fi
} # main
main "$@"