if args.test_modules:
        hw_memset(wb, 0x0, mem_range, [0xffffffff], args.dbg)

        # --------------------------- Introduce error ------------------------
        rng = random.Random(datetime.now())
        offsets = []
        for i, n in enumerate(range(0, 5000)):
            print('Generated {:d} offsets'.format(i), end='\r')
            offset = rng.randrange(0x0, mem_range - 4)
            offset &= ~0b11  # must be 32-bit aligned
            if offset // nbytes not in offsets:
                offsets.append(offset // nbytes)
                if args.dbg:
                    print('dbg: offset: ' + str(offset))
                wb.write(mem_base + offset,
                         wb.read(mem_base + offset) ^ 0x000010000)
        print()

        # Corner case
        #offsets.append((mem_range - 4)//16)
        #wb.write(mem_base + mem_range - 4, wb.read(mem_base + mem_range - 4) ^ 0x00100000)
        #if args.dbg:
        #    print('dbg: 0x{:08x}: 0x{:08x}'.format(mem_base + mem_range - 4, wb.read(mem_base + mem_range - 4)))

        print('dbg: offsets: {:d}'.format(len(offsets)))
        # --------------------------------------------------------------------

        start_time = time.time()
        errors = hw_memtest(wb, 0x0, mem_range, [0xffffffff], args.dbg)
        end_time = time.time()
Exemple #2
0
from datetime import datetime

from rowhammer_tester.scripts.utils import RemoteClient

if __name__ == "__main__":
    wb = RemoteClient()
    wb.open()

    # --------------------------------------------------------------------

    wb.regs.writer_start.write(0)
    wb.regs.writer_reset.write(1)
    time.sleep(10000 / 1e6)
    wb.regs.writer_reset.write(0)

    wb.write(0x20000000, 0xffffffff)  # patttern
    wb.write(0x21000000, 0xffffffff)  # patttern
    wb.write(0x22000000, 0xffffffff)  # patttern
    wb.write(0x23000000, 0xffffffff)  # patttern
    wb.write(0x24000000, 0x00000000)  # offset

    mem_range = 256 * 1024 * 1024  # bytes
    mem_mask = (mem_range // 4 // 4) - 1
    mem_count = mem_mask

    wb.regs.writer_mem_mask.write(mem_mask)  # memory range
    wb.regs.writer_data_mask.write(0x00000000)  # just pattern from address 0x0
    wb.regs.writer_count.write(mem_count)
    wb.regs.writer_start.write(1)

    while True: