Beispiel #1
0
def boot_uartrun(path, faddr, xmmode1k=False):
    ret = False
    rsp = None
    gw_report.clear()

    data = func.hexfile_analyze(path)
    if (len(data) != 1):
        return gw_report.result(str(False))

    #print(data)
    itm = data[0]
    #uartrun [hex(addr), hex(size), checksum]
    ret, rsp = func.cmd(
        'uartrun',
        [hex(itm[0]), hex(len(itm[1])),
         crc16(0, itm[1])])
    #print(ret)
    if (ret == False):
        return gw_report.result(str(ret))
    #print(itm[1])
    if (xmmode1k):
        ret = func.xmdm_send_1k(itm[1])
    else:
        ret = func.xmdm_send(itm[1])
    print(ret)

    return gw_report.result(str(ret))
Beispiel #2
0
def boot_prog_hexf(hexf_path, xmmode1k=False):
    ret = True
    rsp = None
    gw_report.clear()

    data = func.hexfile_analyze(hexf_path)
    #print(hex(data[0][0]), hex(len(data[0][1])))
    #print(hex(data[1][0]), hex(len(data[1][1])))
    #return
    #print(data)
    for itm in data:
        #progr [addr, size]
        ret, rsp = func.cmd('progr', [hex(itm[0]), hex(len(itm[1]))])
        #print(ret)
        if (ret == False):
            break
        #print(itm[1])
        if (xmmode1k):
            ret = func.xmdm_send_1k(itm[1])
        else:
            ret = func.xmdm_send(itm[1])
        print(ret)
        if (ret == False):
            break

    return gw_report.result(str(ret))
Beispiel #3
0
def boot_quit():
    ret = True
    gw_report.clear()

    ret = func.cmd('quit')

    return gw_report.result(str(ret))
Beispiel #4
0
def boot_prog_bin(path, faddr, xmmode1k=False):
    ret = False
    rsp = None
    gw_report.clear()
    try:
        size = os.path.getsize(path)
        fp = open(path, 'rb')
        data = list(fp.read(size))
    except:
        traceback.print_exc()
        return gw_report.result(str(False))

    #progr [hex(addr), hex(size), checksum]
    ret, rsp = func.cmd('progr', [hex(faddr), hex(size), crc16(0, data)])
    #print(ret)
    if (ret == False):
        return gw_report.result(str(ret))
    #print(itm[1])
    if (xmmode1k):
        ret = func.xmdm_send_1k(data)
    else:
        ret = func.xmdm_send(data)
    print(ret)

    return gw_report.result(str(ret))
Beispiel #5
0
def boot_write(faddr, value):
    ret = False
    rsp = None
    gw_report.clear()

    ret, rsp = func.cmd('write', [hex(faddr), hex(value)], 5)
    #print(ret)

    return gw_report.result(str(ret))
Beispiel #6
0
def boot_er64k(faddr):
    ret = False
    rsp = None
    gw_report.clear()

    ret, rsp = func.cmd('er64k', [hex(faddr)], 5)
    #print(ret)

    return gw_report.result(str(ret))
Beispiel #7
0
def boot_etssf():
    ret = False
    rsp = None
    gw_report.clear()

    ret, rsp = func.cmd('etssf', None, 5)
    #print(ret)

    return gw_report.result(str(ret))
Beispiel #8
0
def boot_rdreg(reg):
    ret = False
    rsp = None
    gw_report.clear()

    ret, rsp = func.cmd('rdreg', [hex(reg)])
    #print(ret)

    return gw_report.result(str(ret))
Beispiel #9
0
def boot_wrreg(reg, value):
    ret = False
    rsp = None
    gw_report.clear()

    ret, rsp = func.cmd('wrreg', [hex(reg), hex(value)])
    #print(ret)

    return gw_report.result(str(ret))
Beispiel #10
0
def boot_cmd(c, para=None):
    ret = True
    rsp = None
    gw_report.clear()
    if (para is not None):
        if (type(para) is not list):
            para = [para]
    ret, rsp = func.cmd(c, para)
    print(ret)
    return gw_report.result(str(ret))