From 778e3f5a95b69ee590e43de5d20ec168549cded0 Mon Sep 17 00:00:00 2001
From: dwf1m12 <d.w.flynn@soton.ac.uk>
Date: Mon, 2 Oct 2023 20:05:41 +0100
Subject: [PATCH] add block size 16 DMA transfer checking

---
 software/common/validation/dma_tests.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/software/common/validation/dma_tests.c b/software/common/validation/dma_tests.c
index 87221a7..e6a13ce 100644
--- a/software/common/validation/dma_tests.c
+++ b/software/common/validation/dma_tests.c
@@ -297,7 +297,7 @@ void dma_memory_copy (unsigned int src, unsigned int dest, unsigned int size, un
                                   (size << 21) |  /* dst_prot_ctrl - HPROT[3:1] */
                                   (size << 18) |  /* src_prot_ctrl - HPROT[3:1] */
 //                                  (0    << 14) |  /* R_power */
-                                  (4    << 14) |  /* R_power for 16-word block transfer*/
+                                  (4    << 14) |  /* R_power set for up to 16 transfers */
                                   ((num-1)<< 4) | /* n_minus_1 */
                                   (0    <<  3) |  /* next_useburst */
                                   (2    <<  0) ;  /* cycle_ctrl - auto */
@@ -356,6 +356,21 @@ int dma_simple_test(void)
     }
   }
 
+// then as 16 byte transfers
+  dma_memory_copy ((unsigned int) &source_data_array[0],(unsigned int) &dest_data_array[0], 0, 16);
+  do { /* Wait until PL230 DMA controller return to idle state */
+    current_state = (CMSDK_DMA->DMA_STATUS >> 4)  & 0xF;
+  } while (current_state!=0);
+
+  for (i=0;i<4;i++) {
+    /* Debugging printf: */
+    /*printf (" - dest[i] = %x\n", dest_data_array[i]);*/
+    if (dest_data_array[i]!= i){
+      printf ("ERROR:dest_data_array[%d], expected %x, actual %x\n", i, i, dest_data_array[i]);
+      err_code |= (1<<i);
+    }
+  }
+
   /* Generate return value */
   if (err_code != 0) {
     printf ("ERROR : simple DMA failed (0x%x)\n", err_code);
-- 
GitLab