I'm using lwIP 2.1.2 on an LPC1766. I adapted the lwIP EMAC driver code from lpcopen_2_10_keil_iar_nxp_lpcxpresso_1769.
I've been having an issue where sometimes the Ethernet RX locks up — the processor's Ethernet MAC just stops receiving any packets, even though everything still appears to be configured normally in the MAC registers.
I tracked down the bug to the lwIP driver file lpc17xx_40xx_emac.c, function lpc_low_level_input(). The problem is the line:
p->len = (u16_t) length;
If the following if statement triggers (that is, if it is unable to allocate a new pbuf to replace the one just being taken for this received packet, due to low memory):
if (lpc_rx_queue(lpc_enetif->pnetif) == 0) {
then it re-queues the current pbuf:
lpc_rxqueue_pbuf(lpc_enetif, p);
However, because of the previous line that sets p->len to the length of this received packet, the pbuf now has a shorter length (the length of the packet just received), rather than its original length of ENET_ETH_MAX_FLEN. This means this pbuf is now unable to receive longer packets.
Once that bug happens a few times while receiving short packets, RX is effectively crippled in its ability to receive longer packets, and Ethernet RX effectively halts.
The fix is to move the line
p->len = (u16_t) length;
to be just below the comment:
/* Save size */
ie where it also sets p->tot_len to the length.