]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/ibl.git/commitdiff
Added a read back to the i2c write utility
authorMike Line <m-line1@ti.com>
Thu, 28 Oct 2010 15:49:44 +0000 (11:49 -0400)
committerMike Line <m-line1@ti.com>
Thu, 28 Oct 2010 15:49:44 +0000 (11:49 -0400)
The i2c writer will now verify the write

src/make/ibl_c6472/i2crom_be.map
src/make/ibl_c6472/i2crom_le.map
src/make/makestg2
src/util/i2cWrite/i2cWrite.c
src/util/i2cWrite/i2cWrite.cmd
src/util/romparse/romparse.c

index f9e07ea82af532a222d392b220a343529ce36199..0bff0a5298bb546104e7cf4c681267d24ce7dd98 100644 (file)
@@ -6,7 +6,7 @@ section
   options       = 1
 
   core_freq_mhz    = 625
-  i2c_clk_freq_khz = 50
+  i2c_clk_freq_khz = 200
 
   dev_addr_ext = 0x51
 
index 242971f08765e3312f992a8d86182d2dba858a1b..9c9d1bd6c7dae980ac154d465fad9991b6396563 100644 (file)
@@ -6,7 +6,7 @@ section
   options       = 1
 
   core_freq_mhz    = 625
-  i2c_clk_freq_khz = 50
+  i2c_clk_freq_khz = 200
 
   dev_addr_ext = 0x50
 
index 35d3bdce0d4c5475b1f77f5d2c65a86df1e26516..456628b6bfc703e46f80c22f32302a544ededea6 100644 (file)
@@ -59,6 +59,7 @@ utils:
        make -C $(IBL_ROOT)/util/romparse TARGET=$(TARGET)
        make -C $(IBL_ROOT)/util/i2cRead  TARGET=$(TARGET) $(TARGET)
        make -C $(IBL_ROOT)/util/i2cWrite TARGET=$(TARGET) $(TARGET)
+       make -C $(IBL_ROOT)/util/i2cConfig $(TARGET)
        make -C $(IBL_ROOT)/util/bconvert
 
 clean: $(CLEAN_MODULES)
index f3d93e09edcf2d1aef6016e054f910db1d6556d1..f9370980c1be704ac4aef77138042b34f85aa9bd 100644 (file)
@@ -13,6 +13,7 @@
 #include "i2c.h"
 #include "target.h"
 #include <stdio.h>
+#include <string.h>
 
 #define I2C_SIZE_BYTES  0x10000
 
@@ -27,9 +28,37 @@ unsigned int   dataAddress   = 0;
 #pragma DATA_SECTION(i2cData, ".i2cData")
 unsigned int i2cData[I2C_SIZE_BYTES >> 2];
 
+#pragma DATA_SECTION(i2cRead, ".i2cRead")
+unsigned int i2cRead[I2C_SIZE_BYTES >> 2];
+
 #define I2C_MAX_BLOCK_SIZE_BYTES    256
 unsigned char i2cBlock[I2C_MAX_BLOCK_SIZE_BYTES+4];  /* need 2 bytes for the address */
 
+
+/**
+ * @brief
+ *  Get a single byte of data from i2cData based on big endian ordering
+ */
+
+UINT8 getByte(int idx)
+{
+    int    word;
+    int    byte;
+    UINT8  u;
+    unsigned int v;
+
+    word = idx >> 2;
+    byte = idx & 0x3;
+
+    v = i2cData[word];
+
+    u = (v >> ((3 - byte) << 3)) & 0xff;
+
+    return (u);
+
+}
+
+
 /** 
  *  @brief
  *      Form a block of data to write to the i2c. The block is 
@@ -108,6 +137,11 @@ void main (void)
     int     n;
     int     remain;
     int     progBytes;
+    int     eCount;
+
+    UINT8  *iData;
+    UINT8   writeByte;
+    int     j;
 
     volatile int i;
 
@@ -150,8 +184,51 @@ void main (void)
 
     }
 
+    printf ("I2C write complete, reading data\n");
+
+    memset (i2cRead, 0xffffffff, sizeof(i2cRead));
+
+    /* Read the data back */
+    i2cRet = hwI2cMasterRead (dataAddress,
+                              nbytes,
+                              (UINT8 *)i2cRead,
+                              busAddress,
+                              0x100);
+
+
+    if (i2cRet != I2C_RET_OK)  {
+        showI2cError (i2cRet);
+        return;
+    }
+
+    printf ("I2C read complete, comparing data\n");
+
+    /* The data received was simply packed bytes, but the data sent was in big endian mode,
+     * so the compare must get the ordering correct */
+    iData  = (UINT8 *)i2cRead;
+    eCount = 0;
+    for (j = 0; j < nbytes; j++)  {
+      
+        writeByte = getByte(j);
+        if (writeByte != iData[j])  {
+            printf ("Error at data byte %d: expected 0x%02x, read 0x%02x\n", j, writeByte, iData[j]);
+            eCount += 1;
+        }
+
+        if (eCount >= 20)  {
+          printf ("Too many errors, stopping compare\n");
+          break;
+        }
+
+    }
+
+    if (eCount == 0)
+        printf ("Data compare passed\n");
+    else
+        printf ("Data compare failed\n");
+
+
 
-    printf ("I2C write complete\n");
 }
         
 
index 930050c2adfbc10b57fd8d94685eb50cde78eea6..92913a3b479b3a0cf6d1fd85b672987059024676 100644 (file)
@@ -10,13 +10,15 @@ i2cWrite.oc
 MEMORY
 {
        I2C_DAT  :  origin = 0x800000  length = 0x10000
-       L2       :  origin = 0x810000  length = 0x10000
+       I2C_READ :  origin = 0x810000  length = 0x10000
+       L2       :  origin = 0x820000  length = 0x10000
 
 }
 
 SECTIONS
 {
        .i2cData > I2C_DAT
+       .i2cRead > I2C_READ
        .stack   > L2
        .heap    > L2
        .text    > L2
index 30e19cbd1e167daebd2c41e266e9070ff3c58269..50b9f2d0eb9b2430044f69f6cb809754cd05bebd 100644 (file)
@@ -425,6 +425,10 @@ void createOutput (void)
     for (i = 0; i < PCI_DATA_LEN_32bit; i++)  {
       fprintf (str, "0x%08x\n", pciFile.data[i]);
     }
+  }  else  {
+    for (i = 0; i < PCI_DATA_LEN_32bit; i++)  {
+      fprintf (str, "0x%08x\n", 0);
+    }
   }