Overlapping partitions in pm_static.yml

I am developing application using nRF Connect SDK (v2.5.2) on custom design based on nRF52840. The design is a prototype device and currently have dozens of them assembled and running the same application.

I have added support for OTA and initially, I have defined few partitions in static partition manager configuration file, pm_static.yml:

app:
  address: 0x13200
  region: flash_primary
  size: 0x75e00
mcuboot:
  address: 0x0
  placement:
    before:
    - mcuboot_primary
  region: flash_primary
  size: 0x13000
mcuboot_pad:
  address: 0x13000
  placement:
    align:
      start: 0x1000
    before:
    - mcuboot_primary_app
  region: flash_primary
  size: 0x200
mcuboot_primary:
  address: 0x13000
  orig_span: &id001
  - app
  - mcuboot_pad
  region: flash_primary
  sharers: 0x1
  size: 0x76000
  span: *id001
mcuboot_primary_app:
  address: 0x13200
  orig_span: &id002
  - app
  region: flash_primary
  size: 0x75e00
  span: *id002
mcuboot_secondary:
  address: 0x89000
  placement:
    after:
    - mcuboot_primary
    align:
      start: 0x1000
    align_next: 0x1000
  region: flash_primary
  share_size:
  - mcuboot_primary
  size: 0x76000
storage:
  address: 0xff000
  region: flash_primary
  size: 0x1000
sram_primary:
  address: 0x20000000
  end_address: 0x20040000
  region: sram_primary
  size: 0x40000

With this version of the static partitions file, I haven't utilized the storage partition, until recently, when I discovered that I can't utilize it with NVS as it only has single sector.

Now, I understand that I need to adjust the static partition file to resolve the issues, but the dozens of the prototype devices are already flashed and it is good if I don't need to reflash them from scratch again, as adjusting the mcuboot primary and secondary partitions will require mcuboot to be updated, which currently is possible only with reflashing.

Can I have the storage partition overlap with the mcuboot secondary partition, if I ensure that the secondary slot will never reach the region where the storage partition will lie?

For example, can I define the storage partition like this?

storage:
  address: 0xfc000
  region: flash_primary
  size: 0x4000

If this is possible, by doing this I won't need to reflash all of the devices, as mcuboot partitions layout won't change.

Thank you in advance.

Parents
  • Hi,

    Can I have the storage partition overlap with the mcuboot secondary partition, if I ensure that the secondary slot will never reach the region where the storage partition will lie?

    I do not think this is a good idea, because of the following reasons:

    There is some MCUboot metadata stored at ca the end of mcuboot_secondary.

    Before swapping, MCUboot will calculate a SHA of the mcuboot_secondary to make sure it is not changes. I am not 100% if it will calculcate over all of mcuboot_secondary or just the app part.

    Technically you can add partitions in DFU, after partitions are just information to the app about what is where. But you run a high risk of breaking DFU and thus bricking (need for reflash) your devices if you write storage to mcuboot_secondary.
    And if you do so, you must make sure that you slip the eventual partition in between where it will not crash with anything.

    Maybe we can find another way to do stuff: What kind of data do you want to store here?

  • Thank you very much for your response.

    So basically, I'll need two storage partitions - one for storing BLE settings (settings_storage) and one for storing custom data(custom_storage), like sensors calibrations and similar stuff.

Reply Children
No Data
Related