DFU BLE FOTA not working on nRF5340 Audio DK board

Hi there:

I want to do BLE FOTA on nRF5340 Audio DK board.  I have sdk v2.6.2.  I'm trying to make the existing audio application work by taking the source code as it is from "~/ncs/v2.6.2/nrf/applications/nrf5340_audio".  I added only one line in prj.conf, which is

CONFIG_AUDIO_DFU=2

The build command is as follows.

west build --build-dir ~/ncs/v2.6.2/nrf/applications/nrf5340_audio/build ~/ncs/v2.6.2/nrf/applications/nrf5340_audio --pristine --board nrf5340_audio_dk_nrf5340_cpuapp -- -DNCS_TOOLCHAIN_VERSION=NONE -DCONFIG_SIZE_OPTIMIZATIONS=y

I get errors like below.

In file included from /home/someusr/ncs/v2.6.2/bootloader/mcuboot/boot/zephyr/include/sysflash/sysflash.h:10,
                 from /home/someusr/ncs/v2.6.2/bootloader/mcuboot/boot/bootutil/src/bootutil_misc.c:32:
/home/someusr/ncs/v2.6.2/bootloader/mcuboot/boot/zephyr/include/sysflash/pm_sysflash.h: In function '__flash_area_ids_for_slot':
/home/someusr/ncs/v2.6.2/bootloader/mcuboot/boot/zephyr/include/sysflash/pm_sysflash.h:47:60: error: 'PM_MCUBOOT_SECONDARY_ID' undeclared (first use in this function); did you mean 'PM_MCUBOOT_PRIMARY_ID'?
   47 | #define FLASH_AREA_IMAGE_0_SLOTS    PM_MCUBOOT_PRIMARY_ID, PM_MCUBOOT_SECONDARY_ID
      |                                                            ^~~~~~~~~~~~~~~~~~~~~~~
/home/someusr/ncs/v2.6.2/bootloader/mcuboot/boot/zephyr/include/sysflash/pm_sysflash.h:52:29: note: in expansion of macro 'FLASH_AREA_IMAGE_0_SLOTS'
   52 | #define ALL_AVAILABLE_SLOTS FLASH_AREA_IMAGE_0_SLOTS
      |                             ^~~~~~~~~~~~~~~~~~~~~~~~
/home/someusr/ncs/v2.6.2/bootloader/mcuboot/boot/zephyr/include/sysflash/pm_sysflash.h:67:9: note: in expansion of macro 'ALL_AVAILABLE_SLOTS'
   67 |         ALL_AVAILABLE_SLOTS

I tried with different CONFIG_AUDIO_DFU=1, that gives flash size error.

I have below questions:

1. How to make this application work for BLE FOTA DFU?

2. I have my own application that can run BLE FOTA DFU successfully on nrf5340dk board.  I used the following in mcuboot.overlay file and in prj.conf of the app and mcuboot.conf.  If I need to make this app run on nrf5340 audio board with  BLE FOTA DFU,  what do I need to modify in the following?

mcuboot.overlay
/ {
    chosen {
        nordic,pm-ext-flash = &mx25r64;
    };
};
app prj.conf
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
CONFIG_NRF53_UPGRADE_NETWORK_CORE=y
CONFIG_UPDATEABLE_IMAGE_NUMBER=2
mcuboot.conf
CONFIG_NORDIC_QSPI_NOR=y
CONFIG_BOOT_MAX_IMG_SECTORS=256
CONFIG_LOG=y
CONFIG_MCUBOOT_LOG_LEVEL_WRN=y
CONFIG_NRF53_MULTI_IMAGE_UPDATE=y
CONFIG_UPDATEABLE_IMAGE_NUMBER=2
CONFIG_BOOT_UPGRADE_ONLY=y
CONFIG_PCD_APP=y
CONFIG_FLASH=y
CONFIG_FLASH_SIMULATOR=y
CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y
CONFIG_FLASH_SIMULATOR_STATS=n
CONFIG_BOOT_SIGNATURE_KEY_FILE="/path/somekey.pem"
3.  The nRF5340 Audio DK product brief says
"The nRF5340 Audio DK application uses the MX25R6435F as the SPI NOR Flash."
And, I see the following in ~/ncs/v2.6.2/nrf/applications/nrf5340_audio/dfu/conf/overlay-dfu_external_flash.overlay. I think the solution for my requirement (BLE FOTA DFU on nRF5340 Audio board for my app)  is to understand this better.  Please throw some light on this.  Refer me to a place where I can go through resources around this to understand this better.

    mx25r64: mx25r6435f@2 {

        compatible = "jedec,spi-nor";
        reg = <2>;
        spi-max-frequency = <8000000>;

        jedec-id = [c2 28 17];
        sfdp-bfp = [
            e5 20 f1 ff  ff ff ff 03  44 eb 08 6b  08 3b 04 bb
            ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
            10 d8 00 ff  23 72 f5 00  82 ed 04 cc  44 83 68 44
            30 b0 30 b0  f7 c4 d5 5c  00 be 29 ff  f0 d0 ff ff
        ];
        size = <67108864>;
        has-dpd;
        t-enter-dpd = <10000>;
        t-exit-dpd = <5000>;
        dpd-wakeup-sequence = <30000 20 45000>;
    };

Related