aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJun Nie <jun.nie@linaro.org>2019-08-20 22:39:31 +0800
committerJun Nie <jun.nie@linaro.org>2019-08-22 12:29:36 +0800
commitd90d5ae4a42571265bfd4f7af69aa444e32f7cdb (patch)
tree3c35ed6ec4ceb19a6277bff3654ebfc5381ece23
parentdbd0210cc361ed2c4951d03a189c4f1358d88e80 (diff)
Relocate stack and bss for firmware
Signed-off-by: Jun Nie <jun.nie@linaro.org> Change-Id: I0bff691a60cc26319ad70be4bcd43da4c618672f
-rw-r--r--Makefile2
-rw-r--r--bl2/bl2_el3.ld.S11
-rw-r--r--make_helpers/defaults.mk5
-rw-r--r--plat/imx/imx8m/imx8mm/imx8mm_bl2_el3_setup.c2
-rw-r--r--plat/imx/imx8m/imx8mm/include/imx8mm_private.h1
-rw-r--r--plat/imx/imx8m/imx8mm/include/platform_def.h3
-rw-r--r--plat/imx/imx8m/imx8mm/platform.mk7
7 files changed, 28 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 5855d973..0c38ed06 100644
--- a/Makefile
+++ b/Makefile
@@ -662,6 +662,7 @@ $(eval $(call assert_boolean,USE_TBBR_DEFS))
$(eval $(call assert_boolean,WARMBOOT_ENABLE_DCACHE_EARLY))
$(eval $(call assert_boolean,BL2_AT_EL3))
$(eval $(call assert_boolean,BL2_IN_XIP_MEM))
+$(eval $(call assert_boolean,BL2_SEPARATE_STACK))
$(eval $(call assert_numeric,ARM_ARCH_MAJOR))
$(eval $(call assert_numeric,ARM_ARCH_MINOR))
@@ -718,6 +719,7 @@ $(eval $(call add_define,USE_TBBR_DEFS))
$(eval $(call add_define,WARMBOOT_ENABLE_DCACHE_EARLY))
$(eval $(call add_define,BL2_AT_EL3))
$(eval $(call add_define,BL2_IN_XIP_MEM))
+$(eval $(call add_define,BL2_SEPARATE_STACK))
$(eval $(call add_define,FIP_ROM_OFFSET))
# Define the EL3_PAYLOAD_BASE flag only if it is provided.
diff --git a/bl2/bl2_el3.ld.S b/bl2/bl2_el3.ld.S
index af93a0ce..98ce5463 100644
--- a/bl2/bl2_el3.ld.S
+++ b/bl2/bl2_el3.ld.S
@@ -151,9 +151,18 @@ SECTIONS
#else
} >RAM
#endif
+ _image_binary_end = .;
- stacks (NOLOAD) : {
+#if BL2_SEPARATE_STACK
+ . = BL2_STACK_BASE;
+#endif
+
+ stacks . (NOLOAD) : {
+#if BL2_SEPARATE_STACK
+ __STACKS_START__ = BL2_STACK_BASE;
+#else
__STACKS_START__ = .;
+#endif
*(tzfw_normal_stacks)
__STACKS_END__ = .;
} >RAM
diff --git a/make_helpers/defaults.mk b/make_helpers/defaults.mk
index 289542e3..8d264974 100644
--- a/make_helpers/defaults.mk
+++ b/make_helpers/defaults.mk
@@ -33,6 +33,11 @@ BL2_AT_EL3 := 0
# when BL2_AT_EL3 is 1.
BL2_IN_XIP_MEM := 0
+# BL2 stack and bss memory space start from data segment by default. Change
+# this option to move them to other space so that firmware can be packed in
+# then end if BL2 binary.
+BL2_SEPARATE_STACK := 0
+
# Select the branch protection features to use.
BRANCH_PROTECTION := 0
diff --git a/plat/imx/imx8m/imx8mm/imx8mm_bl2_el3_setup.c b/plat/imx/imx8m/imx8mm/imx8mm_bl2_el3_setup.c
index 5a4fdfdb..bc9bbf5b 100644
--- a/plat/imx/imx8m/imx8mm/imx8mm_bl2_el3_setup.c
+++ b/plat/imx/imx8m/imx8mm/imx8mm_bl2_el3_setup.c
@@ -166,6 +166,8 @@ void bl2_el3_early_platform_setup(u_register_t arg1, u_register_t arg2,
/* select the CKIL source to 32K OSC */
mmio_write_32(0x30360124, 0x1);
+ imx8mm_ddr_init();
+
imx8mm_usdhc_setup();
/* Open handles to a FIP image */
diff --git a/plat/imx/imx8m/imx8mm/include/imx8mm_private.h b/plat/imx/imx8m/imx8mm/include/imx8mm_private.h
index 945d3b56..25d376b4 100644
--- a/plat/imx/imx8m/imx8mm/include/imx8mm_private.h
+++ b/plat/imx/imx8m/imx8mm/include/imx8mm_private.h
@@ -11,5 +11,6 @@
* Function and variable prototypes
******************************************************************************/
void plat_imx8mm_io_setup(void);
+void imx8mm_ddr_init(void);
#endif /* __IMX8MM_PRIVATE_H__ */
diff --git a/plat/imx/imx8m/imx8mm/include/platform_def.h b/plat/imx/imx8m/imx8mm/include/platform_def.h
index 53800af7..88fe8944 100644
--- a/plat/imx/imx8m/imx8mm/include/platform_def.h
+++ b/plat/imx/imx8m/imx8mm/include/platform_def.h
@@ -33,7 +33,8 @@
#if defined(BUILD_BL2)
#define BL2_BASE U(0x7E1000)
-#define BL2_LIMIT U(0x940000)
+#define BL2_STACK_BASE U(0x810000)
+#define BL2_LIMIT U(0x820000)
#define BL31_BASE U(0x900000)
#define BL31_LIMIT U(0x940000)
#define IMX8MM_FIP_BASE U(0x40310000)
diff --git a/plat/imx/imx8m/imx8mm/platform.mk b/plat/imx/imx8m/imx8mm/platform.mk
index 584ffd3e..c0b75edf 100644
--- a/plat/imx/imx8m/imx8mm/platform.mk
+++ b/plat/imx/imx8m/imx8mm/platform.mk
@@ -4,6 +4,8 @@
# SPDX-License-Identifier: BSD-3-Clause
#
+PLAT_DRAM_SOURCES ?= imx8m_ddr
+
PLAT_INCLUDES := -Iplat/imx/common/include \
-Iplat/imx/imx8m/include \
-Iplat/imx/imx8m/imx8mm/include \
@@ -56,7 +58,6 @@ BL2_SOURCES += common/desc_image_load.c \
drivers/delay_timer/delay_timer.c \
drivers/delay_timer/generic_delay_timer.c \
${PLAT_GIC_SOURCES} \
- ${PLAT_DRAM_SOURCES} \
drivers/mmc/mmc.c \
drivers/io/io_block.c \
drivers/io/io_fip.c \
@@ -91,6 +92,10 @@ $(eval $(call add_define,BUILD_BL2))
LOAD_IMAGE_V2 := 1
# Non-TF Boot ROM
BL2_AT_EL3 := 1
+# Stack and BSS segment are in different RAM space
+BL2_SEPARATE_STACK := 1
+
+include ${PLAT_DRAM_SOURCES}/ble.mk
endif
$(eval $(call add_define,SOC_IMX8M))