Page 1 of 1

nRF52840 USB_CDC and BLE

Posted: Thu Oct 31, 2019 9:35 pm
by wrickert
I am trying to get both USB_CDC and BLE to work at the same time. I had this working at one point but now it does not work for me.

If I remove ubluepy then USB_CDC works reliably. I know there is a way to do both but I lost it.

I am working with PCA10056, I added `#define MICROPY_HW_USB_CDC` to the mpconfigboard.h so it behaves like a PCA10056
but with PCA10059's USB_CDC

I guess what I need to know is what configurations are needed to enable both, and what flash command to use. The documentation is somewhat confusing as to what make commands to use? make BOARD=pca10056 sd? make BOARD=pca10056 flash? Some combination thereof? Any help is appreciated.

Re: nRF52840 USB_CDC and BLE

Posted: Fri Nov 01, 2019 6:40 am
by c45713
Hi wrickert,

I used the pca10056 board when developing the PR for the pca10059.
You are correct, the only change needed to get it spinning is to add `#define MICROPY_HW_USB_CDC (1)` in the mpconfigboard.h to make it use USB CDC instead of regular Segger UART.

Next i do the following:

Code: Select all

make BOARD=pca10056 SD=s140
make BOARD=pca10056 SD=s140 sd
The `sd` Makefile target will flash both the SoftDevice and the application. If you already have the SoftDevice on board, you can go directly to `flash` which will only flash the application, in this case at address 0x26000.

Does this work for you?

Re: nRF52840 USB_CDC and BLE

Posted: Fri Nov 01, 2019 8:59 am
by wrickert
Not reliably, no. I've tried two different computers. What seems to happen is that eventually, some combination of flashing seems to take, but it is an extremely unreliable process.

Re: nRF52840 USB_CDC and BLE

Posted: Fri Nov 01, 2019 9:34 am
by c45713
It is a bit hard to tell what is going wrong here.
Which revision of the board do you happen to have?

You can also try the manual steps, just to make 100% sure you are flashing the correct files:

Code: Select all

nrfjprog --program drivers/bluetooth/s140_nrf52_6.1.1/s140_nrf52_6.1.1_softdevice.hex --sectorerase -f nrf52
nrfjprog --program build-pca10056-s140/firmware.hex --sectorerase -f nrf52
I got my switches on my board in these positions:

Code: Select all

VEXT->nRF = OFF
nRF power source = VDD
nRF Only|Default = Default

Re: nRF52840 USB_CDC and BLE

Posted: Fri Nov 01, 2019 9:52 am
by wrickert
Mine is a custom board using the BMD-340 module. I will try those steps.

Re: nRF52840 USB_CDC and BLE

Posted: Fri Nov 01, 2019 2:58 pm
by wrickert
That does seem to be more stable. Thank you.

Re: nRF52840 USB_CDC and BLE

Posted: Tue Jan 07, 2020 11:58 pm
by devnull
Hi;

I am in the same situation, I am using the holyiot_18010 ( http://www.holyiot.com/eacp_view.asp?id=278 ) and have connected VUSB, D+ and D- and Ground, and powered the device via this usb connection.

In my mpconfigboard.h I have changed:

Code: Select all

// USB
#define MICROPY_HW_USB_CDC            (1)

// UART config
#define MICROPY_PY_MACHINE_UART       (0)
However, on connecting the board, no serial port is shown in the /dev devices and lsusb shows nothing either !

Other than connecting D+, D- VBUS and GROUND, were there any other hardware modifications needed, or additional code to change ??

Any suggestions or hints on how you got yours to work ??