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 Reply Children
  • Hi Gabriele, 

    I haven't tried it on the nRF53 but, on the nRF91 what we did was: 

    - Add uart support for mcumgr into boards/arm/nrf9160_pca10090/nrf9160_pca10090_common.dts 

    https://github.com/osaether/zephyr/commit/fbd3daec22eacd7d2d3b1794bb01d9a263d23868

    - Change prj.conf for nRF91 UART transport for smp_svr: 

    https://github.com/osaether/zephyr/commit/ee8e73de279c1cde0cfbe85392c047349f254fc7

    - Then build and flash mcuboot

    - Build and flash smp_svr

    - Intall MCUMgr command line tool: https://github.com/apache/mynewt-mcumgr#command-line-tool

    Use this to list the images in flash, just to test if you can communicate with smp_svr via UART

    sudo mcumgr -t 60 --conntype serial --connstring='dev=/dev/ttyACM0,baud=115200' image list

    - Test with a helloworld example: 

    cd ~/ncs/zephyr/samples/hello_world
    echo "# Enable mcumgr.\nCONFIG_MCUMGR=y" >prj.conf
    echo "# Ensure an MCUboot-compatible binary is generated.\nCONFIG_BOOTLOADER_MCUBOOT=y" >>prj.conf
    echo "# Enable NET BUF\nCONFIG_NET_BUF=y" >>prj.conf
    mkdir build
    cd build
    cmake -GNinja -DBOARD=nrf9160_pca10090 ..
    ninja
    # Sign the bin-file (the mcumgr cli does only work with bin-files):
    ~/ncs/mcuboot/scripts/imgtool.py sign --key ~/ncs/mcuboot/root-rsa-2048.pem --header-size 0x200 --align 8 --version 1.0 --slot-size 0x32000 zephyr/zephyr.bin signed.bin

    -Perform DFU: 

    sudo mcumgr -t 60 --conntype serial --connstring='dev=/dev/ttyACM0,baud=115200' image upload signed.bin

    - Run the image list above and it should show 2 slots. 

  • Hi Hung,
    Thank you, this is a clean step-by-step recipe. I'm sorry I cannot test this in real time. These days much of my effort is on the PCB design. Consider that the DFU must get started from a Windows host, because the product is linked to a Windows PC where the user application runs. Thus, as for the first step, I think I have to install Go for Windows, right ? 

  • I don't think Go is needed for the UART dfu application. 

    However, DFU update is a quite complex application. I would suggest you to get started with testing normal UART application. You will need to have normal SWD programming (not UART DFU) for the development, make sure you have the SWD accessible and has the programmer (can be a nRF53 DK). 

  • Hi Hung

    Let me sum up the state of art as follow-up to this thread.

    I've a nRF5340 custom board and a working Zephyr application I can build (under NCS v1.2.0), flash (using SWD), and run.
    The UART works fine, either as console and generic user data.
    Now, I want to perform DFU through the UART.
    I need to include MCUBoot with MCUmgr with SMP server and Uart transport.

    Here is what I've done

    1. Add Uart support for mcumgr into board file <ncs>/zephyr/boards/arm/qi2m_nrf5340/qi2m_nrf5340_cpuapp_common.dts
    chosen {
    ...
    zephyr,uart-mcumgr = &uart0;
    };

    2. Change prj.conf of my application by adding
    CONFIG_MCUMGR=y
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_NET_BUF=y
    CONFIG_MCUMGR_SMP_UART=y

    3. Rebuilding the application with
    $ west build -b qi2m-nrf5340_cpuapp --build-dir buildout

    I get the error

    ..
    FAILED: zephyr/autogen/pubkey.c
    ModuleNotFoundError: No module named 'cbor'

    Is there anything missed ?
    Does it help to move to NCS 1.3.0 ?

    Thanks

Related