MCUBOOT + OpenThread problems

nRF52840
NCS SDK v1.9.1
nRF52840DK

My application is based on the coap_client sample, and is running on the nRF52840DK.  It runs fine all alone.  I have added code to download 'app_update.bin' to external qspi flash.  Now I want to enable MCUBOOT to swap to the update.  The 'app_update.bin' I downloaded is a test file, and is not properly signed, so I would expect MCUBOOT to reject it.

MCUBOOT fails to detect the downloaded file. Also, after MCUBOOT, the application fails to start openthread, and the LED does not come on.  The network credentials had previously been set by joining an existing network.  

I am enabling the bootloader by adding "overlay-dfu_suport.conf" as a fragment in the build configuration. (Edit Build Configuration -> Add Fragment)

overlay-dfu_support.conf

#
# Copyright (c) 2021 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

# To add this to the project
# Right click on the build, select Edit Build Configuration
# Click Add Fragment, and select this file

# Enable MCUboot bootloader
CONFIG_BOOTLOADER_MCUBOOT=y

# MCU Manager and SMP configuration
CONFIG_MCUMGR=y
CONFIG_MCUMGR_CMD_IMG_MGMT=y
CONFIG_MCUMGR_CMD_OS_MGMT=y
#CONFIG_MCUMGR_SMP_BT=y
#CONFIG_MCUMGR_SMP_BT_AUTHEN=n
#CONFIG_MCUMGR_BUF_COUNT=6

# Increase BT MTU and RX buffer for big size DFU messages
#CONFIG_BT_L2CAP_TX_MTU=260
#CONFIG_BT_BUF_ACL_RX_SIZE=264

# Reduce GAP event length to avoid heavy BLE traffic generated during DFU
#CONFIG_BT_CTLR_SDC_MAX_CONN_EVENT_LEN_DEFAULT=3000

# Enable minimal logging implementation to decrease memory footprint
CONFIG_LOG_MODE_MINIMAL=y

Console output:

*** Booting Zephyr OS build v2.7.99-ncs1-1  ***
I: Starting bootloader
I: Primary image: magic=bad, swap_type=0x0, copy_done=0x2, image_ok=0x2
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: 0x10000
I: nRF5 802154 radio initializedot
*** Booting Zephyr OS build v2.7.99-ncs1-1  ***
CoAP-client 
build time: Dec 13 2022 13:32:27
I: Start CoAP-client sample
I: Swap type: none
Connection is broken

uart:~$ Timeout waiting for 'status' cmd = 0 reply
Connection is brokenTimeout waiting for 'status' cmd = 1 reply
Connection is brokenTimeout waiting for 'status' cmd = 2 reply
Connection is brokenConnection is brokenConnection is brokenTimeout waiting for 'status' cmd = 2 reply
Connection is brokenI: [NOTE]-MAC-----: Failed to send IPv6 UDP msg, len:56, chksum:0eaf, to:None, sec:no, error:Abort, prio:net
I: [NOTE]-MAC-----:     src:[fe80:0:0:0:7c31:41a:71f5:a5a8]:19788
I: [NOTE]-MAC-----:     dst:[ff02:0:0:0:0:0:0:2]:19788
Timeout waiting for 'status' cmd = 2 reply
Connection is brokenConnection is brokenTimeout waiting for 'status' cmd = 4 reply
Connection is brokenTimeout waiting for 'status' cmd = 3 reply

uart:~$ ot state
disabled
Done
uart:~$
uart:~$ ot networkkey
3095a4413ab9c79577121b03aad21e23
Done
uart:~$

That is not the correct network key.

If I then remove the fragment in the build configuration.  It once again runs, and connects to the network with the correct key.

I have added this overlay to use external flash for the DFU.

nrf52840dl+mrf52840.overlay

/* Copyright (c) 2020 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
 */

/ {
	/*
	* In some default configurations within the nRF Connect SDK,
	* e.g. on nRF52840, the chosen zephyr,entropy node is &cryptocell.
	* This devicetree overlay ensures that default is overridden wherever it
	* is set, as this application uses the RNG node for entropy exclusively.
	*/
	chosen {
		zephyr,entropy = &rng;

        /* From: https://github.com/simon-iversen/sdk-zephyr/blob/serial_dfu_ext_flash_hello_world/samples/hello_world/boards/nrf52840dk_nrf52840.overlay
        *  for using external flash for DFU */
        nordic,pm-ext-flash = &mx25r64;
	};
};
&adc {
	status = "disabled";
};
&uart1 {
	status = "disabled";
};
&pwm0 {
	status = "disabled";
};
&i2c0 {
	status = "disabled";
};
&spi0 {
	status = "disabled";
};
&spi1 {
	status = "disabled";
};
&spi2 {
	status = "disabled";
};
&spi3 {
	status = "disabled";
};
&qspi {
	status = "disabled";
};
&usbd {
	status = "disabled";
};
&gpio1 {
	status = "disabled";
};


/* MDF: Added for QSPI NOR Flash support for MCUBoot */
/delete-node/ &boot_partition;
/delete-node/ &slot0_partition;
/delete-node/ &slot1_partition;
/delete-node/ &scratch_partition;

&flash0 {
    partitions {
        compatible = "fixed-partitions";
        #address-cells = <1>;
        #size-cells = <1>;

        boot_partition: partition@0 {
            label = "mcuboot";
            reg = <0x000000000 0x00010000>;
        };

        slot0_partition: partition@10000 {
            label = "image-0";
            reg = <0x000010000 0x0000E8000>;
        };
    };
};

&mx25r64 {
    partitions {
        compatible = "fixed-partitions";
        #address-cells = <1>;
        #size-cells = <1>;

        slot1_partition: partition@0 {
            label = "image-1";
            reg = <0x00000000 0x0000E8000>;
        };
        scratch_partition: partition@e8000 {
            label = "image-scratch";
            reg = <0x0000E8000 0x0000E8000>;
        };
    };
};

Here's what is at image-1:

This all used to work, until I migrated the whole project to a new computer.

It doesn't seem to retrieve the network credentials properly, or recognize that there is a file in the image-1 partition? What's wrong?

Mary

Parents
  • Hi,

    Is it only the network key that is incorrect, or is the whole network dataset wrong?

    The only thing I can think of is that the storage partition could be moved when you define the slots for MCUboot, and somehow corrupts the stored dataset.

    Are you using the exact same project that was working on the old computer? Do you have the old computer available, to do a comparison?

    Best regards,
    Jørgen

Reply
  • Hi,

    Is it only the network key that is incorrect, or is the whole network dataset wrong?

    The only thing I can think of is that the storage partition could be moved when you define the slots for MCUboot, and somehow corrupts the stored dataset.

    Are you using the exact same project that was working on the old computer? Do you have the old computer available, to do a comparison?

    Best regards,
    Jørgen

Children
Related