Matter bridge build process fails with "region `FLASH' overflowed"

Hi guys,

I'm playing with : Matter Bridge from SDK v2.6.0.rc1 on nRF7002-DK. I tried to extend Matter data model with "Temperature color light" and add a new device but it caused that its flash is overflowed:


...
-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/zephyr_pre0.elf section `datas' will not fit in region `FLASH'
/home/ubuntu/Projects/nordic-4.1.2/toolchains/19127b768d/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: region `FLASH' overflowed by 1784 bytes



My question is very simple: How to fix it? What exacly should I change to solve it?
I know that DK has 1MB internal flash and 8MB external flash...I hope. I try to read documentation about Partition manager, Multi-image builds, external flash, XIP but I'm a bit lost. I also tried to find something here in issues. Would it be possible to somehow re-arrange internal flash? or is possible to use external flash instead of internal one? I've played with it a couple of days but without any success. There are too many options for me which must match together (files: *.conf, *.overlay, *.yml, ...). Optimizations like "-Os", "no debug symbols" didn't help me much.

Parents
  • You've already mentioned using optimization flags like -Os to optimize code size. Ensure that these flags are applied correctly and consider experimenting with other optimization flags if necessary. If your device has an external flash memory, you may need to configure the Partition Manager to utilize it effectively. This involves defining memory regions and their sizes in the partition manager configuration file. Make sure that your firmware image is configured to be stored in the external flash if you have one. If your device supports multi-image builds, you can split your firmware into multiple images, each stored in different memory regions. This can help manage memory usage more efficiently.

  • Thank you for the fast response.

    - You didn't mentioned re-arrange internal flash. Does it mean it is not possible?
    - I mentioned optimizations only to show a big picture what I tried to use. I'm not going to follow this way.
    - I checked again the presence of the external flash and found it here in file PCA10143_Schematic_And_PCB.pdf
    where is MX25R6435F chip connected over SPI. The file ./boards/nrf7002dk_nrf5340_cpuapp.overlay contains:

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


    which matches with the chip. Then I would guess it is OK.


    - I'm sure that my device supports multi-image builds because this project is multi-image one and it works well in the original state. It is also possible to see in the folder structure:

    ./child_image/
        - mcuboot
        - hci_ipc


    - If we are talking about "partition manager configuration file", I think that it is about this file ./configuration/nrf7002dk_nrf5340_cpuapp/pm_static_dfu.yml

    Here I made a few experiments but without success, e.g:
    - I increased a bit of "app" size or
    - I removed all blocks with "region: external_flash" and changed a region in blocks with "region: flash_primary" to "region: external_flash"

    I assume this file is connected to files:

    - ./prj.conf
    - ./child_image/mcuboot/prj.conf

    where I added (in both of them), e.g:

    CONFIG_SPI=y
    CONFIG_SPI_NOR=y
    CONFIG_FLASH=y
    CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y
    CONFIG_PM_PARTITION_REGION_SETTINGS_STORAGE_EXTERNAL=y  


    I'm not sure if it is everything or should I add something else.

    I'm afraid that everything what I tried to edit to solve the issue was ignored due to one of this warnings appeared during the build:


    === child image b0n - CPUNET (inherited) end ===
    ...
    
              ---------------------------------------------------------------------
              --- WARNING: Using a bootloader without pm_static.yml.            ---
              --- There are cases where a deployed product can consist of       ---
              --- multiple images, and only a subset of these images can be     ---
              --- upgraded through a firmware update mechanism. In such cases,  ---
              --- the upgradable images must have partitions that are static    ---
              --- and are matching the partition map used by the bootloader     ---
              --- programmed onto the device.                                   ---
              ---------------------------------------------------------------------
    ...
    === child image hci_ipc - CPUNET end ===
    ...
    === child image mcuboot -  end ===
    ...
    -- Found partition manager static configuration: /home/ubuntu/Projects/matter3/examples/nordic/bridge-for-ble-devices/configuration/nrf7002dk_nrf5340_cpuapp/pm_static_dfu.yml
    Partition 'mcuboot' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_pad' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_primary' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_primary_app' is not included in the dynamic resolving since it is statically defined.
    Partition 'settings_storage' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_primary_1' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_secondary' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_secondary_1' is not included in the dynamic resolving since it is statically defined.
    Partition 'pcd_sram' is not included in the dynamic resolving since it is statically defined.
    CMake Warning at /home/ubuntu/Projects/nordic-4.1.2/v2.6.0-rc1/nrf/cmake/partition_manager.cmake:593 (message):
      Could not find memory mapped address for XIP.  Generated update hex files
      will not have the correct base address.  Hence they can not be programmed
      directly to the external flash


    The whole log is matter-bridge.build.zip. It is from the build process with edited prj.conf files only.

    You also mentioned "memory regions". I have an overview what is it but I have no clue how they are connected to the binary code which should filled there. Is my issue "section `datas' will not fit in region `FLASH'" connected to the "app" block? If yes where I can see it?

    I would like to ask you to be more specific in your answer because I'm completely new to this field.

  • Hi,

    Ondro said:
    At the first look, Wifi patch relocation to external flash seemed to be promising but unfortunately it is for external flashes connected over QSPI and not SPI. QSPI is used for Wifi chip. According to the documentation "...fw_patches_ext_flash.html", nRF7002DK is not supported. I found something related to it at devzone: ncs-external-flash-ota-change-qspi-to-spi but I didn't go deeper.

    Ah yeah you're right. The relocation through the XIP features in that documentation requires qspi, so the alternative would be to do a similar relocation using flash API and your own proprietary implementation of this. https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/applications/matter_bridge/doc/matter_bridge_description.html#building-and-running explains how you can enable the wifi fw patch relocation as well

    Ondro said:
    nRF7002DK is not supported

    This is note quite right, but the demo is showcased using a nRF5340DK with a 7002DK as a shield. The nRF7002 supports the firmware patch relocation. But the 7002 is only a host-chip, and it requires a companion chip to work. On the 7002DK there is two nRF devices: The nRF7002 host chpi which is used for Wifi and Wifi-stuff only, connected with SPI to a nRF5340 that is acting as the companion chip (i.e where the application runs). In addition there is an external flash (mx25) that is by default connected to the 5340 with QSPI. Your explanation leads me to believe that you're not quite aware that this is how the 7002Dk is set up, but I could be wrong.

    Ondro said:
    I've read the intermediate course too and I would say that matter_bridge application is very complicated especially on nRF7002DK.

    It is a comprehensive application, yes.

    Ondro said:
    On the base of this I have no clue what to do.

    It might be better to start with simpler applications, i.e familiarize yourself with the other Matter over Thread and Matter over Wifi samples and see how you can optimize their footprint through either fw relocation to the external flash or through 

    Ondro said:
    In my opinion, I don't see any restriction why an region of the external flash should be "unknown". What could be a reason of this error?

    [error] [ Worker] - Address range [0x0013B000 - 0x0013B591] does not map to a known memory.

    Might be that the device does not know of the external flash. How did you set it up in your devicetree files?

    Kind regards,
    Andreas

  • Might be that the device does not know of the external flash. How did you set it up in your devicetree files?

    I didn't make any changes in devicetree. All what I changed was in shared.zip

  • Hi,

    It's been a while since you've heard from me. Have you had any success with setting up your partitions since last time?

    If not, could you share the entire project in a zip?

    Kind regards,
    Andreas

  • Hi,

    I have no progress. I'm working on the build that fits on the internal flash:

    Fortunately,  switching release build + Os optimization  helps me enough but now I'm at 99% of flash usage so we will see

    I'm not expecting that the image size would increase more. And if yes then I would try to enable the wifi fw patch relocation. In my point of view, it could be closed for now.

    Thank you and BR,

    Ondro

  • Hi,

    Great

    Just 1 thing for information: I would recommend that you wait until NCS 2.6.1 before you attempt wifi patch relocation which requires qspi due to a bug in the qspi driver in v2.6.0.

    This has been fixed upstream and will be released within a couple of weeks

    Fix posted upstream: https://github.com/zephyrproject-rtos/zephyr/pull/71373
    Cherry-pick into NCS: https://github.com/nrfconnect/sdk-nrf/pull/14812

    Kind regards,
    Andreas

Reply Children
No Data
Related