Error when trying to add MCU BOOT functionality on a basic blinky example using Zephry/nRF Connect

I wanted to get FOTA running on a PineTime devkit board (nrf52832) just to test and see if it works, but am getting the following error message:

/opt/nordic/ncs/toolchains/580e4ef81c/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/drivers/flash/libdrivers__flash.a(spi_nor.c.obj):(.rodata.spi_nor_config_0+0x0): undefined reference to `__device_dts_ord_88'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Additional error messages:
FAILED: modules/mcuboot/mcuboot_subimage-prefix/src/mcuboot_subimage-stamp/mcuboot_subimage-build mcuboot/zephyr/zephyr.hex mcuboot/zephyr/zephyr.elf /Users/lj/Projects/GitHub/lj/blinky_ble/build_1/modules/mcuboot/mcuboot_subimage-prefix/src/mcuboot_subimage-stamp/mcuboot_subimage-build /Users/lj/Projects/GitHub/lj/blinky_ble/build_1/mcuboot/zephyr/zephyr.hex /Users/lj/Projects/GitHub/lj/blinky_ble/build_1/mcuboot/zephyr/zephyr.elf
cd /Users/lj/Projects/GitHub/lj/blinky_ble/build_1/mcuboot && /opt/nordic/ncs/toolchains/580e4ef81c/Cellar/cmake/3.21.0/bin/cmake --build . --

I'm using Zephyr and nRF Connect for VS Code. BLE was working but got the error when I added these lines to the prj.conf:
# Enable MCUboot and FOTA
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
the full prj.conf is:
CONFIG_GPIO=y
CONFIG_LOG=y

CONFIG_USE_SEGGER_RTT=y

CONFIG_BT=y
CONFIG_BT_DEVICE_NAME="MCU Test"
CONFIG_BT_PERIPHERAL=y

# Enable MCUboot and FOTA
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
I've looked at these articles:

I wonder if this is a clue Troubleshooting devicetree — Zephyr Project Documentation

I have a basic Blinky example I am using to test. I have two builds in it:

  • nrf52dk_52832
  • pinetime_devkit0

I can build on the nrf52dk but not the pinetime. These are from the .dts of each:

	model = "Nordic nRF52 DK NRF52832";
	compatible = "nordic,nrf52-dk-nrf52832";

	chosen {
		zephyr,console = &uart0;
		zephyr,shell-uart = &uart0;
		zephyr,uart-mcumgr = &uart0;
		zephyr,bt-mon-uart = &uart0;
		zephyr,bt-c2h-uart = &uart0;
		zephyr,sram = &sram0;
		zephyr,flash = &flash0;
		zephyr,code-partition = &slot0_partition;
	};

	model = "Pine64 PineTime DevKit0";
	compatible = "pine64,pinetime-devkit0";

	chosen {
		zephyr,console = &uart0;
		zephyr,shell-uart = &uart0;
		zephyr,bt-mon-uart = &uart0;
		zephyr,bt-c2h-uart = &uart0;
		zephyr,sram = &sram0;
		zephyr,flash = &flash0;
		zephyr,code-partition = &slot0_partition;
		zephyr,display = &st7789v;
	};

Repo is here ljunquera/blinky_ble (github.com)

Parents
  • Hello,

    The problem is that the PineTime board enables the 'xt25fb32' flash NOR device on the spi1 bus by default in the devicetree, and the linker error is a result of the SPI driver not being included in the bootloader build.

    Assuming you don't want to use this FLASH NOR device in your bootloader, you can create a devicetree overlay to disable the device for mcuboot. To apply a devicetree overlay for the child image, you can create a folder named 'chilld_image' in your project root with the 'mcuboot.overlay' file. Folder structure should be as follows (Permanent configuration changes to child images):

    blinky_ble/child_image/
    └── mcuboot.overlay

    And the mcuboot.overlay should contain the following:

    /delete-node/ &xt25fb32;
    
    &spi1 {
        status = "disabled"; 
    };

    After you have adding the child_image folder with the mcuboot.overlay, you can perform a pristine build to ensure the overlay is applied to the mcuboot build. 

    Best regards,

    Vidar

  • That worked. Thank you. It did build. I thought it might have to do with incorrect partitions which seem to be a requirement according to this article.

    It states:

    The first step required for Zephyr is making sure your board has flash partitions defined in its device tree. These partitions are:

    • boot_partition: for MCUboot itself

    • slot0_partition: the primary slot of Image 0

    • slot1_partition: the secondary slot of Image 0

    While the pintime_devkit0.dts had:

    &flash0 {
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		/* MCUboot bootloader */
    		boot_partition: partition@0 {
    			label = "mcuboot";
    			reg = <0x00000000 0xc000>;
    		};
    
    		/* main firmware partition */
    		slot0_partition: partition@c000 {
    			label = "image-0";
    			reg = <0x0000C000 0x74000>;
    		};
    	};
    };

  • Good to hear. Yes, the Pinetime board is placing the secondary slot along with the storage partition in the external flash here: https://github.com/nrfconnect/sdk-zephyr/blob/588ae3982bb59bcedc0151cd6619c7672c53537d/boards/arm/pinetime_devkit0/pinetime_devkit0.dts#L151. However, if you want to do the same in the nRF Connect SDK, you need to do it through the Partition Manager as outlined in the Using external flash memory partitions section of the SDK documentation. 

    Note that you can check the current flash partition layout in your project by running the 'Memory report' action in the VS code extension.

Reply Children
No Data
Related