예제 #1
0
def main():
    fd = fs.open_disk(0)
    if fd == -1:
        return

    wdata = fs.ucarray(4096)
    rdata = fs.ucarray(4096)
    seq_full = xrange(0xf0000 / 2 / 8)
    while True:
        for i in xrange(4096):
            wdata[i] = random.choice(xrange(0x100))
        lba = random.choice(seq_full) * 8
        
        res = fs.write_lba(fd, wdata, 8, lba)
        if res == -1:
            print 'Write lba failed in: %#X' % lba
            fs.close_disk(fd)
            return
        
        res = fs.read_lba(fd, rdata, 8, lba)
        if res == -1:
            print 'Read lba failed in: %#X' % lba
            fs.close_disk(fd)
            return

        for i in xrange(4096):
            if rdata[i] != wdata[i]:
                print 'Compare failed in lba: %#X' % lba
                fs.close_disk(fd)
                return

    fs.close_disk(fd)
예제 #2
0
def main():
    fd = fs.open_disk(0)
    if fd == -1:
        return

    import ipdb; ipdb.set_trace()
    
    
    
    sn = fs.sn(fd)
    mn = fs.mn(fd)

    
    
    ftcmd = fs.ftcmd()
    ftcmd.sig = fs.SIGNATURE
    ftcmd.cmd_type = fs.CMD_TYPE_NAME
    ftcmd.size = 512 - 16
    
    rw = fs.ftcmd_rw()
    rw.id = 0xff
    rw.op_flag = 0
    rw.buf_flag = 0
    rw.pos = 0x00800000
    rw.buf = 0
    rw.size = 6

    ctl = fs.ftcmd_ctl()
    ctl.id = 0xff
    ctl.op_flag = 2
    ctl.cmd = 0
    ftsts = fs.ftsts()

    import ipdb; ipdb.set_trace()

    # Reset
    res0 = fs.send_ftcmd(fd, ftcmd, 'nf0', None, ctl, 0)
    
    import ipdb; ipdb.set_trace()
    
    time.sleep(50.0 / 1000)
    # Read id
    res0 = fs.send_ftcmd(fd, ftcmd, 'nf0', rw, None, 0)
    import ipdb; ipdb.set_trace()

    buf = fs.ucarray(512)
    res0 = fs.lba_rw(fd, 0, buf, None, 1, 0)


    fs.close_disk(fd)
예제 #3
0
def main():
    fd = fs.open_disk(0)
    if fd == -1:
        return

    param = fs.flash_param()
    param.ce = 4
    param.block = 64
    param.page = 128
    param.sect = 8
    res = fs.write_param(fd, param)
    if res != 0x50:
        print 'Write param failed. %#X' % res
        print fs.close_disk(fd)
        return

    test_len = 128
    cmd = fs.q_cmd()
    wdata = fs.ucarray(4096)
    rdata = fs.ucarray(4096)
    while True:
        # Write 4k-len data to random place before DATA_BASE/2 for each page
        wpids = random.sample(xrange((0xf0000/2 - 8)/8), test_len)
        for i in xrange(test_len):
            for j in xrange(4096):
                wdata[j] = i        # Init with cid
            res_write = fs.write_lba(fd, wdata, 8, wpids[i] * 8) # XXX: lba = pid * 8
            if res_write != 0x50:
                print 'Write lba failed %#X' % res_write
                print fs.close_disk(fd)
                return
            cmd.cid = i
            cmd.pid = wpids[i]
            cmd.type = fs.FT_PROGRAM
            cmd.page = i
            fs.append_cmd(0, cmd)
        res = fs.flush_send_queue(fd, 0)
        if res != 0x50:
            print 'Flush write queue failed %#X' % res
            print fs.close_disk(fd)
            return
       
        res = fs.read_complete_queue(fd, 0, 3000)
        if res == -1:           # timeout
            print 'Timeout in read write-queue complete status, wpids:'
            print 'Time: %s' % time.asctime()
            print '\n'.join(['%#X' % i for i in wpids])
            print fs.close_disk(fd)
            return

        # Send read
        rpids = random.sample(set(xrange((0xf0000/2 - 8)/8)) - set(wpids), test_len)
        for i in xrange(test_len):
            cmd.cid = i
            cmd.pid = rpids[i]
            cmd.type = fs.FT_READ
            cmd.page = i
            fs.append_cmd(0, cmd)
        res = fs.flush_send_queue(fd, 0)
        if res != 0x50:
            print 'Flush read queue failed %#X' % res
            print fs.close_disk(fd)
            return
        res = fs.read_complete_queue(fd, 0, 3000)
        if res == -1:           # timeout
            print 'Timeout in read read-queue complete status, rpids, %#X' % res
            print 'Time: %s' % time.asctime()
            print '\n'.join(['%#X' % i for i in rpids])
            print fs.close_disk(fd)
            return

        # Read data and compare
        for i in xrange(test_len):
            res_read = fs.read_lba(fd, rdata, 8, rpids[i] * 8) # XXX
            if res_read != 0x50:
                print 'Read lba faild: %#X' % res_read
                print fs.close_disk(fd)
                return
            # for j in xrange(8):
            #     if rdata[j] != i:
            #         break
            # else:
            continue
            print 'Compare error in pid: %#X, time: %s' % (rpids[i], time.asctime())
            print 'Error page %d, write_pid: %#X, read_pid: %#X' % (i, wpids[i], rpids[i])
            print 'Error bytes:'
            for i in range(32):
                print '%d - %#X' % (i, rdata[i])
            print fs.close_disk(fd)
            return

    fs.close_disk(fd)