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.

CCS/EK-TM4C1294XL: why enet_lwip memory pointer is not fixed?

Part Number: EK-TM4C1294XL

Tool/software: Code Composer Studio

Hi

I'm working on the Ethernet port of the board EK-TM4C1294XL and I have configured it using 

#include "lwip/opt.h"
#include "lwip/debug.h"
#include "lwip/stats.h"
#include "lwip/tcp.h"

same as used in the board example " enet_lwip ", my problem with the read received packet data pointer is not fixed location in memory but always changing with increment & decrement (loop change).

So when i want to process the receive data, some time I fail because I look every time at the same memory pointer while every data packet received the actual memory  pointer of data changed.

BR

Hani

  • Hi,

      I'm not clear with your question. When you run the enet_lwip as is, do you see the same problem that you described? Perhaps you can post the code snippet to elaborate the problem. I'm not sure what the problem is. Can you play with the heap size and stack size and see if it makes a difference.? Below are the default. You can change them.

  • Hello Charles

    I played around the heap & stack sizes (1024 & 4096 respectively) in the options with same result, also i found wear thing that despite the heap size was zero, the compiler set value for it and assign memory space in the RAM as in the picture below, also i'm attaching a print screen from the code which i use to catch the data pointer from Ethernet packet.

    Note: my experience with Ethernet data format is very little.

    // heap print screen despite it's configured to zero size.

    // code print screen

  • Hi,

      You code seems to have some similarity to the example created by Adam_Dunkels. See below code snippet and the link to the source file. If you use Adam Dunkels's code as it, do you see problem. You also said you referenced the enet_lwip. Do you see the same problem running the example?

    http://cvs.savannah.gnu.org/viewvc/lwip/contrib/apps/tcpecho_raw/echo.c?revision=1.3&view=markup

    void
    echo_send(struct tcp_pcb *tpcb, struct echo_state *es)
    {
      struct pbuf *ptr;
      err_t wr_err = ERR_OK;
     
      while ((wr_err == ERR_OK) &&
             (es->p != NULL) && 
             (es->p->len <= tcp_sndbuf(tpcb)))
      {
      ptr = es->p;
    
      /* enqueue data for transmission */
      wr_err = tcp_write(tpcb, ptr->payload, ptr->len, 1);
      if (wr_err == ERR_OK)
      {
         u16_t plen;
          u8_t freed;
    
         plen = ptr->len;
         /* continue with next pbuf in chain (if any) */
         es->p = ptr->next;
         if(es->p != NULL)
         {
           /* new reference! */
           pbuf_ref(es->p);
         }
         /* chop first pbuf from chain */
          do
          {
            /* try hard to free pbuf */
            freed = pbuf_free(ptr);
          }
          while(freed == 0);
         /* we can read more data now */
         tcp_recved(tpcb, plen);
       }
       else if(wr_err == ERR_MEM)
       {
          /* we are low on memory, try later / harder, defer to poll */
         es->p = ptr;
       }
       else
       {
         /* other problem ?? */
       }
      }

    You can look at the .map file to see what symbols are being allocated at these RAM locations in your screenshot. You look like you are creating Modbus over TCP. We don't have any expertise and examples with Modbus. If you are using the Modbus library from some other vendor I will suggest you contact them and also LwIP forum for support. At this moment, I don't think your problem is related to the heap size since you have played with them and has no effect. 

  • Hello Charles

    Thanks for your support, the problem was in my Modbus API program.

    BR

    Hani