Static Partition Manager and XIP Variant

Hi, I'm using VS Code and v2.5.0 with a custom board based on an nRF52820. I'm using a Segger J-Link Base to flash the board.

I've managed to set up the DFU example with mcuBoot and a static partition map, can flash that onto our board successfully, and dfu-util can find the board and load code into it over USB, so that's all good.

I've also managed to write our actual application, which I can also configure using a static partition map, with mcuBoot, and I can flash that onto the board and it runs, and I can communicate with that over Bluetooth, so that's all good too!

What I need to do, though, is build our application to go into slot 1, so I can load that onto the board using dfu-util, and be able to update it using DFU, and it's that secondary image bit that I'm struggling with.

Because the DFU app is small and the application itself takes up over half the remaining flash, I need to use XIP, as mcuboot won't be able to copy the image, and I need to use the 

CONFIG_BOOT_BUILD_DIRECT_XIP_VARIANT=y
 

in my prj.conf as DFU will write out application to slot 1.

My static_pm.yml file from the DFU project is:

app:
  address: 0x8200
  end_address: 0x16000
  region: flash_primary
  size: 0xde00
mcuboot:
  address: 0x0
  end_address: 0x8000
  placement:
    before:
    - mcuboot_primary
  region: flash_primary
  size: 0x8000
mcuboot_pad:
  address: 0x8000
  end_address: 0x8200
  placement:
    align:
      start: 0x1000
    before:
    - mcuboot_primary_app
  region: flash_primary
  size: 0x200
mcuboot_primary:
  address: 0x8000
  end_address: 0x16000
  orig_span: &id001
  - app
  - mcuboot_pad
  region: flash_primary
  sharers: 0x1
  size: 0xe000
  span: *id001
mcuboot_primary_app:
  address: 0x8200
  end_address: 0x16000
  orig_span: &id002
  - app
  region: flash_primary
  size: 0xde00
  span: *id002
mcuboot_secondary:
  address: 0x16000
  end_address: 0x40000
  placement:
    after:
    - mcuboot_primary
    align:
      start: 0x1000
    align_next: 0x1000
  region: flash_primary
  size: 0x2a000
sram_primary:
  address: 0x20000000
  end_address: 0x20008000
  region: sram_primary
  size: 0x8000

I guess I was hopeful I could use that same file in my application project, and it would magically build into slot 1, but I knew it wouldn't really be that straightforward.
 
The error I get is
Traceback (most recent call last):
  File "/opt/nordic/ncs/v2.5.0/nrf/scripts/partition_manager_output.py", line 251, in <module>
    main()
  File "/opt/nordic/ncs/v2.5.0/nrf/scripts/partition_manager_output.py", line 247, in main
    write_gpm_config(gpm_config, greg_config, name, header_file)
  File "/opt/nordic/ncs/v2.5.0/nrf/scripts/partition_manager_output.py", line 142, in write_gpm_config
    if any('span' in x for x in gpm_config[domain][image]):
KeyError: 'mcuboot_secondary_app'
CMake Error at /opt/nordic/ncs/v2.5.0/nrf/cmake/partition_manager.cmake:665 (message):
  Partition Manager GLOBAL output generation failed,
I've tried quite a lot of editing of that file and usually then get an error about it not fitting into the space available.
I feel like i'm close to getting this working, but could really do with some help configuring my static_pm file to get the application to build into that second slot.
Alex
Related