cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 LWIP freezes after fixed send number

Kajetan.B
Associate II

I'm using nucleo f429zi with LWIP v 2.1.2. Documentation states that for TX buffer PBUF_RAM should be used. In my case whole LWIP stack freeze after 28 send messages. When I change pbuf type to PBUF_POOL, everything works like a charm. Although in the docs it written that this type should be used for RX buffer. Here is my implementation of udp callback function.

void
udp_descserver_receive_callback(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16_t port) {
 
uint8_t triesNumber = 0;
err_t error;    
udp_connect(upcb, addr, port);
pbuf_free(p);
p = NULL;
p = pbuf_alloc(PBUF_TRANSPORT, sizeof(PING_INFO), PBUF_POOL);
if(p != NULL) {
    pbuf_take(p, &pingInfo, sizeof(PING_INFO));
    do {
        error = udp_send(upcb, p);
        triesNumber++;
    } while (error && triesNumber < RESEND_TRIES);
}
pbuf_free(p);
udp_disconnect(upcb);
}

Also I get message "Assertion failed p != NULL"

My question is, why the method which is contrary to docs works.

2 REPLIES 2

Well that looks prone to die if p is NULL

I'd definitely do something different on line 17 to stop it freeing a NULL pointer.

Are the allocation routines thread safe?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Kajetan.B
Associate II

I could move line 17th inside IF statement. I think they should be I only use one thread, no OS.