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

I want to insert a DFU module through BLE in my old ble project to upgrade my nrf5340 image

    i have look for many DFU examples in NCS1.5.0 , but samples are Abstract ,and can not to start . a ble test  app in phone have a menu that  can  send file to nrf5340 through ble ,  when ble of nrf5340 receive this file  ,file can as  a new image.

  • You should try to merge the peripheral_uart sample with the smp_svr sample, and create a sample peripheral_uart_smp_svr. Then you will be able to use both the UART service, as well as the SMP service:

      

    Then you can do the following to make sure it's working

    1. Add printk("version 1") in peripheral_uart_smp_svr-->main() and flash it to the device
      1. Check if you see "Version 1" in the terminal
    2. Change the above to printk("version 2") and build the sample peripheral_uart_smp_svr again, without flashing
    3. Eventually you can transfer the app_update.bin from step 2 and make sure you see the log "version 2"

    I tried to do this (merge peripheral_uart with smp_svr), but I encountered some issues when transferring the file. However, I can set off some time and get this to work, if you want to?

    Best regards,

    Simon

  • Simon,thank you very much!

    1. I have tried to merge peripheral_uart example and smp_svr example in one project , a ble service would do some ordinary work ,the other ble service will do DFU work , but failed .

    2. I have saw a DFU method of nrf52832 through ble . when nrf52832 receive a DFU command from a connected app in phone , nrf52832 first write 0x01 in flash (address is  0 ), then reset . in the reset period ,app in phone send a DFU file , nrf52832 automatically DFU.  program  in nrf52832 have no code about DFU,  only only only write 0x01 in address 0 flash ,  then reset .i am confusing this for sereral days  , and  just asked former engineer ,he said a DFU code have loaded in bootloader of nrf52832 . i do not know the process of this DFU and how to operate .DOES NCS1.5.0 have this method DFU nrf5340 like this?

    3.maybe can use a ble device name to register  two  ble services,  each service has it's own service connect node , it's own receive event handler, it's own send data function. but i am not skill to do this . example smp-svr own a ble service ,and example peripheral_uart own a ble service, and merge two example into one project .

  • Can you test the following patch with NCS v1.5.1: 

    https://github.com/nrfconnect/sdk-nrf/compare/v1.5.1...simon-iversen:peripheral_uart_dfu

    https://github.com/nrfconnect/sdk-nrf/compare/v1.5.1...simon-iversen:peripheral_uart_dfu.patch

    It will make it possible to perform BLE DFU with the peripheral_uart sample. At least it worked for me:

    *** Booting Zephyr OS build v2.4.99-ncs2  ***
    I: Starting bootloader
    I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Boot source: none
    I: Swap type: none
    I: Bootloader chainload address offset: 0xc000
    *** Booting Zephyr OS build v2.4.99-ncs2  ***
    Application version 1.0.0
    Starting Nordic UART service example
    *** Booting Zephyr OS build v2.4.99-ncs2  ***
    I: Starting bootloader
    I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Secondary image: magic=good, swap_type=0x2, copy_done=0x3, image_ok=0x3
    I: Boot source: none
    I: Swap type: test
    I: Bootloader chainload address offset: 0xc000
    *** Booting Zephyr OS build v2.4.99-ncs2  ***
    Application version 2.0.0
    Starting Nordic UART service example

    Best regards,

    Simon

  • Simon thank you very much!!!

     I am testing your suggestion .neither using  git-bash.exe nor  using SEGGER Embeedded studio in v1.5.1 toolchain folder ,include a header file always is a tough thing to me. results of compile always are  like below shortcut:  . every time when i encount this situation,i alway add a absolute path . in this compounded  peripheral_ uart project ,i must add os_mgmt.c  smp_bt.c and img-mgmt.c in project ,later found there is many other c files to support this project using  this method . is there a few techniques i do not know? 

     I change project prj.conf same to  prj.conf your modified,delete all sources file i added to the project in CMakeLists.txt .only a main.c in project . this main.c file i changed same as you told .i use git-bash.exe in v1.5.1 toolchain folder and west build -b nrf5340dk_nrf5340_cpuapp -d build_nrf5340dk_nrf5340_cpuapp -p ,below is the build result shortcut: ,there is   No such file or directory error

  • If you are using Windows there are some problems regarding Windows maximum path length.

    http://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/known_issues.html#build-system 

    The workaround is to shorten the build folder name, e.g. from “build_nrf5340dk_nrf5340_cpuappns” to “build” or place ncs closer to c://. Use "/d/v1.5.1/nrf" instead of "/d/work/ncs_v1.5.1/v1.5.1/nrf".

    Best regards,

    Simon

Related