<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: LPC17xx lwip driver in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC17xx-lwip-driver/m-p/877109#M35082</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;Hello,&lt;/P&gt;&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;Please take a look to this document&lt;/P&gt;&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;[&lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-330815"&gt;https://community.nxp.com/docs/DOC-330815&lt;/A&gt;]&lt;/P&gt;&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;Where it gives a brief overview of how buffers are managed in the driver and the LWIP applications&lt;/P&gt;&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;Regards,&lt;/P&gt;&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;Aldo.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 12 Apr 2019 22:53:23 GMT</pubDate>
    <dc:creator>AldoG</dc:creator>
    <dc:date>2019-04-12T22:53:23Z</dc:date>
    <item>
      <title>LPC17xx lwip driver</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC17xx-lwip-driver/m-p/877108#M35081</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm facing a problem with my custom board with LPC1768 MCU. I'm using Ethernet and lwip stack.&lt;/P&gt;&lt;P&gt;It works well many times,&amp;nbsp;but now always.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm studying the module lpc17xx_40xx_emac.c and I found something strange. We have a number of TX descriptors configured by the preprocessor symbol&amp;nbsp;LPC_NUM_BUFF_TXDESCS. Suppose it is 4. Now we have two integers, consumer and producer index (cidx and pidx). They both start at zero.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the application produces a new frame, producer index is incremented in lpc_low_level_output().&lt;/P&gt;&lt;P&gt;When a frame is completely transmitted, the consumer index is automatically incremented by the MCU hw.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In lpc_low_level_output(), lpc_tx_ready() is called to read the number of free TX descriptors available. lpc_tx_ready() returns a number in the range 0..3, even if we have 4&amp;nbsp;descriptors. I think this is correct, because we can't fill all the descriptors, otherwise the wrap-around of indexes results in mathematical errors when calculating the number of free descriptors (it's a classical problem of ring buffer). We need to loose one descriptor.&lt;/P&gt;&lt;P&gt;At the beginning (cidx=pidx=0) it returns 3 free descriptors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lpc_low_level_output() blocks if there aren't free descriptors (if lpc_tx_ready() returns 0). Theorically I could call lpc_low_level_output() 100 times without problems: the function blocks until previously added descriptors are serialized out on the wire.&lt;/P&gt;&lt;P&gt;However it seems a wrong behaviour to me. We have to call lpc_tx_reclaim() in order to free the pbufs after they are transmitted.&lt;/P&gt;&lt;P&gt;If the application calls lpc_low_level_output() many consecutive times without calling lpc_tx_reclaim(), it will be able to transmit the data with success (by blocking), but we finally could have some not-freed pbufs in memory.&lt;/P&gt;&lt;P&gt;Indeed lpc_low_level_output() saves the pbufs references in&amp;nbsp;lpc_enetif-&amp;gt;txb[] array, using the produce index as the array index. Here we could overwrite previous pbufs that are really sent but not freed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my application I'm&amp;nbsp;facing a similar problem. The application (MQTT client over mbedTLS session) sends some data during TLS handshake. I noticed that under certain conditions, some pbufs aren't completely freed and remains in the heap. It seems this happen when many output packets are produced in short time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think the application is buggy. I can compile the same code with mingw in a Windows desktop machine and it works well. The only thing that changes is the Ethernet driver. The application and TCP/IP stack is identical.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2019 15:35:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC17xx-lwip-driver/m-p/877108#M35081</guid>
      <dc:creator>giusloq</dc:creator>
      <dc:date>2019-04-03T15:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: LPC17xx lwip driver</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC17xx-lwip-driver/m-p/877109#M35082</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;Hello,&lt;/P&gt;&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;Please take a look to this document&lt;/P&gt;&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;[&lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-330815"&gt;https://community.nxp.com/docs/DOC-330815&lt;/A&gt;]&lt;/P&gt;&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;Where it gives a brief overview of how buffers are managed in the driver and the LWIP applications&lt;/P&gt;&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;Regards,&lt;/P&gt;&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;Aldo.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Apr 2019 22:53:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC17xx-lwip-driver/m-p/877109#M35082</guid>
      <dc:creator>AldoG</dc:creator>
      <dc:date>2019-04-12T22:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: LPC17xx lwip driver</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC17xx-lwip-driver/m-p/877110#M35083</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I think I had the exact same problem.&lt;/P&gt;&lt;P&gt;I fixed it. Check this: &lt;A href="https://community.nxp.com/message/1280119"&gt;https://community.nxp.com/message/1280119&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sébastien&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Mar 2020 13:29:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC17xx-lwip-driver/m-p/877110#M35083</guid>
      <dc:creator>engineering1</dc:creator>
      <dc:date>2020-03-09T13:29:30Z</dc:date>
    </item>
  </channel>
</rss>

