arch: arm: properly enforce MPU-aware linker section alignment
This commit standardizes and simplifies the way we enforce
linker section alignment, to comply with minimum alignment
requirement for MPU, if we build Zephyr with MPU support:
- it enforces alignment with the minimum MPU granularity at
the beginning and end of linker sections that require to
be protected by MPU,
- it enforces alignment with size if required by the MPU
architecture.
Particularly for the Application Memory section, the commit
simplifies how the proper alignment is enforced, removing
the need of calculating the alignment with a post-linker
python script. It also removes the need for an additional
section for padding.
For the Application Shared Memory section(s), the commit
enforces minimum alignment besides the requirement for
alignment with size (for the respective MPUs) and fixes
a bug where the app_data_align was erronously used in the
scipts for auto-generating the linker scripts.
Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
diff --git a/scripts/gen_app_partitions.py b/scripts/gen_app_partitions.py
index 2ed7125..0e7a022 100644
--- a/scripts/gen_app_partitions.py
+++ b/scripts/gen_app_partitions.py
@@ -12,11 +12,10 @@
# when APP_SHARED_MEM is enabled.
print_template = """
/* Auto generated code do not modify */
- . = ALIGN( 1 << LOG2CEIL(data_smem_{0}b_end - data_smem_{0}));
+ MPU_ALIGN(data_smem_{0}b_end - data_smem_{0});
data_smem_{0} = .;
KEEP(*(SORT(data_smem_{0}*)))
- . = ALIGN(_app_data_align);
- . = ALIGN( 1 << LOG2CEIL(data_smem_{0}b_end - data_smem_{0}));
+ MPU_ALIGN(data_smem_{0}b_end - data_smem_{0});
data_smem_{0}b_end = .;
"""
linker_start_seq = """