mirror of
https://github.com/mashed-potatoes/PotatoNV-crossplatform.git
synced 2024-11-12 18:04:19 +01:00
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:
parent
513462840a
commit
7fecc60958
2 changed files with 28 additions and 26 deletions
|
@ -23,9 +23,7 @@ class Fastboot:
|
||||||
|
|
||||||
def write_nvme(self, prop: str, data: bytes):
|
def write_nvme(self, prop: str, data: bytes):
|
||||||
cmd = f"getvar:nve:{prop}@".encode('UTF-8')
|
cmd = f"getvar:nve:{prop}@".encode('UTF-8')
|
||||||
print(cmd.decode("utf-8"))
|
|
||||||
cmd += data
|
cmd += data
|
||||||
ui.info(f"Command: {cmd}")
|
|
||||||
result = self.fb_dev.send(cmd)
|
result = self.fb_dev.send(cmd)
|
||||||
ui.info(f"Getvar result: {result}")
|
ui.info(f"Getvar result: {result}")
|
||||||
|
|
||||||
|
|
|
@ -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 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.""")
|
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-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("--key", "-k", help="What key should be set?")
|
||||||
parser.add_argument("--fblock", "-f", help="Set FBLOCK")
|
parser.add_argument("--fblock", "-f", help="Set FBLOCK")
|
||||||
parser.add_argument("--bootloader", "-b", help="Specify bootloader name")
|
parser.add_argument("--bootloader", "-b", help="Specify bootloader name")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if not args.bootloader:
|
if not args.skip_bootloader:
|
||||||
args.bootloader = prompt({
|
if not args.bootloader:
|
||||||
'type': 'list',
|
args.bootloader = prompt({
|
||||||
'name': 'bootloader',
|
'type': 'list',
|
||||||
'message': 'Select bootloader:',
|
'name': 'bootloader',
|
||||||
'choices': list(map(lambda x: path.basename(path.split(x)[-2]), glob('bootloaders/*/manifest.xml')))
|
'message': 'Select bootloader:',
|
||||||
})['bootloader']
|
'choices': list(map(lambda x: path.basename(path.split(x)[-2]), glob('bootloaders/*/manifest.xml')))
|
||||||
|
})['bootloader']
|
||||||
|
|
||||||
if not args.key:
|
args.manifest = f"./bootloaders/{args.bootloader}/manifest.xml"
|
||||||
args.key = prompt({
|
|
||||||
'type': 'input',
|
if not path.isfile(args.manifest):
|
||||||
'name': 'key',
|
ui.error("Bootloader is invalid or not found!", critical=True)
|
||||||
'message': 'What key should be set?',
|
|
||||||
'validate': lambda val: len(val) == 16 or 'Excepted 16 symbols'
|
if not args.skip_write_key:
|
||||||
})['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
|
return args
|
||||||
|
|
||||||
|
|
||||||
def flash_images(data: dict):
|
def flash_images(data: dict):
|
||||||
flasher = imageflasher.ImageFlasher()
|
flasher = imageflasher.ImageFlasher()
|
||||||
flasher.connect_serial()
|
flasher.connect_serial()
|
||||||
|
@ -89,4 +91,6 @@ def main():
|
||||||
data["name"] = args.bootloader
|
data["name"] = args.bootloader
|
||||||
|
|
||||||
flash_images(data)
|
flash_images(data)
|
||||||
write_nvme(args.key)
|
|
||||||
|
if not args.skip_write_key:
|
||||||
|
write_nvme(args.key)
|
||||||
|
|
Loading…
Reference in a new issue