Adjusting the slots sizes with MCU Boot

Hello :)

I'm trying to set my own sizes of slots when compiling app with MCU.

Default ones consumes the whole flash:

app:
  address: 0x10200
  end_address: 0x88000
  region: flash_primary
  size: 0x77e00
mcuboot:
  address: 0x0
  end_address: 0x10000
  placement:
    before:
    - mcuboot_primary
  region: flash_primary
  size: 0x10000
mcuboot_pad:
  address: 0x10000
  end_address: 0x10200
  placement:
    align:
      start: 0x4000
    before:
    - mcuboot_primary_app
  region: flash_primary
  sharers: 0x1
  size: 0x200
mcuboot_primary:
  address: 0x10000
  end_address: 0x88000
  orig_span: &id001
  - app
  - mcuboot_pad
  region: flash_primary
  size: 0x78000
  span: *id001
mcuboot_primary_app:
  address: 0x10200
  end_address: 0x88000
  orig_span: &id002
  - app
  region: flash_primary
  sharers: 0x1
  size: 0x77e00
  span: *id002
mcuboot_secondary:
  address: 0x88000
  end_address: 0x100000
  orig_span: &id003
  - mcuboot_secondary_pad
  - mcuboot_secondary_app
  region: flash_primary
  size: 0x78000
  span: *id003
mcuboot_secondary_app:
  address: 0x88200
  end_address: 0x100000
  placement:
    after:
    - mcuboot_secondary_pad
  region: flash_primary
  share_size:
  - mcuboot_primary_app
  size: 0x77e00
mcuboot_secondary_pad:
  address: 0x88000
  end_address: 0x88200
  placement:
    after:
    - mcuboot_primary
    align:
      start: 0x4000
  region: flash_primary
  share_size:
  - mcuboot_pad
  size: 0x200
otp:
  address: 0xff8100
  end_address: 0xff83fc
  region: otp
  size: 0x2fc
pcd_sram:
  address: 0x20000000
  end_address: 0x20002000
  placement:
    after:
    - start
  region: sram_primary
  size: 0x2000
rpmsg_nrf53_sram:
  address: 0x20070000
  end_address: 0x20080000
  placement:
    before:
    - end
  region: sram_primary
  size: 0x10000
sram_primary:
  address: 0x20002000
  end_address: 0x20070000
  region: sram_primary
  size: 0x6e000



What I did, I've added the the pm_static.yml with the sections descriptions I want to have:
mcuboot:
  address: 0x0
  end_address: 0x10000
  region: flash_primary
  size: 0x10000

mcuboot_pad:
  address: 0x10000
  end_address: 0x10200
  placement:
    before: mcuboot_primary_app
  region: flash_primary
  size: 0x200

mcuboot_primary:
  address: 0x10000
  end_address: 0x84000
  region: flash_primary
  size: 0x74000

mcuboot_primary_app:
  address: 0x10200
  end_address: 0x84000
  region: flash_primary
  size: 0x73E00

mcuboot_secondary:
  address: 0x84000
  end_address: 0xF8000
  span: [mcuboot_secondary_pad, mcuboot_secondary_app]
  region: flash_primary
  size: 0x74000

mcuboot_secondary_app:
  address: 0x84200
  end_address: 0xF8000
  placement:
    after: [mcuboot_secondary_pad]
  region: flash_primary
  size: 0x73E00

mcuboot_secondary_pad:
  address: 0x84000
  end_address: 0x84200
  placement:
    after: [mcuboot_primary]
  region: flash_primary
  size: 0x200

storage:
  address: 0xf8000
  end_address: 0x100000
  region: flash_primary
  size: 0x8000


Unfortunately I'm getting Partition Manager error:
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 'mcuboot_secondary' is not included in the dynamic resolving since it is statically defined.
Partition 'mcuboot_secondary_app' is not included in the dynamic resolving since it is statically defined.
Partition 'mcuboot_secondary_pad' is not included in the dynamic resolving since it is statically defined.
Partition manager failed: Incorrect amount of gaps found in static configuration. There must be exactly one gap in the static configuration to support placing the dynamic partitions (such as 'app'). Gaps found (0): The most common solution to this problem is to fill the smallest of these gaps with statically defined partition(s) until there is only one gap left. Alternatively re-order the already defined static partitions so that only one gap remains.
Failed to partition region flash_primary, size of region: 1048576
Partition Configuration:
mcuboot:
  size: 65536
mcuboot_pad:
  placement:
    before: mcuboot_primary_app
  size: 512
mcuboot_primary:
  size: 475136
mcuboot_primary_app:
  size: 474624
mcuboot_secondary:
  size: 475136
mcuboot_secondary_app:
  placement:
    after:
    - mcuboot_secondary_pad
  size: 474624
mcuboot_secondary_pad:
  placement:
    after:
    - mcuboot_primary
  size: 512
storage:
  size: 32768




  • app:
      address: 0x10200
      end_address: 0x84000
      region: flash_primary
      size: 0x73E00
    
    mcuboot:
      address: 0x0
      end_address: 0x10000
      region: flash_primary
      size: 0x10000
    
    mcuboot_pad:
      address: 0x10000
      end_address: 0x10200
      placement:
        before: mcuboot_primary_app
      region: flash_primary
      size: 0x200
    
    mcuboot_primary:
      address: 0x10000
      end_address: 0x84000
      orig_span: &id001
      - app
      - mcuboot_pad
      region: flash_primary
      size: 0x74000
      span: *id001
    
    mcuboot_primary_app:
      address: 0x10200
      end_address: 0x84000
      orig_span: &id002
      - app
      region: flash_primary
      size: 0x73E00
      span: *id002
    
    mcuboot_secondary:
      address: 0x84000
      end_address: 0xF8000
      span: [mcuboot_secondary_pad, mcuboot_secondary_app]
      region: flash_primary
      size: 0x74000
    
    mcuboot_secondary_app:
      address: 0x84200
      end_address: 0xF8000
      placement:
        after: [mcuboot_secondary_pad]
      region: flash_primary
      size: 0x73E00
    
    mcuboot_secondary_pad:
      address: 0x84000
      end_address: 0x84200
      placement:
        after: [mcuboot_primary]
      region: flash_primary
      size: 0x200
    
    storage:
      address: 0xf8000
      end_address: 0x100000
      region: flash_primary
      size: 0x8000

    I'm no expert on this, but this seems to be working. You need to add an "app" partition and add some spans for alignment purposes.

    A partition manager report after building results in

    +--------------------------------------------------+
    | 0x0: mcuboot (0x10000 - 64kB)                    |
    +---0x10000: mcuboot_primary (0x74000 - 464kB)-----+
    | 0x10000: mcuboot_pad (0x200 - 512B)              |
    +---0x10200: mcuboot_primary_app (0x73e00 - 463kB)-+
    | 0x10200: app (0x73e00 - 463kB)                   |
    +---0x84000: mcuboot_secondary (0x74000 - 464kB)---+
    | 0x84000: mcuboot_secondary_pad (0x200 - 512B)    |
    | 0x84200: mcuboot_secondary_app (0x73e00 - 463kB) |
    +--------------------------------------------------+
    | 0xf8000: storage (0x8000 - 32kB)                 |
    +--------------------------------------------------+
    
      sram_primary (0x40000 - 256kB):
    +--------------------------------------------+
    | 0x20000000: sram_primary (0x40000 - 256kB) |
    +--------------------------------------------+

Related