diff --git a/install-from-bootloader-fp3.sh b/install-from-bootloader-fp3.sh new file mode 100755 index 0000000000000000000000000000000000000000..e1739cbb1668c53e903a4aaec18ed99641b85a95 --- /dev/null +++ b/install-from-bootloader-fp3.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +# Copyright (C) 2020 ECORP SAS - Author: Romain Hunault +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Parameter +# $1: DEVICE_ID device id +# $2: ARCHIVE_PATH path to archive + +# Exit status +# - 0 : device flashed +# - 1 : generic error +# - 101 : DEVICE_ID missing +# - 102 : ARCHIVE_PATH missing + +DEVICE_ID=$1 +ARCHIVE_PATH=$2 + +if [ -z $DEVICE_ID ] +then + exit 101 +fi + +if [ -z $ARCHIVE_PATH ] +then + exit 102 +fi + +fastboot -s $DEVICE_ID -w +sleep 1 + +fastboot -s $DEVICE_ID flash system $ARCHIVE_PATH/system.img +sleep 1 +fastboot -s $DEVICE_ID flash boot $ARCHIVE_PATH/boot.img +sleep 1 +fastboot -s $DEVICE_ID flash vendor $ARCHIVE_PATH/vendor.img +sleep 1 +fastboot -s $DEVICE_ID flash dtbo $ARCHIVE_PATH/dtbo.img +sleep 1 +fastboot -s $DEVICE_ID flash product $ARCHIVE_PATH/product.img +sleep 1 +fastboot -s $DEVICE_ID flash vbmeta $ARCHIVE_PATH/vbmeta.img +sleep 1 diff --git a/lock-bootloader.sh b/lock-bootloader.sh new file mode 100755 index 0000000000000000000000000000000000000000..aed5ed9a343dde07ae9a3b7731ef56bdd81899fc --- /dev/null +++ b/lock-bootloader.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# Copyright (C) 2020 ECORP SAS - Author: Romain Hunault +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Parameter +# $1: DEVICE_ID device id + +# Exit status +# - 0 : bootloader locked +# - 1 : generic error + +DEVICE_ID=$1 + +if [ -z $DEVICE_ID ] +then + exit 101 +fi + +fastboot -s $DEVICE_ID flashing lock diff --git a/unlock-device.sh b/unlock-device.sh index c56bd49e0e3eb44d22b5df7babfef98145eaae71..cc7843495be08a4302ecaaae1de7a20383648229 100755 --- a/unlock-device.sh +++ b/unlock-device.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (C) 2019 ECORP SAS - Author: Romain Hunault +# Copyright (C) 2019-2020 ECORP SAS - Author: Romain Hunault # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,16 +16,16 @@ # along with this program. If not, see . # Parameter -# $1: DEVICE_LOCKED_PATH cable lock file (typically ${DEVICES_LOCKED_PATH}/${DEVICE}) +# $1: DEVICE_LOCKED_PATH device lock file (typically ${DEVICES_LOCKED_PATH}/${DEVICE}) # Exit status -# - 0 : device unlocked (lock file deleted) -# - 1 : Lock file does not exist +# - 0 : device unlocked +# - 1 : generic error # - 101 : DEVICE_LOCKED_PATH missing DEVICE_LOCKED_PATH=$1 -if [ -z $DEVICE_LOCKED_PATH ] +if [ -z "$DEVICE_LOCKED_PATH" ] then exit 101 fi diff --git a/unlock-fp3.sh b/unlock-fp3.sh new file mode 100755 index 0000000000000000000000000000000000000000..407ff51e999b2ddf32bbddf2f182626b67de4545 --- /dev/null +++ b/unlock-fp3.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Copyright (C) 2020 ECORP SAS - Author: Romain Hunault +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Parameter +# $1: path to archive folder +# $2: device id + +# Exit status +# - 0 : bootloader locked +# - 1 : generic error +# - 101 : $DEVICE_ID missing +# - 102 : $ARCHIVE_PATH missing + +ARCHIVE_PATH=$1 +DEVICE_ID=$2 + +if [ -z $ARCHIVE_PATH ] +then + exit 102 +fi + + +if [ -z $DEVICE_ID ] +then + exit 101 +fi + +fastboot -s $DEVICE_ID flash devinfo $ARCHIVE_PATH/devinfo-unlocked.gpx +sleep 1 +fastboot -s $DEVICE_ID reboot bootloader diff --git a/wait-fastboot.sh b/wait-fastboot.sh new file mode 100755 index 0000000000000000000000000000000000000000..9d7f930c584f4ec61172baac2b1cde16df158ef5 --- /dev/null +++ b/wait-fastboot.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +# Copyright (C) 2020 ECORP SAS - Author: Romain Hunault +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Parameter +# $1: DEVICE_LOCKED_PATH device lock file (typically ${DEVICES_LOCKED_PATH}/${DEVICE}) +# $2: DEVICE_ID id of the device + +# Exit status +# - 0 : device unlocked (lock file deleted) +# - 1 : generic error +# - 101 : DEVICES_LOCKED_PATH missing +# - 102 : DEVICE_ID missing + +DEVICES_LOCKED_PATH=$1 +DEVICE_ID=$2 + +if [ -z $DEVICES_LOCKED_PATH ] +then + exit 10 +fi + +if [ ! -z $DEVICE_ID ] +then + while true + do + fastboot devices | grep --perl-regex "${DEVICE_ID}\tfastboot" + if [ $? == 0 ] + then + + exit 0 + fi + done +fi + +function newDevice +{ + for device in $(fastboot devices | grep fastboot | sed 's/\(.*\)\s*fastboot/\1/') + do + if [ ! -f ${DEVICES_LOCKED_PATH}/${device} ] + then + echo ${device} + fi + done +} + +new_device=false + +while ! $new_device +do + DEVICE_ID=$(newDevice) + + if [ ! -z $DEVICE_ID ] + then + new_device=true + fi + + sleep 1 +done + +echo ${DEVICE_ID} diff --git a/wait-reboot-fastboot.sh b/wait-reboot-fastboot.sh new file mode 100755 index 0000000000000000000000000000000000000000..bfa73f26053f7f680b464d1f399754cde1d09ce2 --- /dev/null +++ b/wait-reboot-fastboot.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# Copyright (C) 2020 ECORP SAS - Author: Romain Hunault +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Parameter +# $1: DEVICE_ID Device we are waiting for reboot + +# Exit status +# - 0 : New device detected +# - 1 : Error +# - 10 : DEVICE_ID is missing +# - 101 : DEVICE_ID is not detected + +DEVICE_ID=$1 + +if [ -z $DEVICE_ID ] +then + exit 10 +fi + +function device_in_recovery +{ + fastboot devices | grep fastboot |grep ${DEVICE_ID} 2>&1 >/dev/null +} + +if ! device_in_recovery +then + exit 101 +fi + +while device_in_recovery +do + sleep 1 +done