]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/pdk.git/blobdiff - packages/ti/drv/uart/test/src/main_uart_test.c
ti/drv/uart: SCI bug fixes and UART test enhancements
[processor-sdk/pdk.git] / packages / ti / drv / uart / test / src / main_uart_test.c
index 372585c81ef483ac41074cbb018a6f329882c07a..3d1c7d8ef81ad4f8cfdcc64227737b561dc75868 100644 (file)
 #include <ti/csl/arch/csl_arch.h>
 #endif
 
+//#define CIO_DRV_CONSOLE
+
+#ifdef CIO_DRV_CONSOLE
+#define UART_test_log            printf
+#define UART_test_log1           printf
+#define UART_test_log2           printf
+#define UART_test_log3           printf
+#else
+#define UART_test_log(x)
+#define UART_test_log1(x,y)
+#define UART_test_log2(x,y,z)
+#define UART_test_log3(x,y,z,l)
+#endif
+
+
 #if defined(SOC_TPR12)
-#define QT_BUILD
+#if defined(SIM_BUILD)
 #define UART_RX_LOOPBACK_ONLY
+#endif
 #define UART_API2_NOT_SUPPORTED
 #define UART_NO_FIFO
-//#define UART_RW_INT_ONLY
 #endif
 
 void Uart_appC7xPreInit(void);
@@ -134,10 +149,10 @@ typedef struct UART_Tests_s
 #define UART_RDVERIFY_READ_LEN (4U)
 
 /* Timeout value of read and write */
-#ifdef QT_BUILD
+#ifdef SIM_BUILD
 #define UART_TEST_TIMEOUT      (50U)
 #else
-#define UART_TEST_TIMEOUT      (5000U)
+#define UART_TEST_TIMEOUT      (10000U)
 #endif
 
 /* Max number of instances to test in multiple instance test case */
@@ -145,22 +160,26 @@ typedef struct UART_Tests_s
 /* MAX Data Pattern Test Size for the Data Tests: */
 #define MAX_TEST_BUFFER_SIZE   256
 
-#define UART_TEST_CACHE_LINE_SIZE (128U)
-#if (defined(_TMS320C6X) || defined (__TI_ARM_V7M4__))
-#pragma DATA_ALIGN (scanPrompt, UART_TEST_CACHE_LINE_SIZE)
-char scanPrompt[MAX_TEST_BUFFER_SIZE];
+#if defined(CSL_CACHE_L2_LINESIZE)
+#define UART_TEST_CACHE_LINE_SIZE CSL_CACHE_L2_LINESIZE
+#elif defined(CSL_CACHE_L1D_LINESIZE)
+#define UART_TEST_CACHE_LINE_SIZE CSL_CACHE_L1D_LINESIZE
 #else
-char scanPrompt[MAX_TEST_BUFFER_SIZE] __attribute__ ((aligned (UART_TEST_CACHE_LINE_SIZE)));
+#define UART_TEST_CACHE_LINE_SIZE (128U)
 #endif
-char echoPrompt[40] = "\n\r Data entered is as follows \r\n";
-char dataPrint[40] = "\r\n enter the data of 16 character \r\n";
-char readTimeoutPrompt[60] = "\r\n Read timed out \r\n";
-char breakErrPrompt[60] = "\r\n Received a break condition error \r\n";
-char rdCancelPrompt[60] = "\r\n Previous read canceled \r\n";
-char wrCancelPrompt[60] = "\r\n Previous write canceled \r\n";
-char fifoTrgLvlData[MAX_TEST_BUFFER_SIZE] = "0123456789112345678921234567893123456789412345678951234567896123456789712345678981234567899123456789";
 
-char stdioPrint[64] = "\r\n enter the data of 16 character and press ENTER \r\n";
+char scanPrompt[MAX_TEST_BUFFER_SIZE] __attribute__ ((aligned (UART_TEST_CACHE_LINE_SIZE)));
+char echoPrompt[40] __attribute__ ((aligned (UART_TEST_CACHE_LINE_SIZE))) = "\n\r Data entered is as follows \r\n";
+char dataPrint[40] __attribute__ ((aligned (UART_TEST_CACHE_LINE_SIZE))) = "\r\n enter the data of 16 character \r\n";
+char readTimeoutPrompt[60] __attribute__ ((aligned (UART_TEST_CACHE_LINE_SIZE))) = "\r\n Read timed out \r\n";
+char breakErrPrompt[60] __attribute__ ((aligned (UART_TEST_CACHE_LINE_SIZE))) = "\r\n Received a break condition error \r\n";
+char rdCancelPrompt[60] __attribute__ ((aligned (UART_TEST_CACHE_LINE_SIZE))) = "\r\n Previous read canceled \r\n";
+char wrCancelPrompt[60] __attribute__ ((aligned (UART_TEST_CACHE_LINE_SIZE))) = "\r\n Previous write canceled \r\n";
+char fifoTrgLvlData[MAX_TEST_BUFFER_SIZE] __attribute__ ((aligned (UART_TEST_CACHE_LINE_SIZE))) =
+                        "0123456789112345678921234567893123456789412345678951234567896123456789712345678981234567899123456789"
+                        "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789abcedef12345"
+                        "6789ABCDEF012345678901234567899876543210deadbeef89512345";
+char stdioPrint[64] __attribute__ ((aligned (UART_TEST_CACHE_LINE_SIZE))) = "\r\n enter the data of 16 character and press ENTER \r\n";
 
 UART_Transaction  callbackTransaction;
 SemaphoreP_Handle callbackSem = NULL;
@@ -245,23 +264,7 @@ Udma_DrvHandle UartApp_udmaInit(UART_HwAttrs *cfg)
 #endif
 
         UdmaInitPrms_init(instId, &initPrms);
-#if defined(SOC_J721E) || defined(SOC_J7200)
-        /*
-         * Modify the default virtual interrupt configuration
-         * in UDMA RM table to support DMA mode, since UART
-         * DMA example uses more than two DMA events which
-         * requires numVintr > 2
-         */
-#if defined (BUILD_MCU2_1)
-        initPrms.rmInitPrms.startVintr = 226U;
-        initPrms.rmInitPrms.numVintr = 18U;
-#endif
-#if (defined (BUILD_MCU1_1) || defined(BUILD_MCU1_0))
-        initPrms.rmInitPrms.startVintr = 124U;
-        initPrms.rmInitPrms.numVintr = 4U;
-#endif
 
-#endif
         retVal = Udma_init(&gUdmaDrvObj, &initPrms);
         if(UDMA_SOK == retVal)
         {
@@ -691,35 +694,6 @@ static uintptr_t l2_global_address (uintptr_t addr)
 
 }
 
-/**
- *  @b Description
- *  @n
- *      The function is used to populate the *test* buffer with a predefined
- *      signature
- *
- *  @param[in]  ptrBuffer
- *      Buffer to be populated
- *  @param[in]  size
- *      Size of the buffer
- *
- *  @retval
- *      Not applicable
- */
-void UART_populateBuffer (uint8_t* ptrBuffer, uint32_t size)
-{
-    uint32_t index;
-    char     ch = 'A';
-
-    /* Populate the data buffer: */
-    for (index = 0; index < size; index++)
-    {
-        *(ptrBuffer + index) = ch++;
-        if (ch == ('Z'+1))
-            ch = 'A';
-    }
-    return;
-}
-
 void UART_callback(UART_Handle handle, void *buf, size_t count)
 {
     UART_osalPostLock(callbackSem);
@@ -1075,7 +1049,7 @@ Void UART_simultaneous_rw_write(UArg a0, UArg a1)
     while (taskSyncFlag == true)
        {
         transaction.buf = (void *)(uintptr_t)addrDataPrint;
-           transaction.count = sizeof(dataPrint);
+           transaction.count = strlen(dataPrint);
            UART_write2(uart, &transaction);
            Osal_delay(100);
        }
@@ -1197,7 +1171,7 @@ static bool UART_test_simultaneous_rw(bool dmaMode)
 
     UART_transactionInit(&transaction);
     transaction.buf = (void *)(uintptr_t)addrEchoPrompt;
-    transaction.count = sizeof(echoPrompt);
+    transaction.count = strlen(echoPrompt);
     if (UART_write2(uart, &transaction) == UART_ERROR)
     {
         goto Err;
@@ -1235,8 +1209,7 @@ Err:
  *  the read is complete.
  *
  */
-//static bool UART_test_read_write_cancel(bool dmaMode)
-bool UART_test_read_write_cancel(bool dmaMode)
+static bool UART_test_read_write_cancel(bool dmaMode)
 {
     UART_Handle       uart = NULL;
     UART_Params       uartParams;
@@ -1302,7 +1275,7 @@ bool UART_test_read_write_cancel(bool dmaMode)
         goto Err;
     }
     /* Delay for 10 seconds to allow user to enter chars */
-#if !defined(QT_BUILD)
+#if !defined(SIM_BUILD)
     Osal_delay(10000);
 #else
     Osal_delay(100);
@@ -1317,7 +1290,7 @@ bool UART_test_read_write_cancel(bool dmaMode)
     /* Print read cancelled prompt */
     UART_transactionInit(&transaction);
     transaction.buf = (void *)(uintptr_t)addrRdCancelPrompt;
-    transaction.count = sizeof(rdCancelPrompt);
+    transaction.count = strlen(rdCancelPrompt);
 #if !defined(UART_API2_NOT_SUPPORTED)
     if (UART_write2(uart, &transaction) == UART_ERROR)
 #else
@@ -1329,7 +1302,7 @@ bool UART_test_read_write_cancel(bool dmaMode)
 
     UART_transactionInit(&transaction);
     transaction.buf = (void *)(uintptr_t)addrDataPrint;
-    transaction.count = sizeof(dataPrint);
+    transaction.count = strlen(dataPrint);
 #if !defined(UART_API2_NOT_SUPPORTED)
     if (UART_write2(uart, &transaction) == UART_ERROR)
 #else
@@ -1365,7 +1338,7 @@ bool UART_test_read_write_cancel(bool dmaMode)
 #endif
     UART_transactionInit(&transaction);
     transaction.buf = (void *)(uintptr_t)addrEchoPrompt;
-    transaction.count = sizeof(echoPrompt);
+    transaction.count = strlen(echoPrompt);
 #if !defined(UART_API2_NOT_SUPPORTED)
     if (UART_write2(uart, &transaction) == UART_ERROR)
 #else
@@ -1418,7 +1391,7 @@ bool UART_test_read_write_cancel(bool dmaMode)
     /* Perform the 1st write */
     UART_transactionInit(&callbackTransaction);
     callbackTransaction.buf = (void *)(uintptr_t)addrWrCancelPrompt;
-    callbackTransaction.count = sizeof(wrCancelPrompt);
+    callbackTransaction.count = strlen(wrCancelPrompt);
 #if !defined(UART_API2_NOT_SUPPORTED)
     if (UART_write2(uart, &callbackTransaction) == UART_ERROR)
 #else
@@ -1437,7 +1410,7 @@ bool UART_test_read_write_cancel(bool dmaMode)
     /* Perform the 2nd write */
     UART_transactionInit(&callbackTransaction);
     callbackTransaction.buf = (void *)(uintptr_t)addrWrCancelPrompt;
-    callbackTransaction.count = sizeof(wrCancelPrompt);
+    callbackTransaction.count = strlen(wrCancelPrompt);
 #if !defined(UART_API2_NOT_SUPPORTED)
     if (UART_write2(uart, &callbackTransaction) == UART_ERROR)
 #else
@@ -1522,7 +1495,7 @@ static bool UART_test_rx_err(bool dmaMode)
        {
            UART_transactionInit(&transaction);
             transaction.buf = (void *)(uintptr_t)addrBreakErrPrompt;
-            transaction.count = sizeof(breakErrPrompt);
+            transaction.count = strlen(breakErrPrompt);
             if (UART_write2(uart, &transaction) == UART_ERROR)
             {
                 goto Err;
@@ -1566,9 +1539,7 @@ static bool UART_test_timeout(bool dmaMode)
     /* Initialize the default configuration params. */
     UART_Params_init(&uartParams);
     uartParams.parityType = uartParity;
-#if defined(UART_API2_NOT_SUPPORTED)
     uartParams.readTimeout = UART_TEST_TIMEOUT;
-#endif
 
     if (dmaMode)
     {
@@ -1597,7 +1568,7 @@ static bool UART_test_timeout(bool dmaMode)
     transaction.buf = (void *)(uintptr_t)scanPrompt;
     transaction.count = UART_TEST_READ_LEN;
     transaction.timeout = UART_TEST_TIMEOUT;
-#if defined(UART_API2_NOT_SUPPORTED)
+#if !defined(UART_API2_NOT_SUPPORTED)
     if (UART_read2(uart, &transaction) == UART_ERROR)
 #else
     if (UART_read(uart, transaction.buf, transaction.count) == UART_ERROR)
@@ -1605,7 +1576,7 @@ static bool UART_test_timeout(bool dmaMode)
     {
         UART_transactionInit(&transaction);
         transaction.buf = (void *)(uintptr_t)addrReadTimeoutPrompt;
-        transaction.count = sizeof(readTimeoutPrompt);
+        transaction.count = strlen(readTimeoutPrompt);
         transaction.timeout = UART_TEST_TIMEOUT;
         if (UART_write2(uart, &transaction) == UART_ERROR)
         {
@@ -1635,7 +1606,7 @@ static bool UART_test_polling_timeout(bool dmaMode)
     UART_Params      uartParams;
     bool             ret = false;
     uint32_t         rdSize = UART_TEST_READ_LEN;
-    uint32_t         wrSize = sizeof(readTimeoutPrompt);
+    uint32_t         wrSize = strlen(readTimeoutPrompt);
 
     /* UART SoC init configuration */
     UART_initConfig(dmaMode);
@@ -1701,7 +1672,7 @@ static bool UART_test_polling_timeout(bool dmaMode)
             goto Err;
         }
 
-        wrSize = sizeof(dataPrint);
+        wrSize = strlen(dataPrint);
         UART_writePolling(uart, (const void *)dataPrint, wrSize);
 
         memset(scanPrompt, 0, sizeof(scanPrompt));
@@ -1712,7 +1683,7 @@ static bool UART_test_polling_timeout(bool dmaMode)
             goto Err;
         }
 #endif
-        wrSize = sizeof(echoPrompt);
+        wrSize = strlen(echoPrompt);
         UART_writePolling(uart, (const void *)echoPrompt, wrSize);
         UART_writePolling(uart, (const void *)scanPrompt, rdSize);
 
@@ -1779,7 +1750,7 @@ static bool UART_test_callback(bool dmaMode)
     }
 
     /* Write DMA or non-DMA test prompt */
-    if (UART_write(uart, (void *)(uintptr_t)addrDataPrint, sizeof(dataPrint)) == UART_ERROR)
+    if (UART_write(uart, (void *)(uintptr_t)addrDataPrint, strlen(dataPrint)) == UART_ERROR)
     {
         goto Err;
     }
@@ -1807,7 +1778,7 @@ static bool UART_test_callback(bool dmaMode)
 
 #endif
 
-    if (UART_write(uart, (void *)(uintptr_t)addrEchoPrompt, sizeof(echoPrompt)) == UART_ERROR)
+    if (UART_write(uart, (void *)(uintptr_t)addrEchoPrompt, strlen(echoPrompt)) == UART_ERROR)
     {
         goto Err;
     }
@@ -1843,7 +1814,7 @@ static bool UART_test_callback(bool dmaMode)
 
     UART_transactionInit(&callbackTransaction);
     callbackTransaction.buf = (void *)(uintptr_t)addrDataPrint;
-    callbackTransaction.count = sizeof(dataPrint);
+    callbackTransaction.count = strlen(dataPrint);
     if (UART_write2(uart, &callbackTransaction) == UART_ERROR)
     {
         goto Err;
@@ -1875,7 +1846,7 @@ static bool UART_test_callback(bool dmaMode)
 
     UART_transactionInit(&callbackTransaction);
     callbackTransaction.buf = (void *)(uintptr_t)addrEchoPrompt;
-    callbackTransaction.count = sizeof(echoPrompt);
+    callbackTransaction.count = strlen(echoPrompt);
     if (UART_write2(uart, &callbackTransaction) == UART_ERROR)
     {
         goto Err;
@@ -2015,7 +1986,6 @@ static bool UART_test_read_verify(bool dmaMode)
     length = UART_read(uart, (void *)&rBuff[12], UART_RDVERIFY_READ_LEN);
 #else
     memset(rBuff, 0, UART_TEST_READ_LEN);
-    Osal_delay(1);
     for (i =0; i < UART_TEST_READ_LEN;i++)
     {
         if (UART_write(uart, (void *)&tBuff[i], 1) == UART_ERROR)
@@ -2058,7 +2028,6 @@ static bool UART_test_read_verify(bool dmaMode)
     UART_read(uart, (void *)&rBuff[0], UART_TEST_READ_LEN);
 #else
     memset(rBuff, 0, UART_TEST_READ_LEN);
-    Osal_delay(1);
     for (i =0; i < UART_TEST_READ_LEN;i++)
     {
         if (UART_write(uart, (void *)&tBuff[i], 1) == UART_ERROR)
@@ -2098,7 +2067,6 @@ static bool UART_test_read_verify(bool dmaMode)
     UART_read(uart, (void *)&rBuff[0], UART_TEST_READ_LEN);
 #else
     memset(rBuff, 0, UART_TEST_READ_LEN);
-    Osal_delay(1);
     for (i =0; i < UART_TEST_READ_LEN;i++)
     {
         if (UART_write(uart, (void *)&tBuff[i], 1) == UART_ERROR)
@@ -2137,7 +2105,6 @@ static bool UART_test_read_verify(bool dmaMode)
     UART_read(uart, (void *)&rBuff[0], UART_TEST_READ_LEN);
 #else
     memset(rBuff, 0, UART_TEST_READ_LEN);
-    Osal_delay(2);
     for (i =0; i < UART_TEST_READ_LEN;i++)
     {
         if (UART_write(uart, (void *)&tBuff[i], 1) == UART_ERROR)
@@ -2219,7 +2186,7 @@ static bool UART_test_read_write(bool dmaMode)
     }
 
     /* Test read/write API's in blocking mode */
-    if (UART_write(uart, (void *)(uintptr_t)addrDataPrint, sizeof(dataPrint)) == UART_ERROR)
+    if (UART_write(uart, (void *)(uintptr_t)addrDataPrint, strlen(dataPrint)) == UART_ERROR)
     {
         goto Err;
     }
@@ -2237,7 +2204,7 @@ static bool UART_test_read_write(bool dmaMode)
     }
 #endif
 
-    UART_write(uart, (void *)(uintptr_t)addrEchoPrompt, sizeof(echoPrompt));
+    UART_write(uart, (void *)(uintptr_t)addrEchoPrompt, strlen(echoPrompt));
 
     UART_write(uart, (void *)(uintptr_t)addrScanPrompt, length);
     UART_close(uart);
@@ -2252,7 +2219,7 @@ static bool UART_test_read_write(bool dmaMode)
     /* Test read2/write2 API's in blocking mode */
     UART_transactionInit(&transaction);
     transaction.buf = (void *)(uintptr_t)addrDataPrint;
-    transaction.count = sizeof(dataPrint);
+    transaction.count = strlen(dataPrint);
     if (UART_write2(uart, &transaction) == UART_ERROR)
     {
         goto Err;
@@ -2278,7 +2245,7 @@ static bool UART_test_read_write(bool dmaMode)
 
     UART_transactionInit(&transaction);
     transaction.buf = (void *)(uintptr_t)addrEchoPrompt;
-    transaction.count = sizeof(echoPrompt);
+    transaction.count = strlen(echoPrompt);
     if (UART_write2(uart, &transaction) == UART_ERROR)
     {
         goto Err;
@@ -2358,7 +2325,7 @@ static bool UART_test_read_write_int_disable(bool dmaMode)
     }
 
     /* Test read/write API's in blocking mode */
-    if (UART_write(uart, (void *)(uintptr_t)addrDataPrint, sizeof(dataPrint)) == UART_ERROR)
+    if (UART_write(uart, (void *)(uintptr_t)addrDataPrint, strlen(dataPrint)) == UART_ERROR)
     {
         goto Err;
     }
@@ -2376,7 +2343,7 @@ static bool UART_test_read_write_int_disable(bool dmaMode)
         goto Err;
     }
 #endif
-    UART_write(uart, (void *)(uintptr_t)addrEchoPrompt, sizeof(echoPrompt));
+    UART_write(uart, (void *)(uintptr_t)addrEchoPrompt, strlen(echoPrompt));
 
     UART_write(uart, (void *)(uintptr_t)addrScanPrompt, length);
     UART_close(uart);
@@ -2391,7 +2358,7 @@ static bool UART_test_read_write_int_disable(bool dmaMode)
     /* Test read2/write2 API's in blocking mode */
     UART_transactionInit(&transaction);
     transaction.buf = (void *)(uintptr_t)addrDataPrint;
-    transaction.count = sizeof(dataPrint);
+    transaction.count = strlen(dataPrint);
     if (UART_write2(uart, &transaction) == UART_ERROR)
     {
         goto Err;
@@ -2417,7 +2384,7 @@ static bool UART_test_read_write_int_disable(bool dmaMode)
 
     UART_transactionInit(&transaction);
     transaction.buf = (void *)(uintptr_t)addrEchoPrompt;
-    transaction.count = sizeof(echoPrompt);
+    transaction.count = strlen(echoPrompt);
     if (UART_write2(uart, &transaction) == UART_ERROR)
     {
         goto Err;
@@ -2450,7 +2417,7 @@ Err:
 }
 
 #ifdef UART_DMA_ENABLE
-#if !defined(UART_RX_LOOPBACK_ONLY)
+#if !defined(SOC_TPR12)
 static uint32_t UART_getMaxNumInst(uint32_t numInst)
 {
     uint32_t     i = 0;
@@ -2610,7 +2577,7 @@ Err:
     uartTestInstance = uartTestStartInst;
     return (ret);
 }
-#endif /* if UART_RX_LOOPBACK_ONLY */
+#endif /* if SOC_TPR12 */
 #endif /* if DMA */
 
 /**
@@ -2638,7 +2605,7 @@ static bool UART_writeInvalidArgs(UART_Handle handle)
     status = UART_write(handle, NULL, 128);
     if (status >= 0)
     {
-        printf("Error: UART Write with invalid buffer returned %d\n", status);
+        UART_test_log1("Error: UART Write with invalid buffer returned %d\n", status);
         return false;
     }
 
@@ -2648,7 +2615,7 @@ static bool UART_writeInvalidArgs(UART_Handle handle)
     status = UART_write(handle, &buffer[0], 0);
     if (status >= 0)
     {
-        printf("Error: UART Write with invalid size returned %d\n", status);
+        UART_test_log1("Error: UART Write with invalid size returned %d\n", status);
         return false;
     }
 
@@ -2658,7 +2625,7 @@ static bool UART_writeInvalidArgs(UART_Handle handle)
     status = UART_writePolling(handle, NULL, 128);
     if (status >= 0)
     {
-        printf("Error: UART Write with invalid buffer returned %d\n", status);
+        UART_test_log1("Error: UART Write with invalid buffer returned %d\n", status);
         return false;
     }
 
@@ -2668,7 +2635,7 @@ static bool UART_writeInvalidArgs(UART_Handle handle)
     status = UART_writePolling(handle, &buffer[0], 0);
     if (status >= 0)
     {
-        printf("Error: UART Write with invalid size returned %d\n", status);
+        UART_test_log1("Error: UART Write with invalid size returned %d\n", status);
         return false;
     }
 
@@ -2700,7 +2667,7 @@ static bool UART_readInvalidArgs(UART_Handle handle)
     status = UART_read(handle, NULL, 128);
     if (status != UART_EINVAL)
     {
-        printf("Error: UART Read with invalid buffer returned %d\n", status);
+        UART_test_log1("Error: UART Read with invalid buffer returned %d\n", status);
         return false;
     }
 
@@ -2710,7 +2677,7 @@ static bool UART_readInvalidArgs(UART_Handle handle)
     status = UART_read(handle, &buffer[0], 0);
     if (status != UART_EINVAL)
     {
-        printf("Error: UART Read with invalid size returned %d\n", status);
+        UART_test_log1("Error: UART Read with invalid size returned %d\n", status);
         return false;
     }
 
@@ -2720,7 +2687,7 @@ static bool UART_readInvalidArgs(UART_Handle handle)
     status = UART_readPolling(handle, NULL, 128);
     if (status != UART_EINVAL)
     {
-        printf("Error: UART Read with invalid buffer returned %d\n", status);
+        UART_test_log1("Error: UART Read with invalid buffer returned %d\n", status);
         return false;
     }
 
@@ -2730,7 +2697,7 @@ static bool UART_readInvalidArgs(UART_Handle handle)
     status = UART_readPolling(handle, &buffer[0], 0);
     if (status != UART_EINVAL)
     {
-        printf("Error: UART Read with invalid size returned %d\n", status);
+        UART_test_log1("Error: UART Read with invalid size returned %d\n", status);
         return false;
     }
 
@@ -2762,7 +2729,7 @@ bool UART_test_api (bool dmaMode)
     handle = UART_open(uartTestInstance, &params);
     if (handle == NULL)
     {
-        printf("Error: Unable to open the UART Instance\n");
+        UART_test_log("Error: Unable to open the UART Instance\n");
         return false;
     }
     /**************************************************************************
@@ -2776,7 +2743,7 @@ bool UART_test_api (bool dmaMode)
     handle = UART_open(0, &params);
     if (handle == NULL)
     {
-        printf("Error: Unable to open the UART Instance\n");
+        UART_test_log("Error: Unable to open the UART Instance\n");
         return false;
     }
 
@@ -2793,6 +2760,37 @@ bool UART_test_api (bool dmaMode)
     return true;
 }
 
+#if defined(SOC_TPR12) && defined(SIM_BUILD)
+
+/**
+ *  @b Description
+ *  @n
+ *      The function is used to populate the *test* buffer with a predefined
+ *      signature
+ *
+ *  @param[in]  ptrBuffer
+ *      Buffer to be populated
+ *  @param[in]  size
+ *      Size of the buffer
+ *
+ *  @retval
+ *      Not applicable
+ */
+void UART_populateBuffer (char* ptrBuffer, uint32_t size)
+{
+    uint32_t index;
+    char     ch = 'A';
+
+    /* Populate the data buffer: */
+    for (index = 0; index < size; index++)
+    {
+        *(ptrBuffer + index) = ch++;
+        if (ch == ('Z'+1))
+            ch = 'A';
+    }
+    return;
+}
+
 /**
  *  @b Description
  *  @n
@@ -2804,7 +2802,12 @@ bool UART_test_api (bool dmaMode)
  *  @retval
  *      Error   -   <0
  */
-uint8_t uartDataBuf[0x2000];
+#if (defined(_TMS320C6X) || defined (__TI_ARM_V7M4__))
+#pragma DATA_ALIGN (uartDataBuf, UART_TEST_CACHE_LINE_SIZE)
+char uartDataBuf[0x2000];
+#else
+char uartDataBuf[0x2000] __attribute__ ((aligned (UART_TEST_CACHE_LINE_SIZE)));
+#endif
 
 bool UART_test_profile_tx(bool dmaMode)
 {
@@ -2817,19 +2820,15 @@ bool UART_test_profile_tx(bool dmaMode)
     uint32_t        numDataSize = sizeof(dataSize)/sizeof(uint32_t);
     uint32_t        baudRate =  921600;
     uintptr_t       ptrTxData;
-#if defined(SOC_TPR12)
     uint32_t        txTimeTaken;
     UART_Stats      stats;
-#endif
     char            testDescription[128];
 
-#if defined(QT_BUILD)
+#if defined(SIM_BUILD)
     numDataSize = 3;
 #endif
 
-#if defined(SOC_TPR12)
     CycleprofilerP_init();
-#endif
 
     /********************************************************************************
      * Execute the test for all data sizes
@@ -2875,7 +2874,7 @@ bool UART_test_profile_tx(bool dmaMode)
             handle = UART_open(uartTestInstance, &params);
             if (handle == NULL)
             {
-                printf ("Error: Unable to open the UART Driver while profiling Transmit Data\n");
+                UART_test_log ("Error: Unable to open the UART Driver while profiling Transmit Data\n");
                 return false;
             }
 
@@ -2922,31 +2921,31 @@ bool UART_test_profile_tx(bool dmaMode)
             /* Populate the transmit buffer: */
             UART_populateBuffer (uartDataBuf, dataSize[dataSizeIndex]);
 
-#if defined(SOC_TPR12)
+            if (dmaMode)
+            {
+                CacheP_wbInv((void *)(uintptr_t)uartDataBuf, (int32_t)dataSize[dataSizeIndex]);
+            }
+
             /****************************************************************
              * Profile the time taken to send out the data
              ****************************************************************/
             txTimeTaken = CycleprofilerP_getTimeStamp();
-#endif
 
             if ((testIndex == 0) || (testIndex == 1))
                 status = UART_write(handle, (void *)ptrTxData, dataSize[dataSizeIndex]);
             else
                 status = UART_writePolling(handle, (void *)ptrTxData, dataSize[dataSizeIndex]);
 
-#if defined(SOC_TPR12)
             txTimeTaken = CycleprofilerP_getTimeStamp() - txTimeTaken;
-#endif
 
             /* Were we able to send out the data */
             if (status != dataSize[dataSizeIndex])
             {
-                printf ("Error: Unable to send out the data [Status %d]\n", status);
+                UART_test_log1 ("Error: Unable to send out the data [Status %d]\n", status);
                 UART_close(handle);
                 return false;
             }
 
-#if defined(SOC_TPR12)
             /* Get the UART Statistics: */
             if (UART_control (handle, UART_CMD_GET_STATS, &stats) < 0)
             {
@@ -2955,13 +2954,12 @@ bool UART_test_profile_tx(bool dmaMode)
             }
 
             /* Debug Message: */
-            printf ("Debug: Transmit Measurements\n");
-            printf ("Debug: Baud Rate        : %d\n", baudRate);
-            printf ("Debug: Data Size        : %d\n", dataSize[dataSizeIndex]);
-            printf ("Debug: Transmit         : %d ticks\n", txTimeTaken);
-            printf ("Debug: Tx Interrupt     : %d\n", stats.numTxInterrupts);
-            printf ("Debug: Tx DMA Interrupt : %d\n", stats.numTxDMAInterrupts);
-#endif
+            UART_test_log ("Debug: Transmit Measurements\n");
+            UART_test_log1 ("Debug: Baud Rate        : %d\n", baudRate);
+            UART_test_log1 ("Debug: Data Size        : %d\n", dataSize[dataSizeIndex]);
+            UART_test_log1 ("Debug: Transmit         : %d ticks\n", txTimeTaken);
+            UART_test_log1 ("Debug: Tx Interrupt     : %d\n", stats.numTxInterrupts);
+            UART_test_log1 ("Debug: Tx DMA Interrupt : %d\n", stats.numTxDMAInterrupts);
 
             /* Close the driver: */
             UART_close(handle);
@@ -2985,7 +2983,7 @@ bool UART_test_profile_tx(bool dmaMode)
         handle = UART_open(uartTestInstance, &params);
         if (!handle)
         {
-            printf ("Error: Unable to open the UART Driver while printing the test banner\n");
+            UART_test_log ("Error: Unable to open the UART Driver while printing the test banner\n");
             return false;
         }
 
@@ -2999,6 +2997,7 @@ bool UART_test_profile_tx(bool dmaMode)
 
     return true;
 }
+#endif
 
 bool UART_test_loopback_data(bool dmaMode)
 {
@@ -3017,7 +3016,7 @@ bool UART_test_loopback_data(bool dmaMode)
     callbackSem = UART_osalCreateBlockingLock(0, &semParams);
 
     /* enable the loopback */
-    verifyLoopback = 1;
+    verifyLoopback = TRUE;
 
     /* UART SoC init configuration */
     UART_initConfig(dmaMode);
@@ -3032,6 +3031,7 @@ bool UART_test_loopback_data(bool dmaMode)
     handle = UART_open(uartTestInstance, &params);
     if (handle == NULL)
     {
+        UART_test_log ("Error: Unable to open the UART Driver!\n");
         goto Err;
     }
 
@@ -3054,6 +3054,7 @@ bool UART_test_loopback_data(bool dmaMode)
     status = UART_read(handle, (void *)pRxBuf, MAX_TEST_BUFFER_SIZE);
     if (status < 0)
     {
+        UART_test_log1 ("Error: UART_read() return %d!\n", status);
         goto Err;
     }
 
@@ -3061,12 +3062,14 @@ bool UART_test_loopback_data(bool dmaMode)
     status = UART_write(handle, (void *)pTxBuf, MAX_TEST_BUFFER_SIZE);
     if (status < 0)
     {
+        UART_test_log1 ("Error: UART_write() return %d!\n", status);
         goto Err;
     }
 
     /* Wait for RX call back */
-    if (UART_osalPendLock(callbackSem, params.writeTimeout) != SemaphoreP_OK)
+    if ((status = UART_osalPendLock(callbackSem, params.writeTimeout)) != SemaphoreP_OK)
     {
+        UART_test_log1 ("Error: UART_osalPendLock() return %d!\n", status);
         goto Err;
     }
 
@@ -3075,6 +3078,7 @@ bool UART_test_loopback_data(bool dmaMode)
     {
         if (scanPrompt[i] != fifoTrgLvlData[i])
         {
+            UART_test_log3 ("Error: UART_test_loopback_data: data fails at index %d (%c != %c)\n", i, scanPrompt[i], fifoTrgLvlData[i]);
             goto Err;
         }
     }
@@ -3141,12 +3145,14 @@ UART_Tests Uart_tests[] =
     {UART_test_read_write_int_disable, false, UART_TEST_ID_INT_DISABLE, "\r\n UART read write test with interrupt disabled"},
     {UART_test_read_verify, false, UART_TEST_ID_RDVERIFY, "\r\n UART non-DMA read API test in loopback mode"},
 #ifdef UART_DMA_ENABLE
-#if !defined(UART_RX_LOOPBACK_ONLY)
+#if !defined(SOC_TPR12)
     {UART_test_multiple_instances, true, UART_TEST_ID_MULTI_INSTS, "\r\n UART DMA multiple instances loopback test "},
 #endif
 #endif
     {UART_test_api, false, UART_TEST_ID_API, "\r\n UART API Test"},
+#if defined(SOC_TPR12) && defined(SIM_BUILD)
     {UART_test_profile_tx, false, UART_TEST_ID_PROF_TX, "\r\n UART non-DMA/DMA Blocking/Polling transmit profiling"},
+#endif
 #ifdef UART_DMA_ENABLE
     {UART_test_loopback_data, true, UART_TEST_ID_DMA_LB_DATA, "\r\n UART DMA read write test with loopback"},
 #endif
@@ -3157,7 +3163,7 @@ UART_Tests Uart_tests[] =
 void UART_test_print_test_desc(UART_Tests *test)
 {
 
-#if !defined(QT_BUILD)
+#if !defined(SIM_BUILD)
     UART_Handle uart = NULL;
     UART_Params uartParams;
     char        testIdPrompt[16] = "\r\n UART UT ";
@@ -3191,7 +3197,7 @@ void UART_test_print_test_desc(UART_Tests *test)
 
 void UART_test_print_test_result(UART_Tests *test, bool pass)
 {
-#if !defined(QT_BUILD)
+#if !defined(SIM_BUILD)
     UART_Handle uart = NULL;
     UART_Params uartParams;
     char        testIdPrompt[16] = "\r\n UART UT ";
@@ -3210,19 +3216,19 @@ void UART_test_print_test_result(UART_Tests *test, bool pass)
 
     /* Print unit test ID */
     sprintf(testId, "%d", test->testId);
-    UART_write(uart, (void *)(uintptr_t)crPrompt, sizeof(crPrompt));
-    UART_write(uart, (void *)(uintptr_t)testIdPrompt, sizeof(testIdPrompt));
-    UART_write(uart, (void *)(uintptr_t)testId, sizeof(testId));
+    UART_write(uart, (void *)(uintptr_t)crPrompt, strlen(crPrompt));
+    UART_write(uart, (void *)(uintptr_t)testIdPrompt, strlen(testIdPrompt));
+    UART_write(uart, (void *)(uintptr_t)testId, strlen(testId));
     if (pass == true)
     {
-        UART_write(uart, (void *)(uintptr_t)resultPass, sizeof(resultPass));
+        UART_write(uart, (void *)(uintptr_t)resultPass, strlen(resultPass));
     }
     else
     {
-        UART_write(uart, (void *)(uintptr_t)resultFail, sizeof(resultFail));
+        UART_write(uart, (void *)(uintptr_t)resultFail, strlen(resultFail));
     }
 
-    UART_write(uart, (void *)(uintptr_t)crPrompt, sizeof(crPrompt));
+    UART_write(uart, (void *)(uintptr_t)crPrompt, strlen(crPrompt));
 
     UART_close(uart);
 #else
@@ -3235,7 +3241,8 @@ void UART_test_print_test_results(bool pass)
     const char  resultPass[32] = "\r\n All tests have passed. \r\n";
     const char  resultFail[32] = "\r\n Some tests have failed. \r\n";
 
-#if !defined(QT_BUILD)
+#if !defined(SIM_BUILD)
+
     /* UART SoC init configuration */
     UART_initConfig(false);
 
@@ -3249,7 +3256,6 @@ void UART_test_print_test_results(bool pass)
     {
         UART_printStatus(resultFail);
     }
-
     UART_stdioDeInit();
 #else
     printf("%s", pass?resultPass:resultFail);
@@ -3445,6 +3451,8 @@ static EDMA_Handle UartApp_edmaInit(void)
 {
     EDMA_errorConfig_t  errorConfig;
     EDMA_instanceInfo_t instanceInfo;
+    EDMA3CCInitParams  initParam;
+    uint32_t            edmaInstId = UART_EDMA_INSTANCE_ID;
     int32_t             errCode;
 
     if (gEdmaHandle != NULL)
@@ -3452,8 +3460,16 @@ static EDMA_Handle UartApp_edmaInit(void)
         return(gEdmaHandle);
     }
 
+    if (uartTestInstance == 2)
+    {
+        /* UART Instance 2 uses DSS EDMA instance B */
+        edmaInstId = EDMA_DRV_INST_DSS_B;
+    }
+
     /* Initialize the UART edma instance */
-    errCode = EDMA_init(UART_EDMA_INSTANCE_ID);
+    EDMA3CCInitParams_init(&initParam);
+    initParam.initParamSet = TRUE;
+    errCode = EDMA_init(edmaInstId, &initParam);
     if (errCode != EDMA_NO_ERROR)
     {
         printf("Error: Unable to initialize EDMA, errorCode = %d\n", errCode);
@@ -3461,7 +3477,7 @@ static EDMA_Handle UartApp_edmaInit(void)
     }
 
     /* Open the UART edma Instance */
-    gEdmaHandle = EDMA_open(UART_EDMA_INSTANCE_ID, &errCode, &instanceInfo);
+    gEdmaHandle = EDMA_open(edmaInstId, &errCode, &instanceInfo);
     if (gEdmaHandle == NULL)
     {
         printf("Error: Unable to open the edma Instance(%d), erorCode = %d\n",
@@ -3486,7 +3502,7 @@ static EDMA_Handle UartApp_edmaInit(void)
 
     return(gEdmaHandle);
 }
-#endif
+#endif /* SOC_TPR12 */
 #endif
 
 #if defined(BUILD_MPU) || defined (__C7100__)