This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

EK-TM4C1294XL: TM4C1294

Part Number: EK-TM4C1294XL

Dear TI Support,

I have a EK-TM4C1294XL evaluation kit. I downloaded SPMA072 (Serial to Ethernet Converter for TM4C129x).

I am able to compile using CCS 11.2.0. The application is running and I am able to open webserver and change Serial Port 0 settings.

I was not able to change IP address in S2E Miscellaneous Settings screen.

When I check misc.shtm file, there is a call to misc.cgi file. However I cannot find any .cgi file.

If I check config1.shtm, I find it calls config.cgi file. But I cannot find this file either.

We need to modify webserver for our application and need to modify these cgi files. 

Do you know where can I find these files?

Thanks for your help,

Felix V.

  • Hello Felix,

    Those aren't file we provide. I checked various resources and we don't provide any .cgi files.

    Those lines are for 'get' calls so it makes me think those files are being received from the webserver itself.

    I will try and ask my more Ethernet savvy colleague for ideas but we aren't webserver experts, I am not sure if he has sufficient background to add more value.

    Best Regards,

    Ralph Jacobi

  • We need to modify webserver for our application and need to modify these cgi files.

    Section 8.5 Writing CGI Functions in TM4C129x Ethernet Applications for Socket-Based TIRTOS NDK has some information on writing CGI functions, albeit using the TI-RTOS NDK rather than the FreeRTOS+lwIP used in SPMA072

    Do you know where can I find these files?

    The CGI files are not actually files in the embedded file system on the Tiva HTTPD server, but rather the server recognises the .cgi file extension and calls a function in C to handle the request.

    Looking in the config.c file within smpa072.zip there is the following array which maps the .cgi filename to a function which is called:

    //*****************************************************************************
    //
    //! This array is passed to the HTTPD server to inform it of special URIs
    //! that are treated as common gateway interface (CGI) scripts.  Each URI name
    //! is defined along with a pointer to the function which is to be called to
    //! process it.
    //
    //*****************************************************************************
    static const tCGI g_psConfigCGIURIs[] =
    {
        { "/config.cgi", ConfigCGIHandler },            // CGI_INDEX_CONFIG
        { "/misc.cgi", ConfigMiscCGIHandler },          // CGI_INDEX_MISC
        { "/defaults.cgi", ConfigDefaultsCGIHandler },  // CGI_INDEX_DEFAULTS
        { "/ip.cgi", ConfigIPCGIHandler },              // CGI_INDEX_IP
    };

  • HI,

      Chester is correct that ip.cgi is mapped to an internal C function ConfigIPCGIHandler in the config.c file. I was able to reproduce the problem. Seems like the new static address is saved into a global variable correctly but missing the step to inform the lwIP stack to pick up the new IP address. Go to ConfigIPCGIHandler and add the function call highlighted in red. After adding this line, it is working for me. In the browser, you will need to type in the new IP address on the URL to see the webpage. The new IP address should also display on the UART COM port. 

    if(bChanged)
    {
    //
    // Shut down connections in preparation for the IP address change.
    //
    ConfigPreUpdateIPAddress();

    ConfigUpdateIPAddress(); // Add this function call

    //
    // Update the working default set and save the parameter block.
    //
    g_sWorkingDefaultParameters = g_sParameters;
    ConfigSave();

    snipped...

  • Thanks for clarifying Chester! I will take a look.

    Felix

  • Thanks Charles! You are correct. This fixed the issue of not accepting new static IP address. It works fine as long as I don't re-start. If I cycle the power on the TIVA, forcing it to reset, it goes back to DHCP mode trying to acquire a dynamic IP address. I need it to remain in static IP mode. I tried to disable LWIP_DHCP in lwipopts.h but didn't help.

    Thanks again for your help.

    Felix

  • Charles, is it possible to make static IP address the default? 

    Felix

  • Hi Felix,

      You can configure for static IP by default. This is how you do it.

    1. In the lwipopts.h file, you need to set the below two #define to 0.

    #define LWIP_DHCP                       0
    #define LWIP_AUTOIP                     0

    2. In the lwip_task.c file, go to the lwIPTaskInit() function.

    Replace:
    lwIPInit(g_ui32SysClock, pui8MAC, 0, 0, 0, IPADDR_USE_DHCP);

    By:
    lwIPInit(g_ui32SysClock, pui8MAC, (192u << 24) | (168u << 16) | (254 << 8) | 136, 0xFFFF0000, 0xFFFF0000, IPADDR_USE_STATIC);

    The above static IP address is an available IP address that I use for testing on my network. You need to enter your own static IP address.
    3. Rebuild the project and then run.

  • Hi Charles, this works. However code above uses a fixed static IP address. We need to be able to modify static IP address using webserver. For some reason, as I said, I am able to change static IP address to any value using your webserver, however, when I reset TIVA, it reverts back to DHCP mode. It tries to acquire IP address from DHCP server and comes back with an arbitrary dynamic address.

    It doesn't stay in static IP mode with the address I just programmed. Is this normal? It seems by looking at the code that webserver should keep last programmed static IP address. I don't know if you observe same behavior on your end.

    Felix

  • Hi,

    when I reset TIVA, it reverts back to DHCP mode. It tries to acquire IP address from DHCP server and comes back with an arbitrary dynamic address.

    I don't think that is possible. If you followed the instructions to set LWIP_DHCP and LWIP_AUTOIP to 0 then the DHCP module is completed removed from the stack after you rebuild the project. You can confirm that in wireshark and you should not see any DHCP transactions. As I mentioned you also need to add the below line so that lwIP is initialized with your static address. After each power cycle, the IP address will be whatever you provided. In my below example, I will only see 192.168.254.136. 

    lwIPInit(g_ui32SysClock, pui8MAC, (192u << 24) | (168u << 16) | (254 << 8) | 136, 0xFFFF0000, 0xFFFF0000, IPADDR_USE_STATIC);

  • Hi Charles, there seems to be a misunderstanding. The example code you provide works as you describe. If I follow your code, there is no DHCP transactions and IP address is static. The problem is that I need to change the address using the webserver. You see, our end customers need to change IP address to whatever value they want. This IP address needs to be saved in non-volatile memory and retrieved on power up. I am having difficulty doing this in the original code. I am trying to modify it. I think, after power up,  I need to provide lwIPInit() with the static IP address I entered using webserver. 

    Felix

  • Hi Charles, I was able to modify code and set IP from webserver and retrieve it from EEPROM. It required very minor changes to original firmware.

    Thanks a lot for the great support.

    Felix

  • Hi Felix,

      Glad you solve the problem yourself. Yes, you can first retrieve the new static address that is saved in the EEprom before you call lwIPInit(). I have not tried it myself yet. Would you mind to share the code that it may benefit others in the future? Thanks. 

  • Hi Charles, here are the steps I followed to convert to static P address:

    SPMA072 Serial to Ethernet Converter (enet-s2e)

    Use this procedure to change to static IP address and make it configurable by webserver. In this example I used following default settings:

    IP address                           192.168.1.4

    Subnet Mask                      255.255.255.0

    Default Gateway              192.168.1.20

     

    1. In config.c, enter default settings to static const tConfigParameters g_sParametersFactory as follows:

     

    //

        // Static IP address (used only if indicated in ui8Flags).

        //

        0xC0A80104,                  // 192.168.1.4

     

        //

        // Default gateway IP address (used only if static IP is in use).

        //

        0xC0A80114,                  //192.168.1.20

     

        //

        // Subnet mask (used only if static IP is in use).

        //

        0xFFFFFF00,                   //255.255.255.0

     

    1. In config.c, force program to use default settings by commenting out code as follows (leave statement in bold uncommented).

     

    // Update the default parameter pointer.

        //

        //if(pui8Buffer)

        //{

        //    g_psDefaultParameters = (tConfigParameters *)pui8Buffer;

        //}

        //else

        //{

            g_psDefaultParameters = (tConfigParameters *)g_psFactoryParameters;

        //}

     

    1. In lwipopts.h file disable DHCP and Auto IP as follows:

     

    /

    // ---------- DHCP options ----------

    //

    //*****************************************************************************

    #define LWIP_DHCP                       0           // default is 0

    //#define DHCP_DOES_ARP_CHECK             ((LWIP_DHCP) && (LWIP_ARP))

     

    //*****************************************************************************

    //

    // ---------- UPNP options ----------

    //

    //*****************************************************************************

    //#define LWIP_UPNP                       0

     

    //*****************************************************************************

    //

    // ---------- PTPD options ----------

    //

    //*****************************************************************************

    //#define LWIP_PTPD                       0

     

    //*****************************************************************************

    //

    // ---------- AUTOIP options ----------

    //

    //*****************************************************************************

    #define LWIP_AUTOIP                     0           // default is 0

    #define LWIP_DHCP_AUTOIP_COOP           ((LWIP_DHCP) && (LWIP_AUTOIP))

     

    1. In config.c, add ConfigUpdateIPAddress() statement as shown:

     

    if(bChanged)

        {

            //

            // Shut down connections in preparation for the IP address change.

            //

            ConfigPreUpdateIPAddress();

             ConfigUpdateIPAddress();

     

            //

            // Update the working default set and save the parameter block.

            //

    1. In lwip_task.c, modify lwIPInit call as follows:

    // Initialize lwIP.

        //

        lwIPInit(g_ui32SysClock, pui8MAC, g_psDefaultParameters->ui32StaticIP, g_psDefaultParameters->ui32SubnetMask, g_psDefaultParameters->ui32GatewayIP, IPADDR_USE_STATIC);

     

        //

        // Setup the remaining services inside the TCP/IP thread's context.

     

    1. Compile and run program. Use default IP address to open webserver. Go to S2E Miscellaneous settings. In IP Address Selection, you can enter a new IP address and then click Update Settings. At this point, a new parameter block has been written to EEPROM.
    2. In config.c, re-enable condition that check for valid parameter block. This will cause program to use new parameters.

       // Update the default parameter pointer.

        //

        if(pui8Buffer)

        {

            g_psDefaultParameters = (tConfigParameters *)pui8Buffer;

        }

        else

        {

            g_psDefaultParameters = (tConfigParameters *)g_psFactoryParameters;

        }

    1. Compile and run program. New static IP address should be active now. From now on, on power up, program will default to static P address and read last saved IP address from EEPROM.