usrlock: Add an option to skip fastboot unlocking

* Also don't ask for bootloader type if we skip uploading it

Change-Id: Ifbb4a296753ce8b5219e99678b1a0e97e00bde91
Signed-off-by: Woomymy <woomy@woomy.be>
This commit is contained in:
Woomymy 2023-11-03 21:05:02 +01:00 committed by Andrey Smirnoff
parent 513462840a
commit 7fecc60958
2 changed files with 28 additions and 26 deletions

View file

@ -23,9 +23,7 @@ class Fastboot:
def write_nvme(self, prop: str, data: bytes):
cmd = f"getvar:nve:{prop}@".encode('UTF-8')
print(cmd.decode("utf-8"))
cmd += data
ui.info(f"Command: {cmd}")
result = self.fb_dev.send(cmd)
ui.info(f"Getvar result: {result}")

View file

@ -24,38 +24,40 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.""")
parser.add_argument("--skip-bootloader", "-s", action="store_true", help="Skip bootloader flashing")
parser.add_argument("--skip-write-key", "-S", action="store_true", help="Skip NVME writing")
parser.add_argument("--key", "-k", help="What key should be set?")
parser.add_argument("--fblock", "-f", help="Set FBLOCK")
parser.add_argument("--bootloader", "-b", help="Specify bootloader name")
args = parser.parse_args()
if not args.bootloader:
args.bootloader = prompt({
'type': 'list',
'name': 'bootloader',
'message': 'Select bootloader:',
'choices': list(map(lambda x: path.basename(path.split(x)[-2]), glob('bootloaders/*/manifest.xml')))
})['bootloader']
if not args.skip_bootloader:
if not args.bootloader:
args.bootloader = prompt({
'type': 'list',
'name': 'bootloader',
'message': 'Select bootloader:',
'choices': list(map(lambda x: path.basename(path.split(x)[-2]), glob('bootloaders/*/manifest.xml')))
})['bootloader']
if not args.key:
args.key = prompt({
'type': 'input',
'name': 'key',
'message': 'What key should be set?',
'validate': lambda val: len(val) == 16 or 'Excepted 16 symbols'
})['key']
args.manifest = f"./bootloaders/{args.bootloader}/manifest.xml"
if not path.isfile(args.manifest):
ui.error("Bootloader is invalid or not found!", critical=True)
if not args.skip_write_key:
if not args.key:
args.key = prompt({
'type': 'input',
'name': 'key',
'message': 'What key should be set?',
'validate': lambda val: len(val) == 16 or 'Excepted 16 symbols'
})['key']
if len(args.key) != 16:
ui.error("Invalid key length!", critical=True)
args.manifest = f"./bootloaders/{args.bootloader}/manifest.xml"
if len(args.key) != 16:
ui.error("Invalid key length!", critical=True)
if not path.isfile(args.manifest):
ui.error("Bootloader is invalid or not found!", critical=True)
return args
def flash_images(data: dict):
flasher = imageflasher.ImageFlasher()
flasher.connect_serial()
@ -89,4 +91,6 @@ def main():
data["name"] = args.bootloader
flash_images(data)
write_nvme(args.key)
if not args.skip_write_key:
write_nvme(args.key)