Place mcuboot_secondary in winbond W25Q64JV extenal flash memory for FOTA using NCS 1.9.1, nrf9160dk

Hi Nordic Team,

I would like to place mcuboot_secondary in winbond W25Q64JV extenal flash memory for FOTA. I would like perform HTTP application and full modem fota.
As my app_update.bin size is very huge and internal flash memory is alomost 90% full, I could not able to do fota update.

Envrionment Details 

SDK : NCS 1.9.1 
Device :  nrf9160dk - customized one
External flash memory - winbond W25Q64JV 8MB

I have followed many devzone tickets, I could not able to place mcuboot_secondary in winbond W25Q64JV extenal flash memory. 

Prj.conf

CONFIG_NCS_SAMPLES_DEFAULTS=y
CONFIG_REBOOT=y

#MCUBOOT
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_IMG_MANAGER=y

# SPI
CONFIG_SPI=y
CONFIG_SPI_NOR=y
CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096

# QSPI
CONFIG_NORDIC_QSPI_NOR=n

# FLASH
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_STREAM_FLASH=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y

# Heap and stacks
CONFIG_HEAP_MEM_POOL_SIZE=6144
CONFIG_MAIN_STACK_SIZE=10240


child_image/mcuboot.conf

# SPI
CONFIG_SPI=y
CONFIG_SPI_NOR=y
CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_NORDIC_QSPI_NOR=n

# MULTITHREAD
CONFIG_MULTITHREADING=y

# MCUboot requires a large stack size, otherwise an MPU fault will occur
CONFIG_MAIN_STACK_SIZE=10240

CONFIG_BOOT_MAX_IMG_SECTORS=256

# Enable flash operations
CONFIG_FLASH=y

# This must be increased to accommodate the bigger images.
CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x10000

# Size of mcuboot partition
CONFIG_SIZE_OPTIMIZATIONS=y

CONFIG_BOOT_ERASE_PROGRESSIVELY=y


child_image/mcuboot/boards/im830_nrf1960.overlay

/ {
    board-control {
        external_flash_pins_routing: switch-ext-mem-ctrl {
          compatible = "nordic,nrf9160dk-optional-routing";
          control-gpios = <&gpio0 19 GPIO_ACTIVE_HIGH>;
          status = "okay";
        };
    };

    chosen {
		  nordic,pm-ext-flash = &w25q64jv;
    };

};


boards/im830_nrf1960_ns.overlay

/ {
    board-control {
        external_flash_pins_routing: switch-ext-mem-ctrl {
          compatible = "nordic,nrf9160dk-optional-routing";
          control-gpios = <&gpio0 19 GPIO_ACTIVE_HIGH>;
          status = "okay";
        };
    };

    chosen {
		  nordic,pm-ext-flash = &w25q64jv;
    };
};


boards/im830_nrf1960_common.dts

/ {
	model = "IM-830 NRF9160";
	compatible = "im830-nrf9160";


	/* These aliases are provided for compatibility with samples */
	aliases {
		led-pwm = &pwm0;
		buzzer-pwm = &pwm1;
	};
};

&adc {
	status = "okay";
};

&gpiote {
	status = "okay";
};

&gpio0 {
	status = "okay";
};

/* PWM0 is intended for LED(PWM Serial) control */
&pwm0 {
	status = "okay";
	ch0-pin = <12>;
};

/* PWM1 is intended for buzzer control */
&pwm1 {
	status = "okay";
	ch0-pin = <1>;
	ch1-pin = <0>;
	ch1-inverted;
};


&uart0 {
	current-speed = <9600>;
	compatible = "nordic,nrf-uarte";
	status = "okay";
	tx-pin = <15>;
	rx-pin = <16>;
};


&i2c1 {
	compatible = "nordic,nrf-twim";
	status = "okay";
	sda-pin = <4>;
	scl-pin = <3>;
	clock-frequency = <100000>;
};


&spi2 {
	compatible = "nordic,nrf-spim";
	status = "okay";
	sck-pin = <8>;
	mosi-pin = <10>;
	miso-pin = <9>;
	miso-pull-up;
	cs-gpios = <&gpio0 11 GPIO_ACTIVE_LOW>;
	icm42605@0 {
		compatible = "invensense,icm42605";
		label = "ICM-42605";
		spi-max-frequency = <1000000>;
		accel-hz = <100>;
		gyro-hz = <100>;
		accel-fs = <2>;
		reg = <0>;
		int-gpios = <&gpio0 6 GPIO_ACTIVE_HIGH>;
	};
};


&spi3 {
	compatible = "nordic,nrf-spim";
	status = "okay";
	sck-pin = <27>;
	mosi-pin = <28>;
	miso-pin = <30>;
	cs-gpios = <&gpio0 31 GPIO_ACTIVE_LOW>;
	w25q64jv: w25q64jv@0 {
		compatible = "jedec,spi-nor";
		label = "W25Q64JV";
		size = <0x8000000>; //8MBytes
		spi-max-frequency = <40000000>;
		reg = <0>;
		jedec-id = [ ef 40 17 ]; 
		wp-gpios = <&gpio0 29 0>;
		hold-gpios = <&gpio0 26 0>;
	};
};

&timer0 {
	status = "okay";
};

&timer1 {
	status = "okay";
};

&timer2 {
	status = "okay";
};

&flash0 {

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

		boot_partition: partition@0 {
			label = "mcuboot";
			reg = <0x00000000 0x10000>;
		};
		slot0_partition: partition@10000 {
			label = "image-0";
		};
		slot0_ns_partition: partition@50000 {
			label = "image-0-nonsecure";
		};
		slot1_partition: partition@80000 {
			label = "image-1";
		};
		slot1_ns_partition: partition@c0000 {
			label = "image-1-nonsecure";
		};
		scratch_partition: partition@f0000 {
			label = "image-scratch";
			reg = <0x000f0000 0xa000>;
		};
		storage_partition: partition@fa000 {
			label = "storage";
			reg = <0x000fa000 0x00006000>;
		};
	};
};

/ {

	reserved-memory {
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;

		sram0_s: image_s@20000000 {
			/* Secure image memory */
		};

		sram0_modem: image_modem@20016000 {
			/* Modem (shared) memory */
		};

		sram0_ns: image_ns@20020000 {
			/* Non-Secure image memory */
		};
	};
};

/* Include partition configuration file */
#include "im830_nrf9160_partition_conf.dts"


boards/im830_nrf9160_partition_conf.dts

&slot0_partition {
	reg = <0x00010000 0x40000>;
};

&slot0_ns_partition {
	reg = <0x00050000 0x30000>;
};

&slot1_partition {
	reg = <0x00080000 0x40000>;
};

&slot1_ns_partition {
	reg = <0x000c0000 0x30000>;
};

&sram0_s {
	reg = <0x20000000 DT_SIZE_K(88)>;
};

&sram0_modem {
	reg = <0x20016000 DT_SIZE_K(40)>;
};

&sram0_ns {
	reg = <0x20020000 DT_SIZE_K(128)>;
};


boards/im830_nrf9160_ns_defconfig

# SPDX-License-Identifier: Apache-2.0

CONFIG_SOC_SERIES_NRF91X=y
CONFIG_SOC_NRF9160_SICA=y
CONFIG_BOARD_IM830_NRF9160_NS=y
# Enable MPU
CONFIG_ARM_MPU=y

# Enable hardware stack protection
CONFIG_HW_STACK_PROTECTION=y

# Enable TrustZone-M
CONFIG_ARM_TRUSTZONE_M=y

# This Board implies building Non-Secure firmware
CONFIG_TRUSTED_EXECUTION_NONSECURE=y

# enable GPIO
CONFIG_GPIO=y
CONFIG_PWM=y

# Enable uart driver
CONFIG_SERIAL=y

# enable console
CONFIG_CONSOLE=y

CONFIG_SPI_NOR=y


CMakeLists.txt

# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)
set(mcuboot_DTC_OVERLAY_FILE "${CMAKE_CURRENT_SOURCE_DIR}/child_image/mcuboot/boards/im830_nrf9160.overlay")
set(mcuboot_CONF_FILE "${CMAKE_CURRENT_SOURCE_DIR}/child_image/mcuboot.conf")

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(IM830_Poc)

target_sources(app PRIVATE src/main.c)

target_compile_options(app PRIVATE -DSDK_UPDATE_1_9_1)


I am getting this build error.

error

Please tell me why I am getting this error. My configurations are correct? How to do it in a proper way?
Its been two weeks I have gone through all the related tickets in devzone, about placing mcuboot_secondary in external flash memory for fota unfortunately none of them worked for me.

Here is my test code.

 im830.rar

Please help me to resolve this issue. Your help will be greately appreciated.

NOTE:

I request to you please dont give any solutions that are done with 
MX25R64 external flash memory and SDK version more than 1.9.1. I want it in NCS 1.9.1 SDK.

Best Regards

Praveen Deshmane

Parents Reply Children
  • I removed CONFIG_MCUBOOT and deleted my build folder and build again. I am getting the same error.

    prj.conf

    CONFIG_NCS_SAMPLES_DEFAULTS=y
    CONFIG_REBOOT=y
    
    #MCUBOOT
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_IMG_MANAGER=y
    
    # SPI
    CONFIG_SPI=y
    CONFIG_SPI_NOR=y
    CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
    
    # QSPI
    CONFIG_NORDIC_QSPI_NOR=n
    
    # FLASH
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_STREAM_FLASH=y
    CONFIG_MPU_ALLOW_FLASH_WRITE=y
    
    # Heap and stacks
    CONFIG_HEAP_MEM_POOL_SIZE=6144
    CONFIG_MAIN_STACK_SIZE=10240
    CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y

    I got the first error again.


    - praveen

  • it seems to be something in the configuration for the SPI, i guess, but I don't quite know what could be causing it, if I remember anything I'll tell you.

  • You don't have a dedicated .overlay file and nowhere there is a pinctrl configuration, you could try adding that. From what I searched about the error, it was that lack of pinctrl for someone(https://devzone.nordicsemi.com/f/nordic-q-a/94414/got-compiler-error-undefined-reference-to-__device_dts_ord_88-when-adding-spi-to-overlay/398366 )

  • Hello Ben Krug,

    I have modified my pm_static.yml a little

    EMPTY_0:
      address: 0xc000
      end_address: 0x10000
      placement:
        before:
        - mcuboot_pad
      region: flash_primary
      size: 0x4000
    app:
      address: 0x20200
      end_address: 0x88000
      region: flash_primary
      size: 0x67e00
    mcuboot:
      address: 0x0
      end_address: 0xc000
      placement:
        before:
        - mcuboot_primary
      region: flash_primary
      size: 0xc000
    mcuboot_pad:
      address: 0x10000
      end_address: 0x10200
      placement:
        align:
          start: 0x8000
        before:
        - mcuboot_primary_app
      region: flash_primary
      size: 0x200
    mcuboot_primary:
      address: 0x10000
      end_address: 0x88000
      orig_span: &id001
      - app
      - spm
      - mcuboot_pad
      region: flash_primary
      sharers: 0x1
      size: 0x78000
      span: *id001
    mcuboot_primary_app:
      address: 0x10200
      end_address: 0x88000
      orig_span: &id002
      - app
      - spm
      region: flash_primary
      size: 0x77e00
      span: *id002
    nrf_modem_lib_ctrl:
      address: 0x20008000
      end_address: 0x200084e8
      inside:
      - sram_nonsecure
      placement:
        after:
        - spm_sram
        - start
      region: sram_primary
      size: 0x4e8
    nrf_modem_lib_rx:
      address: 0x2000a4e8
      end_address: 0x2000c4e8
      inside:
      - sram_nonsecure
      placement:
        after:
        - nrf_modem_lib_tx
      region: sram_primary
      size: 0x2000
    nrf_modem_lib_sram:
      address: 0x20008000
      end_address: 0x2000c4e8
      orig_span: &id003
      - nrf_modem_lib_ctrl
      - nrf_modem_lib_tx
      - nrf_modem_lib_rx
      region: sram_primary
      size: 0x44e8
      span: *id003
    nrf_modem_lib_tx:
      address: 0x200084e8
      end_address: 0x2000a4e8
      inside:
      - sram_nonsecure
      placement:
        after:
        - nrf_modem_lib_ctrl
      region: sram_primary
      size: 0x2000
    otp:
      address: 0xff8108
      end_address: 0xff83fc
      region: otp
      size: 0x2f4
    spm:
      address: 0x10200
      end_address: 0x20200
      inside:
      - mcuboot_primary_app
      placement:
        before:
        - app
      region: flash_primary
      size: 0x10000
    spm_sram:
      address: 0x20000000
      end_address: 0x20008000
      inside:
      - sram_secure
      placement:
        after:
        - start
      region: sram_primary
      size: 0x8000
    sram_nonsecure:
      address: 0x20008000
      end_address: 0x20040000
      orig_span: &id004
      - sram_primary
      - nrf_modem_lib_ctrl
      - nrf_modem_lib_tx
      - nrf_modem_lib_rx
      region: sram_primary
      size: 0x38000
      span: *id004
    sram_primary:
      address: 0x2000c4e8
      end_address: 0x20040000
      region: sram_primary
      size: 0x33b18
    sram_secure:
      address: 0x20000000
      end_address: 0x20008000
      orig_span: &id005
      - spm_sram
      region: sram_primary
      size: 0x8000
      span: *id005
    external_flash:
      address: 0xf0000
      end_address: 0x800000
      device : W25Q64JV
      region: external_flash
      size: 0x710000
    mcuboot_secondary:
      address: 0x0
      device: W25Q64JV
      end_address: 0xf0000
      region: external_flash
      size: 0xf0000

    now I am getting below error



    C:\Users\ift_praveen\ncs\v1.9.1\bootloader\mcuboot\boot\zephyr\include\sysflash\sysflash.h:15:40: error: 'PM_MCUBOOT_SECONDARY_ID' undeclared (first use in this function); did you mean 'PM_MCUBOOT_PRIMARY_ID'?
       15 | #define FLASH_AREA_IMAGE_SECONDARY(x)  PM_MCUBOOT_SECONDARY_ID

    There are threads related to this error. But none of them helped me. Can you please check this one.

    As you pointed pinctrl configuration is not present.
    I would like to know is this below configuration is not sufficient. Regarding this configuration I have already mentioned in the beginning.

    boards/im830_nrf1960_common.dts
    &spi3 {
    	compatible = "nordic,nrf-spim";
    	status = "okay";
    	sck-pin = <27>;
    	mosi-pin = <28>;
    	miso-pin = <30>;
    	cs-gpios = <&gpio0 31 GPIO_ACTIVE_LOW>;
    	w25q64jv: w25q64jv@0 {
    		compatible = "jedec,spi-nor";
    		label = "W25Q64JV";
    		size = <0x8000000>; //8MBytes
    		spi-max-frequency = <40000000>;
    		reg = <0>;
    		jedec-id = [ ef 40 17 ]; 
    		wp-gpios = <&gpio0 29 0>;
    		hold-gpios = <&gpio0 26 0>;
    	};
    };

    What I need to do next?
    - praveen

  • I had the same problem and solved it by adding this to the .overlay file:

    chosen {
    	  nordic,pm-ext-flash = &w25q64jv;
    };

    You have this already in the .overlay file in the child image folder, but you need to have it int he .overlay file on the boards folder, I don't really know why it has to be repeated.

Related