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

Multiple DFU Transports

More of a suggestion than a question:

Using the info available on the infoCenter, especially here and here, I'm trying to implement a way to dynamically select the DFU transport to be used. I was able to build my project without breaking the DFU over BLE functionality; I don't have a way to test the UART yet. My suggestion is changing the identifier "dfu_trans" in one or both of nrf_ble_dfu.c and nrf_uart_dfu.c. The fact that both files were using the same identifier caused build errors in my Segger Studio setup. It doesn't seem like there is any reason for them to share that identifier. So, I changed them to "sdfu_trans" and "bdfu_trans" and was able to build and run.

Another suggestion, more of a request really - it would be nice to be able to select, or simply init and uninit transports from outside the DFU and bootloader libraries. Thanks.

I'm working on a custom board based on the nRF52832. I'm developing on Win 8.1 using SES and a J-Link Plus. SDK version 14.1.

Parents
  • Hi ,In nRF53832, sdk 13.0.0, I want combine BLE DFU and serial DFU in one demo, but when I transplant serial DFU function into BLE DFU demo,or transplant BLE  DFU function into serial DFU demo, BLE DFU can work,but serial DFU can’t, could you tell me how you solve this problem?

    thank you

  • Hi Danni,

      It's been a while, but as I remember, you just add both nrf_ble_dfu.c and nrf_uart_dfu.c to your project.  Then search those files for "dfu_trans".  In 14.1 it exists in both files.  In one of the files, change the name of dfu_trans.  Then you should be able to build. 

    Now, when the bootloader is running in DFU mode, you should be able to start sending DFU packages over the serial port.  You do need to define the serial port pins somewhere, so DFU knows which to configure.  I don't remember how that was done.  I think the final hurdle for me was to take the UART speed on the DFU server (an embedded Linux, in my case) down to 9600, because we didn't have HWFC.  I did try to run at 115200, but it failed.   Here are my notes for setting up and modifying the Python nrfutils:

    • pip install nrfutil
    • cd /usr/lib/python2.7/site-packages/nordicsemi
    • pip install -r setup.py
    • pip install -r requirements.txt
    • vi dfu/dfu_transport_serial.py
      • Find class DfuTransportSerial and change:
        • DEFAULT_BAUD_RATE to 9600
        • DEFAULT_FLOW_CONTROL to False
    • python setup.py build

    Hope that helps.

Reply
  • Hi Danni,

      It's been a while, but as I remember, you just add both nrf_ble_dfu.c and nrf_uart_dfu.c to your project.  Then search those files for "dfu_trans".  In 14.1 it exists in both files.  In one of the files, change the name of dfu_trans.  Then you should be able to build. 

    Now, when the bootloader is running in DFU mode, you should be able to start sending DFU packages over the serial port.  You do need to define the serial port pins somewhere, so DFU knows which to configure.  I don't remember how that was done.  I think the final hurdle for me was to take the UART speed on the DFU server (an embedded Linux, in my case) down to 9600, because we didn't have HWFC.  I did try to run at 115200, but it failed.   Here are my notes for setting up and modifying the Python nrfutils:

    • pip install nrfutil
    • cd /usr/lib/python2.7/site-packages/nordicsemi
    • pip install -r setup.py
    • pip install -r requirements.txt
    • vi dfu/dfu_transport_serial.py
      • Find class DfuTransportSerial and change:
        • DEFAULT_BAUD_RATE to 9600
        • DEFAULT_FLOW_CONTROL to False
    • python setup.py build

    Hope that helps.

Children
  • Hi Jason, we have faced the same problem.

    Can you show us sdk_config.h that woks or Do you remember there are ram configuration or flash configuration we need to change? 

    thank you very much~

  • Hi Phillip.  I didn't have to do any  flash/RAM configuration beyond the "dfu_trans" mods described in my original post.  Just to be clear, these mods are made to the bootloader project, not the application project.  I'll attach my sdk_config.h; the changes from the starting point ("examples/dfu/bootloader_secure_ble") are basically enabling the UART and some RTT functionality for debug output.  Again, make sure the bootloader configures the UART with the correct GPIO.  I plan to make a more detailed explanation using the NRF52 DK, but that will probably be in May or June.2047.sdk_config.h

  • Hi Jason, sorry to disturb you. In SDK13.0.0, when I combined BLE and UART DFU into one project, I find they have different event wait function, BLE DFU use sd_app_evt_wait() but SERIAL DFU use __WFI().  do you have any change?

  • Hi Danni,

      What file is that a picture of?  I didn't really combine the two projects as much as simply add nrf_serial_dfu.c to the bootloader_secrue_ble example.  My changes to main basically involved removeing LED and button code, since I had none.  I think in SDK14.1, code like the code you attached is deeper into the DFU library.  I didn't have to mess with that.  I only added the two dfu files (serial and ble).  Here's a comment from my main, where I thought I would select between serial and BLE:

    /*************************************************************************************
    No need to implement this - there is no way (outside of library mods) to control
    which DFU transport is used. By virtue of adding nrf_ble_dfu.c to the project, we get
    the BLE transport. By then adding nrf_serial_dfu.c we get the serial transport ALSO.
    During bootloader init, both transports will be configured and listening for 
    activity. It would be nice to have more control, but this all happens at 
    link-time, and within the call to nrf_boot_loader_init. 
    if (nrf_power_gpregret_get() == MYPROJ_BL_DFU_UART_START)
    { 
    nrf_power_gpregret_set(MYPROJ_BL_DFU_BLE_START); // Signal bootloader code that we want DFU
    retVal = true; 
    }
    
    if (nrf_power_gpregret_get() == MYPROJ_BL_DFU_BLE_START)
    {
    retVal = true;
    }
    **************************************************************************************/

Related