Upgraded to UniFlash, removed unsupported FDLs and fixed a critical HDLC encoding issue
This commit is contained in:
@@ -41,14 +41,15 @@ def hdlc_encode(data, fdl = False, nocrc = False):
|
||||
else:
|
||||
crc = crc16_xmodem(data)
|
||||
out = []
|
||||
for c in data:
|
||||
rdata = bytearray(data + pack('>H', crc))
|
||||
for c in rdata:
|
||||
if c == 0x7e or c == 0x7d:
|
||||
out.append(0x7d)
|
||||
out.append(c ^ 0x20)
|
||||
else:
|
||||
out.append(c)
|
||||
out = bytes(out)
|
||||
return b'\x7e' + out + pack('>HB', crc, 0x7e)
|
||||
return b'\x7e' + out + b'\x7e'
|
||||
|
||||
def hdlc_decode(data, fdl = False, ignoreCrc = False): # HDLC bug in Unisoc: CRC is also encoded!!!
|
||||
rawdata = bytearray(data[1:-1])
|
||||
@@ -220,6 +221,10 @@ def cmd_data_start(targetAddr, targetLen):
|
||||
datahdr = pack('>LL', targetAddr, targetLen)
|
||||
return shape_data_packet(BSL_CMD_START_DATA, datahdr)
|
||||
|
||||
def cmd_data_start_flash(targetPartId, targetLen, checksum):
|
||||
datahdr = pack('>LLL', targetPartId, targetLen, checksum)
|
||||
return shape_data_packet(BSL_CMD_START_DATA, datahdr)
|
||||
|
||||
def cmd_data_send(data):
|
||||
return shape_data_packet(BSL_CMD_MIDST_DATA, data)
|
||||
|
||||
@@ -255,8 +260,10 @@ def cmd_read_sector_size():
|
||||
def cmd_read_flash_type():
|
||||
return shape_cmd_packet(BSL_CMD_READ_FLASH_TYPE)
|
||||
|
||||
def cmd_enable_flash():
|
||||
return shape_cmd_packet(BSL_CMD_ENABLE_WRITE_FLASH)
|
||||
def cmd_enable_flash(targetAddr):
|
||||
#datahdr = pack('>L', targetAddr)
|
||||
datahdr = pack('>LL', targetAddr, 1)
|
||||
return shape_data_packet(BSL_CMD_ENABLE_WRITE_FLASH, datahdr)
|
||||
|
||||
def cmd_read_flash_info():
|
||||
return shape_cmd_packet(BSL_CMD_READ_FLASH_INFO)
|
||||
|
||||
Reference in New Issue
Block a user