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.

LP-AM243:Problems discovered when modifying Ethernet to static IP

Part Number: LP-AM243

     HI 

      Based on  enet_cpsw_tcpserver  ,After changing the TCP server to a static IP address, the computer client connects to the server and automatically disconnects after about 240 seconds, printing the following                information

 

Method of changing to static IP

  • Hi  

    Kindly follow this link for more details on steps to configure static ip address: e2e.ti.com/.../am2434-cpsw-dual-mac-mode

  • 嗨 

    Based on example enet_ Cpsw_  tcpserver to static IP,instead of  Lwip/ENET_Lwip_cpsw

  • Modify 

    App_setupNetif
    Like below:
    static void App_setupNetif()
    {
        ip4_addr_t ipaddr[2], netmask[2], gw[2];

        DebugP_log("Starting lwIP, local interface IP is dhcp-enabled\r\n");
        hlwipIfApp = LwipifEnetApp_getHandle();
        for (uint32_t netifIdx = 0U; netifIdx < ENET_SYSCFG_NETIF_COUNT; netifIdx++)
        {
            ip4_addr_set_zero(&gw[netifIdx]);
            ip4_addr_set_zero(&ipaddr[netifIdx]);
            ip4_addr_set_zero(&netmask[netifIdx]);
            IP4_ADDR((&gw[netifIdx]), 192,168,1,1);
            IP4_ADDR((&ipaddr[netifIdx]), 192,168,1,(netifIdx+1));
            IP4_ADDR((&netmask[netifIdx]), 255,255,255,0);
            /* Open the netif and get it populated*/
            g_pNetif[netifIdx] = LwipifEnetApp_netifOpen(hlwipIfApp, NETIF_INST_ID0 + netifIdx, &ipaddr[netifIdx], &netmask[netifIdx], &gw[netifIdx]);
            netif_set_status_callback(g_pNetif[netifIdx], App_netifStatusChangeCb);
            netif_set_link_callback(g_pNetif[netifIdx], App_netifLinkChangeCb);
            netif_set_up(g_pNetif[NETIF_INST_ID0 + netifIdx]);
        }
        LwipifEnetApp_startSchedule(hlwipIfApp, g_pNetif[ENET_SYSCFG_DEFAULT_NETIF_IDX]);
    }
  • Hi,

    Modify 

    static void App_setupNetif()
    {
    ip4_addr_t ipaddr[2], netmask[2], gw[2];

    DebugP_log("Starting lwIP, local interface IP is dhcp-enabled\r\n");
    hlwipIfApp = LwipifEnetApp_getHandle();
    for (uint32_t netifIdx = 0U; netifIdx < ENET_SYSCFG_NETIF_COUNT; netifIdx++)
    {
    ip4_addr_set_zero(&gw[netifIdx]);
    ip4_addr_set_zero(&ipaddr[netifIdx]);
    ip4_addr_set_zero(&netmask[netifIdx]);
    IP4_ADDR((&gw[netifIdx]), 192,168,1,1);
    IP4_ADDR((&ipaddr[netifIdx]), 192,168,1,(netifIdx+1));
    IP4_ADDR((&netmask[netifIdx]), 255,255,255,0);
    /* Open the netif and get it populated*/
    g_pNetif[netifIdx] = LwipifEnetApp_netifOpen(hlwipIfApp, NETIF_INST_ID0 + netifIdx, &ipaddr[netifIdx], &netmask[netifIdx], &gw[netifIdx]);
    netif_set_status_callback(g_pNetif[netifIdx], App_netifStatusChangeCb);
    netif_set_link_callback(g_pNetif[netifIdx], App_netifLinkChangeCb);
    netif_set_up(g_pNetif[NETIF_INST_ID0 + netifIdx]);
    }
    LwipifEnetApp_startSchedule(hlwipIfApp, g_pNetif[ENET_SYSCFG_DEFAULT_NETIF_IDX]);
    }

    Result:

          the computer client connects to the server and automatically disconnects after about 240 seconds, printing the following  information,It seems to have automatically changed to DHCP mode。I hope it will always be in static mode。

  • Hi,

    Can you please also comment out  App_allocateIPAddress(); function call in 

    static void App_tcpipInitCompleteCb(void *pArg)
    {
        sys_sem_t *pSem = (sys_sem_t*)pArg;
        EnetAppUtils_assert(pArg != NULL);

        /* init randomizer again (seed per thread) */
        srand((unsigned int)sys_now()/1000);

        App_setupNetif();

       // App_allocateIPAddress();

        sys_sem_signal(pSem);
    }
    This function is triggering the dhcp client process, which is allocating the static ip