Partition sizing

Asset Tracker Template

tags
Asset Tracker Template

You must configure the partition size for the LittleFS backend to accommodate the data types in use, their sizes, and the number of records per type. A minimum partition size is required to ensure proper operation.

How to calculate the needed size:

  • Per-type block need:

blocks per type=data size×records per typeblock size \text{blocks per type} = \left\lceil \frac{\text{data size} \times \text{records per type}}{\text{block size}} \right\rceil

  • Total required blocks:

required blocks=blocks per type+3 \text{required blocks} = \sum \text{blocks per type} + 3

where the +3 accounts for LittleFS metadata and the CoW block.

  • Minimum partition size:

flash size=required blocks×block size \text{flash size} = \text{required blocks} \times \text{block size}

Choose a partition size that meets or exceeds flash_size. The LittleFS partition size is set by the littlefs_storage node in app/boards/att_flash_partitions.dtsi, which both board overlays include:

littlefs_storage: partition@4d2000 {
    label = "littlefs_storage";
    reg = <0x004d2000 0x00100000>;   /* 1 MiB */
};

The second reg cell (0x00100000 above) is the partition size in bytes. To make the partition larger, raise that value and shrink the adjacent external_flash_partition by the same amount so the 32 MiB external flash layout stays consistent.

If the requirement is not met, either grow the partition in att_flash_partitions.dtsi as shown above, or reduce storage pressure (fewer records, smaller data types, or fewer enabled types).

Note

The data types are stored in separate files, so the minimum number of flash blocks needed is ∑ data types + 3.