data = open(r"C:/Users/vikto/Documents/Claude/rt-4d/radio-spi-dump.bin","rb").read()

def runmap(start, end, minrun=256):
    # classify each byte: F=0xff, Z=0x00, E=0x80, D=other; emit runs
    def cls(b):
        if b==0xff: return 'F'
        if b==0x00: return 'Z'
        if b==0x80: return 'E'
        return 'D'
    runs=[]
    i=start
    cur=cls(data[i]); rs=i
    i+=1
    while i<end:
        c=cls(data[i])
        if c!=cur:
            runs.append((cur,rs,i))
            cur=c; rs=i
        i+=1
    runs.append((cur,rs,end))
    # merge: report runs, collapsing tiny D-noise? Just print runs >= minrun OR mark
    out=[]
    for c,s,e in runs:
        out.append((c,s,e,e-s))
    return out

for base,end,name in [(0x198000,0x242000,"BLOB1"),(0x352000,0x3dd000,"BLOB2"),(0x3f0000,0x400000,"BLOB3")]:
    print("="*70, name, hex(base),hex(end))
    runs=runmap(base,end)
    # collapse: print segments where a class dominates for >=1KB
    for c,s,e,l in runs:
        if l>=512:
            print(f"  {c} {s:#08x}-{e:#08x} len={l:#x}({l})")
