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

FOTA update for nrf52840 dongle not working.

Hi!

I'm trying to prepare FOTA firmware using instructions provided by: FOTA upgrades but it seems not working.I have couple of issues and questions. Please help me. 

My environment is NCS 1.6.1 and nrf52840 dongle. I have choose an open-thread cli sample from SDK. Because I need to develop open-thread application. And I have connected UART-USB converter to pins described by .dts file as UART0 (Yes i'm aware of crossing RX and TX): 

&uart0 {
	compatible = "nordic,nrf-uarte";
	status = "okay";
	current-speed = <115200>;
	tx-pin = <20>;
	rx-pin = <24>;
	rts-pin = <17>;
	cts-pin = <22>;
};

So when I'm running on dongle CLI example it works correctly. I see a CLI on my minicom terminal and are able to write commands to configure open-thread. But the problem is when I'm trying to add CONFIG_BOOTLOADER_MCUBOOT. So: 

1. I have got a flash partition error of mcuboot and need to add to "west" command this cmake variable: "-Dmcuboot_OVERLAY_CONFIG=$(pwd)/usb_cdc_acm_log_recovery.conf" and change partition size to 0x10000 this is full config file: 

CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x10000
CONFIG_LOG=y

# The build won't fit on the partition allocated for it without size
# optimizations.
CONFIG_SIZE_OPTIMIZATIONS=y

# Serial
CONFIG_SERIAL=y
CONFIG_UART_LINE_CTRL=y

# MCUBoot serial
CONFIG_MCUBOOT_SERIAL=y
CONFIG_BOOT_SERIAL_CDC_ACM=y

CONFIG_LOG_BACKEND_UART=y
CONFIG_LOG_BACKEND_RTT=n

Now i'm able to compile application with mcuboot. But problem is when I try to run this application. So I have created a .zip file from "merged.hex" file using this command: 

nrfutil pkg generate --hw-version 52 --sd-req=0x00 \
        --application build/zephyr/merged.hex \
        --application-version 1 cli.zip

and upload it using this command: 

nrfutil dfu usb-serial -pkg cli.zip -p /dev/tty.usbmodemD4911D54D2A41

And after that the board is "dead" no cli prompt and no reaction to any inputs. I have tried to use mcuboot serial recovery mode on bootloader and when using command "mynewt-mcumgr-cli --conntype=serial --connstring='dev=/dev/tty.usbmodem14101,baud=115200' image list" i got this: 

Images:
Split status: N/A (0)

So i suspect just nothing works.

And my final question. Do I need to make some special configuration to enable logging over serial in mcuboot? I don't see any logs on my UART adapter. 

So if you could assist me how to run mcuboot application on dongle i will be much appreciated. It's blocking my development now. 

Thanks in advance! 

  • Okej. So... about this topic: Using MCUboot in Serial Recovery Mode. It's not quite correct described because out of the box it doesn't work. I was suppose to make another topic on the forum about it. 

    There are two bugs. 

    1. If you will build mcuboot as described in first stage of preparations it will build correctly. And you will be able to upload .zip package using DFU. But when you will build "smp_svr" as described there will be error. From reasons I don't know MCUBOOT configuration is larger and compiled binary don't fit on it's partition: 

    /Volumes/Programowanie/Nordic/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.bfd: zephyr/zephyr_prebuilt.elf section `text' will not fit in region `FLASH'
    /Volumes/Programowanie/Nordic/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.bfd: region `FLASH' overflowed by 6108 bytes
    collect2: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.

    Of corse there is some solution for that. Need to add a

    "CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x10000" (this is described in one of the tutorial on this forum) to dongle configuration file. But i have doubts that addresses of the final binary will be the same as those in first section build of mcuboot. 
    But when you accomplish building this binary there will be a signed image generated at the end. And it's good because this leads as to another bug. 
    2. When I try to run cmd: "west sign -t imgtool --bin --no-hex -d build/smp_svr -B smp_svr.signed.bin -- --key mcuboot/root-rsa-2048.pem "  it's exit with error: 
    west sign -t imgtool --bin --no-hex -d build/smp_svr \
              -B smp_svr.signed.bin -- --key ./bootloader/mcuboot/root-rsa-2048.pem
    === image configuration:
    partition offset: 65536 (0x10000)
    partition size: 385024 (0x5e000)
    rom start offset: 0 (0x0)
    === signing binaries
    unsigned bin: /Volumes/Programowanie/Nordic/ncs/build/smp_svr/zephyr/zephyr.bin
    signed bin:   smp_svr.signed.bin
    Usage: imgtool sign [OPTIONS] INFILE OUTFILE
    
    Error: Invalid value for '-H' / '--header-size': Minimum value for -H/--header-size is 32
    FATAL ERROR: command exited with status 2: /usr/local/bin/imgtool sign --version 0.0.0+0 --align 4 --header-size 0 --slot-size 385024 --key ./bootloader/mcuboot/root-rsa-2048.pem /Volumes/Programowanie/Nordic/ncs/build/smp_svr/zephyr/zephyr.bin smp_svr.signed.bin
    even adding "-H 32" doesn't help: 
    west sign -t imgtool --bin --no-hex -d build/smp_svr \
              -B smp_svr.signed.bin -- --key ./bootloader/mcuboot/root-rsa-2048.pem -H 32
    === image configuration:
    partition offset: 65536 (0x10000)
    partition size: 385024 (0x5e000)
    rom start offset: 0 (0x0)
    === signing binaries
    unsigned bin: /Volumes/Programowanie/Nordic/ncs/build/smp_svr/zephyr/zephyr.bin
    signed bin:   smp_svr.signed.bin
    Usage: imgtool sign [OPTIONS] INFILE OUTFILE
    
    Error: Header padding was not requested and image does not start with zeros
    FATAL ERROR: command exited with status 2: /usr/local/bin/imgtool sign --version 0.0.0+0 --align 4 --header-size 0 --slot-size 385024 --key ./bootloader/mcuboot/root-rsa-2048.pem -H 32 /Volumes/Programowanie/Nordic/ncs/build/smp_svr/zephyr/zephyr.bin smp_svr.signed.bin
    And this is blocker that hold me on this. So I suppose that dongle is not so well documented as rest of the nordic platforms. 
    Of course i have tried to upload to board new binary "app_update.bin" but it don't work: 
    mynewt-mcumgr-cli --conntype=serial --connstring='dev=/dev/tty.usbmodem14101,baud=115200' image upload -e build/smp_svr/zephyr/app_update.bin
     37.07 KiB / 37.07 KiB [===========================================================] 100.00% 3.14 KiB/s 11s
    Done
    MBP-Grzegorz:ncs $ mynewt-mcumgr-cli --conntype=serial --connstring='dev=/dev/tty.usbmodem14101,baud=115200' image confirm
    Images:
     image=0 slot=0
        version: 0.0.0.0
        bootable: false
        flags:
        hash: Unavailable
    Split status: N/A (0)
    MBP-Grzegorz:ncs $ mynewt-mcumgr-cli --conntype=serial --connstring='dev=/dev/tty.usbmodem14101,baud=115200' reset
    Done
    I have read all internet to find solutions for my problem before i created a ticket. So... :) 
  • GoRo3 said:
    "CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x10000" (this is described in one of the tutorial on this forum)

    Can you please provide a link to this tutorial?

    GoRo3 said:
    Okej. So... about this topic: Using MCUboot in Serial Recovery Mode. It's not quite correct described because out of the box it doesn't work. I was suppose to make another topic on the forum about it. 

    I am getting conflicting information with regards to the MCUboot support on the nRF52840 Dongle. Our most experienced support engineers claim that the solution described in the nRF52840 dongle page is not correct, and that having two bootloaders will cause confliction. 

    I will need some time to investigate. 

  • This is the tutorial: https://devzone.nordicsemi.com/nordic/nrf-connect-sdk-guides/b/software/posts/device-firmware-update-dfu-with-mcuboot-bootloader

    Take your time. It will be nice to make straight this topic. If this is working or not for me and other readers. :) 

    I have some question regarding this. If I order a DK and (I suppose) this will work on the DK, could I just flash dongle (using DK), erasing NRF boot-loader and it should work same? As I understand problem is in first stage bootloader. 

  • First of all the tutorial you are pointing to is written for the nRF52840DK .

    I've been discussing the issue that you posted 2 days ago (with bus fault) with my colleague The issue is related to the Thread Analyzer  which is enabled in the prj_minimal.conf. Is there a reason for choosing this config? This configuration is designed to be used with smaller devices such as nRF52805 and nRF52810, but I assume this was to test in regards to the error "section `text' will not fit in region `FLASH'"

    Can you please try adding the following in your configuration? When adding both Thread Analyzer and USB stack, this might be the root cause of the bus fault.  The nRF52832 does not have USB, therefor will not compile the USB bus stack. This is why you can successfully run on the nRF52832DK.

    CONFIG_THREAD_ANALYZER_AUTO_STACK_SIZE=4096

    Regarding the use of the nRF52840 Dongle, I still encourage you to use the development kit as this is more suitable for development.  The nRF52840 Dongle is complementary hardware to the nRF Connect for Desktop, it is design for quick testing inside of the nRF Connect for Desktop.

Related