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

mcuboot on nRF52840 on nrf9160DK board

I'm trying to get mcuboot to run on the nRF52840 on the nRF9160 board.  I have been able to configure it and get the resulting merged.hex file loaded on the processor and it boots correctly.  However the update.hex is being placed at the wrong location.  The flash partition in the dts file for this processor has:

boot_partition: partition@0 {
   label = "mcuboot";
   reg = <0x000000000 0x0000C000>;
};
slot0_partition: partition@c000 {
   label = "image-0";
   reg = <0x0000C000 0x000067000>;
};
slot1_partition: partition@73000 {
   label = "image-1";
   reg = <0x00073000 0x000067000>;
};
scratch_partition: partition@da000 {
   label = "image-scratch";
   reg = <0x000da000 0x0001e000>;
};
storage_partition: partition@f8000 {
   label = "storage";
   reg = <0x000f8000 0x00008000>;
};

but the generated partitions.yml file contains (extra stuff removed for clarity)

mcuboot:
  address: 0x0
  size: 0xc000
mcuboot_pad:
  address: 0xc000
  size: 0x200
mcuboot_primary:
  address: 0xc000
  size: 0x69000
mcuboot_secondary:
  address: 0x75000
  size: 0x69000
mcuboot_scratch:
  address: 0xde000
  size: 0x1e000
mcuboot_storage:
  address: 0xfc000
  size: 0x4000

The primary and secondary sizes are 0x69000 instead of 0x67000 specified in the flash partitions in the dts file.  I tracked down the cause of this due to the size of the mcuboot_storage being set incorrectly in the partitions.yml.  This looks to be set by a configuration value in the mcuboot/boot/zephyer/Kconfig file:

# Define used by partition_manager.py to deduce size of partition
config PM_PARTITION_SIZE_MCUBOOT_STORAGE
    hex "Flash space reserved for storage."
    default 0x4000
    help
      Flash space set aside for the storage area.

which is set to 0x4000, but needs to be 0x8000 to match the value in the .dts file.

I have tried adding CONFIG_PM_PARTITION_SIZE_MCUBOOT_STORAGE=0x8000 to my prj.conf file, but cmake complains about it being a undefined symbol and ignores it.  So I'm not sure what the correct way to fix this is.  For the near term, I'll just edit the flash map in the .dts file but this doesn't seem like the right answer.  Any suggestions on how to fix this?

Thanks,

-paul 

Related