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

nRF52840 Dongle programming for Windows

I need to write a Windows program that talks to the nRF52840 Dongle.  Is there a .dll or .lib or source code for communicating with the Dongle?  I have programmed the dongle with s140_nrf52_6.1.0_softdevice.hex.  I can not find any documentation of the actual interface that is seen on the PC.  Is it just operated via commands over the COM port?  Are these commands documented?  Where can I find this documentation?

I also need an application to use the nRF52840 Dongle in a pass-through UART mode.  Do I need to load a different hex file into it for that?  Where can I get that?  Is there documentation of the GATT service and characteristic UUIDs for this code?

Thanks!

Parents
  • Hi,

    You can program the nRF52840 with the connectivity firmware (ser_s140_usb_hci) if you want to control it from a PC over USB. On the PC side you would use the pc-ble-driver, or a higher level application that use it (such as nRF Connect for Desktop or nrfutil). The pc-ble-driver then communicates with the nRF using the serialization API.

    What exactly do you mean by passthrough UART mode? UART to BLE? If so, then the NUS service used in the ble_app_uart example that you already found is what you need. You can program the SDK example, but as the nRF52840 dongle does not have an onboard debugger this needs to be done via USB DFU, as explained under  Getting started and Programming in the nRF52840 dongle documentation. Not that there are some issues with the current version of the nRF Connect programmer, so you may be better of using the nrfutil command line tool at this point in time.

  • Sorry, I am still having some problems.

    1. I searched for ser_s140_usb_hci that you mention but I don't find it anywhere.  Can you provide a link?  What is it?

    2. nRF Connect only shows 5 apps I can run.  One of them (Bluetooth Low Energy) installs software on the dongle before running and runs successfully.  This is the only way I have found to put code containing SoftDevice into the dongle.  I have read the Getting Started and Programming links.

    3. I have tried to use the Programmer app launched by nRF Connect.  This gives me the error "Only a single writable region is supported".  Why is this?  I can program an app that does not use SoftDevice, but, for example, connectivity_2.0.1_1m_with_s132_5.0.hex in pc-ble-driver-master\hex\sd_api_v5 contains SoftDevice and will not program this way.

    4. I have tried nrfjprog, but I get this error: "ERROR: There is no debugger connected to the PC."

    5. I have tried nrfutil.  I first ran this command to make a DFU package (no errors):

    nrfutil pkg generate --hw-version 52 --sd-req 0x9D --application-version 5 --application connectivity_2.0.1_1m_with_s132_5.0.hex app_dfu_package.zip

    I then ran this command:

    nrfutil dfu usb_serial -pkg app_dfu_package.zip -p COM4 -b 115200

    which, after some chatter, gives this error:

    pc_ble_driver_py.exceptions.NordicSemiException: Extended Error 0x07: The array of supported SoftDevices for the update does not contain the FWID of the current SoftDevice.

    I pushed the button on the dongle to make the red light flash before doing this.  How do I use nrfutil to program the Dongle?

  • Really, my one question, which I don't yet seem to have an answer to, is exactly how do I write a PC program to use the nRF dongle?

    Here's what I think I understand.  Please verify if I have this correct.

    1. Since nrfutil seems to require sd-req code 0x8C, it appears I have SoftDevice s132_nrf52_3.0.0 loaded into my dongle by nRF Connect when I run Bluetooth Low Energy.  nRF Connect also loads a ble_connectivity app, but I don't know the exact source code or hex file for it.

    2. To put a different version of SoftDevice into the dongle, I need to use the dev board or a segger to program it through P1.  I cannot use DFU for this.

    3. The directory nRF5_SDK_15.0.0_a53641a\examples\connectivity\ble_connectivity\hex contains only this one hex file for the pca10059 (the nRF52840 dongle I have): ble_connectivity_s140_usb_hci_pca10059.hex

    4. The PC code to interface to the connectivity app is pc-ble-driver-master, which only has versions to link with s130 v2.0.1 and s132 v5.0.0.  I need to modify this code to link with s140 to use it with the dongle and the above hex file.  Or, I need to modify it to use s132 3.0.0 instead of s132 5.0.x and hope it is compatible with the connectivity application loaded by the Bluetooth Low Energy app.

    5. I am able to compile ble_connectivity with SD_API_VER  and NRF_SD_BLE_API_VERSION set to 5.  If I set these to 3, the code has compilation errors.

    6. I could not find a file for download named s132_nrf52_5.0.0_softdevice.hex.  I did find s132_nrf52_5.1.0_softdevice.hex.  I don't know if this is compatible with 5.0.0.

    7. If I manage to load connectivity_2.0.1_1m_with_s132_5.0.hex along with s132_nrf52_5.1.0_softdevice.hex maybe I can expect the hrm_v5 application to function?

    8. Instead, I could try to modify the hrm_v5 example to sork with s140, and program the dongle through P1.  I am not sure if this programming procedure is dont twice (once for SoftDevice and once for the app), or if I use mergehex to make one hex file to program.  Or, if I also need to include some code for MBR.

    9. I compiled the source code for

    nRF5_SDK_15.0.0_a53641a\examples\connectivity\ble_connectivity\pca10059\ser_s140_usb_hci

    which produced nrf52840_xxaa.hex, 193 kb.  That distribution also included s140_nrf52_6.1.0_softdevice.hex, 423 kb.  If I use mergehex to combine these, the combined file is 615 kb, but the included hex file ble_connectivity_s140_usb_hci_pca10059.hex is only 607 kb.  I think this means that the code I compiled is different from the distributed hex file.  Any idea why?

  • Hi,

    1. Yes, that seems correct.

    2. No, you can use DFU with nrfutil to program the SoftDevice as well. You will soon be able to use the Programmer app for nRF Connect for Desktop as well, but the current pre-release does not work properly.

    3. ?

    4. You cannot use the pc-ble-driver master branch, as this does not have support for the nRF52840 dongle. the firmware uses the UART peripheral of the nR52832 DK, via the onboard SEGGER debugger which is not present on the nRF52840 dongle. There is absolutely no way this firmware can work on the nRF52840 dongle (the UART pins that are used are not connected to the PC in any way).

    5. You need to build the connectivity firmware with the patches from the pc-ble-driver branch that has support for it (see previous post). The pc-ble-driver documentation describes how to apply the patches.

    6. You should not use any of the S132.... SoftDevices or projects. You need the connectivity firmware for the nRF52840 dongle, which uses the S140 SoftDevice.

    7. No, you cannot expect anything to work as you are not using firmware on the nRF that use the USB in any way. It is effectively not connected to your computer.

    8. Yes.

    9. The size difference could be caused by you not having used the same toolchain as was used to make the precompiled .hex and/or using a different optimization level. (You would also see a difference in size if you enable/disable features such as logging)

  • As far as I can tell some of your answers do not seem right to me.

    The pc-ble-driver project is a program that can be compiled on Windows, not a firmware project.  As I mentioned, I need to write PC code to talk to the dongle.  I understand that the ble_app_uart project is firmware that runs on one of your parts, but not the dongle because the UART would need to be replaced with a USB interface.  I am not talking about that.  The pc-ble-driver branch does contain some hex files for various versions of SoftDevice and connectivity apps, but not something that runs on the Dongle without modification.  The nRF5_SDK_15.0.0_a53641a branch contains an example under connectivity\ble_connectivity\pca10059\ser_s140_usb_hci, which I would expect to be hex code I should be able to use to talk to the dongle.  The PC side of that communication should be some modification of the PC code in pc-ble-driver.  Is that not correct?

    Since I have ble_connectivity_s140_usb_hci_pca10059.hex which is pre-build firmware for connectivity to the dongle using USB, can I just load that into the dongle?  I should just need to update pc-ble-driver on the PC to match the version of SoftDevice used.  I don't know how hard that is.

    Is this clear?  I need to verify which hex file to load into the dongle and what changes I need to make to pc-ble-driver to use s140 instead of s132.

    I have tried to write ble_connectivity_s140_usb_hci_pca10059.hex to the dongle using nrfutil.  After it reports success, the dongle is still in boot loader mode on COM4, and the experimental programmer app reports that only the boot loader is loaded.  I have not found any way to program the combined file ble_connectivity_s140_usb_hci_pca10059.hex into the dongle or to change the SoftDevice loaded to s140_nrf52_6.1.0_softdevice.hex.  How do I do it?

  • Hi,

    I think we are talking about the same thing. I checked with one of the the pc-ble-driver developers and he recommended that you use the v2.3.2 tag of the pc-ble-driver. You should use this version on the PC, and the connectivity firmware connectivity_6.0_1m_with_s140_usb_6.0.hex from here (same tag). This is the same version (pc-ble-driver and connectivity firmware) that will be used for the next release of nRF Connect for desktop.

  • This is what I was looking for!  That code works with s132_nrf52_3.1.0_softdevice.hex, not connectivity_6.0_1m_with_s140_usb_6.0.hex, but s132 v3 seems to be what nRF Connect has loaded into my dongle, so that should work.  I'll let you know if I have any more problems.  Thank you so much.

    I hope in the future, you will update a branch of pc_ble_driver to support s140.

Reply Children
No Data
Related