From e457eea6f94dd08e541bb304d6111b522da5f429 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Tue, 7 Apr 2020 19:07:47 +0200 Subject: [PATCH 01/13] Add script for FP3 --- install-from-bootloader-fp3.sh | 38 ++++++++++++++++++++++++++++++++++ wait-fastboot.sh | 35 +++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100755 install-from-bootloader-fp3.sh create mode 100755 wait-fastboot.sh diff --git a/install-from-bootloader-fp3.sh b/install-from-bootloader-fp3.sh new file mode 100755 index 0000000..dbe8b88 --- /dev/null +++ b/install-from-bootloader-fp3.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +DEVICE_ID=$1 +ARCHIVE_PATH=$2 + +if [ -z $DEVICE_ID ] +then + exit 101 +fi + +if [ -z $ARCHIVE_PATH ] +then + exit 102 +fi + +fastboot flash devinfo $ARCHIVE_PATH/devinfo-unlocked.gpx +sleep 1 +fastboot reboot bootloader +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 +fastboot -s $DEVICE_ID flash mdtp $ARCHIVE_PATH/mdtp.img +sleep 1 + +#fastboot oem lock needed? + +fastboot reboot diff --git a/wait-fastboot.sh b/wait-fastboot.sh new file mode 100755 index 0000000..c5c3a12 --- /dev/null +++ b/wait-fastboot.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +DEVICES_LOCKED_PATH=$1 + +if [ -z $DEVICES_LOCKED_PATH ] +then + exit 10 +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} -- GitLab From eae14abceb430feb1ba2addfe04774b48a0115d1 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Wed, 8 Apr 2020 14:27:28 +0200 Subject: [PATCH 02/13] Wipe user data --- install-from-bootloader-fp3.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/install-from-bootloader-fp3.sh b/install-from-bootloader-fp3.sh index dbe8b88..41a8f39 100755 --- a/install-from-bootloader-fp3.sh +++ b/install-from-bootloader-fp3.sh @@ -18,6 +18,9 @@ sleep 1 fastboot reboot bootloader sleep 1 +fastboot -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 -- GitLab From 4b063d17b19d0c833aa68225edc6ef5f282b5323 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Wed, 8 Apr 2020 14:28:04 +0200 Subject: [PATCH 03/13] Don't flash mdtp partition --- install-from-bootloader-fp3.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/install-from-bootloader-fp3.sh b/install-from-bootloader-fp3.sh index 41a8f39..ccc54af 100755 --- a/install-from-bootloader-fp3.sh +++ b/install-from-bootloader-fp3.sh @@ -33,8 +33,6 @@ fastboot -s $DEVICE_ID flash product $ARCHIVE_PATH/product.img sleep 1 fastboot -s $DEVICE_ID flash vbmeta $ARCHIVE_PATH/vbmeta.img sleep 1 -fastboot -s $DEVICE_ID flash mdtp $ARCHIVE_PATH/mdtp.img -sleep 1 #fastboot oem lock needed? -- GitLab From 28e771b436a5e3a8985eb4edcc976972facce9fb Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Wed, 8 Apr 2020 19:03:03 +0200 Subject: [PATCH 04/13] Handle reboot from bootloader to bootloader --- install-from-bootloader-fp3.sh | 5 ----- unlock-fp3.sh | 12 ++++++++++++ wait-fastboot.sh | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) create mode 100755 unlock-fp3.sh diff --git a/install-from-bootloader-fp3.sh b/install-from-bootloader-fp3.sh index ccc54af..e2c1290 100755 --- a/install-from-bootloader-fp3.sh +++ b/install-from-bootloader-fp3.sh @@ -13,11 +13,6 @@ then exit 102 fi -fastboot flash devinfo $ARCHIVE_PATH/devinfo-unlocked.gpx -sleep 1 -fastboot reboot bootloader -sleep 1 - fastboot -w sleep 1 diff --git a/unlock-fp3.sh b/unlock-fp3.sh new file mode 100755 index 0000000..5f42111 --- /dev/null +++ b/unlock-fp3.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +ARCHIVE_PATH=$1 + +if [ -z $ARCHIVE_PATH ] +then + exit 102 +fi + +fastboot flash devinfo $ARCHIVE_PATH/devinfo-unlocked.gpx +sleep 1 +fastboot reboot bootloader diff --git a/wait-fastboot.sh b/wait-fastboot.sh index c5c3a12..46ee02a 100755 --- a/wait-fastboot.sh +++ b/wait-fastboot.sh @@ -1,12 +1,26 @@ #!/bin/bash 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/') -- GitLab From 201c49f3ce39a40e4fb65d4b4ace5785d5e1af64 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Thu, 9 Apr 2020 14:30:22 +0200 Subject: [PATCH 05/13] Support RPI fastboot version --- install-from-bootloader-fp3.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/install-from-bootloader-fp3.sh b/install-from-bootloader-fp3.sh index e2c1290..5a03d95 100755 --- a/install-from-bootloader-fp3.sh +++ b/install-from-bootloader-fp3.sh @@ -13,6 +13,9 @@ then exit 102 fi + +fastboot flashing unlock + fastboot -w sleep 1 @@ -29,6 +32,6 @@ sleep 1 fastboot -s $DEVICE_ID flash vbmeta $ARCHIVE_PATH/vbmeta.img sleep 1 -#fastboot oem lock needed? +fastboot flashing lock fastboot reboot -- GitLab From 42afda4d9b027628815e6dab298a83499f0e1996 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Thu, 9 Apr 2020 15:21:27 +0200 Subject: [PATCH 06/13] Fix white space --- install-from-bootloader-fp3.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/install-from-bootloader-fp3.sh b/install-from-bootloader-fp3.sh index 5a03d95..d219dcc 100755 --- a/install-from-bootloader-fp3.sh +++ b/install-from-bootloader-fp3.sh @@ -13,9 +13,6 @@ then exit 102 fi - -fastboot flashing unlock - fastboot -w sleep 1 -- GitLab From 70836b79d61754125ad3820fdad595e5b14ca17d Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Thu, 9 Apr 2020 16:33:46 +0200 Subject: [PATCH 07/13] Lock device --- install-from-bootloader-fp3.sh | 31 ++++++++++++++++++++++++++----- lock-bootloader.sh | 32 ++++++++++++++++++++++++++++++++ test/A209GGGP0202 | 0 unlock-device.sh | 10 +++++----- unlock-fp3.sh | 23 +++++++++++++++++++++++ wait-fastboot.sh | 25 +++++++++++++++++++++++++ 6 files changed, 111 insertions(+), 10 deletions(-) create mode 100644 lock-bootloader.sh create mode 100644 test/A209GGGP0202 diff --git a/install-from-bootloader-fp3.sh b/install-from-bootloader-fp3.sh index d219dcc..e1739cb 100755 --- a/install-from-bootloader-fp3.sh +++ b/install-from-bootloader-fp3.sh @@ -1,5 +1,30 @@ #!/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 @@ -13,7 +38,7 @@ then exit 102 fi -fastboot -w +fastboot -s $DEVICE_ID -w sleep 1 fastboot -s $DEVICE_ID flash system $ARCHIVE_PATH/system.img @@ -28,7 +53,3 @@ fastboot -s $DEVICE_ID flash product $ARCHIVE_PATH/product.img sleep 1 fastboot -s $DEVICE_ID flash vbmeta $ARCHIVE_PATH/vbmeta.img sleep 1 - -fastboot flashing lock - -fastboot reboot diff --git a/lock-bootloader.sh b/lock-bootloader.sh new file mode 100644 index 0000000..aed5ed9 --- /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/test/A209GGGP0202 b/test/A209GGGP0202 new file mode 100644 index 0000000..e69de29 diff --git a/unlock-device.sh b/unlock-device.sh index c56bd49..cc78434 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 index 5f42111..cf232ad 100755 --- a/unlock-fp3.sh +++ b/unlock-fp3.sh @@ -1,5 +1,28 @@ #!/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 + +# Exit status +# - 0 : bootloader locked +# - 1 : generic error +# - 102 : $ARCHIVE_PATH missing + ARCHIVE_PATH=$1 if [ -z $ARCHIVE_PATH ] diff --git a/wait-fastboot.sh b/wait-fastboot.sh index 46ee02a..9d7f930 100755 --- a/wait-fastboot.sh +++ b/wait-fastboot.sh @@ -1,5 +1,30 @@ #!/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 -- GitLab From 0659e96208df6840b3fdb53c9953a253c214ca42 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Thu, 9 Apr 2020 16:34:50 +0200 Subject: [PATCH 08/13] delete unused files --- test/A209GGGP0202 | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 test/A209GGGP0202 diff --git a/test/A209GGGP0202 b/test/A209GGGP0202 deleted file mode 100644 index e69de29..0000000 -- GitLab From ea587820f8df3a638efcd9610692f4e67aab4cbf Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Thu, 9 Apr 2020 17:06:55 +0200 Subject: [PATCH 09/13] fix permission --- lock-bootloader.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 lock-bootloader.sh diff --git a/lock-bootloader.sh b/lock-bootloader.sh old mode 100644 new mode 100755 -- GitLab From 6be7757216d360b5024de41af959d39ae1a8b4ff Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Thu, 9 Apr 2020 17:28:07 +0200 Subject: [PATCH 10/13] Add script to wait reboot from fastboot --- wait-reboot-fastboot.sh | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 wait-reboot-fastboot.sh diff --git a/wait-reboot-fastboot.sh b/wait-reboot-fastboot.sh new file mode 100644 index 0000000..bfa73f2 --- /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 -- GitLab From f60cf0eee36244bb30c948bda7e549ac369e918e Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Thu, 9 Apr 2020 17:43:55 +0200 Subject: [PATCH 11/13] Fix script permission --- wait-reboot-fastboot.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 wait-reboot-fastboot.sh diff --git a/wait-reboot-fastboot.sh b/wait-reboot-fastboot.sh old mode 100644 new mode 100755 -- GitLab From 4e850e0fd1cde7c0a59312d762e7ebf564291752 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Thu, 9 Apr 2020 18:26:16 +0200 Subject: [PATCH 12/13] target device --- unlock-fp3.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/unlock-fp3.sh b/unlock-fp3.sh index cf232ad..d618ba6 100755 --- a/unlock-fp3.sh +++ b/unlock-fp3.sh @@ -17,19 +17,28 @@ # 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=$1 if [ -z $ARCHIVE_PATH ] then exit 102 fi -fastboot flash devinfo $ARCHIVE_PATH/devinfo-unlocked.gpx + +if [ -z $DEVICE_ID ] +then + exit 101 +fi + +fastboot -s $DEVICE_ID flash devinfo $ARCHIVE_PATH/devinfo-unlocked.gpx sleep 1 -fastboot reboot bootloader +fastboot -s $DEVICE_ID reboot bootloader -- GitLab From db3033318f438bea28712b14d5ba5715cbef2810 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Thu, 9 Apr 2020 18:55:37 +0200 Subject: [PATCH 13/13] fix mistake --- unlock-fp3.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unlock-fp3.sh b/unlock-fp3.sh index d618ba6..407ff51 100755 --- a/unlock-fp3.sh +++ b/unlock-fp3.sh @@ -26,7 +26,7 @@ # - 102 : $ARCHIVE_PATH missing ARCHIVE_PATH=$1 -DEVICE_ID=$1 +DEVICE_ID=$2 if [ -z $ARCHIVE_PATH ] then -- GitLab