Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support for 5A series #273

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ endif

.SECONDARY:
.PHONY: all clean
all: apycula/GW1N-1.pickle apycula/GW1N-9.pickle apycula/GW1N-4.pickle \

#removed ones that nolonger exist (GW1NS-2) or fail (GW2A-18C)
all: apycula/GW5A-25A.pickle apycula/GW2A-18C.pickle
#all: apycula/GW1N-1.pickle

#all: apycula/GW1N-1.pickle apycula/GW1N-9.pickle apycula/GW1N-4.pickle \
apycula/GW1NS-2.pickle apycula/GW1NS-4.pickle apycula/GW1N-9C.pickle \
apycula/GW1NZ-1.pickle apycula/GW2A-18.pickle apycula/GW2A-18C.pickle


%_stage1.pickle: apycula/tiled_fuzzer.py
python3 -m apycula.tiled_fuzzer $*

Expand Down
73 changes: 71 additions & 2 deletions apycula/attrids.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,23 @@
'IOBUF_IODUTY': 46,
'IOBUF_ODT_DYNTERM': 47,
'MIPI_IBUF_DRIVE': 48,
'MIPI_IBUF_DRIVE_LEVEL': 49
'MIPI_IBUF_DRIVE_LEVEL': 49,

'IOB_UNKNOWN51': 51,
'IOB_UNKNOWN52': 52,
'IOB_UNKNOWN55': 55,
'IOB_UNKNOWN56': 56,
'IOB_UNKNOWN57': 57,
'IOB_UNKNOWN58': 58,
'IOB_UNKNOWN59': 59,
'IOB_UNKNOWN60': 60,
'IOB_UNKNOWN61': 61,
'IOB_UNKNOWN66': 66,
'IOB_UNKNOWN68': 68,
'IOB_UNKNOWN69': 69,
'IOB_UNKNOWN70': 70,
'IOB_UNKNOWN71': 71,
'IOB_UNKNOWN72': 72
}

iob_attrvals = {
Expand Down Expand Up @@ -861,7 +877,8 @@
'REG0_SD': 11,
'REG1_SD': 12,
'REG0_REGSET': 13,
'REG1_REGSET': 14
'REG1_REGSET': 14,
'NEW ATTR ID?': 15
}

cls_attrvals = {
Expand Down Expand Up @@ -1308,6 +1325,58 @@
'INDEL_1': 67,
'IMON_CENTSEL_0': 68,
'IMON_CENTSEL_1': 69,
'IOLOGIC_UNKNOWN74': 74,
'IOLOGIC_UNKNOWN77': 77,
'IOLOGIC_UNKNOWN78': 78,
'IOLOGIC_UNKNOWN79': 79,
'IOLOGIC_UNKNOWN82': 82,
'IOLOGIC_UNKNOWN83': 83,
'IOLOGIC_UNKNOWN84': 84,
'IOLOGIC_UNKNOWN85': 85,
'IOLOGIC_UNKNOWN86': 86,
'IOLOGIC_UNKNOWN87': 87,
'IOLOGIC_UNKNOWN88': 88,
'IOLOGIC_UNKNOWN89': 89,
'IOLOGIC_UNKNOWN90': 90,
'IOLOGIC_UNKNOWN91': 91,
'IOLOGIC_UNKNOWN92': 92,
'IOLOGIC_UNKNOWN93': 93,
'IOLOGIC_UNKNOWN95': 95,
'IOLOGIC_UNKNOWN97': 97,
'IOLOGIC_UNKNOWN98': 98,
'IOLOGIC_UNKNOWN99': 99,
'IOLOGIC_UNKNOWN100': 100,
'IOLOGIC_UNKNOWN101': 101,
'IOLOGIC_UNKNOWN102': 102,
'IOLOGIC_UNKNOWN103': 103,
'IOLOGIC_UNKNOWN104': 104,
'IOLOGIC_UNKNOWN105': 105,
'IOLOGIC_UNKNOWN106': 106,
'IOLOGIC_UNKNOWN107': 107,
'IOLOGIC_UNKNOWN108': 108,
'IOLOGIC_UNKNOWN109': 109,
'IOLOGIC_UNKNOWN110': 110,
'IOLOGIC_UNKNOWN111': 111,
'IOLOGIC_UNKNOWN112': 112,
'IOLOGIC_UNKNOWN113': 113,
'IOLOGIC_UNKNOWN114': 114,
'IOLOGIC_UNKNOWN115': 115,
'IOLOGIC_UNKNOWN116': 116,
'IOLOGIC_UNKNOWN118': 118,
'IOLOGIC_UNKNOWN119': 119,
'IOLOGIC_UNKNOWN120': 120,
'IOLOGIC_UNKNOWN121': 121,
'IOLOGIC_UNKNOWN122': 122,
'IOLOGIC_UNKNOWN123': 123,
'IOLOGIC_UNKNOWN124': 124,
'IOLOGIC_UNKNOWN125': 125,
'IOLOGIC_UNKNOWN126': 126,
'IOLOGIC_UNKNOWN127': 127,
'IOLOGIC_UNKNOWN128': 128,
'IOLOGIC_UNKNOWN129': 129,
'IOLOGIC_UNKNOWN130': 130,
'IOLOGIC_UNKNOWN135': 135,
'IOLOGIC_UNKNOWN136': 136
}

iologic_attrvals = {
Expand Down
7 changes: 7 additions & 0 deletions apycula/bitmatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ def flipud(bmp):
"""
return bmp[::-1]

def transpose(bmp):
"""
Transposes a bitmap (swaps rows and cols)
Returns a reference
"""
return [[bmp[j][i] for j in range(len(bmp))] for i in range(len(bmp[0]))]

def vstack(bmp_0, bmp_1):
"""
Stack matrices in sequence vertically (row wise).
Expand Down
44 changes: 36 additions & 8 deletions apycula/bslib.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,39 @@ def bitarr(frame, pad):

def read_bitstream(fname):
bitmap = []
returnBitmap = []
hdr = []
ftr = []
is_hdr = True
crcdat = bytearray()
preamble = 3
frames = 0
c = 0
is5ASeries = False

calc = crc.Calculator(crc16arc)
with open(fname) as inp:
for line in inp:
if line.startswith("//"): continue
if line.startswith("//"):
#print("line: ", line)
continue
ba = bytearr(line)
if not frames:
if is_hdr:
#print("header:", ba)
hdr.append(ba)
else:
#print("footer:", ba)
ftr.append(ba)
if not preamble and ba[0] != 0xd2: # SPI address
#print("spi address", ba)
crcdat.extend(ba)
if not preamble and ba[0] == 0x3b: # frame count
frames = int.from_bytes(ba[2:], 'big')
print("frame count: ", frames, ba)
is_hdr = False
if not preamble and ba[0] == 0x06: # device ID
print("Device ID:", ba)
if ba == b'\x06\x00\x00\x00\x11\x00\x58\x1b':
padding = 4
elif ba == b'\x06\x00\x00\x00\x11\x00H\x1b':
Expand All @@ -59,19 +70,36 @@ def read_bitstream(fname):
padding = 0
elif ba == b'\x06\x00\x00\x00\x00\x00\x08\x1b':
padding = 0
elif ba == b'\x06\x00\x00\x00\x00\x01\x28\x1b': # GW5A-25A
padding = 0
is5ASeries = True
else:
raise ValueError("Unsupported device", ba)
preamble = max(0, preamble-1)
continue
crcdat.extend(ba[:-8])
crc1 = (ba[-7] << 8) + ba[-8]
crc2 = calc.checksum(crcdat)
assert crc1 == crc2, f"Not equal {crc1} {crc2} for {crcdat}"
crcdat = ba[-6:]

if is5ASeries == False:
crcdat.extend(ba[:-8])
crc1 = (ba[-7] << 8) + ba[-8]
crc2 = calc.checksum(crcdat)
assert crc1 == crc2, f"Not equal {crc1} {crc2} for {crcdat}"
if crc1 != crc2:
print("frame: ", c, ba, len(ba))
print("crcdata: ", crcdat, len(crcdat))
print("crc error - frame:", c, frames, " : ", crc1, " != ", crc2)

crcdat = ba[-6:]

bitmap.append(bitarr(line, padding))
frames = max(0, frames-1)
frames = max(0, frames-1)
c = c + 1

if is5ASeries == False:
returnBitmap = bitmatrix.fliplr(bitmap)
else:
returnBitmap = bitmatrix.transpose(bitmap)

return bitmatrix.fliplr(bitmap), hdr, ftr
return returnBitmap, hdr, ftr

def compressLine(line, key8Z, key4Z, key2Z):
newline = []
Expand Down
Loading