Partition Manager: pm_static + McuMgr + sysbuild

Using connect SDK 3.0.2 and a NRF-DK52840 my goal is fairly simple: My app should be updatable via BLE using a static partition table.
I followed this tutorial: nRF Connect SDK hands-on, part 6: Adding FOTA over Bluetooth LE

So I added the following to my prj.conf:
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y

And to sysbuild.conf I added:
SB_CONFIG_PARTITION_MANAGER=y
SB_CONFIG_BOOTLOADER_MCUBOOT=y

Then defined my pm_static.yml as:

mcuboot:
  address: 0x00000000
  size: 0xC600         # 48 KB

mcuboot_pad:
  address: 0xC600
  size: 0x200         # 2 KB

image_0:
  address: 0xC800
  size: 0x40000        # 256 KB (0x40000 - 0x200)

image_1:
  address: 0x4C800
  size: 0x40000        # 256 KB

storage:
  address: 0x8C800
  size: 0x40000         # 256 KB (NVS or misc data)
But when I build my project I get this error:

: zephyr\zephyr_pre0.elf section `text' will not fit in region `FLASH'
c:/ncs/toolchains/0b393f9e1b/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: region `FLASH' overflowed by 162072 bytes
collect2.exe: error: ld returned 1 exit status


What did I do wrong?
Before adding McuMgr my app was 230520 B in size.

I expected that the bootloader fits into "mcuboot" partition and my app into "image_0". It may look like that it tries to fit my app into "mcuboot"?



Also: what is mcuboot_pad used for? If I just increase the "mcuboot" to 0xC800 and remove mcuboot_pad I get a strange partition config:

Partition 'mcuboot' is not included in the dynamic resolving since it is statically defined.
Partition manager failed: Error when inspecting mcuboot_pad, invalid address 0xcc000, expected 0xcc800,
Failed to partition region flash_primary, size of region: 1048576
Partition Configuration:
image_0:
size: 262144
image_1:
size: 262144
littlefs_storage:
placement:
align:
start: 4096
before:
- nvs_storage
size: 24576
mcuboot:
size: 51200
mcuboot_pad:
placement:
align:
start: 4096
before:
- mcuboot_primary_app
size: 512
mcuboot_secondary:
placement:
after:
- mcuboot_primary
align:
start: 4096
size: 77824
nvs_storage:
placement:
before:
- end
size: 24576
storage:
size: 262144

Related