Commit 429b0305 by lwc-tester

generalizing the flash/test algorithm a bit

parent c5e65005
...@@ -142,9 +142,6 @@ def main(argv): ...@@ -142,9 +142,6 @@ def main(argv):
finally: finally:
tool.end_measurement() tool.end_measurement()
sys.stdout.flush()
sys.stderr.flush()
if __name__ == "__main__": if __name__ == "__main__":
sys.exit(main(sys.argv)) sys.exit(main(sys.argv))
...@@ -78,7 +78,6 @@ def main(argv): ...@@ -78,7 +78,6 @@ def main(argv):
build_dir = argv[2] build_dir = argv[2]
dut = ESP32(build_dir) dut = ESP32(build_dir)
dut.flash() dut.flash()
dut.prepare() dut.prepare()
sys.stdout.write("Board prepared\n") sys.stdout.write("Board prepared\n")
...@@ -100,9 +99,6 @@ def main(argv): ...@@ -100,9 +99,6 @@ def main(argv):
finally: finally:
tool.end_measurement() tool.end_measurement()
sys.stdout.flush()
sys.stderr.flush()
if __name__ == "__main__": if __name__ == "__main__":
sys.exit(main(sys.argv)) sys.exit(main(sys.argv))
...@@ -10,6 +10,7 @@ from test_common import ( ...@@ -10,6 +10,7 @@ from test_common import (
DeviceUnderTestAeadUARTP, DeviceUnderTestAeadUARTP,
compare_dumps, compare_dumps,
eprint, eprint,
FileMutex,
run_nist_aead_test_line, run_nist_aead_test_line,
) )
...@@ -31,12 +32,19 @@ def get_serial(): ...@@ -31,12 +32,19 @@ def get_serial():
class F7(DeviceUnderTestAeadUARTP): class F7(DeviceUnderTestAeadUARTP):
RAM_SIZE = 0x50000 RAM_SIZE = 0x50000
def __init__(self, firmware_path, ram_pattern_path): def __init__(self, build_dir):
DeviceUnderTestAeadUARTP.__init__(self, get_serial()) DeviceUnderTestAeadUARTP.__init__(self)
self.uart_device = get_serial()
devname = os.path.basename(self.uart_device)
self.lock = FileMutex('/var/lock/lwc-compare.%s.lock' % devname)
self.build_dir = build_dir
self.jlink = pylink.JLink() self.jlink = pylink.JLink()
self.jlink.open(779340002) self.jlink.open(779340002)
self.firmware_path = firmware_path
self.ram_pattern_path = ram_pattern_path self.firmware_path = os.path.join(build_dir, 'build', 'f7.bin')
self.ram_pattern_path = os.path.join(build_dir, 'ram_pattern.bin')
def flash(self): def flash(self):
jlink = self.jlink jlink = self.jlink
...@@ -61,13 +69,7 @@ def main(argv): ...@@ -61,13 +69,7 @@ def main(argv):
kat = list(parse_nist_aead_test_vectors(argv[1])) kat = list(parse_nist_aead_test_vectors(argv[1]))
build_dir = argv[2] build_dir = argv[2]
dut = F7( dut = F7(build_dir)
os.path.join(build_dir, 'build', 'f7.bin'),
os.path.join(build_dir, 'ram_pattern.bin'))
try:
tool = LogicMultiplexerTimeMeasurements(0x000c)
tool.begin_measurement()
dut.flash() dut.flash()
dut.prepare() dut.prepare()
...@@ -76,6 +78,10 @@ def main(argv): ...@@ -76,6 +78,10 @@ def main(argv):
dump_a = dut.dump_ram() dump_a = dut.dump_ram()
try:
tool = LogicMultiplexerTimeMeasurements(0x000c)
tool.begin_measurement()
for i, m, ad, k, npub, c in kat: for i, m, ad, k, npub, c in kat:
tool.arm() tool.arm()
run_nist_aead_test_line(dut, i, m, ad, k, npub, c) run_nist_aead_test_line(dut, i, m, ad, k, npub, c)
...@@ -92,8 +98,6 @@ def main(argv): ...@@ -92,8 +98,6 @@ def main(argv):
finally: finally:
tool.end_measurement() tool.end_measurement()
sys.stdout.flush()
sys.stderr.flush()
if __name__ == "__main__": if __name__ == "__main__":
......
...@@ -9,6 +9,7 @@ from test_common import ( ...@@ -9,6 +9,7 @@ from test_common import (
LogicMultiplexerTimeMeasurements, LogicMultiplexerTimeMeasurements,
parse_nist_aead_test_vectors, parse_nist_aead_test_vectors,
DeviceUnderTestAeadUARTP, DeviceUnderTestAeadUARTP,
FileMutex,
eprint, eprint,
run_nist_aead_test_line, run_nist_aead_test_line,
) )
...@@ -31,19 +32,38 @@ class Maixduino(DeviceUnderTestAeadUARTP): ...@@ -31,19 +32,38 @@ class Maixduino(DeviceUnderTestAeadUARTP):
def __init__(self, build_dir): def __init__(self, build_dir):
DeviceUnderTestAeadUARTP.__init__(self) DeviceUnderTestAeadUARTP.__init__(self)
self.uart_device = get_serial()
devname = os.path.basename(self.uart_device)
self.lock = FileMutex('/var/lock/lwc-compare.%s.lock' % devname)
self.build_dir = build_dir self.build_dir = build_dir
def reset(self):
self.ser.setRTS(True)
time.sleep(0.1)
self.ser.setRTS(False)
time.sleep(0.1)
self.ser.setRTS(True)
time.sleep(1)
def prepare(self):
self.ser = serial.Serial(
self.uart_device,
baudrate=1500000,
timeout=5)
self.reset()
DeviceUnderTestAeadUARTP.prepare(self)
def flash(self): def flash(self):
pipe = subprocess.PIPE pipe = subprocess.PIPE
previous_dir = os.path.abspath(os.curdir) previous_dir = os.path.abspath(os.curdir)
os.chdir(self.build_dir) os.chdir(self.build_dir)
cmd = ['platformio', 'run', '-e', 'sipeed-maixduino'] cmd = ['platformio', 'run', '-e', 'sipeed-maixduino']
cmd.extend(['--target', 'upload']) cmd.extend(['--target', 'upload'])
cmd.extend(['--upload-port', get_serial()]) cmd.extend(['--upload-port', self.uart_device])
cmd.extend(['--upload-port', get_serial()])
p = subprocess.Popen( p = subprocess.Popen(
cmd, stdout=sys.stderr, stdin=pipe) cmd, stdout=sys.stderr, stdin=pipe)
stdout, stderr = p.communicate("") stdout, stderr = p.communicate("")
assert p.returncode == 0
eprint("Firmware flashed.") eprint("Firmware flashed.")
os.chdir(previous_dir) os.chdir(previous_dir)
...@@ -60,31 +80,15 @@ def main(argv): ...@@ -60,31 +80,15 @@ def main(argv):
build_dir = argv[2] build_dir = argv[2]
dut = Maixduino(build_dir) dut = Maixduino(build_dir)
try:
tool = LogicMultiplexerTimeMeasurements(0x00c0)
tool.begin_measurement()
dut.flash() dut.flash()
ser = serial.Serial(
get_serial(),
baudrate=1500000,
timeout=5)
ser.setRTS(True)
time.sleep(0.1)
ser.setRTS(False)
time.sleep(0.1)
ser.setRTS(True)
time.sleep(1)
dut.ser = ser
dut.prepare() dut.prepare()
sys.stdout.write("Board prepared\n") sys.stdout.write("Board prepared\n")
sys.stdout.flush() sys.stdout.flush()
try:
tool = LogicMultiplexerTimeMeasurements(0x00c0)
tool.begin_measurement()
for i, m, ad, k, npub, c in kat: for i, m, ad, k, npub, c in kat:
tool.arm() tool.arm()
run_nist_aead_test_line(dut, i, m, ad, k, npub, c) run_nist_aead_test_line(dut, i, m, ad, k, npub, c)
...@@ -96,12 +100,6 @@ def main(argv): ...@@ -96,12 +100,6 @@ def main(argv):
finally: finally:
tool.end_measurement() tool.end_measurement()
sys.stdout.flush()
sys.stderr.flush()
if __name__ == "__main__":
sys.exit(main(sys.argv))
if __name__ == "__main__": if __name__ == "__main__":
......
...@@ -98,9 +98,6 @@ def main(argv): ...@@ -98,9 +98,6 @@ def main(argv):
finally: finally:
tool.end_measurement() tool.end_measurement()
sys.stdout.flush()
sys.stderr.flush()
if __name__ == "__main__": if __name__ == "__main__":
sys.exit(main(sys.argv)) sys.exit(main(sys.argv))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment