lpcware

lwIP hardfault

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by tjoAG on Mon Sep 10 04:49:45 MST 2012
Dear All

I sometimes have some hard fault in the lwIP stack.
I have tried debugging it and have seen this

The hard-fault error happen in the lpc_low_level_input function line 414

<code>
/* Free pbuf from desriptor */
lpc_enetif->rxb[idx] = NULL; <-- Hard fault on this!!!
lpc_enetif->rx_free_descs++;
</code>

This only happens, if the previous call to lpc_rx_queue failed with a pbuf_alloc error

In the case the pbuf_alloc fails, no pbuf is queued. Thereby the
lpc_enetif->prxd[idx].control, lpc_enetif->rxb[idx] etc isn't set.

when the lpc_low_level_input is called again the lpc_enetif is not ready for further processing. The Ethernet frame was received but never queued and cleared?
Could that be the cause?

Should the 'lpc_low_level_input' not react to the return value of lpc_rx_queue if the frame was queued or not?

Why does pbuf_alloc fail? Does I receive to many packets to fast? It is on the local network.

I'm running in FreeRTOS

used buffers:

#define LPC_NUM_BUFF_RXDESCS 3
#define LPC_NUM_BUFF_TXDESCS 3
#define MEM_SIZE(12*1024)

Debug:

lpc_low_level_input: Packet received: 20000630, size 86 (index=1)
lpc_rxqueue_pbuf: pbuf packet queued: 20001260 (free desc=0)
lpc_low_level_input: Packet received: 20000c48, size 64 (index=2)
lpc_rxqueue_pbuf: pbuf packet queued: 20000630 (free desc=0)
......
......
lpc_rxqueue_pbuf: pbuf packet queued: 200019a8 (free desc=0)
lpc_low_level_input: Packet received: 20001390, size 64 (index=1)
lpc_rxqueue_pbuf: pbuf packet queued: 20001fc0 (free desc=0)
lpc_low_level_input: Packet received: 20000d78, size 64 (index=2)
lpc_rxqueue_pbuf: pbuf packet queued: 20001390 (free desc=0)
lpc_low_level_input: Packet received: 200019a8, size 64 (index=0)
lpc_rxqueue_pbuf: pbuf packet queued: 20000d78 (free desc=0)
ow_level_output: pbuf packet(200008aa) sent, chain#=0, size = 68 (index=0)
lpc_low_level_input: Packet received: 200019a8, size 72 (index=1)
lpc_rxqueue_pbuf: pbuf packet queued: 20000d78 (free lpc_low_level_input: Packet received: 200019a8, size 72 (index=2)
lpc_rxqueue_pbuf: pbuf packet queued: 20000d78 (free desc=0)
lpc_low_level_output: pbuf packet(20000a8a) sent, ize 72 (index=0)
lpc_rxqueue_pbuf: pbuf packet queued: 20000d78 (free desc=0)
lpc_low_level_output: pbuf packet(20000c0a) sent, chain#=0, size = 68 (index=0)
lpc_low_levw_level_input: Packet received: 20001fc0, size 72 (index=2)
lpc_rxqueue_pbuf: pbuf packet queued: 20001450 (free desc=0)
lpc_low_level_input: Packet received: 20001ac8, size 64 (index=0)
lpc_rxqueue_pbuf: pbuf packet queued: 20001450 (free desc=0)
lpc_low_level_input: Packet received: 20002140, size 64 (index=1)
lpc_rxqueue_pbuf: pbuf packet queued: 20001ac8 (free desc=0)
lpc_low_level_input: Packet received: 20002758, size 90 (index=2)
lpc_rxqueue_pbuf: pbuf packet queued: 20002140 (free desc=0)
lpc_low_level_input: Packet received: 20001450, size 64 (index=0)
lpc_rxqueue_pbuf: pbuf packet queued: 20002758 (free desc=0)
lpc_low_level_input: Packet received: 20001ac8, size 86 (index=1)
lpc_rxqueue_pbuf: pbuf packet queued: 20001450 (free desc=0)
lpc_low_level_input: Packet received: 20002140, size 64 (index=2)
lpc_rxqueue_pbuf: pbuf packet queued: 20001ac8 (free desc=0)
lpc_low_level_input: Packet received: 20002758, size 64 (index=0)
lpc_rxqueue_pbuf: pbuf packet queued: 20002140 (free desc=0)
lpc_low_level_input: Packet received: 20001450, size 256 (index=1)
lpc_rxqueue_pbuf: pbuf packet queued: 20002758 (free desc=0)
lpc_low_level_input: Packet received: 20001ac8, size 64 (index=2)
lpc_rxqueue_pbuf: pbuf packet queued: 20001450 (free desc=0)
lpc_low_level_input: Packet received: 20002140, size 64 (index=0)
lpc_rxqueue_pbuf: pbuf packet queued: 20001ac8 (free desc=0)
lpc_low_level_input: Packet received: 20002758, size 86 (index=1)
lpc_rxqueue_pbuf: pbuf packet queued: 20002140 (free desc=0)
lpc_low_level_input: Packet received: 20001450, size 64 (index=2)
lpc_rxqueue_pbuf: pbuf packet queued: 20002758 (free desc=0)
lpc_low_level_input: Packet received: 20001ac8, size 86 (index=0)
lpc_rxqueue_pbuf: pbuf packet queued: 20001450 (free desc=0)
lpc_low_level_input: Packet received: 20002140, size 72 (index=1)
lpc_rxqueue_pbuf: pbuf packet queued: 20001ac8 (free desc=0)
lpc_low_level_output: pbuf received: 20002140, size 72 (index=2)
lpc_rxqueue_pbuf: pbuf packet queued: 20001ac8 (free desc=0)
lpc_low_level_output: pbuf packet(2000102a) sent, chain#=0, size = 6 pbuf packet queued: 20001ac8 (free desc=0)
lpc_low_level_output: pbuf packet(200011aa) sent, chain#=0, size = 68 (index=1)
lpc_low_level_input: Packet received: 200lpc_low_level_output: pbuf packet(2000132a) sent, chain#=0, size = 68 (index=2)
lpc_low_level_input: Packet received: 20002758, size 72 (index=2)
lpc_rxqueue_pbuf: pbuf packet queued: 20002140 (free desc=0)
lpc_low_level_output: pbuf packet(2000138a) sent, chain#=0, size = 68 (index=0)
lpc_low_level_input: Packet received: 20001450, size 72 (index=0)
lpc_rxqueue_pbuf: pbuf packet queued: 20002758 (free desc=0)
lpc_low_level_output: pbuf packet(20001462) sent, chain#=0, size = 68 (index=1)
lpc_low_level_input: Packet received: 20001ac8, size 72 (index=1)
pc_rx_queue: could not allocate RX pbuf (free desc=1)
END OF EXECUTION: Hard fault

Next time hard fault error on:
lpc_enetif_input -> lpc_low_level_input -> lpc_enetif->rxb[idx] = NULL; (Line 414)

Thomas



Outcomes