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

Upload application via BLE

Hi, I'm trying to create a PC Python script that upload an application on NRF52 via BLE.

I flashed the NRF52 with this S132/DFU/Application: nRF5_SDK_11.0.0_89a8197/examples/ble_peripheral/ble_app_hrs/pca10040/s132_with_dfu. (Application with DFU service)

I created a zip file that contains my application (a simple blink)app_blink_package1.zip

I tried the zip file using the Android App NRFToolbox and it works.

Now I want to upload the hex file nrf52832_xxaa_s132_blinky_500.hex (the same of the zip file) with the PC and BlueZ gatttool using this python script dfu_debug.py

But I can't switch to DFU mode using Gatttool.

I'm following this guide: https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk52.v0.9.2%2Fbledfu_appswitching.html but I don't understand what is the command for this operation: "Next, you must write the value 01-XX (where XX is the code for the type of image, see DFU Control Point) to the DFU Control Point to start a DFU procedure" In the Android App NRFToolBox I saw this message on the logcat: (Sending Start DFU command (Op Code = 1, Upload Mode = 4) but I can't recreate it with gatttool.

I'm using this command to enable cccd: char-write-req 0x11 0100 but it replies fail

I tried also nRF5_SDK_11.0.0_89a8197/examples/dfu/bootloader/pca10040/dual_bank_ble_s132/armgcc that is only the DFU. In this way gatttool (via dfu_debug.py above) returns OK for each command, except for the last commands after sending the image file, and at the end of the procedure the application doesn't work. Here the log: log_blink.txt

Where is my mistake? Thanks.

Parents Reply Children
  • Surely there must be more direct documentation than having to fish through that rather complex set of sources?

  • Hi David, 

    The best source of documentation is to look at the bootloader protocol as defined here: https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/lib_dfu_transport_ble.html?cp=5_1_3_5_2_2

    It's actually not too difficult. I have an example of doing serial DFU from a NRF52 to another nRF52 here. The code is less than 200 lines of code as far as I remember. 

  • I am feeling very stupid here ... no matter what I look at, I don't seem to find the information I need to use.  I am trying to update the devices already in DFU mode using a Raspberry Pi BT interface ... using a functional gatttool utility.  The python application above does not quite work as it fails getting notification.

    What I am after is some list of what the protocol actually requires ... commands to which characteristic and what notification are expected ... I don't want to have to plow through a tonne of source code to try and find what should be well documented.

    For the last couple of hours, I have been trying to get the nrfsniffer working with a PCA10056 ... and the instructions for Wireshark don't work and the example API seems to cause the PCA10056 to crash.

    I am going in circles with this, and I am about to throw the towel in and find another way to do this.

    Is there any relevant command/ data flow/ notification information on the DFU process anywhere?

  • The python application is to be used with a Nordic nRF5x connect to a PC (or a Raspberry PI), not the native R PI bluetooth. 

    The documentation I point to has the characteristics and the protocol you need to do DFU. I'm not sure what else you are looking for. 

    Before you start your DFU application on the R.PI, I would suggest to write a normal application that can communicate with the NRF5 chip to make a connection, transmit data for example first. 

    I don't think we should continue here, it's better that you can create a new case. You can leave the link to your new case here. 

  • Hi,

    Yes I'm aware that the code you asked me to consult uses a NRF5 chip to make connection. We have a fully working system and have been able to perform DFU using the PCA10056 and Android.

    Obviously doing a DFU does not exclusively require a NRF5 chipset as the upgrades can be achieved using an Android device with a variety of other BT chipsets.

    The reason I've posted to this thread is that the OPs code is based on using bluez/gatttool from a solution that used the native Bluetooth chip and was able to make it work 3 years ago on a older SDK which in turn was based on older code for the NRF51 here github.com/.../ota-dfu-python

    I am trying to modify this to work with the new SDKs but I'm in able to find documentation that would describe the DFU process (which would have been required to write the DFU functionality).

    My attempts to sniff the traffic with the nrfsniffer tool also ended up being highly frustrating and I seem to be having to use a chainsaw to cut bread.

    If you'd prefer this moved to a different thread then please suggest a query that would direct me to information that would help.

    Cheers,

    David

Related