<?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 USB_DeviceCdcAcmEndpointsInit() ignores failures in MCUXpresso SDK</title>
    <link>https://community.nxp.com/t5/MCUXpresso-SDK/USB-DeviceCdcAcmEndpointsInit-ignores-failures/m-p/852684#M1194</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This could be considered both a documentation issue and a programming deficiency.&amp;nbsp; I've got a composite CDC + MSD device that was failing because the endpoint callback array wasn't large enough.&amp;nbsp; The configuration macro USB_DEVICE_CONFIG_ENDPOINTS sets the number of endpoints supported, but what's not mentioned directly in the docs is that it also determines the maximum endpoint&amp;nbsp;&lt;EM&gt;number&lt;/EM&gt;.&amp;nbsp; In this case there were 5 endpoints configured with the highest being numbered 5.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The USB_DeviceInitEndpoint() function does check for this condition at runtime, and returns an error.&amp;nbsp; The documentation is not right (emphasis mine):&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;kStatus_USB_Invalid-Parameter:&amp;nbsp;The epInit or epCallback is NULL pointer. Or the endpoint number &lt;STRONG&gt;is more&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;than&lt;/STRONG&gt; USB_DEVICE_CONFIG_ENDPOINTS&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;...but the code is, and it returns an error if the endpoint number is&amp;nbsp;&lt;EM&gt;not less than&lt;/EM&gt; the configured maximum.&amp;nbsp; The coding issue is in usb_device_cdc_acm.c:&amp;nbsp;&amp;nbsp;USB_DeviceCdcAcmEndpointsInit() takes the error code but doesn't check it, doesn't stop processing endpoints, and then overwrites the error code when it moves on to the interface initialization.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not a biggie, but if anyone's taking bug reports, there you go.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 25 Mar 2019 16:27:04 GMT</pubDate>
    <dc:creator>scottm</dc:creator>
    <dc:date>2019-03-25T16:27:04Z</dc:date>
    <item>
      <title>USB_DeviceCdcAcmEndpointsInit() ignores failures</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/USB-DeviceCdcAcmEndpointsInit-ignores-failures/m-p/852684#M1194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This could be considered both a documentation issue and a programming deficiency.&amp;nbsp; I've got a composite CDC + MSD device that was failing because the endpoint callback array wasn't large enough.&amp;nbsp; The configuration macro USB_DEVICE_CONFIG_ENDPOINTS sets the number of endpoints supported, but what's not mentioned directly in the docs is that it also determines the maximum endpoint&amp;nbsp;&lt;EM&gt;number&lt;/EM&gt;.&amp;nbsp; In this case there were 5 endpoints configured with the highest being numbered 5.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The USB_DeviceInitEndpoint() function does check for this condition at runtime, and returns an error.&amp;nbsp; The documentation is not right (emphasis mine):&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;kStatus_USB_Invalid-Parameter:&amp;nbsp;The epInit or epCallback is NULL pointer. Or the endpoint number &lt;STRONG&gt;is more&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;than&lt;/STRONG&gt; USB_DEVICE_CONFIG_ENDPOINTS&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;...but the code is, and it returns an error if the endpoint number is&amp;nbsp;&lt;EM&gt;not less than&lt;/EM&gt; the configured maximum.&amp;nbsp; The coding issue is in usb_device_cdc_acm.c:&amp;nbsp;&amp;nbsp;USB_DeviceCdcAcmEndpointsInit() takes the error code but doesn't check it, doesn't stop processing endpoints, and then overwrites the error code when it moves on to the interface initialization.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not a biggie, but if anyone's taking bug reports, there you go.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Mar 2019 16:27:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/USB-DeviceCdcAcmEndpointsInit-ignores-failures/m-p/852684#M1194</guid>
      <dc:creator>scottm</dc:creator>
      <dc:date>2019-03-25T16:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: USB_DeviceCdcAcmEndpointsInit() ignores failures</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/USB-DeviceCdcAcmEndpointsInit-ignores-failures/m-p/852685#M1195</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 Scott,&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;Thank you for the report,&lt;/P&gt;&lt;P style="margin: 0in; font-family: Calibri; font-size: 11.0pt;"&gt;I'll inform the SDK team about this.&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;Best 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>Thu, 28 Mar 2019 02:45:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/USB-DeviceCdcAcmEndpointsInit-ignores-failures/m-p/852685#M1195</guid>
      <dc:creator>AldoG</dc:creator>
      <dc:date>2019-03-28T02:45:58Z</dc:date>
    </item>
  </channel>
</rss>

