<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>USB COM CDC on android</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/52727/usb-com-cdc-on-android</link><description>Hi everyone! 
 I have recently implemented USB CDC on a custom NRF52840 device with SDK 15.0 and got it to work with Windows, Mac, and Linux OS. However, when I try it on an Android device I can&amp;#39;t seem to get it to connect and send/receive any data. I</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 01 Oct 2019 10:03:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/52727/usb-com-cdc-on-android" /><item><title>RE: USB COM CDC on android</title><link>https://devzone.nordicsemi.com/thread/212765?ContentTypeID=1</link><pubDate>Tue, 01 Oct 2019 10:03:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:561aa09e-7a7e-444d-a199-495303eb333f</guid><dc:creator>Hadi Deknache</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I have went further with debugging the application and can&amp;#39;t seem to get it to work. I have a question regarding&amp;nbsp; how to get it to communicate with an Android device.&lt;/p&gt;
&lt;p&gt;Do I need to init nrf_drv_clock and enable power event handler in order to connect to device on android?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Currently I run these two functions after I have initialized usbd_init:&lt;/p&gt;
&lt;p&gt;app_usbd_enable();&lt;br /&gt; app_usbd_start();&lt;/p&gt;
&lt;p&gt;But the custom board can&amp;#39;t connect to my android device&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;I found the problem !&lt;/p&gt;
&lt;p&gt;Somehow the defined interface for the&amp;nbsp;HID and CDC&amp;nbsp;was not valid, had to change them to:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * @brief USB cdc interfaces
 */

#define CDC_ACM_COMM_INTERFACE  0
#define CDC_ACM_COMM_EPIN       NRF_DRV_USBD_EPIN2

#define CDC_ACM_DATA_INTERFACE  1
#define CDC_ACM_DATA_EPIN       NRF_DRV_USBD_EPIN1
#define CDC_ACM_DATA_EPOUT      NRF_DRV_USBD_EPOUT1

/**
 * @brief USB composite interfaces
 */
#define APP_USBD_INTERFACE_KBD   3
#define HID_COMM_EPIN NRF_DRV_USBD_EPIN3&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;/Hadi&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB COM CDC on android</title><link>https://devzone.nordicsemi.com/thread/212621?ContentTypeID=1</link><pubDate>Mon, 30 Sep 2019 13:22:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1669b076-39e0-439a-9d74-e02f0b87bcd2</guid><dc:creator>Hadi Deknache</dc:creator><description>&lt;p&gt;Thank you for your help!&lt;/p&gt;
&lt;p&gt;Yes exactly, sorry forgot to mention that we are using BLE+Composite(CDC+HID) together.&lt;/p&gt;
[quote userid="15146" url="~/f/nordic-q-a/52727/usb-com-cdc-on-android/212607"]PS; If you are on SDK 15.0, take look at &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/34605/usb-not-enumerating-after-reset/133051#133051"&gt;this post&lt;/a&gt;.)[/quote]
&lt;p&gt;I looked in the file and it seems that this is already changed to 0x20 as it should be.&lt;/p&gt;
&lt;p&gt;I have added the preprocessor flag to my makefile and compiled it but do not get the fatal error print anymore, but seem like it still is stuck at the same place as it is not continuing.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Tried with segger instead and get the following error in nrf_drv_power (DEADBEEF):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;error&amp;gt; app: ERROR 3735928559 [Unknown error code] at /home/dek/bitbucket/nRF52_DK/sdk/nRF5_SDK_15.0.0_a53641a/integration/nrfx/legacy/nrf_drv_power.c:352
PC at: 0x0003A403
&amp;lt;error&amp;gt; app: End of error report
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Seem like it is failing on this step according to the error above:&amp;nbsp;&lt;strong&gt;ASSERT(m_initialized); /* This module has to be enabled first */&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Seem like the error is triggered when changing the values in sdk_config, it is not triggered from nrf_drv_clock or&amp;nbsp;&lt;span&gt;app_usbd_power_events_enable fucntion call. Am I missing something when changing the POWER_ENABLE,&amp;nbsp;&lt;/span&gt;APP_USBD_CONFIG_POWER_EVENTS_PROCESS, etc.. in sdk_config???&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;UPDATE 2:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Further debugging with segger shows that the application fails at this step:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;sdh_state_observer_notify(NRF_SDH_EVT_STATE_ENABLED);&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Is it RAM that has to be increased?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/* Linker script to configure memory regions.  */

SEARCH_DIR(.)
GROUP(-lgcc -lc -lnosys)

MEMORY
{
  FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0xda000
  RAM (rwx) :  ORIGIN = 0x20005290, LENGTH = 0x10000
}

SECTIONS
{
}

SECTIONS
{
  . = ALIGN(4);
  .mem_section_dummy_ram :
  {
  }
  .cli_sorted_cmd_ptrs :
  {
    PROVIDE(__start_cli_sorted_cmd_ptrs = .);
    KEEP(*(.cli_sorted_cmd_ptrs))
    PROVIDE(__stop_cli_sorted_cmd_ptrs = .);
  } &amp;gt; RAM
  .fs_data :
  {
    PROVIDE(__start_fs_data = .);
    KEEP(*(.fs_data))
    PROVIDE(__stop_fs_data = .);
  } &amp;gt; RAM
  .log_dynamic_data :
  {
    PROVIDE(__start_log_dynamic_data = .);
    KEEP(*(SORT(.log_dynamic_data*)))
    PROVIDE(__stop_log_dynamic_data = .);
  } &amp;gt; RAM

} INSERT AFTER .data;

SECTIONS
{
  .mem_section_dummy_rom :
  {
  }
  .sdh_ble_observers :
  {
    PROVIDE(__start_sdh_ble_observers = .);
    KEEP(*(SORT(.sdh_ble_observers*)))
    PROVIDE(__stop_sdh_ble_observers = .);
  } &amp;gt; FLASH
  .sdh_soc_observers :
  {
    PROVIDE(__start_sdh_soc_observers = .);
    KEEP(*(SORT(.sdh_soc_observers*)))
    PROVIDE(__stop_sdh_soc_observers = .);
  } &amp;gt; FLASH
  .sdh_state_observers :
  {
    PROVIDE(__start_sdh_state_observers = .);
    KEEP(*(SORT(.sdh_state_observers*)))
    PROVIDE(__stop_sdh_state_observers = .);
  } &amp;gt; FLASH
  .sdh_stack_observers :
  {
    PROVIDE(__start_sdh_stack_observers = .);
    KEEP(*(SORT(.sdh_stack_observers*)))
    PROVIDE(__stop_sdh_stack_observers = .);
  } &amp;gt; FLASH
  .sdh_req_observers :
  {
    PROVIDE(__start_sdh_req_observers = .);
    KEEP(*(SORT(.sdh_req_observers*)))
    PROVIDE(__stop_sdh_req_observers = .);
  } &amp;gt; FLASH
    .nrf_queue :
  {
    PROVIDE(__start_nrf_queue = .);
    KEEP(*(.nrf_queue))
    PROVIDE(__stop_nrf_queue = .);
  } &amp;gt; FLASH
    .nrf_balloc :
  {
    PROVIDE(__start_nrf_balloc = .);
    KEEP(*(.nrf_balloc))
    PROVIDE(__stop_nrf_balloc = .);
  } &amp;gt; FLASH
    .cli_command :
  {
    PROVIDE(__start_cli_command = .);
    KEEP(*(.cli_command))
    PROVIDE(__stop_cli_command = .);
  } &amp;gt; FLASH
  .crypto_data :
  {
    PROVIDE(__start_crypto_data = .);
    KEEP(*(SORT(.crypto_data*)))
    PROVIDE(__stop_crypto_data = .);
  } &amp;gt; FLASH
  .pwr_mgmt_data :
  {
    PROVIDE(__start_pwr_mgmt_data = .);
    KEEP(*(SORT(.pwr_mgmt_data*)))
    PROVIDE(__stop_pwr_mgmt_data = .);
  } &amp;gt; FLASH
  .log_const_data :
  {
    PROVIDE(__start_log_const_data = .);
    KEEP(*(SORT(.log_const_data*)))
    PROVIDE(__stop_log_const_data = .);
  } &amp;gt; FLASH

} INSERT AFTER .text

INCLUDE &amp;quot;nrf_common.ld&amp;quot;&lt;/pre&gt;&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB COM CDC on android</title><link>https://devzone.nordicsemi.com/thread/212607?ContentTypeID=1</link><pubDate>Mon, 30 Sep 2019 12:51:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b23a28c9-32bb-49fa-9fb2-eb9bb7bb3f0b</guid><dc:creator>Sigurd</dc:creator><description>[quote userid="68658" url="~/f/nordic-q-a/52727/usb-com-cdc-on-android/212520"]If I am using a softdevice should I still call nrf_Drv_clock_init?[/quote]
&lt;p&gt;The driver nrf_drv_clock should handle that fine, as long as you have the&amp;nbsp;SOFTDEVICE_PRESENT&amp;nbsp;preprocessor define. My guess is that you are getting the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/group__nrf__drv__clock.html?cp=5_1_6_9_0_3_0_9#gac7d38f3c52e0a383560eed2c1fbb14f8"&gt;NRF_ERROR_MODULE_ALREADY_INITIALIZED&lt;/a&gt;&amp;nbsp;error. If you want BLE+USBD CDC ACM, you should take a look at the&amp;nbsp;usbd_ble_uart example. (PS; If you are on SDK 15.0, take look at &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/34605/usb-not-enumerating-after-reset/133051#133051"&gt;this post&lt;/a&gt;.)&lt;/p&gt;
[quote userid="68658" url="~/f/nordic-q-a/52727/usb-com-cdc-on-android/212520"]When calling nrf_drv_clock_init, I get &amp;lt;error&amp;gt; app: Fatal error[/quote]
&lt;p&gt;Add DEBUG as&amp;nbsp;&lt;span&gt;preprocessor define, and the error-code should be printed instead. If you are using SES, you only need to set the build configuration to &amp;quot;Debug&amp;quot;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt=" " height="96" src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1569847729451v1.png" width="231" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB COM CDC on android</title><link>https://devzone.nordicsemi.com/thread/212520?ContentTypeID=1</link><pubDate>Mon, 30 Sep 2019 10:50:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e4a12b5-1f7e-43f2-847f-b6eb9f69c42b</guid><dc:creator>Hadi Deknache</dc:creator><description>&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I tested the original USBD CDC ACM example and seem to work, but the application that I have made does not work with Android. When comparing the two applications, the only difference in the code is that I had not added nrf_drv_clock_init, app_usbd_power_events_enable, and some of the defines related to nrf power are set to 0. I tried to add these and change the defines but the application fail during init of the usbd&lt;/p&gt;
&lt;p&gt;When calling nrf_drv_clock_init, I get &amp;lt;error&amp;gt; app: Fatal error&lt;/p&gt;
&lt;p&gt;If I am using a softdevice should I still call nrf_Drv_clock_init?&lt;/p&gt;
&lt;p&gt;I have also these configurations in sdk config, could this be the cause of the application failing?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// &amp;lt;0=&amp;gt; NRF_CLOCK_LF_SRC_RC 
// &amp;lt;1=&amp;gt; NRF_CLOCK_LF_SRC_XTAL 
// &amp;lt;2=&amp;gt; NRF_CLOCK_LF_SRC_SYNTH 

#ifndef NRF_SDH_CLOCK_LF_SRC
#define NRF_SDH_CLOCK_LF_SRC 1
#endif

// &amp;lt;o&amp;gt; NRF_SDH_CLOCK_LF_RC_CTIV - SoftDevice calibration timer interval. 
#ifndef NRF_SDH_CLOCK_LF_RC_CTIV
#define NRF_SDH_CLOCK_LF_RC_CTIV 0
#endif

// &amp;lt;o&amp;gt; NRF_SDH_CLOCK_LF_RC_TEMP_CTIV - SoftDevice calibration timer interval under constant temperature. 
// &amp;lt;i&amp;gt; How often (in number of calibration intervals) the RC oscillator shall be calibrated
// &amp;lt;i&amp;gt;  if the temperature has not changed.

#ifndef NRF_SDH_CLOCK_LF_RC_TEMP_CTIV
#define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 0
#endif

// &amp;lt;o&amp;gt; NRF_SDH_CLOCK_LF_ACCURACY  - External clock accuracy used in the LL to compute timing.
 
// &amp;lt;0=&amp;gt; NRF_CLOCK_LF_ACCURACY_250_PPM 
// &amp;lt;1=&amp;gt; NRF_CLOCK_LF_ACCURACY_500_PPM 
// &amp;lt;2=&amp;gt; NRF_CLOCK_LF_ACCURACY_150_PPM 
// &amp;lt;3=&amp;gt; NRF_CLOCK_LF_ACCURACY_100_PPM 
// &amp;lt;4=&amp;gt; NRF_CLOCK_LF_ACCURACY_75_PPM 
// &amp;lt;5=&amp;gt; NRF_CLOCK_LF_ACCURACY_50_PPM 
// &amp;lt;6=&amp;gt; NRF_CLOCK_LF_ACCURACY_30_PPM 
// &amp;lt;7=&amp;gt; NRF_CLOCK_LF_ACCURACY_20_PPM 
// &amp;lt;8=&amp;gt; NRF_CLOCK_LF_ACCURACY_10_PPM 
// &amp;lt;9=&amp;gt; NRF_CLOCK_LF_ACCURACY_5_PPM 
// &amp;lt;10=&amp;gt; NRF_CLOCK_LF_ACCURACY_2_PPM 
// &amp;lt;11=&amp;gt; NRF_CLOCK_LF_ACCURACY_1_PPM 

#ifndef NRF_SDH_CLOCK_LF_ACCURACY
#define NRF_SDH_CLOCK_LF_ACCURACY 7
#endif&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>