Partition management for multiple peripherals and partitions

Hello everyone,

I'm trying to add an external flash memory to the address range of the main memory. There is already an existing EEPROM, which will be deprecated later, and a Flash memory is added now. Both are connected via SPI. My intention is the following:

  • Leave the EEPROM as it is for now in the configuration
  • Add the flash memory to SPI
  • Define an extended memory space (My intention is to start it at the address 0x90000)
  • Create two partitions for the Flash:
    • Config partition: This needs only be 100 kiB, replacing the functionality of the EEPROM, and will be directly addressed
    • McuBoot swap partition: This will be where the image for the firmware update will be placed. This will be the rest of the memory.

Right now I always get the following warning when building and I'm not sure if I have configured everything correctly:

unit address and first address in 'reg' (0x200090000) don't match for /soc/spi@40004000/flash_at25pe80@2/partitions/partition@0
unit address and first address in 'reg' (0x200090400) don't match for /soc/spi@40004000/flash_at25pe80@2/partitions/partition@1

I have configured my application the following way:

CONFIG_SPI=y
CONFIG_SPI_NOR=y
CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_PM_PARTITION_REGION_LITTLEFS_EXTERNAL=y
CONFIG_PM_PARTITION_REGION_SETTINGS_STORAGE_EXTERNAL=y
CONFIG_PM_PARTITION_REGION_NVS_STORAGE_EXTERNAL=y
CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y
CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y

Device tree (SPI reg 1 is reserved for another device currently in development, but does not need a partition):

&spi1 {
	compatible = "nordic,nrf-spi";
	status = "okay";
	pinctrl-0 = <&spi1_default>;
	pinctrl-1 = <&spi1_sleep>;
	pinctrl-names = "default", "sleep";
	cs-gpios = <&gpio0 11 GPIO_ACTIVE_LOW>, <&gpio0 12 GPIO_ACTIVE_LOW>, <&gpio0 13 GPIO_ACTIVE_LOW>; //SIO_11 MCU_0403_A - SPI_CS1
	eeprom_m95040:eeprom_m95040@0 {
		// M95040 is compatible with atmel at25 eeprom driver
		compatible = "atmel,at25";
		reg = <0>;
		size = <DT_SIZE_K(512)>;
		pagesize = <512>;
		address-width = <24>;
		spi-max-frequency = <8000000>;
		timeout = <5>;
	};
	flash_at25pe80:flash_at25pe80@2 {
		compatible = "jedec,spi-nor";
		status = "okay";
		size = < DT_SIZE_M(8) >;
		reg = < 2 >;
		jedec-id = [1f 25 00];
		spi-max-frequency = < 8000000 >;
	};
};

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

		boot_partition: partition@0 {
			label = "mcuboot";
			reg = <0x0 0xc000>;
		};
		slot0_partition: partition@c000 {
			label = "image-0";
			reg = <0xc000 0x32000>;
		};
		slot1_partition: partition@3e000 {
			label = "image-1";
			reg = <0x3e000 0x32000>;
		};
		scratch_partition: partition@70000 {
			label = "image-scratch";
			reg = <0x70000 0xa000>;
		};
		storage_partition: partition@7a000 {
			label = "storage";
			reg = <0x7a000 0x6000>;
		};
	};
};

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

		confflash: partition@0 {
			label = "config";
			reg = < 2 0x90000 0x400 >;
		};
		extflash: partition@1 {
			label = "external-flash";
			reg = < 2 0x90400 0xFFC00 >;
		};
	};
};

/{
	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;
		nordic,pm-ext-flash = &extflash;
	};
}

partition.yml

app:
  address: 0x9200
  end_address: 0x42000
  region: flash_primary
  size: 0x38e00 #App size 227.5 KB
mcuboot:
  address: 0x0
  end_address: 0x9000
  placement:
    before:
    - mcuboot_primary
  region: flash_primary
  size: 0x9000 #38 KB MCU Bootloader
mcuboot_pad:
  address: 0x9000
  end_address: 0x9200
  placement:
    align:
      start: 0x1000
    before:
    - mcuboot_primary_app
  region: flash_primary
  size: 0x200
mcuboot_primary:
  address: 0x9000
  end_address: 0x42000
  orig_span: &id001
  - mcuboot_pad
  - app
  region: flash_primary
  sharers: 0x1
  size: 0x39000
  span: *id001
mcuboot_primary_app:
  address: 0x9200
  end_address: 0x42000
  orig_span: &id002
  - app
  region: flash_primary
  size: 0x38E00
  span: *id002
mcuboot_secondary:
  address: 0x90000
  device: /soc/spi1/flash_at25pe80@2
  end_address: 0x18FFF
  region: external_flash
  size: 0x100000 #1 MiB / 8 Mbit
nvs_storage:
  address: 0x7b000
  end_address: 0x80000
  placement:
    align:
      start: 0x1000
    before:
    - end
  region: flash_primary
  size: 0x5000
sram_primary:
  address: 0x20000000
  end_address: 0x20020000
  region: sram_primary
  size: 0x20000

I have not defined any custom regions, as the documentation is (in my opinion) abysmal for this with too few examples. But I would gladly be proven otherwise.

The goal is for the config partition to be writable by address, and for McuBoot to use the second partition as an extension, although this may be implemented at a later time.

Sadly I have not found an example where multiple SPI devices are used, one of them a flash device and with addressable partitions, so I don't know where the warning is coming from, as it doesn't show what it expects from me.

Much thanks for any help,

Rico

Parents
  • Hi Rico,

    I will support you with this case. Please be informed that unfortunately we might take some days with this. That is because we are understaffed due to the summer vacation season, and it looks like I will need to research a bit for this.

    I would like to confirm about these configurations that you are setting:

    CONFIG_PM_PARTITION_REGION_LITTLEFS_EXTERNAL=y
    CONFIG_PM_PARTITION_REGION_SETTINGS_STORAGE_EXTERNAL=y
    CONFIG_PM_PARTITION_REGION_NVS_STORAGE_EXTERNAL=y

    Do you want all of these regions on external flash? You mentioned you only want some configs and MCUboot secondary there.

    Could you please also share your compiled DTS? It's in <build directory>/zephyr/zephyr.dts.

    Hieu

  • I do not need all of these, if I reread the options again correctly. I falsely understood from the documentation that all three should be set, when it is only one of then.

    The compiled DTS file is the following (the pins are not yet correctly, but it is the complete hardware architecture):

    /dts-v1/;
    
    / {
    	#address-cells = < 0x1 >;
    	#size-cells = < 0x1 >;
    	model = "carl_sensor";
    	compatible = "krafft,carl-sensor";
    	chosen {
    		zephyr,entropy = &rng;
    		zephyr,flash-controller = &flash_controller;
    		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;
    		nordic,pm-ext-flash = &extflash;
    	};
    	aliases {
    		pwm-red = &pwm_red;
    		pwm-green = &pwm_green;
    		pwm-blue = &pwm_blue;
    		hall-int = &hall_int;
    		enable-5v = &shdn_ltc3525;
    		tilt1 = &tilt1;
    		tilt2 = &tilt2;
    		eeprom-0 = &eeprom_m95040;
    		exflash = &flash_at25pe80;
    		adc-0 = &ads1219;
    		gyroscope = &adxrs649;
    		accel = &adxl372;
    		rtc = &rv3028;
    		bq35100-ge = &bq35100_ge;
    		bq35100-alarm = &bq35100_alarm;
    		cy15b104 = &cy15b104;
    	};
    	soc {
    		#address-cells = < 0x1 >;
    		#size-cells = < 0x1 >;
    		compatible = "nordic,nRF52833-QIAA", "nordic,nRF52833", "nordic,nRF52", "simple-bus";
    		interrupt-parent = < &nvic >;
    		ranges;
    		nvic: interrupt-controller@e000e100 {
    			#address-cells = < 0x1 >;
    			compatible = "arm,v7m-nvic";
    			reg = < 0xe000e100 0xc00 >;
    			interrupt-controller;
    			#interrupt-cells = < 0x2 >;
    			arm,num-irq-priority-bits = < 0x3 >;
    			phandle = < 0x1 >;
    		};
    		systick: timer@e000e010 {
    			compatible = "arm,armv7m-systick";
    			reg = < 0xe000e010 0x10 >;
    			status = "disabled";
    		};
    		ficr: ficr@10000000 {
    			compatible = "nordic,nrf-ficr";
    			reg = < 0x10000000 0x1000 >;
    			status = "okay";
    		};
    		uicr: uicr@10001000 {
    			compatible = "nordic,nrf-uicr";
    			reg = < 0x10001000 0x1000 >;
    			status = "okay";
    		};
    		sram0: memory@20000000 {
    			compatible = "mmio-sram";
    			reg = < 0x20000000 0x20000 >;
    		};
    		clock: clock@40000000 {
    			compatible = "nordic,nrf-clock";
    			reg = < 0x40000000 0x1000 >;
    			interrupts = < 0x0 0x1 >;
    			status = "okay";
    		};
    		power: power@40000000 {
    			compatible = "nordic,nrf-power";
    			reg = < 0x40000000 0x1000 >;
    			interrupts = < 0x0 0x1 >;
    			status = "okay";
    			#address-cells = < 0x1 >;
    			#size-cells = < 0x1 >;
    			gpregret1: gpregret1@4000051c {
    				compatible = "nordic,nrf-gpregret";
    				reg = < 0x4000051c 0x1 >;
    				status = "okay";
    			};
    			gpregret2: gpregret2@40000520 {
    				compatible = "nordic,nrf-gpregret";
    				reg = < 0x40000520 0x1 >;
    				status = "okay";
    			};
    		};
    		radio: radio@40001000 {
    			compatible = "nordic,nrf-radio";
    			reg = < 0x40001000 0x1000 >;
    			interrupts = < 0x1 0x1 >;
    			status = "okay";
    			dfe-supported;
    			ieee802154-supported;
    			ble-2mbps-supported;
    			ble-coded-phy-supported;
    			tx-high-power-supported;
    			ieee802154: ieee802154 {
    				compatible = "nordic,nrf-ieee802154";
    				status = "disabled";
    			};
    		};
    		uart0: uart@40002000 {
    			compatible = "nordic,nrf-uarte";
    			reg = < 0x40002000 0x1000 >;
    			interrupts = < 0x2 0x1 >;
    			status = "okay";
    			current-speed = < 0x1c200 >;
    			pinctrl-0 = < &uart0_default >;
    			pinctrl-1 = < &uart0_sleep >;
    			pinctrl-names = "default", "sleep";
    		};
    		i2c0: i2c@40003000 {
    			compatible = "nordic,nrf-twi";
    			#address-cells = < 0x1 >;
    			#size-cells = < 0x0 >;
    			reg = < 0x40003000 0x1000 >;
    			clock-frequency = < 0x61a80 >;
    			interrupts = < 0x3 0x1 >;
    			status = "okay";
    			pinctrl-0 = < &i2c0_default >;
    			pinctrl-1 = < &i2c0_sleep >;
    			pinctrl-names = "default", "sleep";
    			adxl372: adxl372@53 {
    				compatible = "adi,adxl372x";
    				reg = < 0x53 >;
    				int1-gpios = < &gpio0 0x17 0x0 >;
    			};
    			rv3028: rv3028@52 {
    				compatible = "microcrystal,rv3028";
    				reg = < 0x52 >;
    				int-gpios = < &gpio0 0x1e 0x1 >;
    			};
    			ads1219: ads1219@40 {
    				compatible = "ti,ads1219";
    				reg = < 0x40 >;
    				drdy-gpios = < &gpio0 0xb 0x1 >;
    				#io-channel-cells = < 0x1 >;
    				#address-cells = < 0x1 >;
    				#size-cells = < 0x0 >;
    				phandle = < 0xc >;
    				channel@3 {
    					reg = < 0x3 >;
    					zephyr,gain = "ADC_GAIN_1";
    					zephyr,reference = "ADC_REF_EXTERNAL0";
    					zephyr,acquisition-time = < 0x43e8 >;
    					zephyr,resolution = < 0x18 >;
    					zephyr,vref-mv = < 0x1388 >;
    				};
    				channel@4 {
    					reg = < 0x4 >;
    					zephyr,gain = "ADC_GAIN_1";
    					zephyr,reference = "ADC_REF_EXTERNAL0";
    					zephyr,acquisition-time = < 0x43e8 >;
    					zephyr,resolution = < 0x18 >;
    					zephyr,vref-mv = < 0x1388 >;
    				};
    			};
    		};
    		spi0: spi@40003000 {
    			compatible = "nordic,nrf-spim";
    			#address-cells = < 0x1 >;
    			#size-cells = < 0x0 >;
    			reg = < 0x40003000 0x1000 >;
    			interrupts = < 0x3 0x1 >;
    			max-frequency = < 0x7a1200 >;
    			easydma-maxcnt-bits = < 0x10 >;
    			status = "disabled";
    		};
    		i2c1: i2c@40004000 {
    			compatible = "nordic,nrf-twim";
    			#address-cells = < 0x1 >;
    			#size-cells = < 0x0 >;
    			reg = < 0x40004000 0x1000 >;
    			clock-frequency = < 0x186a0 >;
    			interrupts = < 0x4 0x1 >;
    			status = "disabled";
    		};
    		spi1: spi@40004000 {
    			compatible = "nordic,nrf-spi";
    			#address-cells = < 0x1 >;
    			#size-cells = < 0x0 >;
    			reg = < 0x40004000 0x1000 >;
    			interrupts = < 0x4 0x1 >;
    			max-frequency = < 0x7a1200 >;
    			easydma-maxcnt-bits = < 0x10 >;
    			status = "okay";
    			pinctrl-0 = < &spi1_default >;
    			pinctrl-1 = < &spi1_sleep >;
    			pinctrl-names = "default", "sleep";
    			cs-gpios = < &gpio0 0xb 0x1 >, < &gpio0 0xc 0x1 >, < &gpio0 0xd 0x1 >;
    			eeprom_m95040: eeprom_m95040@0 {
    				compatible = "atmel,at25";
    				reg = < 0x0 >;
    				size = < 0x80000 >;
    				pagesize = < 0x200 >;
    				address-width = < 0x18 >;
    				spi-max-frequency = < 0x7a1200 >;
    				timeout = < 0x5 >;
    			};
    			cy15b104: cy15b104@1 {
    				compatible = "infineon,cy15b104";
    				reg = < 0x1 >;
    				size = < 0x400000 >;
    				address-width = < 0x18 >;
    				spi-max-frequency = < 0x2faf080 >;
    				timeout = < 0x5 >;
    			};
    			flash_at25pe80: flash_at25pe80@2 {
    				compatible = "jedec,spi-nor";
    				status = "okay";
    				size = < 0x800000 >;
    				reg = < 0x2 >;
    				jedec-id = [ 1F 25 00 ];
    				spi-max-frequency = < 0x7a1200 >;
    				partitions {
    					compatible = "fixed-partitions";
    					#address-cells = < 0x2 >;
    					#size-cells = < 0x1 >;
    					confflash: partition@0 {
    						label = "config";
    						reg = < 0x2 0x90000 0x400 >;
    					};
    					extflash: partition@1 {
    						label = "external-flash";
    						reg = < 0x2 0x90400 0xffc00 >;
    					};
    				};
    			};
    		};
    		nfct: nfct@40005000 {
    			compatible = "nordic,nrf-nfct";
    			reg = < 0x40005000 0x1000 >;
    			interrupts = < 0x5 0x1 >;
    			status = "okay";
    		};
    		gpiote: gpiote@40006000 {
    			compatible = "nordic,nrf-gpiote";
    			reg = < 0x40006000 0x1000 >;
    			interrupts = < 0x6 0x5 >;
    			status = "okay";
    		};
    		adc: adc@40007000 {
    			compatible = "nordic,nrf-saadc";
    			reg = < 0x40007000 0x1000 >;
    			interrupts = < 0x7 0x1 >;
    			status = "disabled";
    			#io-channel-cells = < 0x1 >;
    		};
    		timer0: timer@40008000 {
    			compatible = "nordic,nrf-timer";
    			status = "disabled";
    			reg = < 0x40008000 0x1000 >;
    			cc-num = < 0x4 >;
    			max-bit-width = < 0x20 >;
    			interrupts = < 0x8 0x1 >;
    			prescaler = < 0x0 >;
    		};
    		timer1: timer@40009000 {
    			compatible = "nordic,nrf-timer";
    			status = "disabled";
    			reg = < 0x40009000 0x1000 >;
    			cc-num = < 0x4 >;
    			max-bit-width = < 0x20 >;
    			interrupts = < 0x9 0x1 >;
    			prescaler = < 0x0 >;
    		};
    		timer2: timer@4000a000 {
    			compatible = "nordic,nrf-timer";
    			status = "disabled";
    			reg = < 0x4000a000 0x1000 >;
    			cc-num = < 0x4 >;
    			max-bit-width = < 0x20 >;
    			interrupts = < 0xa 0x1 >;
    			prescaler = < 0x0 >;
    			phandle = < 0xb >;
    		};
    		rtc0: rtc@4000b000 {
    			compatible = "nordic,nrf-rtc";
    			reg = < 0x4000b000 0x1000 >;
    			cc-num = < 0x3 >;
    			interrupts = < 0xb 0x1 >;
    			status = "disabled";
    			clock-frequency = < 0x8000 >;
    			prescaler = < 0x1 >;
    		};
    		temp: temp@4000c000 {
    			compatible = "nordic,nrf-temp";
    			reg = < 0x4000c000 0x1000 >;
    			interrupts = < 0xc 0x1 >;
    			status = "okay";
    		};
    		rng: random@4000d000 {
    			compatible = "nordic,nrf-rng";
    			reg = < 0x4000d000 0x1000 >;
    			interrupts = < 0xd 0x1 >;
    			status = "okay";
    		};
    		ecb: ecb@4000e000 {
    			compatible = "nordic,nrf-ecb";
    			reg = < 0x4000e000 0x1000 >;
    			interrupts = < 0xe 0x1 >;
    			status = "okay";
    		};
    		ccm: ccm@4000f000 {
    			compatible = "nordic,nrf-ccm";
    			reg = < 0x4000f000 0x1000 >;
    			interrupts = < 0xf 0x1 >;
    			length-field-length-8-bits;
    			status = "okay";
    		};
    		wdt: wdt0: watchdog@40010000 {
    			compatible = "nordic,nrf-wdt";
    			reg = < 0x40010000 0x1000 >;
    			interrupts = < 0x10 0x1 >;
    			status = "okay";
    		};
    		rtc1: rtc@40011000 {
    			compatible = "nordic,nrf-rtc";
    			reg = < 0x40011000 0x1000 >;
    			cc-num = < 0x4 >;
    			interrupts = < 0x11 0x1 >;
    			status = "disabled";
    			clock-frequency = < 0x8000 >;
    			prescaler = < 0x1 >;
    		};
    		qdec: qdec0: qdec@40012000 {
    			compatible = "nordic,nrf-qdec";
    			reg = < 0x40012000 0x1000 >;
    			interrupts = < 0x12 0x1 >;
    			status = "disabled";
    		};
    		comp: comparator@40013000 {
    			compatible = "nordic,nrf-comp";
    			reg = < 0x40013000 0x1000 >;
    			interrupts = < 0x13 0x1 >;
    			status = "disabled";
    			#io-channel-cells = < 0x1 >;
    		};
    		egu0: swi0: egu@40014000 {
    			compatible = "nordic,nrf-egu", "nordic,nrf-swi";
    			reg = < 0x40014000 0x1000 >;
    			interrupts = < 0x14 0x1 >;
    			status = "okay";
    		};
    		egu1: swi1: egu@40015000 {
    			compatible = "nordic,nrf-egu", "nordic,nrf-swi";
    			reg = < 0x40015000 0x1000 >;
    			interrupts = < 0x15 0x1 >;
    			status = "okay";
    		};
    		egu2: swi2: egu@40016000 {
    			compatible = "nordic,nrf-egu", "nordic,nrf-swi";
    			reg = < 0x40016000 0x1000 >;
    			interrupts = < 0x16 0x1 >;
    			status = "okay";
    		};
    		egu3: swi3: egu@40017000 {
    			compatible = "nordic,nrf-egu", "nordic,nrf-swi";
    			reg = < 0x40017000 0x1000 >;
    			interrupts = < 0x17 0x1 >;
    			status = "okay";
    		};
    		egu4: swi4: egu@40018000 {
    			compatible = "nordic,nrf-egu", "nordic,nrf-swi";
    			reg = < 0x40018000 0x1000 >;
    			interrupts = < 0x18 0x1 >;
    			status = "okay";
    		};
    		egu5: swi5: egu@40019000 {
    			compatible = "nordic,nrf-egu", "nordic,nrf-swi";
    			reg = < 0x40019000 0x1000 >;
    			interrupts = < 0x19 0x1 >;
    			status = "okay";
    		};
    		timer3: timer@4001a000 {
    			compatible = "nordic,nrf-timer";
    			status = "disabled";
    			reg = < 0x4001a000 0x1000 >;
    			cc-num = < 0x6 >;
    			max-bit-width = < 0x20 >;
    			interrupts = < 0x1a 0x1 >;
    			prescaler = < 0x0 >;
    		};
    		timer4: timer@4001b000 {
    			compatible = "nordic,nrf-timer";
    			status = "disabled";
    			reg = < 0x4001b000 0x1000 >;
    			cc-num = < 0x6 >;
    			max-bit-width = < 0x20 >;
    			interrupts = < 0x1b 0x1 >;
    			prescaler = < 0x0 >;
    		};
    		pwm0: pwm@4001c000 {
    			compatible = "nordic,nrf-pwm";
    			reg = < 0x4001c000 0x1000 >;
    			interrupts = < 0x1c 0x1 >;
    			status = "okay";
    			#pwm-cells = < 0x3 >;
    			pinctrl-0 = < &pwm0_default >;
    			pinctrl-1 = < &pwm0_sleep >;
    			pinctrl-names = "default", "sleep";
    			phandle = < 0xd >;
    		};
    		pdm0: pdm@4001d000 {
    			compatible = "nordic,nrf-pdm";
    			reg = < 0x4001d000 0x1000 >;
    			interrupts = < 0x1d 0x1 >;
    			status = "disabled";
    		};
    		acl: acl@4001e000 {
    			compatible = "nordic,nrf-acl";
    			reg = < 0x4001e000 0x1000 >;
    			status = "okay";
    		};
    		flash_controller: flash-controller@4001e000 {
    			compatible = "nordic,nrf52-flash-controller";
    			reg = < 0x4001e000 0x1000 >;
    			partial-erase;
    			#address-cells = < 0x1 >;
    			#size-cells = < 0x1 >;
    			flash0: flash@0 {
    				compatible = "soc-nv-flash";
    				erase-block-size = < 0x1000 >;
    				write-block-size = < 0x4 >;
    				reg = < 0x0 0x80000 >;
    				partitions {
    					compatible = "fixed-partitions";
    					#address-cells = < 0x1 >;
    					#size-cells = < 0x1 >;
    					boot_partition: partition@0 {
    						label = "mcuboot";
    						reg = < 0x0 0xc000 >;
    					};
    					slot0_partition: partition@c000 {
    						label = "image-0";
    						reg = < 0xc000 0x32000 >;
    					};
    					slot1_partition: partition@3e000 {
    						label = "image-1";
    						reg = < 0x3e000 0x32000 >;
    					};
    					scratch_partition: partition@70000 {
    						label = "image-scratch";
    						reg = < 0x70000 0xa000 >;
    					};
    					storage_partition: partition@7a000 {
    						label = "storage";
    						reg = < 0x7a000 0x6000 >;
    					};
    				};
    			};
    		};
    		ppi: ppi@4001f000 {
    			compatible = "nordic,nrf-ppi";
    			reg = < 0x4001f000 0x1000 >;
    			status = "okay";
    		};
    		mwu: mwu@40020000 {
    			compatible = "nordic,nrf-mwu";
    			reg = < 0x40020000 0x1000 >;
    			status = "okay";
    		};
    		pwm1: pwm@40021000 {
    			compatible = "nordic,nrf-pwm";
    			reg = < 0x40021000 0x1000 >;
    			interrupts = < 0x21 0x1 >;
    			status = "disabled";
    			#pwm-cells = < 0x3 >;
    		};
    		pwm2: pwm@40022000 {
    			compatible = "nordic,nrf-pwm";
    			reg = < 0x40022000 0x1000 >;
    			interrupts = < 0x22 0x1 >;
    			status = "disabled";
    			#pwm-cells = < 0x3 >;
    		};
    		spi2: spi@40023000 {
    			compatible = "nordic,nrf-spim";
    			#address-cells = < 0x1 >;
    			#size-cells = < 0x0 >;
    			reg = < 0x40023000 0x1000 >;
    			interrupts = < 0x23 0x1 >;
    			max-frequency = < 0x7a1200 >;
    			easydma-maxcnt-bits = < 0x10 >;
    			status = "disabled";
    		};
    		rtc2: rtc@40024000 {
    			compatible = "nordic,nrf-rtc";
    			reg = < 0x40024000 0x1000 >;
    			cc-num = < 0x4 >;
    			interrupts = < 0x24 0x1 >;
    			status = "disabled";
    			clock-frequency = < 0x8000 >;
    			prescaler = < 0x1 >;
    		};
    		i2s0: i2s@40025000 {
    			compatible = "nordic,nrf-i2s";
    			#address-cells = < 0x1 >;
    			#size-cells = < 0x0 >;
    			reg = < 0x40025000 0x1000 >;
    			interrupts = < 0x25 0x1 >;
    			status = "disabled";
    		};
    		usbd: usbd@40027000 {
    			compatible = "nordic,nrf-usbd";
    			reg = < 0x40027000 0x1000 >;
    			interrupts = < 0x27 0x1 >;
    			num-bidir-endpoints = < 0x1 >;
    			num-in-endpoints = < 0x7 >;
    			num-out-endpoints = < 0x7 >;
    			num-isoin-endpoints = < 0x1 >;
    			num-isoout-endpoints = < 0x1 >;
    			status = "disabled";
    		};
    		uart1: uart@40028000 {
    			compatible = "nordic,nrf-uarte";
    			reg = < 0x40028000 0x1000 >;
    			interrupts = < 0x28 0x1 >;
    			status = "disabled";
    		};
    		pwm3: pwm@4002d000 {
    			compatible = "nordic,nrf-pwm";
    			reg = < 0x4002d000 0x1000 >;
    			interrupts = < 0x2d 0x1 >;
    			status = "disabled";
    			#pwm-cells = < 0x3 >;
    		};
    		spi3: spi@4002f000 {
    			compatible = "nordic,nrf-spim";
    			#address-cells = < 0x1 >;
    			#size-cells = < 0x0 >;
    			reg = < 0x4002f000 0x1000 >;
    			interrupts = < 0x2f 0x1 >;
    			max-frequency = < 0x1e84800 >;
    			easydma-maxcnt-bits = < 0x10 >;
    			rx-delay-supported;
    			rx-delay = < 0x2 >;
    			status = "disabled";
    		};
    		gpio0: gpio@50000000 {
    			compatible = "nordic,nrf-gpio";
    			gpio-controller;
    			reg = < 0x50000000 0x200 0x50000500 0x300 >;
    			#gpio-cells = < 0x2 >;
    			status = "okay";
    			port = < 0x0 >;
    			phandle = < 0x6 >;
    		};
    		gpio1: gpio@50000300 {
    			compatible = "nordic,nrf-gpio";
    			gpio-controller;
    			reg = < 0x50000300 0x200 0x50000800 0x300 >;
    			#gpio-cells = < 0x2 >;
    			ngpios = < 0xa >;
    			status = "okay";
    			port = < 0x1 >;
    			phandle = < 0xe >;
    		};
    	};
    	pinctrl: pin-controller {
    		compatible = "nordic,nrf-pinctrl";
    		uart0_default: uart0_default {
    			phandle = < 0x2 >;
    			group1 {
    				psels = < 0x1d >, < 0x20009 >;
    			};
    			group2 {
    				psels = < 0x1001c >, < 0x3000a >;
    				bias-pull-up;
    			};
    		};
    		uart0_sleep: uart0_sleep {
    			phandle = < 0x3 >;
    			group1 {
    				psels = < 0x1d >, < 0x1001c >, < 0x20009 >, < 0x3000a >;
    				low-power-enable;
    			};
    		};
    		i2c0_default: i2c0_default {
    			phandle = < 0x4 >;
    			group1 {
    				psels = < 0xc001a >, < 0xb001b >;
    			};
    		};
    		i2c0_sleep: i2c0_sleep {
    			phandle = < 0x5 >;
    			group1 {
    				psels = < 0xc001a >, < 0xb001b >;
    				low-power-enable;
    			};
    		};
    		pwm0_default: pwm0_default {
    			phandle = < 0x9 >;
    			group1 {
    				psels = < 0x160018 >, < 0x170016 >, < 0x180015 >;
    				nordic,invert;
    			};
    		};
    		pwm0_sleep: pwm0_sleep {
    			phandle = < 0xa >;
    			group1 {
    				psels = < 0x160018 >, < 0x170016 >, < 0x180015 >;
    				low-power-enable;
    			};
    		};
    		spi1_default: spi1_default {
    			phandle = < 0x7 >;
    			group1 {
    				psels = < 0x40029 >, < 0x50028 >, < 0x60004 >;
    			};
    		};
    		spi1_sleep: spi1_sleep {
    			phandle = < 0x8 >;
    			group1 {
    				psels = < 0x40029 >, < 0x50028 >, < 0x60004 >;
    				low-power-enable;
    			};
    		};
    	};
    	rng_hci: entropy_bt_hci {
    		compatible = "zephyr,bt-hci-entropy";
    		status = "okay";
    	};
    	cpus {
    		#address-cells = < 0x1 >;
    		#size-cells = < 0x0 >;
    		cpu@0 {
    			device_type = "cpu";
    			compatible = "arm,cortex-m4f";
    			reg = < 0x0 >;
    			#address-cells = < 0x1 >;
    			#size-cells = < 0x1 >;
    			itm: itm@e0000000 {
    				compatible = "arm,armv7m-itm";
    				reg = < 0xe0000000 0x1000 >;
    				swo-ref-frequency = < 0x1e84800 >;
    			};
    		};
    	};
    	sw_pwm: sw-pwm {
    		compatible = "nordic,nrf-sw-pwm";
    		status = "disabled";
    		generator = < &timer2 >;
    		clock-prescaler = < 0x0 >;
    		#pwm-cells = < 0x3 >;
    	};
    	zephyr,user {
    		io-channels = < &ads1219 0x3 >, < &ads1219 0x4 >;
    		io-channel-names = "gyro_rate", "gyro_temp";
    	};
    	pwmleds {
    		compatible = "pwm-leds";
    		pwm_red: pwm_red {
    			status = "okay";
    			pwms = < &pwm0 0x0 0x1312d00 0x1 >;
    			label = "PWM_RED";
    		};
    		pwm_green: pwm_green {
    			status = "okay";
    			pwms = < &pwm0 0x1 0x1312d00 0x1 >;
    			label = "PWM_GREEN";
    		};
    		pwm_blue: pwm_blue {
    			status = "okay";
    			pwms = < &pwm0 0x2 0x1312d00 0x1 >;
    			label = "PWM_BLUE";
    		};
    	};
    	control {
    		compatible = "gpio-leds";
    		shdn_ltc3525: shdn_ltc3525 {
    			status = "okay";
    			gpios = < &gpio1 0x6 0x0 >;
    			label = "SHDN_5V";
    		};
    		bq35100_ge: bq35100_ge {
    			status = "okay";
    			gpios = < &gpio1 0x7 0x0 >;
    			label = "GE_EN";
    		};
    	};
    	interrupts {
    		compatible = "gpio-keys";
    		tilt1: tilt1 {
    			status = "okay";
    			gpios = < &gpio0 0x13 0x1 >;
    			label = "TILT1";
    		};
    		tilt2: tilt2 {
    			status = "okay";
    			gpios = < &gpio0 0x19 0x1 >;
    			label = "TILT2";
    		};
    		hall_int: hall_int {
    			status = "okay";
    			gpios = < &gpio1 0x5 0x1 >;
    			label = "ACT";
    		};
    		bq35100_alarm: bq35100_alarm {
    			status = "okay";
    			gpios = < &gpio1 0x3 0x1 >;
    			label = "ALARM";
    		};
    	};
    	adxrs649: adxrs649 {
    		status = "okay";
    		compatible = "adi,adxrs649";
    		io-channels = < &ads1219 0x3 >, < &ads1219 0x4 >;
    		st1-gpios = < &gpio0 0x10 0x0 >;
    	};
    };
    

  • I can't see anything that immediately stand out. Could you please just build one more time (not pristine build/clean and rebuild) and share the full log?

    It might also be helpful to look at the preprocessed spi_nor.c file to see what expanded into the missing ordinal. The method is documented here: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.4.1/zephyr/build/dts/troubleshooting.html#look-at-the-preprocessor-output.

  • I've deleted the whole build folder and created a new build configuration.

    Two errors stick out to me in line 475:

    c:/users/sw2.krafft/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: zephyr/drivers/flash/libdrivers__flash.a(spi_nor.c.obj):(.rodata.spi_nor_config_0+0x0): undefined reference to `__device_dts_ord_100'

    This the SPI error I've suspected. And earlier at line 73 (with context):

    CMake Warning (dev) at C:/carl-ble-sensor-firmware/build/mcuboot/child_image_preload.cmake:8 (set):
      Syntax error in cmake code at
    
        C:/carl-ble-sensor-firmware/build/mcuboot/child_image_preload.cmake:8
    
      when parsing string
    
        C:\Users\sw2.KRAFFT\ncs\toolchains\31f4403e35\opt\bin\python.exe
    
      Invalid escape sequence \U

    I'm not sure where the error with the escape sequence comes from.

    I'm also not entirely sure what to do with the created spi_nor.c.i. __device_dts_ord_100 is defined as a struct and also used as part of a SPI configuration. It appears at two positions:

    # 968 "C:/Users/sw2.KRAFFT/ncs/zephyr/include/zephyr/device.h"
    extern const struct device __device_dts_ord_0; extern const struct device __device_dts_ord_12; extern const struct device __device_dts_ord_11; extern const struct device __device_dts_ord_1; extern const struct device __device_dts_ord_7; extern const struct device __device_dts_ord_58; extern const struct device __device_dts_ord_86; extern const struct device __device_dts_ord_62; extern const struct device __device_dts_ord_49; extern const struct device __device_dts_ord_95; extern const struct device __device_dts_ord_96; extern const struct device __device_dts_ord_97; extern const struct device __device_dts_ord_98; extern const struct device __device_dts_ord_84; extern const struct device __device_dts_ord_8; extern const struct device __device_dts_ord_91; extern const struct device __device_dts_ord_92; extern const struct device __device_dts_ord_9; extern const struct device __device_dts_ord_93; extern const struct device __device_dts_ord_94; extern const struct device __device_dts_ord_100; extern const struct device __device_dts_ord_101; extern const struct device __device_dts_ord_102; extern const struct device __device_dts_ord_64; extern const struct device __device_dts_ord_59; extern const struct device __device_dts_ord_78; extern const struct device __device_dts_ord_71; extern const struct device __device_dts_ord_51; extern const struct device __device_dts_ord_48; extern const struct device __device_dts_ord_88; extern const struct device __device_dts_ord_52; extern const struct device __device_dts_ord_53; extern const struct device __device_dts_ord_54; extern const struct device __device_dts_ord_55; extern const struct device __device_dts_ord_56; extern const struct device __device_dts_ord_57; extern const struct device __device_dts_ord_42; extern const struct device __device_dts_ord_46; extern const struct device __device_dts_ord_89; extern const struct device __device_dts_ord_90; extern const struct device __device_dts_ord_66; extern const struct device __device_dts_ord_63; extern const struct device __device_dts_ord_3; extern const struct device __device_dts_ord_2; extern const struct device __device_dts_ord_4; extern const struct device __device_dts_ord_36; extern const struct device __device_dts_ord_37; extern const struct device __device_dts_ord_38; extern const struct device __device_dts_ord_39; extern const struct device __device_dts_ord_40; extern const struct device __device_dts_ord_5; extern const struct device __device_dts_ord_26; extern const struct device __device_dts_ord_6; extern const struct device __device_dts_ord_27; extern const struct device __device_dts_ord_28; extern const struct device __device_dts_ord_29; extern const struct device __device_dts_ord_30; extern const struct device __device_dts_ord_31; extern const struct device __device_dts_ord_32; extern const struct device __device_dts_ord_33; extern const struct device __device_dts_ord_34; extern const struct device __device_dts_ord_35; extern const struct device __device_dts_ord_13; extern const struct device __device_dts_ord_19; extern const struct device __device_dts_ord_20; extern const struct device __device_dts_ord_21; extern const struct device __device_dts_ord_16; extern const struct device __device_dts_ord_41; extern const struct device __device_dts_ord_45; extern const struct device __device_dts_ord_44; extern const struct device __device_dts_ord_43; extern const struct device __device_dts_ord_17; extern const struct device __device_dts_ord_22; extern const struct device __device_dts_ord_24; extern const struct device __device_dts_ord_25; extern const struct device __device_dts_ord_23; extern const struct device __device_dts_ord_10;
    

    # 1359 "C:/Users/sw2.KRAFFT/ncs/zephyr/drivers/flash/spi_nor.c"
    static const struct spi_nor_config spi_nor_config_0 = {
     .spi = { .bus = (&__device_dts_ord_100), .config = { .frequency = 8000000, .operation = (((8) << (5U))) | 0 | 0, .slave = 2, .cs = (&(struct spi_cs_control) { .gpio = { .port = (&__device_dts_ord_3), .pin = 23, .dt_flags = 1, }, .delay = (0), }), } }
                                         ,
    
    
    
     .layout = {
      .pages_count = ((8388608 / 8) / 4096),
      .pages_size = 4096,
     },
    
    
    
     .flash_size = 8388608 / 8,
     .jedec_id = {31 , 37 , 0 },
    

    I'm not able to paste long texts somehow in the code window, I click 'okay' and nothing happens. Is there any other way to paste or attach the log and the spi_nor.c.i?

  • Bjoern Bialy said:
    I'm not sure where the error with the escape sequence comes from.

    That error doesn't make much sense to me either. I think it might be the script being unable to pick up certain files correctly, and the commands are badly generated. Let's see if it goes away after we fix the missing ordinal issue.

    Bjoern Bialy said:
    I'm also not entirely sure what to do with the created spi_nor.c.i. __device_dts_ord_100 is defined as a struct and also used as part of a SPI configuration. It appears at two positions:

    The idea is to check between the spi_nor.c.i file and the spi_nor.c file to see what expanded into the missing __device_dts_ord_100. That can give us a clue for where the missing configuration is.

    For example, from the #1359 log, we can match it to line 1359 in spi_nor.c:

    static const struct spi_nor_config spi_nor_config_0 = {
    	.spi = SPI_DT_SPEC_INST_GET(0, SPI_WORD_SET(8),
    				    CONFIG_SPI_NOR_CS_WAIT_DELAY),
    #if !defined(CONFIG_SPI_NOR_SFDP_RUNTIME)
    
    #if defined(CONFIG_FLASH_PAGE_LAYOUT)
    	.layout = {
    		.pages_count = LAYOUT_PAGES_COUNT,
    		.pages_size = CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE,
    	},

    So, it looks like the SPI_DT_SPEC_INST_GET couldn't expand properly. 

    How are you specifying the SPI flash in DTS?
    Is it provided to both the application and MCUboot?
    Is CONFIG_SPI_NOR also set for the application?

    Does the error happen during the MCUboot child image build, or during the application build?

    Bjoern Bialy said:
    I'm not able to paste long texts somehow in the code window, I click 'okay' and nothing happens. Is there any other way to paste or attach the log and the spi_nor.c.i?

    You can just attach the file to the case. I often do it by dragging and dropping. However, you can also use the Insert menu.

    It will be helpful if I can get all of the following:

    • Full pristine build log (full context)
    • Build log from building again, without cleaning the previous build (the log should be condensed and show only the issue)
    • MCUboot .config file
    • MCUboot zephyr.dts file
    • Application .config file
    • Application zephyr.dts file
  • Just want to share that I learned a different and more convenient approach than the .i file referencing today. We can check the devicetree_generated.h file in the build directories.

    If the build failed during MCUboot linking phase, we will want to look at <build dir>/mcuboot/include/generated/devicetree_generated.h.

    If the build failed during the application linking phase, we will want to look at <build_dir/include/generated/devicetree_generated.h.

  • I have attached the files per your instructions. I've also added the devicetree_generated.h of both McuBoot and the application. I hope it will help somehow.

    EDIT: I have also added the spi_nor.c.i.

    6663.Logs-2023-09-13.zip

Reply Children
Related