[Cryptech-Commits] [test/coretest_bp_entropy] 01/01: (1) Enabled high speed. Added uart read to check that read words. Added long test.

git at cryptech.is git at cryptech.is
Sat May 24 21:52:11 UTC 2014


This is an automated email from the git hooks/post-receive script.

joachim at secworks.se pushed a commit to branch master
in repository test/coretest_bp_entropy.

commit e0d03cb25c484b77378bf4d927a08a366ce5b485
Author: Joachim Strömbergson <joachim at secworks.se>
Date:   Sat May 24 23:52:05 2014 +0200

    (1) Enabled high speed. Added uart read to check that read words. Added long test.
---
 src/sw/entropy_tester.py | 64 +++++++++++++++++++++++++++++++++++-------------
 1 file changed, 47 insertions(+), 17 deletions(-)

diff --git a/src/sw/entropy_tester.py b/src/sw/entropy_tester.py
index 1b0e19d..57c0562 100755
--- a/src/sw/entropy_tester.py
+++ b/src/sw/entropy_tester.py
@@ -67,7 +67,7 @@ STOP_BITS = 1
 
 # Delay times.
 PROC_DELAY_TIME = 0.001
-COMM_DELAY_TIME = 0.01
+COMM_DELAY_TIME = 0.005
 
 
 # Verbose operation on/off
@@ -80,6 +80,10 @@ READ_CMD              = '\x10'
 WRITE_CMD             = '\x11'
 
 UART_ADDR_PREFIX      = '\x00'
+UART_ADDR_NAME0       = '\x00'
+UART_ADDR_NAME1       = '\x01'
+UART_ADDR_TYPE        = '\x02'
+UART_ADDR_VERSION     = '\x03'
 UART_ADDR_BIT_RATE    = '\x10'
 UART_ADDR_DATA_BITS   = '\x11'
 UART_ADDR_STOP_BITS   = '\x12'
@@ -182,15 +186,24 @@ def read_word(prefix, addr, ser):
 # read_rng1_rng2()
 #-------------------------------------------------------------------
 def read_rng1_rng2(ser):
+    if VERBOSE:
+        print "Reading rng1 and rng2 three times."
+    
     for i in range(3):
         read_word(BPENT_ADDR_PREFIX, BPENT_ADDR_RD_RNG1_RNG2, ser)
 
 
 #-------------------------------------------------------------------
 # read_n_data()
+#
+# Note we do a lot of read ops here.
 #-------------------------------------------------------------------
 def read_n_data(ser):
-    for i in range(10):
+    n = int(1E6)
+    if VERBOSE:
+        print "Reading n vector %d times." % n
+
+    for i in range(n):
         read_word(BPENT_ADDR_PREFIX, BPENT_ADDR_RD_N, ser)
 
 
@@ -198,11 +211,27 @@ def read_n_data(ser):
 # read_p_data()
 #-------------------------------------------------------------------
 def read_p_data(ser):
-    for i in range(10):
+    n = 10
+    if VERBOSE:
+        print "Reading p vector %d times." % n
+
+    for i in range(n):
         read_word(BPENT_ADDR_PREFIX, BPENT_ADDR_RD_P, ser)
 
 
 #-------------------------------------------------------------------
+# read_uart()
+#
+# We try to read from the uart to get some read ops working.
+#-------------------------------------------------------------------
+def read_uart(ser):
+        read_word(UART_ADDR_PREFIX, UART_ADDR_NAME0, ser)
+        read_word(UART_ADDR_PREFIX, UART_ADDR_NAME1, ser)
+        read_word(UART_ADDR_PREFIX, UART_ADDR_TYPE, ser)
+        read_word(UART_ADDR_PREFIX, UART_ADDR_VERSION, ser)
+
+
+#-------------------------------------------------------------------
 # main()
 #
 # Parse any arguments and run the tests.
@@ -228,18 +257,18 @@ def main():
         sys.exit(1)
 
     # Try and switch baud rate in the FPGA and then here.
-#    bit_rate_high = chr((BIT_RATE2 >> 8) & 0xff)
-#    bit_rate_low = chr(BIT_RATE2 & 0xff)
-#
-#    if VERBOSE:
-#        print("Changing to new baud rate.")
-#        print("Baud rate: %d" % BAUD_RATE2)
-#        print("Bit rate high byte: 0x%02x" % ord(bit_rate_high))
-#        print("Bit rate low byte:  0x%02x" % ord(bit_rate_low))
-#
-#    write_serial_bytes([SOC, WRITE_CMD, UART_ADDR_PREFIX, UART_ADDR_BIT_RATE,
-#                        '\x00', '\x00', bit_rate_high, bit_rate_low, EOC], ser)
-#    ser.baudrate=BAUD_RATE2
+    bit_rate_high = chr((BIT_RATE2 >> 8) & 0xff)
+    bit_rate_low = chr(BIT_RATE2 & 0xff)
+
+    if VERBOSE:
+        print("Changing to new baud rate.")
+        print("Baud rate: %d" % BAUD_RATE2)
+        print("Bit rate high byte: 0x%02x" % ord(bit_rate_high))
+        print("Bit rate low byte:  0x%02x" % ord(bit_rate_low))
+
+    write_serial_bytes([SOC, WRITE_CMD, UART_ADDR_PREFIX, UART_ADDR_BIT_RATE,
+                        '\x00', '\x00', bit_rate_high, bit_rate_low, EOC], ser)
+    ser.baudrate=BAUD_RATE2
 
     try:
         my_thread = threading.Thread(target=read_serial_thread, args=(ser,))
@@ -250,12 +279,13 @@ def main():
     my_thread.daemon = True
     my_thread.start()
 
+    # Test the communication by reading name etc from uart.
+    read_uart(ser)
 
     # Perform RNG read ops.
     read_rng1_rng2(ser)
-    read_n_data(ser)
     read_p_data(ser)
-
+    read_n_data(ser)
 
     # Exit nicely.
     time.sleep(50 * COMM_DELAY_TIME)



More information about the Commits mailing list