Sysbuild and MCUboot porting build error

Hi,

I am working on a project with an nrf9160 on a custom board that I first developed with NCS v2.6.1.

I am trying to upgrade to latest NCS v2.9.1 but I am facing an issue a link stage.

I moved my custom board definition to HW model v2 without any (visible) issue and I want to move the build system to sysbuild and use MCUboot as immutable first-stage bootloader.
If followed the different guides and looked at how it has been done in the existing samples in NCS repository but I am facing an issue at link time where it says that a section does not fit in FLASH region.

[544/549] Linking C executable zephyr/zephyr_pre0.elf
...
/home/alexandre/ncs/toolchains/b77d8c1312/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/zephyr_pre0.elf section `text' will not fit in region `FLASH'
/home/alexandre/ncs/toolchains/b77d8c1312/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 154696 bytes
collect2: error: ld returned 1 exit status

Here is the result of the partition manager report.

  flash_primary (0x100000 - 1024kB): 
+--------------------------------------------------+
+---0x0: b0_container (0x8000 - 32kB)--------------+
| 0x0: b0 (0x8000 - 32kB)                          |
+---0x8000: s0 (0xc000 - 48kB)---------------------+
| 0x8000: s0_pad (0x200 - 512B)                    |
+---0x8200: s0_image (0xbe00 - 47kB)---------------+
| 0x8200: mcuboot (0xbe00 - 47kB)                  |
+--------------------------------------------------+
| 0x14000: EMPTY_0 (0x4000 - 16kB)                 |
+---0x18000: s1 (0xc000 - 48kB)--------------------+
| 0x18000: s1_pad (0x200 - 512B)                   |
| 0x18200: s1_image (0xbe00 - 47kB)                |
+--------------------------------------------------+
| 0x24000: EMPTY_1 (0x4000 - 16kB)                 |
+---0x28000: mcuboot_primary (0x68000 - 416kB)-----+
+---0x28000: tfm_secure (0x8000 - 32kB)------------+
| 0x28000: mcuboot_pad (0x200 - 512B)              |
+---0x28200: app_image (0x67e00 - 415kB)-----------+
+---0x28200: mcuboot_primary_app (0x67e00 - 415kB)-+
| 0x28200: tfm (0x7e00 - 31kB)                     |
+---0x30000: tfm_nonsecure (0x60000 - 384kB)-------+
| 0x30000: app (0x60000 - 384kB)                   |
+--------------------------------------------------+
| 0x90000: mcuboot_secondary (0x68000 - 416kB)     |
| 0xf8000: EMPTY_2 (0x6000 - 24kB)                 |
+---0xfe000: nonsecure_storage (0x2000 - 8kB)------+
| 0xfe000: settings_storage (0x2000 - 8kB)         |
+--------------------------------------------------+

I don't know where to start to investigate this issue. Also I am not sure to fully understand what are the different image built in non-secure mode (b0, s0, s1, ...).

Regards

Alexandre

Parents Reply Children
  • Hello and thanks for your answer !

    Unfortunately adding version 2.9.1 broke my 2.6.1 installation.
    I get a cmake error regarding python when trying to build:

    -- CMake version: 3.21.0
    -- Using NCS Toolchain 2.8.20241119.788085347090 for building. (/home/alexandre/ncs/toolchains/b77d8c1312/cmake)
    CMake Error at /home/alexandre/ncs/toolchains/2be090971e/usr/local/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
      Could NOT find Python3 (missing: Interpreter) (Required is at least version
      "3.8")
    
          Reason given by package: 
              Interpreter: Cannot run the interpreter "/home/alexandre/ncs/toolchains/b77d8c1312/usr/local/bin/python3"

  • Hello,

    Have you tried using an older version of the NCS toolchain? It looks like you are currently using v2.8.0.

  • Sorry for the delay,

    I tried to specify the toolchain to use because I have both NCS version 2.6.1 and 2.9.1 installed but it does not work. I end up removing toolchain for 2.9.1 but I still have the same issue with toolchain 2.6:

    -- CMake version: 3.21.0
    -- Using NCS Toolchain 2.6.20240304.188451165982 for building. (/home/alexandre/ncs/toolchains/2be090971e/cmake)
    CMake Error at /home/alexandre/ncs/toolchains/2be090971e/usr/local/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
      Could NOT find Python3 (missing: Interpreter) (Required is at least version
      "3.8")
    
          Reason given by package: 
              Interpreter: Cannot run the interpreter "/home/alexandre/ncs/toolchains/b77d8c1312/usr/local/bin/python3"

    It still tries to run interpreter in toolchain b77d8c1312 which correspond to toolchain for 2.9.1 (I think).

    I will try to clean my env and reinstall it.

  • I assume this path does not exist anymore since you have removed the toolcain: /home/alexandre/ncs/toolchains/b77d8c1312/usr/local/bin/python3? Either way, I think you should be able to build the previous project with the new toolchain.

  • Ok finally was able to recreate both 2.6.1 and 2.9.1 working environment.

    The problem is the one described in the error (ofc), my image is too big.

    - With NCS v2.6.1, I was using nrf immutable bootlader with a single app section (~984kB).

      flash_primary (0x100000 - 1024kB): 
    +---------------------------------------------+
    +---0x0: tfm_secure (0x8000 - 32kB)-----------+
    | 0x0: tfm (0x8000 - 32kB)                    |
    +---0x8000: tfm_nonsecure (0xf6000 - 984kB)---+
    | 0x8000: app (0xf6000 - 984kB)               |
    +---0xfe000: nonsecure_storage (0x2000 - 8kB)-+
    | 0xfe000: settings_storage (0x2000 - 8kB)    |
    +---------------------------------------------+
    
      otp (0x2f4 - 756B): 
    +------------------------------+
    | 0xff8108: otp (0x2f4 - 756B) |
    +------------------------------+
    
      sram_primary (0x40000 - 256kB): 
    +--------------------------------------------------+
    +---0x20000000: sram_secure (0x8000 - 32kB)--------+
    | 0x20000000: tfm_sram (0x8000 - 32kB)             |
    +---0x20008000: sram_nonsecure (0x38000 - 224kB)---+
    +---0x20008000: nrf_modem_lib_sram (0x4568 - 17kB)-+
    | 0x20008000: nrf_modem_lib_ctrl (0x4e8 - 1kB)     |
    | 0x200084e8: nrf_modem_lib_tx (0x2080 - 8kB)      |
    | 0x2000a568: nrf_modem_lib_rx (0x2000 - 8kB)      |
    +--------------------------------------------------+
    | 0x2000c568: sram_primary (0x33a98 - 206kB)       |
    +--------------------------------------------------+
    

    - With NCS v2.9.1 and mcuboot I now have 2 app section much smaller (416kB) wich is not enough for my app (~515kB).

    Memory region         Used Size  Region Size  %age Used
               FLASH:      528312 B       984 KB     52.43%
                 RAM:      120920 B     211608 B     57.14%
            IDT_LIST:          0 GB        32 KB      0.00%

    I will try to reduce my app size but I would like to first use mcuboot in single app image mode in order to get back to a single 900kB section and later I will add an external flash to switch to dual image mode.

    What config do I need to add (and where) to achieve single image mode this (using sysbuild) and where do I define the slot size ? Because of the SPM, defining it in DTS does not work right ?

    Regards,

Related