This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

USB not enumerating without JLinkExe running

Hi,

I am having a problems with USB enumerating with a custom board based on the nRF52840. The board is self powered by LiPo battery. I am developing by connecting to the board with a J-Link Pro over SWD. I am using the armgcc toolchain. My application is SDK 15 based and implements a BLE peripheral and I'm trying to support a USB virtual com port. My applications BLE functionality is working great. I am able to see NRF_LOG_INFO print outs.

Using USBD CDC, I am able to connect my device over USB to my Macbook Pro and send/receive bytes to my application over USB using app_usbd_cdc_acm_write() and receiving in my cdc_acm_user_ev_handler().

I am able to plug and un-plug the USB cable and I see the /dev/tty.usbmodem**** appear and disappear and I receive related events in my cdc_acm_user_ev_handler().  After disconnect/reconnect, I am continue to be able to send/receive bytes to my application over USB.

The problem comes when I quit JLinkExe (regardless of leaving the J-Link Pro connected to the target):

When I quit JLinkExe, my Mac and the target continue to be able to communicate over USB, however if I disconnect the USB cable, and reconnect, I can not get the device to re-enumerate no matter how many times I unplug and re-plug the cable.

If I relaunch JLinkExe, and type "connect", I immediately see my custom board enumerating on the Mac.

I read the following threads:

https://devzone.nordicsemi.com/f/nordic-q-a/37217/ble-nus-central-usb-usb-not-enabled-on-power-detection

https://devzone.nordicsemi.com/f/nordic-q-a/37477/unable-to-run-uart-ble-app-example-without-debugger

And I updated the erreta to 0x20, but my application does not link retarget.c so I don't understand the __putchar signature change. I tried making that change and adding retarget.c, but it does not get used by the linker (and results in no change). I disabled logging with NRF_LOG_ENABLED, and I no longer see any printouts via JLinkRTTClient, but I still have the same failure to enumerate if JLinkExe is not connected.

Any ideas?

Thanks!

Jeremy

  • Good question, and now I feel dumb for not trying that!!

    So, as it turns out I do not see these issues with the usbc_cdc_acm example in SDK 15.1. I am able to successfully plug/un-plug the USB cable (through a hub, without a hub, through two hubs) and the Mac enumerates my custom board as a /dev/tty.usbmodem**** regardless of if JLinkExe is connected or not. Yay, it's not the hardware!

    Next, I tried the usbd_ble_uart sample with the same (working) results. Hub or no hub, JLinkExe or not, it works! Also, shedding further light onto the issue, the USB enumeration is *instant*. In the best case scenario with my app, the enumeration takes maybe two seconds, worst case (no hub, no JLinkExe) it takes like 7 seconds.

    My app is refreshing an OLED screen via ~8MHz SPI on a timer interrupt. When I boosted the priority of the USBD above the SPI (i.e. to a lower number than the SPI code) everything started working reliably.

    Sigh :)

    Thanks for the advice!

Related