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

nRF5340 - UART programming option

Hello,

I'm in the process of developing the HW board for a nRF5340-based product.
I need the customer could update the firmware using a serial port (USB or Bluetooth is not acceptable).
Is it possible to do that ? Where to found documentation on this ?

Regards,
Gabriele

Parents
  • Hi Gabriele, 

    I afraid the nrfutil tool that Igor pointed wouldn't work with the nRF53 (only support nRF52 and nRF5 SDK). 

    The nRF53 is not supported by our nRF5SDK (which the nrfutil supports) 

    For nRF53 you would need to use NRF Connect SDK. To do DFU with UART on nRF Connect SDK you would need to use mcumgr and smpsvr. 
    Please read about the smpsvr here

    And mcumgr here.

    We have an example of using smpsvr and mcumgr via UART for the Thingy91 here. It's for the nRF9160 but it should be similar syntax for the nRF53.

  • Hi Hung,
    at first glance this seems a very complicated path. It makes me wonder if it will work in the end.
    I'll try to understand the documents you've linked

  • Hi,

    After you have flashed the smp_svr you can use the mcumgr to DFU your image . 


    After you have your image list with 2 images, you need to either test or confirm the image and trigger a reset for your app to run. 
    Call `Image test <image sha>` or `image confirm <image sha>` and then do a reset. Your application should run after that. 

  • Hi,
    The swap mechanism went well!
    After a "image confirm" the new image (My App) is the active one, persistently.
    But what ? I cannot upload a brand new image.
    How to restore the DFU functionality ?
  • Hi Gabriele, 
    You would need to integrate smpsvr into your application. 
    It's pretty simple. You can just follow the instruction here
    The instruction is for BLE , to do UART DFU you use CONFIG_MCUMGR_SMP_UART = y instead of CONFIG_MCUMGR_SMP_BT. 
    In your main.c you need to call 

    os_mgmt_register_group();
    img_mgmt_register_group();

    In the example, I have prepared the .bin files that you can use to update. Note that after you do : 

    mcumgr -t 20 --conntype serial --connstring=COM37 image upload app_update_new.bin

    You still need to confirm the image "image confirm <img_sha>" and then do a reset. I haven't looked into how you can confirm the image and reset automatically yet.

    peripheral_lbs_dfu_uart.zip

  • Dear Huang
    Thank you for guiding me with lot of patience.
    1) At build time I get a couple of warnings
    warning: implicit declaration of function 'os_mgmt_register_group'
    warning: implicit declaration of function 'img_mgmt_register_group'
    Is there something I can do about it, or just ignore and go on ?
    2) Are you sure app_update.bin us the correct binary image ?
    Indeed we have a variety of choices:
    - app_update.bin
    - app_signed.hex
    - app_test_update.hex
    - app_moved_test_update.hex
    My goal is to control from MyApp whether to stay in MyApp or reboot in "SMP Server mode" to upload a new version of MyApp
  • Hi Gabriele, 

    1.I'm sorry I forgot to check the warnings. You need to add 

    #include "os_mgmt/os_mgmt.h"

    #include "img_mgmt/img_mgmt.h"

    to you main.c

    A good reference for using the bootloader is to have a look at the smpsvr sample located at \zephyr\samples\subsys\mgmt\mcumgr\smp_svr

    2. Yes you use app_update.bin. If you have a look at the link on FOTA I pointed to earlier you can find that suggestion. 
    You can sign the image yourself but I haven't been very successfully managed to do so. The documentation is here: https://docs.zephyrproject.org/latest/samples/subsys/mgmt/mcumgr/smp_svr/README.html

    If you want to switch between smpsvr and your application, I think it's the mcumgr handle it. I haven't looked into how you do it automatically yet. Will get back when I find the way. 

Reply
  • Hi Gabriele, 

    1.I'm sorry I forgot to check the warnings. You need to add 

    #include "os_mgmt/os_mgmt.h"

    #include "img_mgmt/img_mgmt.h"

    to you main.c

    A good reference for using the bootloader is to have a look at the smpsvr sample located at \zephyr\samples\subsys\mgmt\mcumgr\smp_svr

    2. Yes you use app_update.bin. If you have a look at the link on FOTA I pointed to earlier you can find that suggestion. 
    You can sign the image yourself but I haven't been very successfully managed to do so. The documentation is here: https://docs.zephyrproject.org/latest/samples/subsys/mgmt/mcumgr/smp_svr/README.html

    If you want to switch between smpsvr and your application, I think it's the mcumgr handle it. I haven't looked into how you do it automatically yet. Will get back when I find the way. 

Children
Related