Content originally posted in LPCWare by wellsk on Thu Jul 05 12:36:28 MST 2012
Hi Thomas,
Forget anything I ever said about the PRAM, your are right here, your memory is setup correctly. Sorry about going in the wrong direction here.
>The MCU is the LPC1788 FBD208 with 512 kB flash
I was interested in the device number to get an idea of how much internal memory was supported. The following debug messages...
<code>
lpc_low_level_input: Packet dropped with errors (0xffffffff)
</code>
...usually occur when buffers are attempted to be used with memory that cannot be used for DMA with Ethernet and were pre-populated with 0xFF's. I don't think this is the case here, but just wanted to make sure there was enough memory mapped there. There is probably enough memory, I think your ok here.
>In KEIL it is possible to memory assign C-files to specific regions in memory from within the GUI. Isn't that the same as set it in a scatter file?
With the 17xx, to get the most out of internal IRAM, you'll need to use a scatter file. For RW/ZI data is assigned to IRAM that can't be used for DMA. pbufs, memory allocaiton, descriptors/buffers are assigned to DMA-capable IRAM. For the 18xx/43xx, the dialog can be used.
>Would it be an idea to move the lpc17_emac.0 to address 0xA0000000 in external SDRAM to see if that helps? (I would like using the PRAM because of the speed)
Probably not unless you really need the extra memory, I don't think the issue is memory or placement related.
>Even if the received packet is badly corrupted, why is result a missing ref count in a structure? Receiving corrupted frames will eventually happen on a network::
This is a legitimate bug. I *can* repeat this issue here, and will provide a fix (see below) for this. This issue occurs when a RX packet fails, the RX packet queue is reset, and a non-NULL pointer is returned to the caller in this condition. When this failure occurs, the input function is supposed to return a NULL pointer indicating the failure, but this seems to have been missed. The fix is below (see update line):
<code>
LWIP_DEBUGF(UDP_LPC_EMAC | LWIP_DBG_TRACE,
("lpc_low_level_input: Packet dropped with errors (0x%x)\n",
lpc_enetif->prxs[idx].statusinfo));
p = NULL; /* UPDATE: Add this line to return NULL on failure */
} else {
/* A packet is waiting, get length */
length = (lpc_enetif->prxs[idx].statusinfo & 0x7FF) + 1;
</code>
A big thanks for helping to identify this issue! But this won't specifically fix the issue you are seeing, which is non-reception of packets (and possibly no transmit of packets). The incoming packet status (lpc_low_level_input: Packet dropped with errors (0xffffffff)) for you indicates something is wrong somewhere. You mentioned earlier you were using high-speed buffers for the MII signals? I'm not sure this is really needed and may be causing problems with clock skew between the chip/PHY. It may be something to check - youu might try pulling the buffer and routing jumpers instead to see it it helps.
I ran your posted configurations on my EA1788 board with the FLASH variant, Keil toolchain, and the TCP Echo standalone example.
Here is what I see via debug with your attached configuration. It seems to run fine.
<code>
Starting LWIP TCP echo server...
pbuf_alloc(length=1536)
pbuf_alloc(length=1536) == 20000118
lpc_rxqueue_pbuf: pbuf packet queued: 20000118 (free desc=7)
pbuf_alloc(length=1536)
pbuf_alloc(length=1536) == 20000730
lpc_rxqueue_pbuf: pbuf packet queued: 20000730 (free desc=6)
pbuf_alloc(length=1536)
pbuf_alloc(length=1536) == 20000d48
lpc_rxqueue_pbuf: pbuf packet queued: 20000d48 (free desc=5)
pbuf_alloc(length=1536)
pbuf_alloc(length=1536) == 20001360
lpc_rxqueue_pbuf: pbuf packet queued: 20001360 (free desc=4)
pbuf_alloc(length=1536)
pbuf_alloc(length=1536) == 20001978
lpc_rxqueue_pbuf: pbuf packet queued: 20001978 (free desc=3)
pbuf_alloc(length=1536)
pbuf_alloc(length=1536) == 20001f90
lpc_rxqueue_pbuf: pbuf packet queued: 20001f90 (free desc=2)
pbuf_alloc(length=1536)
pbuf_alloc(length=1536) == 200025a8
lpc_rxqueue_pbuf: pbuf packet queued: 200025a8 (free desc=1)
pbuf_alloc(length=1536)
pbuf_alloc(length=1536) == 20002bc0
lpc_rxqueue_pbuf: pbuf packet queued: 20002bc0 (free desc=0)
pbuf_alloc(length=308)
pbuf_alloc(length=308) == 2000321c
pbuf_header: old 20003264 new 2000325c (8)
pbuf_header: old 2000325c new 20003248 (20)
ip_output_if: en0
IP header:
+-------------------------------+
| 4 | 5 | 0x00 | 336 | (v, hl, tos, len)
+-------------------------------+
| 0 |000| 0 | (id, flags, offset)
+-------------------------------+
| 255 | 17 | 0xba9d | (ttl, proto, chksum)
+-------------------------------+
| 0 | 0 | 0 | 0 | (src)
+-------------------------------+
| 255 | 255 | 255 | 255 | (dest)
+-------------------------------+
netif->output()pbuf_free(2000321c)
pbuf_free: deallocating 2000321c
pbuf_alloc(length=308)
pbuf_alloc(length=308) == 2000321c
pbuf_header: old 20003264 new 2000325c (8)
pbuf_header: old 2000325c new 20003248 (20)
ip_output_if: en0
IP header:
+-------------------------------+
| 4 | 5 | 0x00 | 336 | (v, hl, tos, len)
+-------------------------------+
| 1 |000| 0 | (id, flags, offset)
+-------------------------------+
| 255 | 17 | 0xba9c | (ttl, proto, chksum)
+-------------------------------+
| 0 | 0 | 0 | 0 | (src)
+-------------------------------+
| 255 | 255 | 255 | 255 | (dest)
+-------------------------------+
netif->output()pbuf_header: old 20003248 new 2000323a (14)
lpc_low_level_output: pbuf packet(2000323a) sent, chain#=0, size = 350 (index=0)
pbuf_free(2000321c)
pbuf_free: 2000321c has ref 1, ending here.
pbuf_alloc(length=42)
pbuf_alloc(length=42) == 200033a0
lpc_low_level_output: pbuf packet(200033b0) sent, chain#=0, size = 42 (index=1)
pbuf_free(200033a0)
pbuf_free: 200033a0 has ref 1, ending here.
lpc_low_level_input: Packet received: 20000118, size 594 (index=0)
pbuf_alloc(length=1536)
pbuf_alloc(length=1536) == 200033e4
lpc_rxqueue_pbuf: pbuf packet queued: 200033e4 (free desc=0)
pbuf_header: old 20000128 new 20000136 (-14)
ip_input: iphdr->dest 0x200a010a netif->ip_addr 0x0 (0x0, 0x0, 0x200a010a)
ip_input: UDP packet to DHCP client port 68
ip_input: DHCP packet accepted.
ip_input:
IP header:
+-------------------------------+
| 4 | 5 | 0x00 | 576 | (v, hl, tos, len)
+-------------------------------+
| 0 |000| 0 | (id, flags, offset)
+-------------------------------+
| 64 | 17 | 0x508b | (ttl, proto, chksum)
+-------------------------------+
| 10 | 1 | 10 | 1 | (src)
+-------------------------------+
| 10 | 1 | 10 | 32 | (dest)
+-------------------------------+
ip_input: p->len 576 p->tot_len 576
pbuf_header: old 20000136 new 2000014a (-20)
pbuf_header: old 2000014a new 20000152 (-8)
pbuf_alloc(length=308)
pbuf_alloc(length=308) == 20000380
pbuf_header: old 200003c8 new 200003c0 (8)
pbuf_header: old 200003c0 new 200003ac (20)
ip_output_if: en0
IP header:
+-------------------------------+
| 4 | 5 | 0x00 | 336 | (v, hl, tos, len)
+-------------------------------+
| 2 |000| 0 | (id, flags, offset)
+-------------------------------+
| 255 | 17 | 0xba9b | (ttl, proto, chksum)
+-------------------------------+
| 0 | 0 | 0 | 0 | (src)
+-------------------------------+
| 255 | 255 | 255 | 255 | (dest)
+-------------------------------+
netif->output()pbuf_header: old 200003ac new 2000039e (14)
lpc_low_level_output: pbuf packet(2000039e) sent, chain#=0, size = 350 (index=2)
pbuf_free(20000380)
pbuf_free: 20000380 has ref 1, ending here.
pbuf_free(20000118)
pbuf_free: deallocating 20000118
lpc_tx_reclaim_st: Freeing packet 2000321c (index 0)
pbuf_free(2000321c)
pbuf_free: deallocating 2000321c
lpc_tx_reclaim_st: Freeing packet 200033a0 (index 1)
pbuf_free(200033a0)
pbuf_free: deallocating 200033a0
lpc_tx_reclaim_st: Freeing packet 20000380 (index 2)
pbuf_free(20000380)
pbuf_free: deallocating 20000380
lpc_low_level_input: Packet received: 20000730, size 594 (index=1)
pbuf_alloc(length=1536)
pbuf_alloc(length=1536) == 20000118
lpc_rxqueue_pbuf: pbuf packet queued: 20000118 (free desc=0)
pbuf_header: old 20000740 new 2000074e (-14)
ip_input: iphdr->dest 0x200a010a netif->ip_addr 0x0 (0x0, 0x0, 0x200a010a)
ip_input: UDP packet to DHCP client port 68
ip_input: DHCP packet accepted.
ip_input:
IP header:
+-------------------------------+
| 4 | 5 | 0x00 | 576 | (v, hl, tos, len)
+-------------------------------+
| 0 |000| 0 | (id, flags, offset)
+-------------------------------+
| 64 | 17 | 0x508b | (ttl, proto, chksum)
+-------------------------------+
| 10 | 1 | 10 | 1 | (src)
+-------------------------------+
| 10 | 1 | 10 | 32 | (dest)
+-------------------------------+
ip_input: p->len 576 p->tot_len 576
pbuf_header: old 2000074e new 20000762 (-20)
pbuf_header: old 20000762 new 2000076a (-8)
pbuf_alloc(length=42)
pbuf_alloc(length=42) == 20000998
lpc_low_level_output: pbuf packet(200009a8) sent, chain#=0, size = 42 (index=3)
pbuf_free(20000998)
pbuf_free: 20000998 has ref 1, ending here.
pbuf_free(20000730)
pbuf_free: deallocating 20000730
lpc_tx_reclaim_st: Freeing packet 20000998 (index 3)
pbuf_free(20000998)
pbuf_free: deallocating 20000998
pbuf_alloc(length=42)
pbuf_alloc(length=42) == 20000730
lpc_low_level_output: pbuf packet(20000740) sent, chain#=0, size = 42 (index=0)
pbuf_free(20000730)
pbuf_free: 20000730 has ref 1, ending here.
lpc_tx_reclaim_st: Freeing packet 20000730 (index 0)
pbuf_free(20000730)
pbuf_free: deallocating 20000730
lpc_low_level_input: Packet received: 20000d48, size 96 (index=2)
pbuf_alloc(length=1536)
pbuf_alloc(length=1536) == 20000730
lpc_rxqueue_pbuf: pbuf packet queued: 20000730 (free desc=0)
pbuf_header: old 20000d58 new 20000d66 (-14)
ip_input: iphdr->dest 0xff0a010a netif->ip_addr 0x200a010a (0xa010a, 0xa010a, 0xff000000)
ip_input: packet accepted on interface en
ip_input:
IP header:
+-------------------------------+
| 4 | 5 | 0x00 | 78 | (v, hl, tos, len)
+-------------------------------+
| 0 |010| 0 | (id, flags, offset)
+-------------------------------+
| 64 | 17 | 0x118b | (ttl, proto, chksum)
+-------------------------------+
| 10 | 1 | 10 | 20 | (src)
+-------------------------------+
| 10 | 1 | 10 | 255 | (dest)
+-------------------------------+
ip_input: p->len 78 p->tot_len 78
pbuf_header: old 20000d66 new 20000d7a (-20)
pbuf_free(20000d48)
pbuf_free: deallocating 20000d48
lpc_low_level_input: Packet received: 20001360, size 64 (index=3)
pbuf_alloc(length=1536)
pbuf_alloc(length=1536) == 20000d48
lpc_rxqueue_pbuf: pbuf packet queued: 20000d48 (free desc=0)
pbuf_free(20001360)
pbuf_free: deallocating 20001360
</code>