[Cryptech-Commits] [user/ft/stm32-dev-bridge] 05/05: Make post-mortem analysis using gdb easier.

git at cryptech.is git at cryptech.is
Wed Sep 2 14:58:33 UTC 2015


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

fredrik at thulin.net pushed a commit to branch master
in repository user/ft/stm32-dev-bridge.

commit 1ee0be1ef00f2be29210edee155716e6f359d2f5
Author: Fredrik Thulin <fredrik at thulin.net>
Date:   Wed Sep 2 16:55:21 2015 +0200

    Make post-mortem analysis using gdb easier.
    
    Use a number of volatile (in-memory) variables to track status
    in order to be able to break the program anywhere in the "have failed"
    loop and see what failed with both address and data tests.
---
 src/fmc-test/src/main.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/src/fmc-test/src/main.c b/src/fmc-test/src/main.c
index 69c5bb0..ce04bee 100644
--- a/src/fmc-test/src/main.c
+++ b/src/fmc-test/src/main.c
@@ -34,6 +34,8 @@
 //------------------------------------------------------------------------------
 RNG_HandleTypeDef rng_inst;
 
+volatile uint32_t data_diff = 0;
+volatile uint32_t addr_diff = 0;
 
 
 //------------------------------------------------------------------------------
@@ -88,26 +90,25 @@ int main(void)
 	led_off(GPIO_PIN_LED_BLUE);
 
 		// vars
-	int test_ok;
+	volatile int data_test_ok = 0, addr_test_ok = 0, successful_runs = 0;
 
 		// main loop (test, until an error is detected)
   while (1)
   {
 			// test data bus
-		test_ok = test_fpga_data_bus();
+		data_test_ok = test_fpga_data_bus();
+			// test address bus
+		addr_test_ok = test_fpga_address_bus();
 
 			// check for errors (abort testing in case of error)
-		if (test_ok < TEST_NUM_ROUNDS) break;
-
-
-			// test address bus
-		test_ok = test_fpga_address_bus();
+		if (data_test_ok < TEST_NUM_ROUNDS) break;
 
 			// check for errors (abort testing in case of error)
-		if (test_ok < TEST_NUM_ROUNDS) break;
+		if (addr_test_ok < TEST_NUM_ROUNDS) break;
 
 			// toggle yellow led to indicate, that we are alive
 		led_toggle(GPIO_PIN_LED_YELLOW);
+		successful_runs++;
   }
 
 		// error handler
@@ -135,6 +136,7 @@ int test_fpga_data_bus(void)
 		// run some rounds of data bus test
 	for (c=0; c<TEST_NUM_ROUNDS; c++)
 	{
+		data_diff = 0;
 			// try to generate "random" number
 		hal_result = HAL_RNG_GenerateRandomNumber(&rng_inst, &rnd);
 		if (hal_result != HAL_OK) break;
@@ -150,9 +152,8 @@ int test_fpga_data_bus(void)
 			// compare (abort testing in case of error)
 		if (buf != rnd)
 		{
-			uint32_t diff = buf;
-			diff ^= rnd;
-			diff = 0;	// place breakpoint here if needed
+			data_diff = buf;
+			data_diff ^= rnd;
 			break;
 		}
 	}
@@ -173,12 +174,13 @@ int test_fpga_address_bus(void)
 		// run some rounds of address bus test
   for (c=0; c<TEST_NUM_ROUNDS; c++)
   {
+    addr_diff = 0;
 			// try to generate "random" number
     hal_result = HAL_RNG_GenerateRandomNumber(&rng_inst, &rnd);
     if (hal_result != HAL_OK) break;
 
 			// we only have 2^22 32-bit words
-		rnd &= 0x00FFFFFC;
+    rnd &= 0x00FFFFFC;
 
 			// don't test zero addresses (fpga will store data, not address)
     if (rnd == 0) continue;
@@ -198,9 +200,8 @@ int test_fpga_address_bus(void)
 			// compare (abort testing in case of error)
     if (buf != rnd)
 		{
-			uint32_t diff = buf;
-			diff ^= rnd;
-			diff = 0;	// place breakpoint here if needed
+			addr_diff = buf;
+			addr_diff ^= rnd;
 			break;
 		}
   }



More information about the Commits mailing list