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.

TM4C1294KCPDT: TCP Receive payload issue

Part Number: TM4C1294KCPDT


Hi,

I'm trying to implement a HTTPS Post on Tiva C Using MbedTLS and non-OS based system. I'm using LwIP.

I'm able to post the data and see the result on the server end but after a successful post the tcp receive callback function is receiving a buffer in which the payload is pointing to memory location of ResetISR and the next payload in the same buffer is pointing to a unknown memory location due to which I'm receiving a bus fault and my processor goes into fault ISR.

Can anyone help me understand what is going on and why this is happening?

This is the screenshot of the buffer

0x00063341 is the location of ResetISR which I could see on Memory Browser.

next->payload is pointing to 0x56BDFCD6

Regards,

Deepak

  • Hi,

      Can you increase the stack size and see if that makes a difference? Try with 2x of your current stack size and see if the fault goes away. 

  • Deepak Rai said:
    Can anyone help me understand what is going on and why this is happening?

    Perhaps the receiver is being overrun, datasheet register DMARIS status bits often indicate what kind of abnormal interrupt event occurred. 

  • I tried to increase the size but i'm getting an error 

    error #10099-D: program will not fit into available memory. run placement with alignment fails for section "DATA_GROUP" size 0x1ad3 . Available memory ranges:
    SRAM size: 0x40000 unused: 0x1a7d max hole: 0x1a78

    I tried increasing my Heap and it resolves the problem momentarily but again after some time i get a fault.

    Is there a way to check what my memory is getting used for? I didnt write the whole code base that i have. i'm just trying to add some functionality so i want to know the memory usage.

    Regards,

    Deepak

  • You might have a memory leak somewhere. The SRAM is 256k and you seem to use most of it. You have 0x1a7d bytes of SRAM memory space left. When you increase the heap it fail because there is not enough dynamic memory left. Not sure if your problem is due to your MbedTLS. You might want to first remove the MbedTLS and see if you are getting any issue with just the lwip TCP/IP. We have no experience with the 3rd party MbedTLS. There is not much I can help here. I think you can get better assistance the your MbedTLS  vendor.  

      You can check the .map file to find the allocation of the code/data. 

  • Hi Charles,

    In memory allocation I can see that 96% of SRAM is being used.

    And without MbedTLS, 85% is being used which i feel is still very high. Yeah i'm not facing this issue at that point but i wanna know how can I reduce it. 

    Without MbedTLS, .bss is using 216k out of which I can see 

    .bss:ram_heap(mem.obj) is 131k 

    .bss:memp_memory_PBUF_POOL_base is 66K

    these two are using most of the ram which have nothing to do with MbedTLS.

    Regards,

    Deepak

  • This link about LwIP dynamic memory management may be of some help. https://lwip.fandom.com/wiki/Lwipopts.h

    Did you set the MEM_LIBC_MALLOC to 1 or you are using the LwiP's custom heap management? If you have MEM_LIBC_MALLOC  un-commented and set to 1, I will suggest you comment the #define and see it makes a difference. 

    did you change the lwipopts.h by any chance? 

  • This is my Memory options in lwipopts.h

    // ---------- Memory options ----------
    //
    //*****************************************************************************
    //#define MEM_LIBC_MALLOC 0
    #define MEM_ALIGNMENT 4
    #define MEM_SIZE (128 * 1024)// (128 * 1024)
    //#define MEMP_OVERFLOW_CHECK 0
    //#define MEMP_SANITY_CHECK 0
    //#define MEM_USE_POOLS 0
    //#define MEMP_USE_CUSTOM_POOLS 0

    As you can see MEM_LIBC_MALLOC  is commented out. My MEM_SIZE is what 131k I can see in my memory browser.

    Can I reduce it? And will that be a negative impact on  my code?

    Regards,

    Deepak

  • Now that kind of explain why you have a large heap size usage. The TivaWare Ethernet example only uses 64x1024. You can reduce it to the same as the example and see if that makes a difference?

    Below is the lwipopts.h for the TivaWare enet_io.c example. 

    //*****************************************************************************
    //
    // ---------- Memory options ----------
    //
    //*****************************************************************************
    //#define MEM_LIBC_MALLOC                 0
    #define MEM_ALIGNMENT                   4           // default is 1
    #define MEM_SIZE                        (64 * 1024)  // default is 1600
    //#define MEMP_OVERFLOW_CHECK             0
    //#define MEMP_SANITY_CHECK               0
    //#define MEM_USE_POOLS                   0
    //#define MEMP_USE_CUSTOM_POOLS           0
    
    //*****************************************************************************
    //
    // ---------- Internal Memory Pool Sizes ----------
    //
    //*****************************************************************************
    #define MEMP_NUM_PBUF                     48    // Default 16
    //#define MEMP_NUM_RAW_PCB                4
    //#define MEMP_NUM_UDP_PCB                4
    #define MEMP_NUM_TCP_PCB                  16    // Default 5
    //#define MEMP_NUM_TCP_PCB_LISTEN         8
    #define MEMP_NUM_TCP_SEG                  32  // Default 16
    //#define MEMP_NUM_REASSDATA              5
    //#define MEMP_NUM_ARP_QUEUE              30
    //#define MEMP_NUM_IGMP_GROUP             8
    #define MEMP_NUM_SYS_TIMEOUT              8
    //#define MEMP_NUM_NETBUF                 2
    //#define MEMP_NUM_NETCONN                4
    //#define MEMP_NUM_TCPIP_MSG_API          8
    //#define MEMP_NUM_TCPIP_MSG_INPKT        8
    #define PBUF_POOL_SIZE                    48    // Default 16

  • Hi Charles,

    I decreased the MEM_SIZE and now I have the SRAM available but still I'm facing that issue. 

    Sometimes it works perfectly fine and sometimes still the tcp payload points to an undefined location.

    I have tried changing the stack size and heap  and i'm unable to find the reason for such behavior. 

    Do you have any idea about why this is happening?

    regards,

    Deepak

  • How did you change the stack size?

    Did you change in both areas like below example?

     Other than the stack size I really don't know what could have caused your problem. Normally, the hard fault is mostly related to insufficient stack. Looks like not in your case unless you didn't increase stack size correctly. Please note that our expertise is not on the 3rd party software such as LwIp.  In the meantime, i will suggest you follow this app note http://www.ti.com/lit/an/spma043/spma043.pdf to diagnose the hard fault problem.