Commit 429b0305 by lwc-tester

generalizing the flash/test algorithm a bit

parent c5e65005
......@@ -142,9 +142,6 @@ def main(argv):
finally:
tool.end_measurement()
sys.stdout.flush()
sys.stderr.flush()
if __name__ == "__main__":
sys.exit(main(sys.argv))
......@@ -78,7 +78,6 @@ def main(argv):
build_dir = argv[2]
dut = ESP32(build_dir)
dut.flash()
dut.prepare()
sys.stdout.write("Board prepared\n")
......@@ -100,9 +99,6 @@ def main(argv):
finally:
tool.end_measurement()
sys.stdout.flush()
sys.stderr.flush()
if __name__ == "__main__":
sys.exit(main(sys.argv))
......@@ -10,6 +10,7 @@ from test_common import (
DeviceUnderTestAeadUARTP,
compare_dumps,
eprint,
FileMutex,
run_nist_aead_test_line,
)
......@@ -31,12 +32,19 @@ def get_serial():
class F7(DeviceUnderTestAeadUARTP):
RAM_SIZE = 0x50000
def __init__(self, firmware_path, ram_pattern_path):
DeviceUnderTestAeadUARTP.__init__(self, get_serial())
def __init__(self, build_dir):
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.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):
jlink = self.jlink
......@@ -61,21 +69,19 @@ def main(argv):
kat = list(parse_nist_aead_test_vectors(argv[1]))
build_dir = argv[2]
dut = F7(
os.path.join(build_dir, 'build', 'f7.bin'),
os.path.join(build_dir, 'ram_pattern.bin'))
dut = F7(build_dir)
dut.flash()
dut.prepare()
sys.stdout.write("Board prepared\n")
sys.stdout.flush()
dump_a = dut.dump_ram()
try:
tool = LogicMultiplexerTimeMeasurements(0x000c)
tool.begin_measurement()
dut.flash()
dut.prepare()
sys.stdout.write("Board prepared\n")
sys.stdout.flush()
dump_a = dut.dump_ram()
for i, m, ad, k, npub, c in kat:
tool.arm()
run_nist_aead_test_line(dut, i, m, ad, k, npub, c)
......@@ -92,8 +98,6 @@ def main(argv):
finally:
tool.end_measurement()
sys.stdout.flush()
sys.stderr.flush()
if __name__ == "__main__":
......
......@@ -9,6 +9,7 @@ from test_common import (
LogicMultiplexerTimeMeasurements,
parse_nist_aead_test_vectors,
DeviceUnderTestAeadUARTP,
FileMutex,
eprint,
run_nist_aead_test_line,
)
......@@ -31,19 +32,38 @@ class Maixduino(DeviceUnderTestAeadUARTP):
def __init__(self, build_dir):
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
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):
pipe = subprocess.PIPE
previous_dir = os.path.abspath(os.curdir)
os.chdir(self.build_dir)
cmd = ['platformio', 'run', '-e', 'sipeed-maixduino']
cmd.extend(['--target', 'upload'])
cmd.extend(['--upload-port', get_serial()])
cmd.extend(['--upload-port', get_serial()])
cmd.extend(['--upload-port', self.uart_device])
p = subprocess.Popen(
cmd, stdout=sys.stderr, stdin=pipe)
stdout, stderr = p.communicate("")
assert p.returncode == 0
eprint("Firmware flashed.")
os.chdir(previous_dir)
......@@ -60,31 +80,15 @@ def main(argv):
build_dir = argv[2]
dut = Maixduino(build_dir)
dut.flash()
dut.prepare()
sys.stdout.write("Board prepared\n")
sys.stdout.flush()
try:
tool = LogicMultiplexerTimeMeasurements(0x00c0)
tool.begin_measurement()
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()
sys.stdout.write("Board prepared\n")
sys.stdout.flush()
for i, m, ad, k, npub, c in kat:
tool.arm()
run_nist_aead_test_line(dut, i, m, ad, k, npub, c)
......@@ -96,12 +100,6 @@ def main(argv):
finally:
tool.end_measurement()
sys.stdout.flush()
sys.stderr.flush()
if __name__ == "__main__":
sys.exit(main(sys.argv))
if __name__ == "__main__":
......
......@@ -98,9 +98,6 @@ def main(argv):
finally:
tool.end_measurement()
sys.stdout.flush()
sys.stderr.flush()
if __name__ == "__main__":
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