From db1f81892001cd469d1b968893184ce30a984e93 Mon Sep 17 00:00:00 2001 From: bongbui321 Date: Thu, 21 Mar 2024 01:25:04 -0400 Subject: [PATCH 1/2] getactiveslot --- edl | 3 ++- edlclient/Library/firehose_client.py | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/edl b/edl index 0665f79..fd77ae8 100755 --- a/edl +++ b/edl @@ -45,6 +45,7 @@ Usage: edl qfp [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] edl getstorageinfo [--loader=filename] [--memory=memtype] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] [--devicemodel=value] edl setbootablestoragedrive [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] [--devicemodel=value] + edl getactiveslot [--memory=memtype] [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] [--devicemodel=value] edl setactiveslot [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] [--devicemodel=value] edl send [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--portname=portname] [--serial] [--devicemodel=value] edl xml [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial] [--devicemodel=value] @@ -153,7 +154,7 @@ print("Qualcomm Sahara / Firehose Client V3.62 (c) B.Kerler 2018-2023.") def parse_cmd(rargs): cmds = ["server", "printgpt", "gpt", "r", "rl", "rf", "rs", "w", "wl", "wf", "ws", "e", "es", "ep", "footer", "peek", "peekhex", "peekdword", "peekqword", "memtbl", "poke", "pokehex", "pokedword", "pokeqword", - "memcpy", "secureboot", "pbl", "qfp", "getstorageinfo", "setbootablestoragedrive", "setactiveslot", + "memcpy", "secureboot", "pbl", "qfp", "getstorageinfo", "setbootablestoragedrive", "getactiveslot", "setactiveslot", "send", "xml", "rawxml", "reset", "nop", "modules", "memorydump", "provision", "qfil"] for cmd in cmds: if rargs[cmd]: diff --git a/edlclient/Library/firehose_client.py b/edlclient/Library/firehose_client.py index b0e5795..c5cb1d6 100644 --- a/edlclient/Library/firehose_client.py +++ b/edlclient/Library/firehose_client.py @@ -16,6 +16,7 @@ from edlclient.Library.firehose import firehose from edlclient.Library.xmlparser import xmlparser from edlclient.Library.utils import do_tcp_server from edlclient.Library.utils import LogBase, getint +from edlclient.Library.gpt import AB_FLAG_OFFSET, AB_PARTITION_ATTR_SLOT_ACTIVE from edlclient.Config.qualcomm_config import memory_type from edlclient.Config.qualcomm_config import infotbl, msmids, secureboottbl, sochw import fnmatch @@ -639,6 +640,25 @@ class firehose_client(metaclass=LogBase): return False else: return self.firehose.cmd_setbootablestoragedrive(int(options[""])) + elif cmd == "getactiveslot": + res = self.firehose.detect_partition(options, "boot_a") + if res[0]: + lun = res[1] + partition = res[2] + active = ((partition.flags >> (AB_FLAG_OFFSET*8))&0xFF) & AB_PARTITION_ATTR_SLOT_ACTIVE == AB_PARTITION_ATTR_SLOT_ACTIVE + if active: + self.printer("Current active slot : a") + return True + res = self.firehose.detect_partition(options, "boot_b") + if res[0]: + lun = res[1] + partition = res[2] + active = ((partition.flags >> (AB_FLAG_OFFSET*8))&0xFF) & AB_PARTITION_ATTR_SLOT_ACTIVE == AB_PARTITION_ATTR_SLOT_ACTIVE + if active: + self.printer("Current active slot : b") + return True + self.error("Can't detect active slot. Please make sure your device has slot A/B") + return False elif cmd == "setactiveslot": if not self.check_param([""]): return False From 4514b83693e2cb48feadd97b3201131acaa33a32 Mon Sep 17 00:00:00 2001 From: Hoang Bui <47828508+bongbui321@users.noreply.github.com> Date: Thu, 21 Mar 2024 01:27:44 -0400 Subject: [PATCH 2/2] fix typeo --- edlclient/Library/firehose_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/edlclient/Library/firehose_client.py b/edlclient/Library/firehose_client.py index c5cb1d6..b4c39bd 100644 --- a/edlclient/Library/firehose_client.py +++ b/edlclient/Library/firehose_client.py @@ -647,7 +647,7 @@ class firehose_client(metaclass=LogBase): partition = res[2] active = ((partition.flags >> (AB_FLAG_OFFSET*8))&0xFF) & AB_PARTITION_ATTR_SLOT_ACTIVE == AB_PARTITION_ATTR_SLOT_ACTIVE if active: - self.printer("Current active slot : a") + self.printer("Current active slot: a") return True res = self.firehose.detect_partition(options, "boot_b") if res[0]: @@ -655,7 +655,7 @@ class firehose_client(metaclass=LogBase): partition = res[2] active = ((partition.flags >> (AB_FLAG_OFFSET*8))&0xFF) & AB_PARTITION_ATTR_SLOT_ACTIVE == AB_PARTITION_ATTR_SLOT_ACTIVE if active: - self.printer("Current active slot : b") + self.printer("Current active slot: b") return True self.error("Can't detect active slot. Please make sure your device has slot A/B") return False