I am facing a tx underrun error in lpc1768 emac driver

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I am facing a tx underrun error in lpc1768 emac driver

3,078 Views
ankish_sharma1
Contributor I

I am using lpc port for lwip2.0.1 and facing a random delay in transmission .Debugging the emac driver gives me a tx underrun bit set in the TSV0 register every time a delay occurs.Had someone experienced the same issue and is there some reliable fix for this.

Thanks

Labels (1)
0 Kudos
22 Replies

2,496 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
According to the aforementioned underrun errors description, the underrun error is mainly related to sending the unavailable-fragment, however from your reply, underrun error cause Modbus client retransmit data, actually, it should cause the Modbus server (LPC) retransmit data to Modbus client, so I'm a bit confused with it, whether you can share some comments.
In further, I was wondering if you can share the trace file of the Wireshark.

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,496 Views
ankish_sharma
Contributor I

 i can not see a trace of the outgoing packet from the server on the wireshark trace there is a retransmission from the client i am attaching the wireshark trace for analysis

Sent from Yahoo Mail on Android

On Mon, Mar 18, 2019 at 13:53, jeremyzhou<admin@community.nxp.com> wrote:

#yiv3831587256 * #yiv3831587256 a #yiv3831587256 body {font-family:Helvetica, Arial, sans-serif;}#yiv3831587256 #yiv3831587256 h1, #yiv3831587256 h2, #yiv3831587256 h3, #yiv3831587256 h4, #yiv3831587256 h5, #yiv3831587256 h6, #yiv3831587256 p, #yiv3831587256 hr {}#yiv3831587256 .yiv3831587256button td {}

|

NXP Community

|

Re: I am facing a tx underrun error in lpc1768 emac driver

reply from jeremyzhou in LPC Microcontrollers - View the full discussion

Hi,

According to the aforementioned underrun errors description, the underrun error is mainly related to sending the unavailable-fragment, however from your reply, underrun error cause Modbus client retransmit data, actually, it should cause the Modbus server (LPC) retransmit data to Modbus client, so I'm a bit confused with it, whether you can share some comments.

In further, I was wondering if you can share the trace file of the Wireshark.

Have a great day,

TIC

 

0 Kudos

2,496 Views
jeremyzhou
NXP Employee
NXP Employee

Hi ankish sharma,

I'm still analysing the attachment now, and I'll appreciate a lot if you can introduce the function about your prototype briefly, it can help me figure the 'issue' out.
Looking forward to your reply.
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,496 Views
ankish_kacktwan
Contributor I

The server is an lpc1768 cpu based modbus coupler with io modules attached

to it and uses lwip2.0 tcpip stack for communication the client is an

siemens plc which sends the modbus request with diffrent function code and

the modbus server sends the response to the Plc

0 Kudos

2,496 Views
jeremyzhou
NXP Employee
NXP Employee

Hi ankish sharma,

Thanks for your reply.
Whether the demo code pause at the breakpoint when the TCP/IP layer handles the time-out ACK event with retransmitting the segment, in trace data, as I can't find the record when the server transmits this segment data (Seq: 6185~6444).

pastedImage_3.png


Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,496 Views
ankish_sharma1
Contributor I

Hi jeremyzho,

You are right the segment is not available in the trace because it hits the underrun breakpoint before it for debugging and the wireshark trace is from the firmware without a breakpoint introduced in it for Tx underrun interrupt.

And I am wondering why the lpc lwip driver not retransmitting the segment which had caused the underrun in the driver

if you can help me on this

Mit freundlichen Grüßen

Best regards

Ankish Sharma

Software Development

Helmholz GmbH & Co. KG

Hannberger Weg 2

91091 Großenseebach

Germany

Phone: +49 9135 7380 - 0

Fax: +49 9135 7380 - 110

E-Mail: Ankish.Sharma@helmholz.de<mailto:Ankish.Sharma@helmholz.de>

Internet: www.helmholz.de<http://www.helmholz.de>;

Reg. Gericht Fürth (Bay.) HRA 10671

Persönlich haftende Gesellschafterin Helmholz Verwaltungs GmbH

Reg. Gericht Fürth (Bay.) HRB 15642

Geschäftsführer: Carsten Bokholt, Karsten Eichmüller

0 Kudos

2,496 Views
jeremyzhou
NXP Employee
NXP Employee

Hi ankish sharma ,

Thanks for your reply.
I'm not clear with your reply, whether you mean the trace is recorded in debug condition and without placing any breakpoints, is it right.
Just according to the trace, we're hard to jump to the conclusion that the issue is related to LPC driver, it may be related to Lwip library
In the current, above all, find out the rule of replicating the issue, otherwise, it's hard to think out some ideas to fix it
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,496 Views
ankish_sharma1
Contributor I

Yes the trace is without a breakpoint

But I have also sent you the internal registers screenshot which clearly shows an Tx underrun interrupt triggered causing a retransmission from the client without the packet retransmission from the

Lpc driver which should retransmit in case of a buffer underrun.

I tried to disable the EMC Burst Control as my Rx and Tx buffer and the lwip pbuf for transmission are in the external SDRAM.

It increased the time after which a tx underrun occurs but I can still see the tx underrun after 2 hours or so causing retransmission from the client.

Attaching the LPC internal registers trace in which tx underrun can be seen clearly.

Mit freundlichen Grüßen

Best regards

Ankish Sharma

Software Development

Helmholz GmbH & Co. KG

Hannberger Weg 2

91091 Großenseebach

Germany

Phone: +49 9135 7380 - 0

Fax: +49 9135 7380 - 110

E-Mail: Ankish.Sharma@helmholz.de<mailto:Ankish.Sharma@helmholz.de>

Internet: www.helmholz.de<http://www.helmholz.de>;

Reg. Gericht Fürth (Bay.) HRA 10671

Persönlich haftende Gesellschafterin Helmholz Verwaltungs GmbH

Reg. Gericht Fürth (Bay.) HRB 15642

Geschäftsführer: Carsten Bokholt, Karsten Eichmüller

0 Kudos

2,496 Views
jeremyzhou
NXP Employee
NXP Employee

Hi ankish sharma ,

Thanks for your reply.
The retransmit should be handled by TCP protocol, in another word, the Lwip is in charge of it, not the LPC driver.
It seems that the key to the issue is the cause of raise underrun error, I'm curious that whether the issue happens when doing transmitting testing on the Data Link layer instead of using the Lwip.
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,494 Views
ankish_sharma1
Contributor I

Is it possible to decrease the speed of the MII management hardware by appropriate value in the MCFG register of the MCU which is running at a Host Clock divided by 44 and the host clock is 120MHz

So it is currently running at a speed of 2.7 MHz

In order to prevent the TX Underrun

And also trying to figure out the reason for improved performance by disabling the EMC Burst

Control

Would like to mention my pbufs , TX and RX Descriptors are in the SDRAM which I believe are accessed by EMC of the CPU

Mit freundlichen Grüßen

Best regards

Ankish Sharma

Software Development

Helmholz GmbH & Co. KG

Hannberger Weg 2

91091 Großenseebach

Germany

Phone: +49 9135 7380 - 0

Fax: +49 9135 7380 - 110

E-Mail: Ankish.Sharma@helmholz.de<mailto:Ankish.Sharma@helmholz.de>

Internet: www.helmholz.de<http://www.helmholz.de>;

Reg. Gericht Fürth (Bay.) HRA 10671

Persönlich haftende Gesellschafterin Helmholz Verwaltungs GmbH

Reg. Gericht Fürth (Bay.) HRB 15642

Geschäftsführer: Carsten Bokholt, Karsten Eichmüller

0 Kudos

2,496 Views
ankish_sharma1
Contributor I

What do you mean by testing on Data Link Layer?

I am looking for an explanation for the ethernet communication process in LPC

I tried to figure out the process from the user manual of LPC 1768 but its not very clear for me to debug my issue

Which is very much related to the ethernet MAC driver

As far as I understood the transmission process it works as

/* Save size of packet, descriptor is not last */

lpc_enetif->ptxd[idx].Control = ENET_TCTRL_SIZE(q->len) | ENET_TCTRL_INT |

ENET_TCTRL_LAST;

lpc_enetif->txb[idx] = p;

Activating the packet transfer complete interrupt in control register

Also the last segment interrupt activated

lpc_enetif->ptxd[idx].Packet = (u32_t) q->payload;

Packet section is uploaded by the payload

idx = Chip_ENET_IncTXProduceIndex(LPC_ETHERNET);

and the TXProducer index is incremented to indicate the TXConsumer buffer maintained by the hardware to consume the packet and send it out on the datalink layer

and after the segment is been send by the hardware it triggers an TxDoneInt interrupt which is been handled in the ETH_IRQHandler

My question is :

If the hardware segment transfer is only triggered by increasing the producer index how is it possible than there is an TXunderrun which is according to the user manual

The transmission fragment data is not available when the Ethernet block has already

started sending the frame. This is a nonfatal error. An Underrun status will be returned

on transfer and the TxError bit in IntStatus will be set.

It will be very helpful for mw to debug this issue if you explain me these points

Mit freundlichen Grüßen

Best regards

Ankish Sharma

Software Development

Helmholz GmbH & Co. KG

Hannberger Weg 2

91091 Großenseebach

Germany

Phone: +49 9135 7380 - 0

Fax: +49 9135 7380 - 110

E-Mail: Ankish.Sharma@helmholz.de<mailto:Ankish.Sharma@helmholz.de>

Internet: www.helmholz.de<http://www.helmholz.de>;

Reg. Gericht Fürth (Bay.) HRA 10671

Persönlich haftende Gesellschafterin Helmholz Verwaltungs GmbH

Reg. Gericht Fürth (Bay.) HRB 15642

Geschäftsführer: Carsten Bokholt, Karsten Eichmüller

0 Kudos

2,496 Views
jeremyzhou
NXP Employee
NXP Employee

Hi ankish sharma ,

Thanks for your reply.
Q1) What do you mean by testing on Data Link Layer?
-- Just using the EMAC drive to handle the Ethernet transmission.
Q2) Is it possible to decrease the speed of the MII management hardware by appropriate value in the MCFG register of the MCU which is running at a Host Clock divided by 44 and the host clock is 120MHz?
-- Please give a try and tell me the testing result.

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,496 Views
ankish_sharma1
Contributor I

Hi jeremyzhou<https://community.nxp.com/people/jeremyzhou?et=watches.email.thread>,

Have tried to lower the speed of the MII management hardware without any luck on Tx Underrun

Still Tx underrun seems a mystery for me as neither you or lpc user manual have a clear explanation for the reason of TX underrun or any fix to resolve the issue

Its surely is not the issue with the upper layers as I am not getting any packet drop or any asserts in the lwip stack

Is there any document by LPC to understand the functioning of ethernet hardware block?

Can you provide me with a fix to retransmit the dropped segment by the emac so that packet lost on the transmission can be prevented?

Mit freundlichen Grüßen

Best regards

Ankish Sharma

Software Development

Helmholz GmbH & Co. KG

Hannberger Weg 2

91091 Großenseebach

Germany

Phone: +49 9135 7380 - 0

Fax: +49 9135 7380 - 110

E-Mail: Ankish.Sharma@helmholz.de<mailto:Ankish.Sharma@helmholz.de>

Internet: www.helmholz.de<http://www.helmholz.de>;

Reg. Gericht Fürth (Bay.) HRA 10671

Persönlich haftende Gesellschafterin Helmholz Verwaltungs GmbH

Reg. Gericht Fürth (Bay.) HRB 15642

Geschäftsführer: Carsten Bokholt, Karsten Eichmüller

0 Kudos

2,496 Views
jeremyzhou
NXP Employee
NXP Employee

Hi ankish sharma
Thanks for your reply.
It seems a bit weird.
I was wondering if you can share the compile-able demo (Note: Without the Lwip) which can replicate the underrun error, and introduce the process of testing, as I'd like to contact the AE team for the further checking.
In addition, whether you tell me what the transmit and receive chip you use.
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,494 Views
ankish_sharma1
Contributor I

I cant send you the demo as it is a part of a registered product

The chip I am using is an LPC1778FBD208

While debugging the issue I tried to increase the

BACK-TO-BACK INTER-PACKET-GAP and NON-BACK-TO-BACK INTER-PACKET-GAP PART2 value from default value of 0x15 and 0x12 to 0x18 and 0x13

Which is the minimum possible period between the end of any transmitted packet to the beginning of the next

And it happened to be that the TX underrun occurring period has been increased considerably from approx. 4 hrs to 10 hrs or so

But still I am getting the Tx underrun after 10 hours

Should I consider to increase the interpacket gap to counter the TX underrun error I am facing?

What impact will it make on the throughput of my system?

Kindly help me to find the right fix for this issue

Mit freundlichen Grüßen

Best regards

Ankish Sharma

Software Development

Helmholz GmbH & Co. KG

Hannberger Weg 2

91091 Großenseebach

Germany

Phone: +49 9135 7380 - 0

Fax: +49 9135 7380 - 110

E-Mail: Ankish.Sharma@helmholz.de<mailto:Ankish.Sharma@helmholz.de>

Internet: www.helmholz.de<http://www.helmholz.de>;

Reg. Gericht Fürth (Bay.) HRA 10671

Persönlich haftende Gesellschafterin Helmholz Verwaltungs GmbH

Reg. Gericht Fürth (Bay.) HRB 15642

Geschäftsführer: Carsten Bokholt, Karsten Eichmüller

0 Kudos

2,494 Views
jeremyzhou
NXP Employee
NXP Employee

Hi ankish sharma

Thanks for your reply.
Definitely, It provides a new idea to get rid of the TX underrun error, in my opinion, I'd like to increase the inter PacketGap value to do further testing, note that a transmitting sublayer uses a larger inter PacketGap will decrease its throughput.
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,496 Views
ankish_kacktwan
Contributor I

Hi I am using Lauterbach script for debugging the firmware 

It is a Modbus server communicating with a Modbus client at 100mbs ethernet link with lwip stack in it.

It works fine for couple of hours but then it shows me random delays of approximately an 1 sec which causes the Modbus client to retransmit the data

I am not getting any trace of packet drop even after debugging the lwip stack for sometime so i suspected it to be a emac driver issue so i put a break point in the ethernet port form the  Lwip demo in the LPCOpen library ethernet IRQ function where it gets the tx underun interrupt.

I have attached the Wireshark trace for the mentioned delay as well 192.168.72.1 is my Modbus client and 192.168.72.231 is my lpc 1768 Modbus server with lwip stack for tcp/ip communication. 

void ETH_IRQHandler(void)
{
#if NO_SYS == 1
 /* Interrupts are not used without an RTOS */
 NVIC_DisableIRQ(ETHERNET_IRQn);
#else
 signed portBASE_TYPE xRecTaskWoken = pdFALSE, XTXTaskWoken = pdFALSE;
 uint32_t ints;
 /* Interrupts are of 2 groups - transmit or receive. Based on the
    interrupt, kick off the receive or transmit (cleanup) task */
 /* Get pending interrupts */
 ints = Chip_ENET_GetIntStatus(LPC_ETHERNET);
 if (ints & RXINTGROUP) {
  /* RX group interrupt(s) */
  /* Give semaphore to wakeup RX receive task. Note the FreeRTOS
     method is used instead of the LWIP arch method. */
  int_rx_cnt++;
  xSemaphoreGiveFromISR(lpc_enetdata.rx_sem, &xRecTaskWoken);
 }
 if (ints & TXINTGROUP) {
  if (ints & (ENET_INT_TXUNDERRUN | ENET_INT_TXERROR))
   tx_error++;
  /* TX group interrupt(s) */
  /* Give semaphore to wakeup TX cleanup task. Note the FreeRTOS
     method is used instead of the LWIP arch method. */
  int_tx_cnt++;
  xSemaphoreGiveFromISR(lpc_enetdata.tx_clean_sem, &XTXTaskWoken);
 }
 /* Clear pending interrupts */
 Chip_ENET_ClearIntStatus(LPC_ETHERNET, ints);
 /* Context switch needed? */
 portEND_SWITCHING_ISR(xRecTaskWoken || XTXTaskWoken);
#endif
}2019-03-15 08_20_26-Greenshot.png
0 Kudos

2,496 Views
ankish_sharma
Contributor I

Yes i am using the lpcopen example as a templet for my design but still facing the random delay with tx underun interrupt set with no tx error interrupt

0 Kudos

2,496 Views
jeremyzhou
NXP Employee
NXP Employee

Hi ankish sharma

Thank you for your reply.
Whether you can upload a simplified demo which can replicate the issue, meanwhile, please introduce the testing process, as I'd like to replicate it on my site and it can help to figure the issue out.
Looking forward to your reply.

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,495 Views
jeremyzhou
NXP Employee
NXP Employee

Hi ankish sharma,

Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
The underrun error would happen by these causes, just according to your description, it's hard to say which cause you may encounter.

pastedImage_1.png
So I'd like to suggest you do more test to find the exact cause, in further, LPCOpen library has provided the Lwip demo, you can refer to it for details.

LPCOpen Software for LPC17XX | NXP 

 

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos