33 lines
879 B
Python
Executable File
33 lines
879 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""Produce a config/frp image with the OEM allow-unlock flag set.
|
|
|
|
aboot's read_allow_oem_unlock() checks the LSB of the last byte of the
|
|
"config" (or "frp") partition. Setting it allows 'fastboot oem unlock-go'
|
|
to write the authoritative RPMB devinfo on VB1/secure-boot devices.
|
|
"""
|
|
|
|
import argparse
|
|
import sys
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("locked")
|
|
parser.add_argument("unlocked")
|
|
args = parser.parse_args()
|
|
data = bytearray(open(args.locked, "rb").read())
|
|
if not data:
|
|
print("FAIL: input is empty")
|
|
return 1
|
|
print("locked : last byte=%d" % data[-1])
|
|
data[-1] |= 1
|
|
with open(args.unlocked, "wb") as handle:
|
|
handle.write(data)
|
|
print("unlocked: last byte=%d -> %s (%d bytes)" %
|
|
(data[-1], args.unlocked, len(data)))
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|