Skip to main content
Daniel Beyzade
Associate
January 6, 2017
Solved

STM32F107VC LWIP DHCP / TCP / UDP Input Issue

  • January 6, 2017
  • 1 reply
  • 1130 views
Posted on January 06, 2017 at 12:15

Hello,

I am using a custom board with a STM32F107VC processor. I am trying to get LWIP working in combination with FREERTOS. I am building using STM32Cube and importing into STM32 System Workbench,

I can see DHCP packets being sent from my controller, arriving on the network (seen via wireshark). My DHCP server responds, but the micro controller does not seem to be able to process the message correctly.

I can see that the tcpip_input thread is being called because I can put a breakpoint into it. This then progress into sys_mbox_trypost() which seems to be failing with a -1 ERR_MEM which has a note above it 'could not post, queue must be full'

Does anyone have any idea what the issue may be?

Thank you

Daniel

    This topic has been closed for replies.
    Best answer by Daniel Beyzade
    Posted on January 07, 2017 at 00:43

    Actually the issue was that the main LWIP tcpip thread was not starting with and errored -1 out of memory message. Therefore the mailbox was not processed and after several incoming packets was full.

    Fixed by increasing heap in linker as follows:

    _Min_Heap_Size = 0x2000; /* required amount of heap */

    _Min_Stack_Size = 0x400; /* required amount of stack */

    Why STM32Cube isn't doing this... who knows

    Now I get DHCP. Ping and can open TCP server socket 

    Daniel 

    1 reply

    Mohamed Fakhfakh
    Associate
    January 6, 2017
    Posted on January 06, 2017 at 22:55

    It's clear that you don't have enaugh space in the queue.

    Check that you have defined in lwipopts.h :

    TCPIP_MBOX_SIZE

    DEFAULT_UDP_RECVMBOX_SIZE

    DEFAULT_TCP_RECVMBOX_SIZE

    DEFAULT_ACCEPTMBOX_SIZE

    with enaugh size.

    eg :

    #define TCPIP_MBOX_SIZE                           64

    #define DEFAULT_UDP_RECVMBOX_SIZE

    64

    #define DEFAULT_TCP_RECVMBOX_SIZE

    64

    #define DEFAULT_ACCEPTMBOX_SIZE     

    64

    if they are present and the size is high, check the sys_mbox_t sys_mbox_new(int size) function declaration. If you are not using the size argument that means that you are not using those defines. if so, call xQueueCreate using size.

    Daniel Beyzade
    Daniel BeyzadeAuthorBest answer
    Associate
    January 7, 2017
    Posted on January 07, 2017 at 00:43

    Actually the issue was that the main LWIP tcpip thread was not starting with and errored -1 out of memory message. Therefore the mailbox was not processed and after several incoming packets was full.

    Fixed by increasing heap in linker as follows:

    _Min_Heap_Size = 0x2000; /* required amount of heap */

    _Min_Stack_Size = 0x400; /* required amount of stack */

    Why STM32Cube isn't doing this... who knows

    Now I get DHCP. Ping and can open TCP server socket 

    Daniel