1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- import sys
- from memtest import WishboneInterface, MemoryTester, HDMIOutput
- from memtest import HyperRAMController
- def RAM_ADDR_CS(cs, addr):
- return (cs << 30) | addr
- def main(argv0, port='/dev/ttyUSB1', filename=None):
-
- wb = WishboneInterface(port)
-
- hyperram = HyperRAMController(wb, 0x00000)
- memtest = MemoryTester(wb, 0x10000)
- hdmi = HDMIOutput(wb, 0x20000)
-
- hdmi.disable()
- wb.aux_csr(0)
-
- if hyperram.init() is False:
- print("[!] Init failed")
- return -1
- hyperram.set_runtime(True)
-
- if filename is None:
-
- for cs in range(4):
- if not (hyperram.csm & (1 << cs)):
- continue
- print("[+] Testing CS=%d" % cs)
- good = memtest.run(RAM_ADDR_CS(cs, 0), 1<<21)
- if good:
- print("[.] All good !")
- else:
- print("[!] Errors found !")
- else:
-
- print("[+] Uploading image data")
- img = open(filename, 'rb').read()
- img = bytearray([(a << 4) | b for a, b in zip(img[0::2], img[1::2])])
- memtest.load_data(RAM_ADDR_CS(3, 0), img)
-
- print("[+] Uploading palette")
- for i in range(4*16):
- hdmi.pal_write(i, i&15)
-
- print("[+] Starting DMA")
- wb.aux_csr(1)
- hdmi.enable(RAM_ADDR_CS(3, 0), 16)
-
- return 0
- if __name__ == '__main__':
- sys.exit(main(*sys.argv) or 0)
|