diff options
author | Fredrik Thulin <fredrik@thulin.net> | 2015-09-02 16:55:21 +0200 |
---|---|---|
committer | Fredrik Thulin <fredrik@thulin.net> | 2015-09-02 16:55:21 +0200 |
commit | 1ee0be1ef00f2be29210edee155716e6f359d2f5 (patch) | |
tree | c6de71820e39d1491d7bf346dcfb4bf09e22ecc5 /src/fmc-test | |
parent | 53e92f830110356f853b365041acc972a83faeef (diff) |
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.
Diffstat (limited to 'src/fmc-test')
-rw-r--r-- | src/fmc-test/src/main.c | 31 |
1 files 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; } } |