iblConfig now accepts ethboot changes from input.txt DEV.MAD_UTILS.IBL.01.00.00.12
authorIvan Pang <i-pang@ti.com>
Tue, 29 Nov 2011 00:50:29 +0000 (19:50 -0500)
committerIvan Pang <i-pang@ti.com>
Tue, 29 Nov 2011 00:50:29 +0000 (19:50 -0500)
src/util/iblConfig/build/Makefile
src/util/iblConfig/src/iblConfig.c

index a92440d382f9e8426aa845b40d8bf701a80ab0bd..a4842841e16af53c9bb3485690b37585b6d40434 100644 (file)
@@ -2,7 +2,7 @@
 # Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
 ###############################################################################
 
-CC               = gcc
+CC               = gcc 
 AR               = ar
 
 ###############################################################################
@@ -78,6 +78,13 @@ gen_input:
        echo "file_name = ibl.bin" > input.txt
        echo "device = $(DEVICE_ID)" >> input.txt
        echo "offset = $(I2C_MAP_ADDR)" >> input.txt
+       echo "ethBoot-doBootp = " >> input.txt
+       echo "ethBoot-bootFormat = " >> input.txt
+       echo "ethBoot-ipAddr = " >> input.txt
+       echo "ethBoot-serverIp = " >> input.txt
+       echo "ethBoot-gatewayIp = " >> input.txt
+       echo "ethBoot-netmask = " >> input.txt
+       echo "ethBoot-fileName = " >> input.txt
 
 ###############################################################################
 # Cleanup                                                                    
index 5df594560a55f9ecdd3d8f7b0d19dfe04e40e65d..0c666f4643b6697b27947d97555c2f0e79cdde67 100644 (file)
@@ -3,14 +3,24 @@
 
 #define TRUE 1
 #define FALSE 0
-#define MAX_LINE_LENGTH 40
-char *input_file = "./input.txt";
+#define MAX_LINE_LENGTH 80
+#define DEFAULT_ETHBOOT_IDX 0
+#define EVM_C6678_ETHBOOT_IDX 2
 
 /* Parameters defined in the input_file */
 #define FILE_NAME      "file_name"
 #define DEVICE_ID      "device"
 #define OFFSET_ADDR    "offset"
+#define DOBOOTP  "ethBoot-doBootp"
+#define BOOTFORMAT  "ethBoot-bootFormat"
+#define IPADDR  "ethBoot-ipAddr"
+#define SERVERIP  "ethBoot-serverIp"
+#define GATEWAYIP  "ethBoot-gatewayIp"
+#define NETMASK  "ethBoot-netmask"
+#define FILENAME  "ethBoot-fileName"
+
 
+char *input_file = "./input.txt";
 char        file_name[MAX_LINE_LENGTH];
 uint32_t    device_id;
 uint32_t    offset;
@@ -21,7 +31,7 @@ typedef ibl_t (*ibl_config_fn)(void);
 int main (void)
 {
     ibl_t ibl_params;
-    FILE    *fp;
+    FILE    *fp, *mfp;
     int    ret;
     ibl_config_fn cfg[] = {
            [1] = &c6455_ibl_config,
@@ -67,6 +77,10 @@ int main (void)
 
     if (device_id > 0 && device_id < ncfgs)
            ibl_params = (*cfg[device_id])();
+               
+       mfp = fopen(input_file, "r");
+       modifyIblConfig(mfp, &ibl_params);
+       fclose(mfp);
     
     if (fwrite((void*)&ibl_params, sizeof(ibl_t), 1, fp) != 1) {
         fclose(fp);
@@ -204,3 +218,71 @@ int parse_input_file(FILE *fp)
     return TRUE;
 }
 
+int modifyIblConfig(FILE *fp, ibl_t *ibl)
+{
+    char line[MAX_LINE_LENGTH];
+    char tokens[] = " :=;\n\r";
+    char *key, *data;
+       unsigned char ethBootIdx=DEFAULT_ETHBOOT_IDX, i0, i1, i2, i3;
+    if ((device_id == 6) || (device_id == 7)) 
+        ethBootIdx = EVM_C6678_ETHBOOT_IDX;
+    memset(line, 0, MAX_LINE_LENGTH);
+
+    while(fgets(line, MAX_LINE_LENGTH, fp) != '\0')
+       {
+               key  = (char *)strtok(line, tokens);
+               data = (char *)strtok(NULL, tokens);
+               if ( (key == NULL) || (data == NULL) ) {} 
+               else if (strcmp(key, DOBOOTP) == 0)
+               {
+                       if (strcmp(data, "TRUE") == 0)
+                               ibl->bootModes[ethBootIdx].u.ethBoot.doBootp = TRUE;
+                       else
+                               ibl->bootModes[ethBootIdx].u.ethBoot.doBootp = FALSE;
+               }
+               else if (strcmp(key, BOOTFORMAT) == 0)
+               {
+                       if (strcmp(data, "ELF") == 0)
+                               ibl->bootModes[ethBootIdx].u.ethBoot.bootFormat = ibl_BOOT_FORMAT_ELF;
+                       else
+                               ibl->bootModes[ethBootIdx].u.ethBoot.bootFormat = ibl_BOOT_FORMAT_BBLOB;
+               }
+               else if (strcmp(key, IPADDR) == 0)
+               {
+                       i0 = atoi((unsigned char*)strtok(data, "."));
+                       i1 = atoi((unsigned char*)strtok(NULL, "."));
+                       i2 = atoi((unsigned char*)strtok(NULL, "."));
+                       i3 = atoi((unsigned char*)strtok(NULL, "."));
+                       SETIP(ibl->bootModes[ethBootIdx].u.ethBoot.ethInfo.ipAddr, i0, i1, i2, i3);
+               }
+               else if (strcmp(key, SERVERIP) == 0)
+               {
+                       i0 = atoi((unsigned char*)strtok(data, "."));
+                       i1 = atoi((unsigned char*)strtok(NULL, "."));
+                       i2 = atoi((unsigned char*)strtok(NULL, "."));
+                       i3 = atoi((unsigned char*)strtok(NULL, "."));
+                       SETIP(ibl->bootModes[ethBootIdx].u.ethBoot.ethInfo.serverIp, i0, i1, i2, i3);
+               }
+               else if (strcmp(key, GATEWAYIP) == 0)
+               {
+                       i0 = atoi((unsigned char*)strtok(data, "."));
+                       i1 = atoi((unsigned char*)strtok(NULL, "."));
+                       i2 = atoi((unsigned char*)strtok(NULL, "."));
+                       i3 = atoi((unsigned char*)strtok(NULL, "."));
+                       SETIP(ibl->bootModes[ethBootIdx].u.ethBoot.ethInfo.gatewayIp, i0, i1, i2, i3);
+               }
+               else if (strcmp(key, NETMASK) == 0)
+               {
+                       i0 = atoi((unsigned char*)strtok(data, "."));
+                       i1 = atoi((unsigned char*)strtok(NULL, "."));
+                       i2 = atoi((unsigned char*)strtok(NULL, "."));
+                       i3 = atoi((unsigned char*)strtok(NULL, "."));
+                       SETIP(ibl->bootModes[ethBootIdx].u.ethBoot.ethInfo.netmask, i0, i1, i2, i3);
+               }
+               else if (strcmp(key, FILENAME) == 0)
+               {
+                       strcpy(ibl->bootModes[ethBootIdx].u.ethBoot.ethInfo.fileName, data);
+               }
+       }
+    return TRUE;
+}