summaryrefslogtreecommitdiffstats
path: root/fpga/interface
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2014-01-10 23:15:55 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2014-01-10 23:15:55 -0600
commit32b7b87d3dcd0d0f780fdfa8d5c2859bda8b175a (patch)
treef20a5f1b61c071752cde0c4fb07dd452da713e2d /fpga/interface
parent0ffb793cb56ec10a43ae241299b347bc4fef7b5c (diff)
downloadulab-32b7b87d3dcd0d0f780fdfa8d5c2859bda8b175a.tar.gz
ulab-32b7b87d3dcd0d0f780fdfa8d5c2859bda8b175a.zip
Lower the uLab FPGA viewer GPMC clock to reduce errors on prototype lashup
Add memory stress tests to GPMC test program
Diffstat (limited to 'fpga/interface')
-rw-r--r--fpga/interface/beaglebone_black/gpmc/test/bbb-gpmc-test.c127
1 files changed, 122 insertions, 5 deletions
diff --git a/fpga/interface/beaglebone_black/gpmc/test/bbb-gpmc-test.c b/fpga/interface/beaglebone_black/gpmc/test/bbb-gpmc-test.c
index 9b17634..2c5dc99 100644
--- a/fpga/interface/beaglebone_black/gpmc/test/bbb-gpmc-test.c
+++ b/fpga/interface/beaglebone_black/gpmc/test/bbb-gpmc-test.c
@@ -34,7 +34,7 @@
#include <sys/mman.h>
#include <fcntl.h>
-#define MEMORY_SPACE_ADDRESS_BITS 15
+#define MEMORY_SPACE_ADDRESS_BITS 16
#define GPMC_BASE 0x50000000
#define GPMC_REGLEN 0x10000000
@@ -119,11 +119,17 @@ static void gpmc_setup(void)
// *(gpmc + displacement + GPMC_CONFIG4) = 0x06020802; // Assert WE on fclk2, deassert WE on fclk6, assert OE on fclk2, deassert OE on fclk8
// *(gpmc + displacement + GPMC_CONFIG5) = 0x00060808; // Data valid on fclk 6, cycle time 8 fclks
- // 100MHz compatible SRAM device
- *(gpmc + displacement + GPMC_CONFIG2) = 0x00001000; // Assert CS on fclk0, deassert CS on fclk16
+// // 100MHz compatible SRAM device
+// *(gpmc + displacement + GPMC_CONFIG2) = 0x00001000; // Assert CS on fclk0, deassert CS on fclk16
+// *(gpmc + displacement + GPMC_CONFIG3) = 0x00000400; // Assert ADV on fclk 0, deassert ADV on fclk 4
+// *(gpmc + displacement + GPMC_CONFIG4) = 0x0c041004; // Assert WE on fclk4, deassert WE on fclk12, assert OE on fclk4, deassert OE on fclk16
+// *(gpmc + displacement + GPMC_CONFIG5) = 0x000c1010; // Data valid on fclk 12, cycle time 16 fclks
+
+ // 50MHz compatible SRAM device
+ *(gpmc + displacement + GPMC_CONFIG2) = 0x00001f00; // Assert CS on fclk0, deassert CS on fclk31
*(gpmc + displacement + GPMC_CONFIG3) = 0x00000400; // Assert ADV on fclk 0, deassert ADV on fclk 4
- *(gpmc + displacement + GPMC_CONFIG4) = 0x0c041004; // Assert WE on fclk4, deassert WE on fclk12, assert OE on fclk4, deassert OE on fclk16
- *(gpmc + displacement + GPMC_CONFIG5) = 0x000c1010; // Data valid on fclk 12, cycle time 16 fclks
+ *(gpmc + displacement + GPMC_CONFIG4) = 0x1f041f04; // Assert WE on fclk4, deassert WE on fclk31, assert OE on fclk4, deassert OE on fclk31
+ *(gpmc + displacement + GPMC_CONFIG5) = 0x00101f1f; // Data valid on fclk 16, cycle time 31 fclks
*(gpmc + displacement + GPMC_CONFIG6) = 0x00000000; // No back to back cycle restrictions
*(gpmc + displacement + GPMC_CONFIG7) = 0x00000e50; // CS0: Set base address 0x10000000, 32MB region, and enable CS
@@ -180,6 +186,117 @@ static void io_setup(void)
// for (j=0;j<0x3ff; j++) {
// *(gpio + j) = j;
// }
+
+ // DEBUG ONLY
+ // Looping memory test
+ unsigned int test_base = (MEMORY_SIZE/2);
+ unsigned int test_length = (MEMORY_SIZE/2);
+ unsigned int total_errors;
+ unsigned char error_count[MEMORY_SIZE];
+ int i;
+ int loop;
+ unsigned int overall_total_errors;
+ overall_total_errors = 0;
+ for (loop=0; loop<10;loop++) {
+ printf("Memory test loop %d\n", loop);
+ for (i=0; i<test_length; i++) {
+ error_count[i] = 0;
+ }
+ printf("\tTesting inversion pattern\n");
+ // Test with 0xaa
+ for (i=0;i<test_length; i++) {
+ *(gpio_char + test_base + i) = 0xaa;
+ }
+ for (i=0;i<test_length; i++) {
+ unsigned char result = *(gpio_char + test_base + i);
+ if ((result != 0xaa)) {
+ error_count[i] = error_count[i] + 1;
+ printf("\terror detected at offset 0x%02x (was 0x%02x, expected 0x%02x, second read attempt returned 0x%02x)\n", i, result, 0xaa, (*(gpio_char + test_base + i)));
+ }
+ }
+ // Test with 0x55
+ for (i=0;i<test_length; i++) {
+ *(gpio_char + test_base + i) = 0x55;
+ }
+ for (i=0;i<test_length; i++) {
+ unsigned char result = *(gpio_char + test_base + i);
+ if ((result != 0x55)) {
+ error_count[i] = error_count[i] + 1;
+ printf("\terror detected at offset 0x%02x (was 0x%02x, expected 0x%02x, second read attempt returned 0x%02x)\n", i, result, 0x55, (*(gpio_char + test_base + i)));
+ }
+ }
+ total_errors = 0;
+ for (i=0; i<test_length; i++) {
+ total_errors = total_errors + error_count[i];
+ if (error_count[i] > 0) {
+ printf("\t%d\terror(s) found at offset 0x%02x\n", error_count[i], i);
+ }
+ }
+
+ printf("\tTesting all ones/zeros\n");
+ // Test with 0xff
+ for (i=0;i<test_length; i++) {
+ *(gpio_char + test_base + i) = 0xff;
+ }
+ for (i=0;i<test_length; i++) {
+ unsigned char result = *(gpio_char + test_base + i);
+ if ((result != 0xff)) {
+ error_count[i] = error_count[i] + 1;
+ printf("\terror detected at offset 0x%02x (was 0x%02x, expected 0x%02x, second read attempt returned 0x%02x)\n", i, result, 0xff, (*(gpio_char + test_base + i)));
+ }
+ }
+ // Test with 0x00
+ for (i=0;i<test_length; i++) {
+ *(gpio_char + test_base + i) = 0x00;
+ }
+ for (i=0;i<test_length; i++) {
+ unsigned char result = *(gpio_char + test_base + i);
+ if ((result != 0x00)) {
+ error_count[i] = error_count[i] + 1;
+ printf("\terror detected at offset 0x%02x (was 0x%02x, expected 0x%02x, second read attempt returned 0x%02x)\n", i, result, 0x00, (*(gpio_char + test_base + i)));
+ }
+ }
+
+ printf("\tTesting alternating ones/zeros\n");
+ // Test with 0xff
+ for (i=0;i<test_length; i=i+2) {
+ *(gpio_char + test_base + i) = 0xff;
+ *(gpio_char + test_base + i + 1) = 0x00;
+ }
+ for (i=0;i<test_length; i=i+2) {
+ unsigned char result;
+ result = *(gpio_char + test_base + i);
+ if ((result != 0xff)) {
+ error_count[i] = error_count[i] + 1;
+ printf("\terror detected at offset 0x%02x (was 0x%02x, expected 0x%02x, second read attempt returned 0x%02x)\n", i, result, 0xff, (*(gpio_char + test_base + i)));
+ }
+ result = *(gpio_char + test_base + i + 1);
+ if ((result != 0x00)) {
+ error_count[i] = error_count[i] + 1;
+ printf("\terror detected at offset 0x%02x (was 0x%02x, expected 0x%02x, second read attempt returned 0x%02x)\n", i, result, 0x00, (*(gpio_char + test_base + i)));
+ }
+ }
+
+ total_errors = 0;
+ for (i=0; i<test_length; i++) {
+ total_errors = total_errors + error_count[i];
+ if (error_count[i] > 0) {
+ printf("\t%d\terror(s) found at offset 0x%02x\n", error_count[i], i);
+ }
+ }
+ printf("\tTest region size:\t%d\n", test_length);
+ printf("\tTotal errors found:\t%d\n", total_errors);
+ fflush(stdout);
+ overall_total_errors = overall_total_errors + total_errors;
+ }
+ for (i=0;i<MEMORY_SIZE; i++) {
+ *(gpio_char + i) = 0;
+ }
+ printf("Total errors found over all loops:\t%d\n", overall_total_errors);
+ fflush(stdout);
+ return;
+
+
int j;
for (j=0;j<MEMORY_SIZE; j++) {
*(gpio_char + j) = ((unsigned char)j);