Failing to build using sysbuild/NCS2.9.0 with MCUboot for DFU enabled for app/CPU-NET/Wifi fw

Situation : custom nrf5340/nrf7002 board (very close to production...). Main image is overflowing available internal flash (with a MCUboot 64kB partition).

Secondary slots etc are on 8Mb external flash (QSPI connected)

Up to now, using the 'multi-image build' process (migrated from 2.6->2.8->2.9 in search of stable wifi/networking operation).

I want to move the wifi fw patches (approx 80kB) to the external flash also (CONFIG_WIFI_PATCHES_EXT_FLASH_STORE=y). This forces me to move to sysbuild as the mechanism to generate the required .hex files is not supported in the old mutli-image CMakefiles. This successfully puts the wifi bin file (nrf70.bin) in the external flash... 

The build was working, but then when flashed to the board mcuboot refused to run the app. No error or explanation. I tried updating the partition sizes to let it have 64kB so I could also enable serial download over USB.... and now I cannot get the build to complete.

It fails building mcuboot, with an error indicating that 'PM_MCUBOOT_PRIMARY_1_ID' is not defined.

...

oot/bootutil/src/bootutil_public.c
In file included from C:/ncs/v2.9.0/bootloader/mcuboot/boot/zephyr/include/sysflash/sysflash.h:12,
from C:/ncs/v2.9.0/bootloader/mcuboot/boot/bootutil/src/bootutil_public.c:43:
C:/ncs/v2.9.0/bootloader/mcuboot/boot/zephyr/include/sysflash/pm_sysflash.h: In function '__flash_area_ids_for_slot':
C:/ncs/v2.9.0/bootloader/mcuboot/boot/zephyr/include/sysflash/pm_sysflash.h:20:37: error: 'PM_MCUBOOT_PRIMARY_1_ID' undeclared (first use in this function); did you mean 'PM_MCUBOOT_PRIMARY_2_ID'?
20 | #define FLASH_AREA_IMAGE_1_SLOTS PM_MCUBOOT_PRIMARY_1_ID, PM_MCUBOOT_SECONDARY_1_ID,
| ^~~~~~~~~~~~~~~~~~~~~~~

This is the id for the 'ram-flash' partition that simulates the primary partition for the CPU-NET DFU operation (as explained in the tutorials about DFU). The pm_sysflash.h is I think looking for 2 image slots, instead of the 3 it should expect (app, cpu-net, wifi fw).

The generated pm_config.h indeed does not contain this id, despite it being defined in my pm_static.yml:


# need fake flash ram flash partition to do cpunet DFU...
mcuboot_primary_1:
    region: ram_flash
    address: 0x0
    affiliation:
        - mcuboot
    size: 0x40000
    device: flash_ctrl
    #  end_address: 0x40000
    #  device: nordic_ram_flash_controller

ram_flash:
  address: 0x40000
  end_address: 0x40000
  region: ram_flash
  size: 0x0
I have the dts controller defined as:
/ {
    soc {
        /* Add a flash controller which has the compatible
         * 'zephyr,sim-flash'. This will ensure that the flash
         * simulator can use it. None of the other properties in this
         * node is used for anything.
         */
        nordic_ram_flash_controller: nordic_ram-flash-controller@0 {
            compatible = "zephyr,sim-flash";
            reg = <0x00000000 DT_SIZE_K(40)>;
            #address-cells = <1>;
            #size-cells = <1>;
            erase-value = <0xff>;

            /* This node label must match that used in the flash
             * simulator.
             */
            flash_sim0: flash_sim@0 {
                status = "okay";
                compatible = "soc-nv-flash";
                erase-block-size = <4096>;
                write-block-size = <4>;
                reg = <0x00000000 DT_SIZE_K(256)>;

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

                    /* This partition must be defined for
                     * MCUboot to find the partition ID
                     * of the primary slot for image 1,
                     * which is stored in this partition.
                     */
                    slot2_partition: partition@0 {
                        label = "image-2";
                        reg = <0x00000000 0x00000A000>;
                    };
                };
            };
        };
    };
};
(copied from nrf/modules/mcuboot/flash_sim.overlay)
and the entries in the sysbuild/mcuboot/prj.conf to enable the simulator from the nrf5340_exip_image.conf in the same place:
# The network core cannot access external flash directly. The flash simulator must be used to
# provide a memory region that is used to forward the new firmware to the network core.
CONFIG_FLASH_SIMULATOR=y
CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y
CONFIG_FLASH_SIMULATOR_STATS=n
Why doesn't sysbuild generate the PM defines for the priimary_1 partition? What dependancy did I break?
Parents
  • AHaug said:
    I've converted this ticket to private since you've shared some firmware (not sure if it was intentional to have it as public).

    No problem for it being public, the shared source is just the wifi_sta sample updated to build (in principle) with mcuboot and external flash for slots including the wifi fw.

    AHaug said:
    I couldn't spot anything immediately within your sample, so I will have to spend some time going through the sample as well as to try and set up a sample similar to the requirements that you have listed to familiarize myself with XIP + wifi fw patch offloading. To do this I will base it on the mcuboot configuration from the sample I sent you

    In principle the mcuboot config is based on the config changes you sent in that ticket (particularly the enabling of LTO).

    The problem appear to be centered around getting the PM under sysbuild to recognise the primary slot for the DFU of the CPU-NET image (mcuboot_primary_1) : it doesn't seem to generate this partition (which is a 'fake flash RAM partition)...Its undoubtly something simple enough in the Kconfig, but the intermixed dependancies in this system are so hard to make work...

Reply
  • AHaug said:
    I've converted this ticket to private since you've shared some firmware (not sure if it was intentional to have it as public).

    No problem for it being public, the shared source is just the wifi_sta sample updated to build (in principle) with mcuboot and external flash for slots including the wifi fw.

    AHaug said:
    I couldn't spot anything immediately within your sample, so I will have to spend some time going through the sample as well as to try and set up a sample similar to the requirements that you have listed to familiarize myself with XIP + wifi fw patch offloading. To do this I will base it on the mcuboot configuration from the sample I sent you

    In principle the mcuboot config is based on the config changes you sent in that ticket (particularly the enabling of LTO).

    The problem appear to be centered around getting the PM under sysbuild to recognise the primary slot for the DFU of the CPU-NET image (mcuboot_primary_1) : it doesn't seem to generate this partition (which is a 'fake flash RAM partition)...Its undoubtly something simple enough in the Kconfig, but the intermixed dependancies in this system are so hard to make work...

Children
No Data
Related