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! 

  • Hello,

    I'm not sure I understand what you are trying to achieve. Can you please elaborate? In our OpenThread documentation the nrf52840dongle_nrf52840 is used as RCP to connect the OpenThread Border Router. In the documentation for programming the dongle, MCUBoot is not used, which I think is the reason for the board is "dead". 

    For development we highly encourage developers to use our nRF52840 DK which is much more friendly in regards to programming.

    Kind regards,
    Øyvind

  • Hi. 

    I need to develop sensor based on openThread. But I want to use some kind of Over The Air updates. So I have started development od basic steps - need to have update over the air. It could be FOTA as in FOTA upgrades described or DFU - this examples I didn't find in NCS. 

    I try to configure use of MCUboot to get FOTA upgrades but, on all examples that I have tried it didn't work. You could take even basic zephyr or NCS blinky examples. When adding CONFIG_BOOTLOADER_MCUBOOT to their prj.conf and reproducing my steps from above the dongle is not working. Won't boot-up and no logs printed to the serial.

    I'm on it for couple of days now and pretty frustrated. All information that i find on the documents or forum is not solving my problem. Se question is what i'm doing wrong? 

    I have tried this on 52832dk, and it works out of the box (using west flash cmd)- so i suppose that problem is with dongle configuration. 52840DK I will have in couple of weeks as it is not ordered yet but I have bunch of dongles from last project. 

  • Hello, 

    First of all, in the nRF Connect SDK v1.6.1, have you verified that the Thread:CLI sample supports nRF52840 Dongle? This is added in the latest version of NCS, coming v1.7.0.

    The mix of nrfutil and mcuboot is most likely what is causing issues here. 

    Can you please try running nrfutil dfu with zephyr.hex instead of merged.hex? I will would highly encourage you to move to a DK, as the dongle is not designed for development use.

    Kind regards,
    Øyvind

  • Hi. 

    I think we could drop a Thread:CLI sample for now. It's not relevant to the problem. I have made some progress but still program crashes. I have taken a ble_lbs example and try to compile it with mcuboot enable. This is my configuration: 

    # BEGIN Configurations from basic/minimal
    
    CONFIG_NCS_SAMPLES_DEFAULTS=y
    
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_NAME="Nordic_LBS"
    
    # Enable the LBS service
    CONFIG_BT_LBS=y
    CONFIG_BT_LBS_POLL_BUTTON=y
    CONFIG_DK_LIBRARY=y
    
    CONFIG_BOOTLOADER_MCUBOOT=y
    
    # Drivers and peripherals
    CONFIG_I2C=n
    CONFIG_WATCHDOG=n
    CONFIG_GPIO=n
    CONFIG_PINMUX=n
    CONFIG_SPI=n
    CONFIG_SERIAL=n
    
    # Power management
    CONFIG_PM=n
    
    # Interrupts
    CONFIG_DYNAMIC_INTERRUPTS=n
    CONFIG_IRQ_OFFLOAD=n
    
    # Memory protection
    CONFIG_THREAD_STACK_INFO=n
    CONFIG_THREAD_CUSTOM_DATA=n
    CONFIG_FPU=n
    
    # Boot
    CONFIG_BOOT_BANNER=n
    CONFIG_BOOT_DELAY=0
    
    # Console
    CONFIG_CONSOLE=n
    CONFIG_UART_CONSOLE=n
    CONFIG_STDOUT_CONSOLE=n
    CONFIG_PRINTK=n
    CONFIG_EARLY_CONSOLE=n
    
    # Build
    CONFIG_SIZE_OPTIMIZATIONS=y
    
    # ARM
    CONFIG_ARM_MPU=n
    # END Configurations from basic/minimal
    
    # In order to correctly tune the stack sizes for the threads the following
    # Configurations can enabled to print the current use:
    CONFIG_THREAD_NAME=y
    CONFIG_THREAD_ANALYZER=y
    CONFIG_THREAD_ANALYZER_AUTO=y
    CONFIG_THREAD_ANALYZER_RUN_UNLOCKED=y
    CONFIG_THREAD_ANALYZER_USE_PRINTK=y
    CONFIG_CONSOLE=y
    CONFIG_UART_CONSOLE=y
    CONFIG_SERIAL=y
    CONFIG_PRINTK=y
    CONFIG_EARLY_CONSOLE=y
    
    # Example output of thread analyzer
    # SDC RX              : unused 816 usage 208 / 1024 (20 %)
    # BT RX               : unused 1784 usage 416 / 2200 (18 %)
    # BT TX               : unused 992 usage 544 / 1536 (35 %)
    # thread_analyzer     : unused 136 usage 376 / 512 (73 %)
    # sysworkq            : unused 1824 usage 224 / 2048 (10 %)
    # MPSL signal         : unused 520 usage 504 / 1024 (49 %)
    # idle 00             : unused 192 usage 64 / 256 (25 %)
    # main                : unused 136 usage 888 / 1024 (86 %)
    # Configurations set based on thread analyzer output.
    CONFIG_SDC_RX_STACK_SIZE=324
    CONFIG_BT_RX_STACK_SIZE=1024
    CONFIG_BT_HCI_TX_STACK_SIZE_WITH_PROMPT=y
    CONFIG_BT_HCI_TX_STACK_SIZE=640
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=256
    CONFIG_MPSL_SIGNAL_STACK_SIZE=640
    CONFIG_MAIN_STACK_SIZE=1024
    CONFIG_IDLE_STACK_SIZE=128
    CONFIG_ISR_STACK_SIZE=1024
    
    # Disable features not needed
    CONFIG_TIMESLICING=n
    CONFIG_MINIMAL_LIBC_MALLOC=n
    CONFIG_LOG=y
    CONFIG_ASSERT=y
    
    # Disable Bluetooth features not needed
    CONFIG_BT_DEBUG_NONE=y
    CONFIG_BT_ASSERT=y
    CONFIG_BT_DATA_LEN_UPDATE=n
    CONFIG_BT_PHY_UPDATE=n
    CONFIG_BT_GATT_CACHING=n
    CONFIG_BT_GATT_SERVICE_CHANGED=n
    CONFIG_BT_GAP_PERIPHERAL_PREF_PARAMS=n
    CONFIG_BT_SETTINGS_CCC_LAZY_LOADING=y
    CONFIG_BT_HCI_VS_EXT=n
    
    # Disable Bluetooth controller features not needed
    CONFIG_BT_CTLR_PRIVACY=n
    CONFIG_BT_CTLR_PHY_2M=n
    
    # Reduce Bluetooth buffers
    CONFIG_BT_BUF_EVT_DISCARDABLE_COUNT=1
    CONFIG_BT_BUF_EVT_DISCARDABLE_SIZE=43
    CONFIG_BT_BUF_EVT_RX_COUNT=2
    
    CONFIG_BT_CONN_TX_MAX=2
    CONFIG_BT_L2CAP_TX_BUF_COUNT=2
    CONFIG_BT_CTLR_RX_BUFFERS=1
    CONFIG_BT_BUF_ACL_TX_COUNT=3
    CONFIG_BT_BUF_ACL_TX_SIZE=27
    
    CONFIG_MCUMGR_SMP_BT=y
    CONFIG_MCUMGR_SMP_BT_AUTHEN=n
    CONFIG_MCUMGR_SMP_SHELL=y

    And after building I'm writing `merged.hex` to the board using `nrfutil`. Thank to enabling uart_console and adding uart<->USB converter I see this error: 

    Starting Bluetooth Peripheral LBS example
    I: No GC Done marker found: restarting gc
    ThrE: ***** BUS FAULT *****
    E:   Imprecise data bus error
    E: r0/a1:  0x00000031  r1/a2:  0x00000065  r2/a3:  0xb0000000
    E: r3/a4:  0x00037011 r12/ip:  0xaaaaaaaa r14/lr:  0x0002ab3b
    E:  xpsr:  0x21000000
    E: Faulting instruction address (r15/pc): 0x00037012
    E: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
    E: Current thread: 0x20001450 (thread_analyzer)
    Starting Bluetooth Peripheral LBS example
    I: No GC Done marker found: restarting gc
    ThrE: ***** BUS FAULT *****
    E:   Imprecise data bus error
    E: r0/a1:  0x00000040  r1/a2:  0x00000065  r2/a3:  0xb0000000
    E: r3/a4:  0x00037011 r12/ip:  0xaaaaaaaa r14/lr:  0x0002ab3b
    E:  xpsr:  0x01000000
    E: Faulting instruction address (r15/pc): 0x000234f6
    E: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
    E: Current thread: 0x20001450 (thread_analyzer)
    Starting Bluetooth Peripheral LBS example
    I: No GC Done marker found: restarting gc
    ThrE: ***** BUS FAULT *****
    E:   Imprecise data bus error
    E: r0/a1:  0x00000000  r1/a2:  0x00000065  r2/a3:  0x00037644
    E: r3/a4:  0x40002000 r12/ip:  0xaaaaaaaa r14/lr:  0x0002ab33
    E:  xpsr:  0x21000000
    E: Faulting instruction address (r15/pc): 0x00036552
    E: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
    E: Current thread: 0x20001450 (thread_analyzer)

    I have check addresses using `arm-none-eabi-addr2line` I so where error occurs. And it is in: 

    MBP-Grzegorz:peripheral_lbs $ ~/Programowanie/Nordic/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi-addr2line -e build/zephyr/zephyr.elf 0x000234f6
    /Volumes/Programowanie/Nordic/ncs/modules/hal/nordic/nrfx/soc/nrfx_coredep.h:172
    MBP-Grzegorz:peripheral_lbs $ ~/Programowanie/Nordic/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi-addr2line -e build/zephyr/zephyr.elf 0x00036552
    /Users/grzegorz/Programowanie/Nordic/ncs/zephyr/drivers/serial/uart_nrfx_uarte.c:469
    MBP-Grzegorz:peripheral_lbs $ ~/Programowanie/Nordic/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi-addr2line -e build/zephyr/zephyr.elf 0x00037012
    ??:0
    MBP-Grzegorz:peripheral_lbs $ ~/Programowanie/Nordic/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi-addr2line -e build/zephyr/zephyr.elf 0x0002ab3b
    /Users/grzegorz/Programowanie/Nordic/ncs/zephyr/drivers/serial/uart_nrfx_uarte.c:485

    So moving further analyzing this address I see that error occur at: 

    * 0x0002ab3b

    static int wait_tx_ready(const struct device *dev)
    {
    	int key;
    
    	do {
    		/* wait arbitrary time before back off. */
    		bool res;
    
    		NRFX_WAIT_FOR(is_tx_ready(dev), 100, 1, res); <----- HERE! 
    
    		if (res) {
    			key = irq_lock();
    			if (is_tx_ready(dev)) {
    				break;
    			}
    
    			irq_unlock(key);
    		}
    		if (IS_ENABLED(CONFIG_MULTITHREADING)) {
    			k_msleep(1);
    		}
    	} while (1);
    
    	return key;
    }

    * 0x00037012

    static bool is_tx_ready(const struct device *dev)
    {
    	NRF_UARTE_Type *uarte = get_uarte_instance(dev);
    	bool ppi_endtx = get_dev_config(dev)->flags & UARTE_CFG_FLAG_PPI_ENDTX;
    
    	return nrf_uarte_event_check(uarte, NRF_UARTE_EVENT_TXSTOPPED) ||
    		(!ppi_endtx ?
    		       nrf_uarte_event_check(uarte, NRF_UARTE_EVENT_ENDTX) : 0); <--- HERE! 
    }

    So do you know what could cause the problem? 

    When using this example without MCUBOOT enabled of course it works. I have taken the nrf 52832DK and try on it and the problem don't occur. I suppose it's related to nrf52840dongle configuration. 

  • Ok, let's start from scratch. The as stated in the nRF52840 Dongle page under Supported boards in Zephyr
    The board is factory-programmed with Nordic’s bootloader from Nordic’s nRF5 SDK. With this option, you’ll use Nordic’s nrfutil program to create firmware packages supported by this bootloader and flash them to the device. That said, it is also possible to use the MCUboot bootloader with this board to flash Zephyr applications. You need to do some one-time set-up to build and flash MCUboot on your board. From that point on, you can build and flash other Zephyr applications using MCUboot’s serial recovery mode. This process does not overwrite the built-in Nordic bootloader. This is from Using MCUboot in Serial Recovery Mode subchapter.

    Can you please follow the instructions from the latter link and let me know how that works for you?

    Thanks. 

    Kind regards,
    Øyvind

Related