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
  • 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_MCUBOOT=y
    CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y

    I got this below error

  • no I dont have pm.yml or pm_static.yml file

    I have attached my project above.
     
    -Praveen

  • that could also be a problem, as the MCUBOOT config enables the partition manager by default, and the partition manager, from my understanding at least, requires a pm.yml or pm_static.yml file, you could try finding one for the same flash you're using and see if the problem still exists.

  • I tried adding pm_static.yml file before

    EMPTY_0:
      address: 0xc000
      end_address: 0x10000
      placement:
        before:
        - mcuboot_pad
      region: flash_primary
      size: 0x4000
    app:
      address: 0x20200
      end_address: 0x100000
      region: flash_primary
      size: 0xdfe00
    external_flash:
      address: 0xf0000
      end_address: 0x800000
      device : W25Q64JV
      region: external_flash
      size: 0x710000
    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: 0x100000
      orig_span: &id001
      - app
      - spm
      - mcuboot_pad
      region: flash_primary
      size: 0xf0000
      span: *id001
    mcuboot_primary_app:
      address: 0x10200
      end_address: 0x100000
      orig_span: &id002
      - app
      - spm
      region: flash_primary
      size: 0xefe00
      span: *id002
    mcuboot_secondary:
      address: 0x0
      device: W25Q64JV
      end_address: 0xf0000
      region: external_flash
      size: 0xf0000

    now also tried


    This is the same error that we got before. I think CONFIG_MCUBOOT=y is not needed.

    - Praveen

Related