From d45b56346476caee8d182e4a335fc8b5764a8483 Mon Sep 17 00:00:00 2001
From: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Date: Mon, 26 Sep 2022 11:27:57 +0200
Subject: [PATCH v2] apalis/colibri_imx6/-imx6ull/_imx7: update env memory layout

Update the distro config env memory layout for the Apalis iMX6,
Colibri iMX6, Colibri iMX6ULL and Colibri iMX7:

- loadaddr=0x84200000 (resp. 0x14200000 on them i.MX 6) allows for 64MB
  area for uncompressing (ie FIT images)
- fdt_addr_r = loadaddr + 64MB : allows for 64MB kernel
- scriptaddr = fdt_addr_r + 512KB : allows for 512KB fdt
- pxefile_addr_r = scriptaddr + 512KB : allows for 512KB script
- ramdisk_addr_r = pxefile_addr_r + 512KB : allows for 1MB extlinux.conf

Memory layout analogous to 64-bit one from commit fd5c7173ade4
("imx8m{m,n}_venice: update env memory layout") but left pxefile_addr_r
updated according to doc/develop/distro.rst.

This fixes a potential issue caused by the compressed kernel being
relocated on top of the ramdisk causing its corruption.

Upstream-Status: Submitted [https://lore.kernel.org/all/20220927155052.40056-1-marcel@ziswiler.com/]
Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
---

 configs/apalis_imx6_defconfig          |  1 +
 configs/colibri-imx6ull-emmc_defconfig |  1 +
 configs/colibri-imx6ull_defconfig      |  1 +
 configs/colibri_imx6_defconfig         |  1 +
 configs/colibri_imx7_defconfig         |  1 +
 configs/colibri_imx7_emmc_defconfig    |  1 +
 include/configs/apalis_imx6.h          | 10 +++++-----
 include/configs/colibri-imx6ull.h      | 10 +++++-----
 include/configs/colibri_imx6.h         | 10 +++++-----
 include/configs/colibri_imx7.h         | 10 +++++-----
 10 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/configs/apalis_imx6_defconfig b/configs/apalis_imx6_defconfig
index ea4ad276e7f..aa033a4bca8 100644
--- a/configs/apalis_imx6_defconfig
+++ b/configs/apalis_imx6_defconfig
@@ -21,6 +21,7 @@ CONFIG_SPL_MMC=y
 CONFIG_SPL_SERIAL=y
 CONFIG_SPL=y
 CONFIG_CMD_HDMIDETECT=y
+CONFIG_SYS_LOAD_ADDR=0x14200000
 CONFIG_AHCI=y
 CONFIG_SYS_MEMTEST_START=0x10000000
 CONFIG_SYS_MEMTEST_END=0x10010000
diff --git a/configs/colibri-imx6ull-emmc_defconfig b/configs/colibri-imx6ull-emmc_defconfig
index eb4b6a79eaa..e83262efc82 100644
--- a/configs/colibri-imx6ull-emmc_defconfig
+++ b/configs/colibri-imx6ull-emmc_defconfig
@@ -21,6 +21,7 @@ CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SYS_PROMPT="Colibri iMX6ULL # "
+CONFIG_SYS_LOAD_ADDR=0x84200000
 # CONFIG_BOOTM_PLAN9 is not set
 # CONFIG_BOOTM_RTEMS is not set
 # CONFIG_CMD_ELF is not set
diff --git a/configs/colibri-imx6ull_defconfig b/configs/colibri-imx6ull_defconfig
index d0825472b2f..97f8d2e0fa9 100644
--- a/configs/colibri-imx6ull_defconfig
+++ b/configs/colibri-imx6ull_defconfig
@@ -23,6 +23,7 @@ CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SYS_PROMPT="Colibri iMX6ULL # "
+CONFIG_SYS_LOAD_ADDR=0x84200000
 # CONFIG_BOOTM_PLAN9 is not set
 # CONFIG_BOOTM_RTEMS is not set
 # CONFIG_CMD_ELF is not set
diff --git a/configs/colibri_imx6_defconfig b/configs/colibri_imx6_defconfig
index 4f38d5cb483..80cba8f8a1e 100644
--- a/configs/colibri_imx6_defconfig
+++ b/configs/colibri_imx6_defconfig
@@ -21,6 +21,7 @@ CONFIG_SPL_MMC=y
 CONFIG_SPL_SERIAL=y
 CONFIG_SPL=y
 CONFIG_CMD_HDMIDETECT=y
+CONFIG_SYS_LOAD_ADDR=0x14200000
 CONFIG_SYS_MEMTEST_START=0x10000000
 CONFIG_SYS_MEMTEST_END=0x10010000
 CONFIG_DISTRO_DEFAULTS=y
diff --git a/configs/colibri_imx7_defconfig b/configs/colibri_imx7_defconfig
index e0de7f1ab18..64dd93237e1 100644
--- a/configs/colibri_imx7_defconfig
+++ b/configs/colibri_imx7_defconfig
@@ -10,6 +10,7 @@ CONFIG_TARGET_COLIBRI_IMX7=y
 CONFIG_IMX_RDC=y
 CONFIG_IMX_BOOTAUX=y
 CONFIG_IMX_HAB=y
+CONFIG_SYS_LOAD_ADDR=0x84200000
 CONFIG_OF_BOARD_FIXUP=y
 CONFIG_SYS_MEMTEST_START=0x80000000
 CONFIG_SYS_MEMTEST_END=0x8c000000
diff --git a/configs/colibri_imx7_emmc_defconfig b/configs/colibri_imx7_emmc_defconfig
index e4083b55c3a..c4f9058140a 100644
--- a/configs/colibri_imx7_emmc_defconfig
+++ b/configs/colibri_imx7_emmc_defconfig
@@ -11,6 +11,7 @@ CONFIG_ARMV7_BOOT_SEC_DEFAULT=y
 CONFIG_IMX_RDC=y
 CONFIG_IMX_BOOTAUX=y
 CONFIG_IMX_HAB=y
+CONFIG_SYS_LOAD_ADDR=0x84200000
 CONFIG_SYS_MEMTEST_START=0x80000000
 CONFIG_SYS_MEMTEST_END=0x8c000000
 CONFIG_DISTRO_DEFAULTS=y
diff --git a/include/configs/apalis_imx6.h b/include/configs/apalis_imx6.h
index aa93d10f852..6eee23b7cf2 100644
--- a/include/configs/apalis_imx6.h
+++ b/include/configs/apalis_imx6.h
@@ -83,11 +83,11 @@
 
 #define MEM_LAYOUT_ENV_SETTINGS \
 	"bootm_size=0x20000000\0" \
-	"fdt_addr_r=0x12100000\0" \
-	"kernel_addr_r=0x11000000\0" \
-	"pxefile_addr_r=0x17100000\0" \
-	"ramdisk_addr_r=0x12200000\0" \
-	"scriptaddr=0x17000000\0"
+	"fdt_addr_r=0x18200000\0" \
+	"kernel_addr_r=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
+	"pxefile_addr_r=0x18300000\0" \
+	"ramdisk_addr_r=0x18400000\0" \
+	"scriptaddr=0x18280000\0"
 
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	BOOTENV \
diff --git a/include/configs/colibri-imx6ull.h b/include/configs/colibri-imx6ull.h
index 9e5212acb2e..1722966de3b 100644
--- a/include/configs/colibri-imx6ull.h
+++ b/include/configs/colibri-imx6ull.h
@@ -43,11 +43,11 @@
 
 #define MEM_LAYOUT_ENV_SETTINGS \
 	"bootm_size=0x10000000\0" \
-	"fdt_addr_r=0x82100000\0" \
-	"kernel_addr_r=0x81000000\0" \
-	"pxefile_addr_r=0x87100000\0" \
-	"ramdisk_addr_r=0x82200000\0" \
-	"scriptaddr=0x87000000\0"
+	"fdt_addr_r=0x88200000\0" \
+	"kernel_addr_r=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
+	"pxefile_addr_r=0x88300000\0" \
+	"ramdisk_addr_r=0x88400000\0" \
+	"scriptaddr=0x88280000\0"
 
 #define UBI_BOOTCMD \
 	"ubiargs=ubi.mtd=ubi root=ubi0:rootfs rw rootfstype=ubifs " \
diff --git a/include/configs/colibri_imx6.h b/include/configs/colibri_imx6.h
index 9ca6bef192f..e5031eb42f1 100644
--- a/include/configs/colibri_imx6.h
+++ b/include/configs/colibri_imx6.h
@@ -72,11 +72,11 @@
 
 #define MEM_LAYOUT_ENV_SETTINGS \
 	"bootm_size=0x10000000\0" \
-	"fdt_addr_r=0x12100000\0" \
-	"kernel_addr_r=0x11000000\0" \
-	"pxefile_addr_r=0x17100000\0" \
-	"ramdisk_addr_r=0x12200000\0" \
-	"scriptaddr=0x17000000\0"
+	"fdt_addr_r=0x18200000\0" \
+	"kernel_addr_r=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
+	"pxefile_addr_r=0x18300000\0" \
+	"ramdisk_addr_r=0x18400000\0" \
+	"scriptaddr=0x18280000\0"
 
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	BOOTENV \
diff --git a/include/configs/colibri_imx7.h b/include/configs/colibri_imx7.h
index 3dba7bcef25..fd156819993 100644
--- a/include/configs/colibri_imx7.h
+++ b/include/configs/colibri_imx7.h
@@ -83,11 +83,11 @@
 
 #define MEM_LAYOUT_ENV_SETTINGS \
 	"bootm_size=0x10000000\0" \
-	"fdt_addr_r=0x82000000\0" \
-	"kernel_addr_r=0x81000000\0" \
-	"pxefile_addr_r=0x87100000\0" \
-	"ramdisk_addr_r=0x82100000\0" \
-	"scriptaddr=0x87000000\0"
+	"fdt_addr_r=0x88200000\0" \
+	"kernel_addr_r=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
+	"pxefile_addr_r=0x88300000\0" \
+	"ramdisk_addr_r=0x88400000\0" \
+	"scriptaddr=0x88280000\0"
 
 #define UBI_BOOTCMD	\
 	"ubiargs=ubi.mtd=ubi root=ubi0:rootfs rootfstype=ubifs " \
-- 
2.35.1

