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

Weird flash usage report while using TF-M

Hi!

If I build my project with TF-M I noticed that at least the flash usage report differs dramatically compared to the original firmware:

Original:

Memory region | Used Size | Region Size | %age Used
        FLASH:   206060 B      409088 B      50.37%
         SRAM:    83760 B      178968 B      46.80%

With TF-M enabled:

Memory region | Used Size | Region Size | %age Used
        FLASH:   193676 B        208 KB      90.93%
         SRAM:    79024 B      178968 B      44.16%

The actual firmware size makes sense so far and both variants boot fine. My expectation was that the sections should be more or less identical.

Regards

Caspar

Parents
  • For my understanding the partitions should look like this (DT exerpt):

    boot_partition: partition@0 {
        label = "mcuboot";
        reg = < 0x0 0x10000 >;
    };
    slot0_partition: partition@10000 {
        label = "image-0";
        reg = < 0x10000 0x50000 >;
    };
    slot0_ns_partition: partition@50000 {
        label = "image-0-nonsecure";
        reg = < 0x60000 0x20000 >;
    };
    slot1_partition: partition@80000 {
        label = "image-1";
        reg = < 0x80000 0x50000 >;
    };
    slot1_ns_partition: partition@c0000 {
        label = "image-1-nonsecure";
        reg = < 0xd0000 0x20000 >;
    };

    But regardless of what I put in here, I the ns-partition size is always 208 kB (aka 0x34000). This matches what I can see in pm_config.h but can't see where those values come from.

  • Hi again!

    I asked the developers about this. You can increase the non-secure partition by decreasing the TFM partition of the pm_manager KConfig. More specifically, you can open <zephyr_root>/nrf/subsys/partition_manager/Kconfig and tweak the partitizon-size following code:

    partition=BL2
    partition-size=0x8000
    rsource "Kconfig.template.partition_size"
    
    partition=TFM
    partition-size=0x40000
    rsource "Kconfig.template.partition_size"
    
    partition=TFM_EXTRA
    partition-size=0x10000
    rsource "Kconfig.template.partition_size"

    I tested by changing TFM to 0x30000, giving me 272 kB for the non-secure application. Be aware that TFM is large since "everything" is enabled.

    Best regards,
    Carl Richard

  • Can confirm, this works. Do I see that right that this mechanism ignores the partitions as defined in the device tree completely?

Reply Children
Related