This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

MCUBoot flash offset

Hi,

I'm working on the bootloader part of a project. Using nrf Connect, the integrated MCUBoot bootloader, trying to figure out how all the parts fit together. Running into something I can't quite find back in the documentation.

For me FLASH_AREA_OFFSET(image_1) returns 0x70000. Makes sense, because that's how I've defined image 1 in the dts:

slot1_partition: partition@70000 {
    label = "image-1";
    reg = <0x00070000 0x00064000>;
};

However, when I enable the bootloader (CONFIG_BOOTLOADER_MCUBOOT=y), FLASH_AREA_OFFSET(image_1) returns 0x83000. That's an offset of 0x13000 bytes; makes sense that MCUBoot needs space, but I can't quite figure out how this value is defined, and how it relates to the values in my dts.

Would like to know how this works, because I have a storage partition defined, and i don't want to risk overwriting it with a future upgrade because of a changing offset (and thus location of that storage partition).

Parents Reply Children
  • Here is some additional reading that also help me.

    Thread about pm.yml:
    https://devzone.nordicsemi.com/f/nordic-q-a/65528/nrf9160-defining-extra-flash-partition

    Using nordics PM requires some additional mcuconfig. Here is a thread on how to add a .conf for mcuboot without touching the stuff in the zephyr tree:
    https://devzone.nordicsemi.com/f/nordic-q-a/66210/change-mcuboot_menuconfig-configuration/270799#270799

    Additionally, you have fallen in the same trap I did. The MCUBoot documentation is only valid if you run "pure" zephyr, i.e. not NCS. Since NCS uses Partition Manager all documenation regarding MCUBoot and .dts is not usable. Atleast what I have found in my research.

    Here is an example pm_static based upon my project.

    mcuboot:
      address: <mcuboot start>
      size: <mcuboot size>
      region: flash_primary -- change this to the flash of your choice
    mcuboot_pad:
      address: <pad start>
      size: <pad size, I go with 0x200>
      region: flash_primary
    mcuboot_primary:
      region: flash_primary -- change this to the flash of your choice
      address: <main app image start>
      size: <main app image size>
      span: [mcuboot_pad, app]
    mcuboot_secondary:
      address: <start of secondary app image>
      size: <size>
      region: flash_primary -- change this to the flash of your choice
    mcuboot_scratch:
      address: <start>
      size: <size>
      region: flash_primary -- change this to the flash of your choice
    --Use this if you need a littleFS 
    littlefs_storage:
      address:<start>
      size: <size>
      region: external_flash
    -- this partition I think is required if you run openthread 
    --since it needs to store some settings in flash
    settings_storage:
      address: <start>
      size: <size>
      region: flash_primary

  • Hi Shaney,

    Thanks again! You're totally right, this is not the first time I'm lost in the documentation. There's a lot of it, but a lot doesn't apply (because it outdated, or doesn't apply due to some configuration which isn't mentioned), and an overall 'how everything fits together' document seems to be missing.

    Anyway, trick seems to be to use a static layout; now the build picks up my pm_static.yml, yay Slight smile

Related