def get_area_info(dev):
for i in [0,1,2]:
- print("===================")
packed = pack_pkt(ARE_CMD, [str(i)])
dev.send_data(packed)
info = dev.recv_data(23)
msg = unpack_pkt(info)
fmt = '>BIIII'
KOA, SAD, EAD, EAU, WAU = struct.unpack(fmt, bytes(int(x, 16) for x in msg))
- print(f'Area {KOA} - {hex(SAD)}:{hex(EAD)}')
- print(f'Erase {hex(EAU)} bytes - write {hex(WAU)} bytes')
+ print(f'Area {KOA}: {hex(SAD)}:{hex(EAD)} (erase {hex(EAU)} - write {hex(WAU)})')
def get_dev_info(dev):
-
packed = pack_pkt(SIG_CMD, "")
dev.send_data(packed)
info = dev.recv_data(18)
fmt = '>IIIBBHH'
_HEADER, SCI, RMB, NOA, TYP, BFV, _FOOTER = struct.unpack(fmt, info)
- print('Chip info:')
print('====================')
- print(f'Serial interface speed: {SCI} Hz')
- print(f'Recommend max UART baud rate {RMB} bps')
- print(f'User area in Code flash [{NOA & 0x1}|{NOA & 0x02 >> 1}]')
- print(f'User area in Data flash [{NOA & 0x03 >> 2}]')
- print(f'Config area [{NOA & 0x04 >> 3}]')
if TYP == 0x02:
- print('RA MCU + RA2/RA4 Series')
+ print('Chip: RA MCU + RA2/RA4 Series')
elif TYP == 0x03:
- print('RA MCU + RA6 Series')
+ print('Chip: RA MCU + RA6 Series')
else:
print('Unknown MCU type')
- print(f'Boot firmware version {BFV >> 8}.{BFV & 0xFF}')
- print('====================')
+ print(f'Serial interface speed: {SCI} Hz')
+ print(f'Recommend max UART baud rate: {RMB} bps')
+ print(f'User area in Code flash [{NOA & 0x1}|{NOA & 0x02 >> 1}]')
+ print(f'User area in Data flash [{NOA & 0x03 >> 2}]')
+ print(f'Config area [{NOA & 0x04 >> 3}]')
+ print(f'Boot firmware: version {BFV >> 8}.{BFV & 0xFF}')
def verify_img(dev, img, start_addr, end_addr):