From 5caeec82d6cd5ad0bc4c5e8717619357116a132c Mon Sep 17 00:00:00 2001
From: Dariusz Iwanoczko <dariusz.iwanoczko@genexis.eu>
Date: Thu, 17 Apr 2025 16:04:26 +0200
Subject: [PATCH] base-files: read iopsys,rootfs-data-alignment from FIT image

Replaced the hardcoded rootfs data alignment value with dynamic retrieval
from the FIT image using the iopsys,rootfs-data-alignment property.
This ensures that the alignment is consistent with the value embedded
during image generation and improves flexibility across different devices.

Issue: #16567
---
 package/base-files/files/lib/functions/iopsys-system-layout.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/package/base-files/files/lib/functions/iopsys-system-layout.sh b/package/base-files/files/lib/functions/iopsys-system-layout.sh
index 569d4e8b9b7..0d0aff5e36a 100644
--- a/package/base-files/files/lib/functions/iopsys-system-layout.sh
+++ b/package/base-files/files/lib/functions/iopsys-system-layout.sh
@@ -56,7 +56,7 @@ create_rootfs_data_loop_device() {
     local data_size
     local data_position
     local overlay_position
-    local alignment=$(( 512 * 1024 ))
+    local alignment
     local loop_dev
 
     if [ "$current_or_other" = "current" ]; then
@@ -65,6 +65,7 @@ create_rootfs_data_loop_device() {
         boot_part=$(find_mmc_part "boot$(iopsys_get_next_bank_id)")
     fi
 
+    alignment=$(fdtget -t i "$boot_part" -d $(( 512*1024 )) / iopsys,rootfs-data-alignment) || return 1
     last_image=$(fdtget --list "$boot_part" /images | tail -n1) || return 1
     data_size=$(fdtget -t i "$boot_part" "/images/$last_image" data-size) > /dev/null 2>&1 || return 1
     data_position=$(fdtget -t i "$boot_part" "/images/$last_image" data-position) > /dev/null 2>&1 || return 1
-- 
GitLab