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.

lwip saving tcp client structs to unreadable memory when I tried to port energia's ethernet code to ccs

Part Number: TM4C1294NCPDT
Other Parts Discussed in Thread: ENERGIA

Hello,

I've been trying to get tcp functionality working in code composer studio. To start off I'm simply porting energia's ethernet classes to ccs. They haven't really changed since I put them into ccs, and it compiles just fine.

Internally, it keeps track of tcp clients by having a struct array for them. When I got more than one tcp client, it would suddenly hard fault. I traced it back and found that the pbuf containing structs for some reason start using unreadable, memory mapped denied memory, so when I try to read client information out of them it throws a fault. My memory isn't too small, it's 0x10000 and 0x15000 for heap and stack. What else could cause this kind of issue?

  • The code that causes the problem is in available in this file, this line specifically after more than one client is added. The only difference between this and the one I added to ccs is that the __sync_fetch_and_null macro was removed due to relying on gcc, and it was used in a part of the code that's atomic anyway as all interrupts are disabled.

    I call it from this code, it works fine until the second client upon which the server.available() fails. 

    void roveComm_GetMsg(uint16_t* dataID, size_t* size, void* data) 
    {
      uint8_t flags = 0;
      uint16_t seqNum = 0;
      roveIP senderIP;
      EthernetClient client;
      
      *dataID = 0;
      *size = 0;
      client = tcpServer.available();
    
      if(client && client.available() != 0)
      {
        for(int i = 0; i < client.available(); i++)
        {
          RoveCommBuffer[i] = client.read();
        }
        client.stop();
        RoveCommParseMsg(RoveCommBuffer, dataID, size, data, &seqNum, &flags);
        RoveCommHandleSystemMsg(RoveCommBuffer, dataID, size, data, &seqNum, &flags, &client);
      }
      else if (roveEthernet_GetUdpMsg(&senderIP, RoveCommBuffer, sizeof(RoveCommBuffer)) == ROVE_ETHERNET_ERROR_SUCCESS)
      {
        RoveCommParseMsg(RoveCommBuffer, dataID, size, data, &seqNum, &flags);  
        RoveCommHandleSystemMsg(RoveCommBuffer, dataID, size, data, &seqNum, &flags, senderIP);
      }
    }

  • Hello Drue,

    We have LWIP examples included as part of TivaWare examples, why are those not usable for you?

    We aren't really in position to support a project that came out of Energia as in our TM4C team we know nothing about that platform. Also we don't have much knowledge of lwip beyond what our TivaWare examples provide. So because of this, if you don't use the TivaWare examples, I don't think we can help you with the issue you are facing...