No-wipe newflasher upgrade flow for the XQ-EC72, keeping Magisk root. Includes the Linux procedure for re-enabling US 5G over the Qualcomm diag port: the pyserial EFS2 client, the policyman band files that get written, and a backup of the device's original band config. Claude-Session: https://claude.ai/code/session_01Ctisr9uXe4H8XsscZ2exGE
51 lines
1.3 KiB
Python
51 lines
1.3 KiB
Python
import serial, time
|
|
|
|
def fcs16(data):
|
|
fcs = 0xFFFF
|
|
for b in data:
|
|
fcs = (fcs >> 8) ^ TAB[(fcs ^ b) & 0xFF]
|
|
return (~fcs) & 0xFFFF
|
|
|
|
# build CRC-CCITT (reflected, 0x8408) table
|
|
TAB = []
|
|
for i in range(256):
|
|
c = i
|
|
for _ in range(8):
|
|
c = (c >> 1) ^ 0x8408 if (c & 1) else (c >> 1)
|
|
TAB.append(c)
|
|
|
|
def hdlc(payload):
|
|
crc = fcs16(payload)
|
|
frame = bytes(payload) + bytes([crc & 0xFF, (crc >> 8) & 0xFF])
|
|
out = bytearray()
|
|
for b in frame:
|
|
if b == 0x7E: out += b'\x7d\x5e'
|
|
elif b == 0x7D: out += b'\x7d\x5d'
|
|
else: out.append(b)
|
|
out.append(0x7E)
|
|
return bytes(out)
|
|
|
|
def unhdlc(data):
|
|
if not data: return data
|
|
data = data.rstrip(b'\x7e')
|
|
out = bytearray(); esc = False
|
|
for b in data:
|
|
if esc: out.append(b ^ 0x20); esc = False
|
|
elif b == 0x7D: esc = True
|
|
else: out.append(b)
|
|
return bytes(out)
|
|
|
|
for dev in ['/dev/ttyUSB0','/dev/ttyUSB1']:
|
|
try:
|
|
s = serial.Serial(dev, 115200, timeout=1.5)
|
|
s.reset_input_buffer()
|
|
# DIAG_VERNO_F = 0x00
|
|
s.write(hdlc([0x00]))
|
|
time.sleep(0.4)
|
|
r = s.read(256)
|
|
print(dev, 'raw', r[:40].hex())
|
|
dec = unhdlc(r)
|
|
print(' decoded first byte:', hex(dec[0]) if dec else 'none', 'len', len(dec))
|
|
s.close()
|
|
except Exception as e:
|
|
print(dev, 'ERR', e)
|