All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 0/7] Enable falcon boot for LS1043ARDB
@ 2017-09-14 19:01 York Sun
  2017-09-14 19:01 ` [U-Boot] [PATCH v2 1/7] spl: fix assignment of board info to global data York Sun
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: York Sun @ 2017-09-14 19:01 UTC (permalink / raw)
  To: u-boot

This is the 2nd version to enable falcon boot for LS1043ARDB. With
SPL FIT patches merged, enabling falcon boot for this board is
straight forward after fixing some errors introduced by other
commits.

Secure boot is dropped in this set due to SPL image size issue.
Recent changes made the SPL image bigger and the secure boot image
doesn't fit any more. A follow-up patch set will enable secure boot
if the image can be future trimmed to fit.

Changes in v2:
New patch to fix spl after rebasing to latest master.
New patch to fix compiling error after rebasing to latest mater.
New patch to fix gd->ram_size error after rebasing to latest mater.
Drop checking secure boot in this patch after rebasing to latest mater.
Recent change in SPL makes the image size bigger.
Relace getenv_f() with env_get_f() after rebasing to latet master.

York Sun (7):
  spl: fix assignment of board info to global data
  cmd: spl: fix compiling error when CONFIG_CMD_SPL_WRITE_SIZE not
    defined
  armv8: fsl-layerscape: Avoid running dram_init_banksize again
  armv8: ls1043ardb: Use static DDR setting for SPL boot
  armv8: layerscape: Eanble falcon boot
  armv8: ls1043ardb: Enable spl_board_init() function
  armv8: ls1043ardb_sdcard: Enable falcon boot

 arch/arm/cpu/armv8/fsl-layerscape/cpu.c            |  18 ++-
 .../arm/cpu/armv8/fsl-layerscape/doc/README.falcon | 140 +++++++++++++++++++++
 arch/arm/cpu/armv8/fsl-layerscape/spl.c            |  29 +++++
 arch/arm/include/asm/system.h                      |   2 +-
 arch/arm/lib/spl.c                                 |  11 ++
 board/freescale/ls1043ardb/ddr.c                   |  46 +++++++
 board/freescale/ls1043ardb/ddr.h                   |  67 ++++++++++
 cmd/spl.c                                          |   2 +
 common/spl/spl.c                                   |   8 +-
 configs/ls1043ardb_nand_SECURE_BOOT_defconfig      |   1 +
 configs/ls1043ardb_nand_defconfig                  |   1 +
 configs/ls1043ardb_sdcard_SECURE_BOOT_defconfig    |   1 +
 configs/ls1043ardb_sdcard_defconfig                |   7 ++
 include/configs/ls1043a_common.h                   |   7 +-
 include/configs/ls1043ardb.h                       |  11 +-
 15 files changed, 342 insertions(+), 9 deletions(-)
 create mode 100644 arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon

-- 
2.7.4

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v2 1/7] spl: fix assignment of board info to global data
  2017-09-14 19:01 [U-Boot] [PATCH v2 0/7] Enable falcon boot for LS1043ARDB York Sun
@ 2017-09-14 19:01 ` York Sun
  2017-09-17 17:54   ` Simon Glass
  2017-09-14 19:01 ` [U-Boot] [PATCH v2 2/7] cmd: spl: fix compiling error when CONFIG_CMD_SPL_WRITE_SIZE not defined York Sun
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: York Sun @ 2017-09-14 19:01 UTC (permalink / raw)
  To: u-boot

This partially reverts commit 15eb1d43bf470b85e9031c2fce7e0ce7b27dd321
which intended to move assignment of board info earlier, into
board_init_r(). However, function preload_console_init() is called
either from spl_board_init() or from board_init_f(). For the latter
case, the board info assignment is much earlier than board_init_r().
Moving such assignment to board_init_r() would be moving it later.

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Lokesh Vutla <lokeshvutla@ti.com>
CC: Ravi Babu <ravibabu@ti.com>
CC: Lukasz Majewski <lukma@denx.de>
CC: Tom Rini <trini@konsulko.com>

---

Changes in v2:
New patch to fix spl after rebasing to latest master.

 common/spl/spl.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index ce9819e..98b0ca0 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -365,7 +365,10 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	struct spl_image_info spl_image;
 
 	debug(">>spl:board_init_r()\n");
-	gd->bd = &bdata;
+
+	if (!gd->bd)
+		gd->bd = &bdata;
+
 #ifdef CONFIG_SPL_OS_BOOT
 	dram_init_banksize();
 #endif
@@ -450,6 +453,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
  */
 void preloader_console_init(void)
 {
+	if (!gd->bd)
+		gd->bd = &bdata;
+
 	gd->baudrate = CONFIG_BAUDRATE;
 
 	serial_init();		/* serial communications setup */
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v2 2/7] cmd: spl: fix compiling error when CONFIG_CMD_SPL_WRITE_SIZE not defined
  2017-09-14 19:01 [U-Boot] [PATCH v2 0/7] Enable falcon boot for LS1043ARDB York Sun
  2017-09-14 19:01 ` [U-Boot] [PATCH v2 1/7] spl: fix assignment of board info to global data York Sun
@ 2017-09-14 19:01 ` York Sun
  2017-09-14 19:01 ` [U-Boot] [PATCH v2 3/7] armv8: fsl-layerscape: Avoid running dram_init_banksize again York Sun
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 18+ messages in thread
From: York Sun @ 2017-09-14 19:01 UTC (permalink / raw)
  To: u-boot

CONFIG_CMD_SPL_WRITE_SIZE is used for writing parameters to non-volatile
storage. So far it is only used for NAND. Fix compiling error when this
macro is not used for SD.

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Anatolij Gustschin <agust@denx.de>

---

Changes in v2:
New patch to fix compiling error after rebasing to latest mater.

 cmd/spl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/cmd/spl.c b/cmd/spl.c
index 4d84492..3b8992a 100644
--- a/cmd/spl.c
+++ b/cmd/spl.c
@@ -121,9 +121,11 @@ static int spl_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 				(void *)images.ft_addr);
 			env_set_addr("fdtargsaddr", images.ft_addr);
 			env_set_hex("fdtargslen", fdt_totalsize(images.ft_addr));
+#ifdef CONFIG_CMD_SPL_WRITE_SIZE
 			if (fdt_totalsize(images.ft_addr) >
 			    CONFIG_CMD_SPL_WRITE_SIZE)
 				puts("WARN: FDT size > CMD_SPL_WRITE_SIZE\n");
+#endif
 			break;
 #endif
 		case SPL_EXPORT_ATAGS:
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v2 3/7] armv8: fsl-layerscape: Avoid running dram_init_banksize again
  2017-09-14 19:01 [U-Boot] [PATCH v2 0/7] Enable falcon boot for LS1043ARDB York Sun
  2017-09-14 19:01 ` [U-Boot] [PATCH v2 1/7] spl: fix assignment of board info to global data York Sun
  2017-09-14 19:01 ` [U-Boot] [PATCH v2 2/7] cmd: spl: fix compiling error when CONFIG_CMD_SPL_WRITE_SIZE not defined York Sun
@ 2017-09-14 19:01 ` York Sun
  2017-09-17 17:54   ` Simon Glass
  2017-09-14 19:01 ` [U-Boot] [PATCH v2 4/7] armv8: ls1043ardb: Use static DDR setting for SPL boot York Sun
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: York Sun @ 2017-09-14 19:01 UTC (permalink / raw)
  To: u-boot

gd->ram_size is reduced in this function to reserve secure memory.
Avoid running this function again to further reduce memory size.
This fixes issue for SPL boot with PPA image loaded in which case
secure memory is incorrectly allocated due to repeated calling.

Signed-off-by: York Sun <york.sun@nxp.com>

---

Changes in v2:
New patch to fix gd->ram_size error after rebasing to latest mater.

 arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
index d21a494..fe5f4a9 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
@@ -698,8 +698,19 @@ int dram_init_banksize(void)
 	 * memory. The DDR extends from low region to high region(s) presuming
 	 * no hole is created with DDR configuration. gd->arch.secure_ram tracks
 	 * the location of secure memory. gd->arch.resv_ram tracks the location
-	 * of reserved memory for Management Complex (MC).
+	 * of reserved memory for Management Complex (MC). Because gd->ram_size
+	 * is reduced by this function if secure memory is reserved, checking
+	 * gd->arch.secure_ram should be done to avoid running it repeatedly.
 	 */
+
+#ifdef CONFIG_SYS_MEM_RESERVE_SECURE
+	if (gd->arch.secure_ram & MEM_RESERVE_SECURE_MAINTAINED) {
+		debug("No need to run again, skip %s\n", __func__);
+
+		return 0;
+	}
+#endif
+
 	gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
 	if (gd->ram_size > CONFIG_SYS_DDR_BLOCK1_SIZE) {
 		gd->bd->bi_dram[0].size = CONFIG_SYS_DDR_BLOCK1_SIZE;
@@ -797,6 +808,11 @@ int dram_init_banksize(void)
 	}
 #endif
 
+#ifdef CONFIG_SYS_MEM_RESERVE_SECURE
+	debug("%s is called. gd->ram_size is reduced to %lu\n",
+	      __func__, (ulong)gd->ram_size);
+#endif
+
 	return 0;
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v2 4/7] armv8: ls1043ardb: Use static DDR setting for SPL boot
  2017-09-14 19:01 [U-Boot] [PATCH v2 0/7] Enable falcon boot for LS1043ARDB York Sun
                   ` (2 preceding siblings ...)
  2017-09-14 19:01 ` [U-Boot] [PATCH v2 3/7] armv8: fsl-layerscape: Avoid running dram_init_banksize again York Sun
@ 2017-09-14 19:01 ` York Sun
  2017-09-14 19:01 ` [U-Boot] [PATCH v2 5/7] armv8: layerscape: Eanble falcon boot York Sun
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 18+ messages in thread
From: York Sun @ 2017-09-14 19:01 UTC (permalink / raw)
  To: u-boot

This board has soldered DDR chips. To reduce the SPL image size,
use static DDR setting instead of dynamic DDR driver.

Signed-off-by: York Sun <york.sun@nxp.com>

---

Changes in v2:
Drop checking secure boot in this patch after rebasing to latest mater.
Recent change in SPL makes the image size bigger.

 board/freescale/ls1043ardb/ddr.c | 46 +++++++++++++++++++++++++++
 board/freescale/ls1043ardb/ddr.h | 67 ++++++++++++++++++++++++++++++++++++++++
 include/configs/ls1043ardb.h     |  6 ++--
 3 files changed, 116 insertions(+), 3 deletions(-)

diff --git a/board/freescale/ls1043ardb/ddr.c b/board/freescale/ls1043ardb/ddr.c
index 354b864..c8f3b5a 100644
--- a/board/freescale/ls1043ardb/ddr.c
+++ b/board/freescale/ls1043ardb/ddr.c
@@ -169,18 +169,64 @@ int fsl_ddr_get_dimm_params(dimm_params_t *pdimm,
 
 	return 0;
 }
+#else
+
+phys_size_t fixed_sdram(void)
+{
+	int i;
+	char buf[32];
+	fsl_ddr_cfg_regs_t ddr_cfg_regs;
+	phys_size_t ddr_size;
+	ulong ddr_freq, ddr_freq_mhz;
+
+	ddr_freq = get_ddr_freq(0);
+	ddr_freq_mhz = ddr_freq / 1000000;
+
+	printf("Configuring DDR for %s MT/s data rate\n",
+	       strmhz(buf, ddr_freq));
+
+	for (i = 0; fixed_ddr_parm_0[i].max_freq > 0; i++) {
+		if ((ddr_freq_mhz > fixed_ddr_parm_0[i].min_freq) &&
+		    (ddr_freq_mhz <= fixed_ddr_parm_0[i].max_freq)) {
+			memcpy(&ddr_cfg_regs,
+			       fixed_ddr_parm_0[i].ddr_settings,
+			       sizeof(ddr_cfg_regs));
+			break;
+		}
+	}
+
+	if (fixed_ddr_parm_0[i].max_freq == 0)
+		panic("Unsupported DDR data rate %s MT/s data rate\n",
+		      strmhz(buf, ddr_freq));
+
+	ddr_size = (phys_size_t) 2048 * 1024 * 1024;
+	fsl_ddr_set_memctl_regs(&ddr_cfg_regs, 0, 0);
+
+	return ddr_size;
+}
 #endif
 
 int fsl_initdram(void)
 {
 	phys_size_t dram_size;
 
+#ifdef CONFIG_SYS_DDR_RAW_TIMING
 #if defined(CONFIG_SPL_BUILD) || !defined(CONFIG_SPL)
 	puts("Initializing DDR....\n");
 	dram_size = fsl_ddr_sdram();
 #else
 	dram_size =  fsl_ddr_sdram_size();
 #endif
+#else
+#if defined(CONFIG_SPL_BUILD) || !defined(CONFIG_SPL)
+	puts("Initialzing DDR using fixed setting\n");
+	dram_size = fixed_sdram();
+#else
+	gd->ram_size = 0x80000000;
+
+	return 0;
+#endif
+#endif
 	erratum_a008850_post();
 
 #ifdef CONFIG_FSL_DEEP_SLEEP
diff --git a/board/freescale/ls1043ardb/ddr.h b/board/freescale/ls1043ardb/ddr.h
index a77ddf3..926eff8 100644
--- a/board/freescale/ls1043ardb/ddr.h
+++ b/board/freescale/ls1043ardb/ddr.h
@@ -45,4 +45,71 @@ static const struct board_specific_parameters *udimms[] = {
 	udimm0,
 };
 
+#ifndef CONFIG_SYS_DDR_RAW_TIMING
+fsl_ddr_cfg_regs_t ddr_cfg_regs_1600 = {
+	.cs[0].bnds = 0x0000007F,
+	.cs[1].bnds = 0,
+	.cs[2].bnds = 0,
+	.cs[3].bnds = 0,
+	.cs[0].config = 0x80040322,
+	.cs[0].config_2 = 0,
+	.cs[1].config = 0,
+	.cs[1].config_2 = 0,
+	.cs[2].config = 0,
+	.cs[3].config = 0,
+	.timing_cfg_3 = 0x010C1000,
+	.timing_cfg_0 = 0x91550018,
+	.timing_cfg_1 = 0xBBB48C42,
+	.timing_cfg_2 = 0x0048C111,
+	.ddr_sdram_cfg = 0xC50C0008,
+	.ddr_sdram_cfg_2 = 0x00401100,
+	.ddr_sdram_cfg_3 = 0,
+	.ddr_sdram_mode = 0x03010210,
+	.ddr_sdram_mode_2 = 0,
+	.ddr_sdram_mode_3 = 0x00010210,
+	.ddr_sdram_mode_4 = 0,
+	.ddr_sdram_mode_5 = 0x00010210,
+	.ddr_sdram_mode_6 = 0,
+	.ddr_sdram_mode_7 = 0x00010210,
+	.ddr_sdram_mode_8 = 0,
+	.ddr_sdram_mode_9 = 0x00000500,
+	.ddr_sdram_mode_10 = 0x04000000,
+	.ddr_sdram_mode_11 = 0x00000400,
+	.ddr_sdram_mode_12 = 0x04000000,
+	.ddr_sdram_mode_13 = 0x00000400,
+	.ddr_sdram_mode_14 = 0x04000000,
+	.ddr_sdram_mode_15 = 0x00000400,
+	.ddr_sdram_mode_16 = 0x04000000,
+	.ddr_sdram_interval = 0x18600618,
+	.ddr_data_init = 0xDEADBEEF,
+	.ddr_sdram_clk_cntl = 0x03000000,
+	.ddr_init_addr = 0,
+	.ddr_init_ext_addr = 0,
+	.timing_cfg_4 = 0x00000002,
+	.timing_cfg_5 = 0x03401400,
+	.timing_cfg_6 = 0,
+	.timing_cfg_7 = 0x13300000,
+	.timing_cfg_8 = 0x02115600,
+	.timing_cfg_9 = 0,
+	.ddr_zq_cntl = 0x8A090705,
+	.ddr_wrlvl_cntl = 0x8675F607,
+	.ddr_wrlvl_cntl_2 = 0x07090800,
+	.ddr_wrlvl_cntl_3 = 0,
+	.ddr_sr_cntr = 0,
+	.ddr_sdram_rcw_1 = 0,
+	.ddr_sdram_rcw_2 = 0,
+	.ddr_cdr1 = 0x80040000,
+	.ddr_cdr2 = 0x0000A181,
+	.dq_map_0 = 0,
+	.dq_map_1 = 0,
+	.dq_map_2 = 0,
+	.dq_map_3 = 0,
+	.debug[28] = 0x00700046,
+
+};
+fixed_ddr_parm_t fixed_ddr_parm_0[] = {
+	{1550, 1650, &ddr_cfg_regs_1600},
+	{0, 0, NULL}
+};
+#endif
 #endif
diff --git a/include/configs/ls1043ardb.h b/include/configs/ls1043ardb.h
index ca1d862..da87497 100644
--- a/include/configs/ls1043ardb.h
+++ b/include/configs/ls1043ardb.h
@@ -28,13 +28,13 @@
 
 #define CONFIG_SYS_SPD_BUS_NUM		0
 
-#define CONFIG_FSL_DDR_BIST
 #ifndef CONFIG_SPL
-#define CONFIG_FSL_DDR_INTERACTIVE	/* Interactive debugging */
-#endif
 #define CONFIG_SYS_DDR_RAW_TIMING
+#define CONFIG_FSL_DDR_INTERACTIVE	/* Interactive debugging */
+#define CONFIG_FSL_DDR_BIST
 #define CONFIG_ECC_INIT_VIA_DDRCONTROLLER
 #define CONFIG_MEM_INIT_VALUE           0xdeadbeef
+#endif
 
 #ifdef CONFIG_RAMBOOT_PBL
 #define CONFIG_SYS_FSL_PBL_PBI board/freescale/ls1043ardb/ls1043ardb_pbi.cfg
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v2 5/7] armv8: layerscape: Eanble falcon boot
  2017-09-14 19:01 [U-Boot] [PATCH v2 0/7] Enable falcon boot for LS1043ARDB York Sun
                   ` (3 preceding siblings ...)
  2017-09-14 19:01 ` [U-Boot] [PATCH v2 4/7] armv8: ls1043ardb: Use static DDR setting for SPL boot York Sun
@ 2017-09-14 19:01 ` York Sun
  2017-09-17 17:54   ` Simon Glass
  2017-09-25 14:17   ` Łukasz Majewski
  2017-09-14 19:01 ` [U-Boot] [PATCH v2 6/7] armv8: ls1043ardb: Enable spl_board_init() function York Sun
  2017-09-14 19:01 ` [U-Boot] [PATCH v2 7/7] armv8: ls1043ardb_sdcard: Enable falcon boot York Sun
  6 siblings, 2 replies; 18+ messages in thread
From: York Sun @ 2017-09-14 19:01 UTC (permalink / raw)
  To: u-boot

Add jump_to_image_linux() for arm64. Add "noreturn" flag to
armv8_switch_to_el2(). Add hooks to fsl-layerscape to enable falcon
boot.

Signed-off-by: York Sun <york.sun@nxp.com>

---

Changes in v2:
Relace getenv_f() with env_get_f() after rebasing to latet master.

 .../arm/cpu/armv8/fsl-layerscape/doc/README.falcon | 140 +++++++++++++++++++++
 arch/arm/cpu/armv8/fsl-layerscape/spl.c            |  29 +++++
 arch/arm/include/asm/system.h                      |   2 +-
 arch/arm/lib/spl.c                                 |  11 ++
 4 files changed, 181 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon b/arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon
new file mode 100644
index 0000000..282b19f
--- /dev/null
+++ b/arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon
@@ -0,0 +1,140 @@
+Falcon boot option
+------------------
+Falcon boot is a short cut boot method for SD/eMMC targets. It skips loading the
+RAM version U-Boot. Instead, it loads FIT image and boot directly to Linux.
+CONFIG_SPL_OS_BOOT enables falcon boot. CONFIG_SPL_LOAD_FIT enables the FIT
+image support (also need CONFIG_SPL_OF_LIBFDT, CONFIG_SPL_FIT and optionally
+CONFIG_SPL_GZIP).
+
+To enable falcon boot, a hook function spl_start_uboot() returns 0 to indicate
+booting U-Boot is not the first choice. The kernel FIT image needs to be put
+at CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR. SPL mmc driver reads the header to
+determine if this is a FIT image. If true, FIT image components are parsed and
+copied or decompressed (if applicable) to their desitinations. If FIT image is
+not found, normal U-Boot flow will follow.
+
+An important part of falcon boot is to prepare the device tree. A normal U-Boot
+does FDT fixups when booting Linux. For falcon boot, Linux boots directly from
+SPL, skipping the normal U-Boot. The device tree has to be prepared in advance.
+A command "spl export" should be called under the normal RAM version U-Boot.
+It is equivalent to go through "bootm" step-by-step until device tree fixup is
+done. The device tree in memory is the one needed for falcon boot. Falcon boot
+flow suggests to save this image to SD/eMMC at the location pointed by macro
+CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR, with maximum size specified by macro
+CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS. However, when FIT image is used for
+Linux, the device tree stored in FIT image overwrites the memory loaded by spl
+driver from these sectors. We could change this loading order to favor the
+stored sectors. But when secure boot is enabled, these sectors are used for
+signature header and needs to be loaded before the FIT image. So it is important
+to understand the device tree in FIT image should be the one actually used, or
+leave it abscent to favor the stored sectors. It is easier to deploy the FIT
+image with embedded static device tree to multiple boards.
+
+Macro CONFIG_SYS_SPL_ARGS_ADDR serves two purposes. One is the pointer to load
+the stored sectors to. Normally this is the static device tree. The second
+purpose is the memory location of signature header for secure boot. After the
+FIT image is loaded into memory, it is validated against the signature header
+before individual components are extracted (and optionally decompressed) into
+their final memory locations, respectivelly. After the validation, the header
+is no longer used. The static device tree is copied into this location. So
+this macro is passed as the location of device tree when booting Linux.
+
+Steps to prepare static device tree
+-----------------------------------
+To prepare the static device tree for Layerscape boards, it is important to
+understand the fixups in U-Boot. Memory size and location, as well as reserved
+memory blocks are added/updated. Ethernet MAC addressed are updated. FMan
+microcode (if used) is embedded in the device tree. Kernel command line and
+initrd information are embedded. Others including CPU status, boot method,
+Ethernet port status, etc. are also updated.
+
+Following normal booting process, all variables are set, all images are loaded
+before "bootm" command would be issued to boot, run command
+
+spl export fdt <address>
+
+where the address is the location of FIT image. U-Boot goes through the booting
+process as if "bootm start", "bootm loados", "bootm ramdisk"... commands but
+stops before "bootm go". There we have the fixed-up device tree in memory.
+We can check the device tree header by these commands
+
+fdt addr <fdt address>
+fdt header
+
+Where the fdt address is the device tree in memory. It is printed by U-Boot.
+It is useful to know the exact size. One way to extract this static device
+tree is to save it to eMMC/SD using command in U-Boot, and extract under Linux
+with these commands, repectivelly
+
+mmc write <address> <sector> <sectors>
+dd if=/dev/mmcblk0 of=<filename> bs=512 skip=<sector> count=<sectors>
+
+Note, U-Boot takes values as hexadecimals while Linux takes them as decimals by
+default. If using NAND or other storage, the commands are slightly different.
+When we have the static device tree image, we can re-make the FIT image with
+it. It is important to specify the load addresses in FIT image for every
+components. Otherwise U-Boot cannot load them correctly.
+
+Generate FIT image with static device tree
+------------------------------------------
+Example:
+
+/dts-v1/;
+
+/ {
+	description = "Image file for the LS1043A Linux Kernel";
+	#address-cells = <1>;
+
+	images {
+		kernel at 1 {
+			description = "ARM64 Linux kernel";
+			data = /incbin/("./arch/arm64/boot/Image.gz");
+			type = "kernel";
+			arch = "arm64";
+			os = "linux";
+			compression = "gzip";
+			load = <0x80080000>;
+			entry = <0x80080000>;
+		};
+		fdt at 1 {
+			description = "Flattened Device Tree blob";
+			data = /incbin/("./fsl-ls1043ardb-static.dtb");
+			type = "flat_dt";
+			arch = "arm64";
+			compression = "none";
+			load = <0x90000000>;
+		};
+		ramdisk at 1 {
+			description = "LS1043 Ramdisk";
+                        data = /incbin/("./rootfs.cpio.gz");
+			type = "ramdisk";
+			arch = "arm64";
+			os = "linux";
+			compression = "gzip";
+			load = <0xa0000000>;
+		};
+	};
+
+	configurations {
+		default = "config at 1";
+		config at 1 {
+			description = "Boot Linux kernel";
+			kernel = "kernel at 1";
+			fdt = "fdt at 1";
+			ramdisk = "ramdisk at 1";
+			loadables = "fdt", "ramdisk";
+		};
+	};
+};
+
+The "loadables" is not optional. It tells SPL which images to load into memory.
+
+Other things to consider
+-----------------------
+Falcon boot skips a lot of initialization in U-Boot. If Linux expects the
+hardware to be initialized by U-Boot, the related code should be ported to SPL
+build. For example, if Linux expect Ethernet PHY to be initialized in U-Boot
+(which is not a common case), the PHY initialization has to be included in
+falcon boot. This increases the SPL image size and should be handled carefully.
+If Linux has PHY driver enabled, it still depends on the correct MDIO bus setup
+in U-Boot. Normal U-Boot sets the MDC ratio to generate a proper clock signal.
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/spl.c b/arch/arm/cpu/armv8/fsl-layerscape/spl.c
index 2776240..30b5432 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/spl.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/spl.c
@@ -116,4 +116,33 @@ void board_init_f(ulong dummy)
 	gd->arch.tlb_allocated = gd->arch.tlb_addr;
 #endif	/* CONFIG_SPL_FSL_LS_PPA */
 }
+
+#ifdef CONFIG_SPL_OS_BOOT
+/*
+ * Return
+ * 0 if booting into OS is selected
+ * 1 if booting into U-Boot is selected
+ */
+int spl_start_uboot(void)
+{
+	char s[8];
+
+	env_init();
+	env_get_f("boot_os", s, sizeof(s));
+	if ((s != NULL) && (*s != '0' && *s != 'n' && *s != 'N' &&
+			    *s != 'f' && *s != 'F'))
+		return 0;
+
+	return 1;
+}
+#endif	/* CONFIG_SPL_OS_BOOT */
+#ifdef CONFIG_SPL_LOAD_FIT
+int board_fit_config_name_match(const char *name)
+{
+	/* Just empty function now - can't decide what to choose */
+	debug("%s: %s\n", __func__, name);
+
+	return 0;
+}
+#endif
 #endif /* CONFIG_SPL_BUILD */
diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
index 79bd19a..7d8dc44 100644
--- a/arch/arm/include/asm/system.h
+++ b/arch/arm/include/asm/system.h
@@ -215,7 +215,7 @@ void __asm_switch_ttbr(u64 new_ttbr);
  * @entry_point: kernel entry point
  * @es_flag:     execution state flag, ES_TO_AARCH64 or ES_TO_AARCH32
  */
-void armv8_switch_to_el2(u64 args, u64 mach_nr, u64 fdt_addr,
+void __noreturn armv8_switch_to_el2(u64 args, u64 mach_nr, u64 fdt_addr,
 			 u64 arg4, u64 entry_point, u64 es_flag);
 /*
  * Switch from EL2 to EL1 for ARMv8
diff --git a/arch/arm/lib/spl.c b/arch/arm/lib/spl.c
index 27d6682..ab5d227 100644
--- a/arch/arm/lib/spl.c
+++ b/arch/arm/lib/spl.c
@@ -7,6 +7,7 @@
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
+
 #include <common.h>
 #include <config.h>
 #include <spl.h>
@@ -47,6 +48,15 @@ void __weak board_init_f(ulong dummy)
  * image.
  */
 #ifdef CONFIG_SPL_OS_BOOT
+#ifdef CONFIG_ARM64
+void __noreturn jump_to_image_linux(struct spl_image_info *spl_image)
+{
+	debug("Entering kernel arg pointer: 0x%p\n", spl_image->arg);
+	cleanup_before_linux();
+	armv8_switch_to_el2((u64)spl_image->arg, 0, 0, 0,
+			    spl_image->entry_point, ES_TO_AARCH64);
+}
+#else
 void __noreturn jump_to_image_linux(struct spl_image_info *spl_image)
 {
 	unsigned long machid = 0xffffffff;
@@ -62,4 +72,5 @@ void __noreturn jump_to_image_linux(struct spl_image_info *spl_image)
 	cleanup_before_linux();
 	image_entry(0, machid, spl_image->arg);
 }
+#endif	/* CONFIG_ARM64 */
 #endif
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v2 6/7] armv8: ls1043ardb: Enable spl_board_init() function
  2017-09-14 19:01 [U-Boot] [PATCH v2 0/7] Enable falcon boot for LS1043ARDB York Sun
                   ` (4 preceding siblings ...)
  2017-09-14 19:01 ` [U-Boot] [PATCH v2 5/7] armv8: layerscape: Eanble falcon boot York Sun
@ 2017-09-14 19:01 ` York Sun
  2017-09-14 19:01 ` [U-Boot] [PATCH v2 7/7] armv8: ls1043ardb_sdcard: Enable falcon boot York Sun
  6 siblings, 0 replies; 18+ messages in thread
From: York Sun @ 2017-09-14 19:01 UTC (permalink / raw)
  To: u-boot

CONFIG_SPL_BOARD_INIT is used for SPL boot. Enable it in defconfig
for LS1043ARDB SPL targets.

Signed-off-by: York Sun <york.sun@nxp.com>
---

Changes in v2: None

 configs/ls1043ardb_nand_SECURE_BOOT_defconfig   | 1 +
 configs/ls1043ardb_nand_defconfig               | 1 +
 configs/ls1043ardb_sdcard_SECURE_BOOT_defconfig | 1 +
 configs/ls1043ardb_sdcard_defconfig             | 1 +
 4 files changed, 4 insertions(+)

diff --git a/configs/ls1043ardb_nand_SECURE_BOOT_defconfig b/configs/ls1043ardb_nand_SECURE_BOOT_defconfig
index 5c8599e..416182a 100644
--- a/configs/ls1043ardb_nand_SECURE_BOOT_defconfig
+++ b/configs/ls1043ardb_nand_SECURE_BOOT_defconfig
@@ -17,6 +17,7 @@ CONFIG_BOOTDELAY=10
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/ram0 earlycon=uart8250,mmio,0x21c0500 mtdparts=60000000.nor:2m at 0x100000(nor_bank0_uboot),40m at 0x1100000(nor_bank0_fit),7m(nor_bank0_user),2m at 0x4100000(nor_bank4_uboot),40m at 0x5100000(nor_bank4_fit),-(nor_bank4_user);7e800000.flash:1m(nand_uboot),1m(nand_uboot_env),20m(nand_fit);spi0.0:1m(uboot),5m(kernel),1m(dtb),9m(file_system)"
 CONFIG_SPL=y
+CONFIG_SPL_BOARD_INIT=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0xf0
 CONFIG_SPL_CRYPTO_SUPPORT=y
diff --git a/configs/ls1043ardb_nand_defconfig b/configs/ls1043ardb_nand_defconfig
index e5310fe..d680d93 100644
--- a/configs/ls1043ardb_nand_defconfig
+++ b/configs/ls1043ardb_nand_defconfig
@@ -16,6 +16,7 @@ CONFIG_BOOTDELAY=10
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/ram0 earlycon=uart8250,mmio,0x21c0500 mtdparts=60000000.nor:2m at 0x100000(nor_bank0_uboot),40m at 0x1100000(nor_bank0_fit),7m(nor_bank0_user),2m at 0x4100000(nor_bank4_uboot),40m at 0x5100000(nor_bank4_fit),-(nor_bank4_user);7e800000.flash:1m(nand_uboot),1m(nand_uboot_env),20m(nand_fit);spi0.0:1m(uboot),5m(kernel),1m(dtb),9m(file_system)"
 CONFIG_SPL=y
+CONFIG_SPL_BOARD_INIT=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0xf0
 CONFIG_SPL_ENV_SUPPORT=y
diff --git a/configs/ls1043ardb_sdcard_SECURE_BOOT_defconfig b/configs/ls1043ardb_sdcard_SECURE_BOOT_defconfig
index bdd7ea7..b2144f3 100644
--- a/configs/ls1043ardb_sdcard_SECURE_BOOT_defconfig
+++ b/configs/ls1043ardb_sdcard_SECURE_BOOT_defconfig
@@ -18,6 +18,7 @@ CONFIG_BOOTDELAY=10
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/ram0 earlycon=uart8250,mmio,0x21c0500 mtdparts=60000000.nor:2m at 0x100000(nor_bank0_uboot),40m at 0x1100000(nor_bank0_fit),7m(nor_bank0_user),2m at 0x4100000(nor_bank4_uboot),40m at 0x5100000(nor_bank4_fit),-(nor_bank4_user);7e800000.flash:1m(nand_uboot),1m(nand_uboot_env),20m(nand_fit);spi0.0:1m(uboot),5m(kernel),1m(dtb),9m(file_system)"
 CONFIG_SPL=y
+CONFIG_SPL_BOARD_INIT=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x110
 CONFIG_SPL_CRYPTO_SUPPORT=y
diff --git a/configs/ls1043ardb_sdcard_defconfig b/configs/ls1043ardb_sdcard_defconfig
index efdaaa3..2ce2aba 100644
--- a/configs/ls1043ardb_sdcard_defconfig
+++ b/configs/ls1043ardb_sdcard_defconfig
@@ -18,6 +18,7 @@ CONFIG_BOOTDELAY=10
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/ram0 earlycon=uart8250,mmio,0x21c0500 mtdparts=60000000.nor:2m at 0x100000(nor_bank0_uboot),40m at 0x1100000(nor_bank0_fit),7m(nor_bank0_user),2m at 0x4100000(nor_bank4_uboot),40m at 0x5100000(nor_bank4_fit),-(nor_bank4_user);7e800000.flash:1m(nand_uboot),1m(nand_uboot_env),20m(nand_fit);spi0.0:1m(uboot),5m(kernel),1m(dtb),9m(file_system)"
 CONFIG_SPL=y
+CONFIG_SPL_BOARD_INIT=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0xf0
 CONFIG_SPL_ENV_SUPPORT=y
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v2 7/7] armv8: ls1043ardb_sdcard: Enable falcon boot
  2017-09-14 19:01 [U-Boot] [PATCH v2 0/7] Enable falcon boot for LS1043ARDB York Sun
                   ` (5 preceding siblings ...)
  2017-09-14 19:01 ` [U-Boot] [PATCH v2 6/7] armv8: ls1043ardb: Enable spl_board_init() function York Sun
@ 2017-09-14 19:01 ` York Sun
  2017-09-17 17:55   ` Simon Glass
  6 siblings, 1 reply; 18+ messages in thread
From: York Sun @ 2017-09-14 19:01 UTC (permalink / raw)
  To: u-boot

Update defconfig to enable falcon boot, add needed macros to board
header file. Because environment variables are not avaiable during
SPL stage for SD boot, set "boot_os=y" as default.

Signed-off-by: York Sun <york.sun@nxp.com>

---

Changes in v2: None

 configs/ls1043ardb_sdcard_defconfig | 6 ++++++
 include/configs/ls1043a_common.h    | 7 ++++---
 include/configs/ls1043ardb.h        | 5 +++++
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/configs/ls1043ardb_sdcard_defconfig b/configs/ls1043ardb_sdcard_defconfig
index 2ce2aba..37b3257 100644
--- a/configs/ls1043ardb_sdcard_defconfig
+++ b/configs/ls1043ardb_sdcard_defconfig
@@ -25,6 +25,7 @@ CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_I2C=y
+# CONFIG_CMD_IMLS is not set
 CONFIG_CMD_MMC=y
 CONFIG_CMD_NAND=y
 CONFIG_CMD_SF=y
@@ -52,3 +53,8 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_SPL_OS_BOOT=y
+CONFIG_SPL_LOAD_FIT=y
+CONFIG_SPL_OF_LIBFDT=y
+CONFIG_SPL_FIT=y
+CONFIG_SPL_GZIP=y
diff --git a/include/configs/ls1043a_common.h b/include/configs/ls1043a_common.h
index 002830c..734729a 100644
--- a/include/configs/ls1043a_common.h
+++ b/include/configs/ls1043a_common.h
@@ -73,10 +73,10 @@
 #define CONFIG_SPL_STACK		0x1001e000
 #define CONFIG_SPL_PAD_TO		0x1d000
 
-#define CONFIG_SYS_SPL_MALLOC_START	(CONFIG_SYS_TEXT_BASE + \
-					CONFIG_SYS_MONITOR_LEN)
+#define CONFIG_SYS_SPL_MALLOC_START	(CONFIG_SPL_BSS_START_ADDR + \
+					CONFIG_SPL_BSS_MAX_SIZE)
 #define CONFIG_SYS_SPL_MALLOC_SIZE	0x100000
-#define CONFIG_SPL_BSS_START_ADDR	0x80100000
+#define CONFIG_SPL_BSS_START_ADDR	0x8f000000
 #define CONFIG_SPL_BSS_MAX_SIZE		0x80000
 
 #ifdef CONFIG_SECURE_BOOT
@@ -280,6 +280,7 @@
 	"load_addr=0xa0000000\0"		\
 	"kernel_size=0x2800000\0"		\
 	"console=ttyS0,115200\0"		\
+	"boot_os=y\0"				\
 	"mtdparts=" MTDPARTS_DEFAULT "\0"	\
 	BOOTENV					\
 	"boot_scripts=ls1043ardb_boot.scr\0"	\
diff --git a/include/configs/ls1043ardb.h b/include/configs/ls1043ardb.h
index da87497..f9843f5 100644
--- a/include/configs/ls1043ardb.h
+++ b/include/configs/ls1043ardb.h
@@ -46,6 +46,11 @@
 
 #ifdef CONFIG_SD_BOOT
 #define CONFIG_SYS_FSL_PBL_RCW board/freescale/ls1043ardb/ls1043ardb_rcw_sd.cfg
+#define CONFIG_CMD_SPL
+#define CONFIG_SYS_SPL_ARGS_ADDR	0x90000000
+#define CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR	0x10000
+#define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR	0x500
+#define CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS	30
 #endif
 
 /*
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v2 1/7] spl: fix assignment of board info to global data
  2017-09-14 19:01 ` [U-Boot] [PATCH v2 1/7] spl: fix assignment of board info to global data York Sun
@ 2017-09-17 17:54   ` Simon Glass
  2017-09-18 15:46     ` York Sun
  0 siblings, 1 reply; 18+ messages in thread
From: Simon Glass @ 2017-09-17 17:54 UTC (permalink / raw)
  To: u-boot

Hi York,

On 14 September 2017 at 13:01, York Sun <york.sun@nxp.com> wrote:
> This partially reverts commit 15eb1d43bf470b85e9031c2fce7e0ce7b27dd321
> which intended to move assignment of board info earlier, into
> board_init_r(). However, function preload_console_init() is called
> either from spl_board_init() or from board_init_f(). For the latter
> case, the board info assignment is much earlier than board_init_r().
> Moving such assignment to board_init_r() would be moving it later.
>
> Signed-off-by: York Sun <york.sun@nxp.com>
> CC: Lokesh Vutla <lokeshvutla@ti.com>
> CC: Ravi Babu <ravibabu@ti.com>
> CC: Lukasz Majewski <lukma@denx.de>
> CC: Tom Rini <trini@konsulko.com>
>
> ---
>
> Changes in v2:
> New patch to fix spl after rebasing to latest master.
>
>  common/spl/spl.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index ce9819e..98b0ca0 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -365,7 +365,10 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
>         struct spl_image_info spl_image;
>
>         debug(">>spl:board_init_r()\n");
> -       gd->bd = &bdata;
> +
> +       if (!gd->bd)
> +               gd->bd = &bdata;
> +
>  #ifdef CONFIG_SPL_OS_BOOT
>         dram_init_banksize();
>  #endif
> @@ -450,6 +453,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
>   */
>  void preloader_console_init(void)
>  {
> +       if (!gd->bd)
> +               gd->bd = &bdata;
> +

It seems odd that enabling the console sets this data.

What was the impact of moving it later for your board?


>         gd->baudrate = CONFIG_BAUDRATE;
>
>         serial_init();          /* serial communications setup */
> --
> 2.7.4
>

Regards,
Simon

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v2 3/7] armv8: fsl-layerscape: Avoid running dram_init_banksize again
  2017-09-14 19:01 ` [U-Boot] [PATCH v2 3/7] armv8: fsl-layerscape: Avoid running dram_init_banksize again York Sun
@ 2017-09-17 17:54   ` Simon Glass
  0 siblings, 0 replies; 18+ messages in thread
From: Simon Glass @ 2017-09-17 17:54 UTC (permalink / raw)
  To: u-boot

On 14 September 2017 at 13:01, York Sun <york.sun@nxp.com> wrote:
> gd->ram_size is reduced in this function to reserve secure memory.
> Avoid running this function again to further reduce memory size.
> This fixes issue for SPL boot with PPA image loaded in which case
> secure memory is incorrectly allocated due to repeated calling.
>
> Signed-off-by: York Sun <york.sun@nxp.com>
>
> ---
>
> Changes in v2:
> New patch to fix gd->ram_size error after rebasing to latest mater.
>
>  arch/arm/cpu/armv8/fsl-layerscape/cpu.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v2 5/7] armv8: layerscape: Eanble falcon boot
  2017-09-14 19:01 ` [U-Boot] [PATCH v2 5/7] armv8: layerscape: Eanble falcon boot York Sun
@ 2017-09-17 17:54   ` Simon Glass
  2017-09-25 14:17   ` Łukasz Majewski
  1 sibling, 0 replies; 18+ messages in thread
From: Simon Glass @ 2017-09-17 17:54 UTC (permalink / raw)
  To: u-boot

+Philippe for review

On 14 September 2017 at 13:01, York Sun <york.sun@nxp.com> wrote:
> Add jump_to_image_linux() for arm64. Add "noreturn" flag to
> armv8_switch_to_el2(). Add hooks to fsl-layerscape to enable falcon
> boot.
>
> Signed-off-by: York Sun <york.sun@nxp.com>
>
> ---
>
> Changes in v2:
> Relace getenv_f() with env_get_f() after rebasing to latet master.
>
>  .../arm/cpu/armv8/fsl-layerscape/doc/README.falcon | 140 +++++++++++++++++++++
>  arch/arm/cpu/armv8/fsl-layerscape/spl.c            |  29 +++++
>  arch/arm/include/asm/system.h                      |   2 +-
>  arch/arm/lib/spl.c                                 |  11 ++
>  4 files changed, 181 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v2 7/7] armv8: ls1043ardb_sdcard: Enable falcon boot
  2017-09-14 19:01 ` [U-Boot] [PATCH v2 7/7] armv8: ls1043ardb_sdcard: Enable falcon boot York Sun
@ 2017-09-17 17:55   ` Simon Glass
  0 siblings, 0 replies; 18+ messages in thread
From: Simon Glass @ 2017-09-17 17:55 UTC (permalink / raw)
  To: u-boot

On 14 September 2017 at 13:01, York Sun <york.sun@nxp.com> wrote:
> Update defconfig to enable falcon boot, add needed macros to board
> header file. Because environment variables are not avaiable during
> SPL stage for SD boot, set "boot_os=y" as default.
>
> Signed-off-by: York Sun <york.sun@nxp.com>
>
> ---
>
> Changes in v2: None
>
>  configs/ls1043ardb_sdcard_defconfig | 6 ++++++
>  include/configs/ls1043a_common.h    | 7 ++++---
>  include/configs/ls1043ardb.h        | 5 +++++
>  3 files changed, 15 insertions(+), 3 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v2 1/7] spl: fix assignment of board info to global data
  2017-09-17 17:54   ` Simon Glass
@ 2017-09-18 15:46     ` York Sun
  2017-09-20 15:20       ` York Sun
  0 siblings, 1 reply; 18+ messages in thread
From: York Sun @ 2017-09-18 15:46 UTC (permalink / raw)
  To: u-boot

On 09/17/2017 10:55 AM, Simon Glass wrote:
> Hi York,
> 
> On 14 September 2017 at 13:01, York Sun <york.sun@nxp.com> wrote:
>> This partially reverts commit 15eb1d43bf470b85e9031c2fce7e0ce7b27dd321
>> which intended to move assignment of board info earlier, into
>> board_init_r(). However, function preload_console_init() is called
>> either from spl_board_init() or from board_init_f(). For the latter
>> case, the board info assignment is much earlier than board_init_r().
>> Moving such assignment to board_init_r() would be moving it later.
>>
>> Signed-off-by: York Sun <york.sun@nxp.com>
>> CC: Lokesh Vutla <lokeshvutla@ti.com>
>> CC: Ravi Babu <ravibabu@ti.com>
>> CC: Lukasz Majewski <lukma@denx.de>
>> CC: Tom Rini <trini@konsulko.com>
>>
>> ---
>>
>> Changes in v2:
>> New patch to fix spl after rebasing to latest master.
>>
>>   common/spl/spl.c | 8 +++++++-
>>   1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/common/spl/spl.c b/common/spl/spl.c
>> index ce9819e..98b0ca0 100644
>> --- a/common/spl/spl.c
>> +++ b/common/spl/spl.c
>> @@ -365,7 +365,10 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
>>          struct spl_image_info spl_image;
>>
>>          debug(">>spl:board_init_r()\n");
>> -       gd->bd = &bdata;
>> +
>> +       if (!gd->bd)
>> +               gd->bd = &bdata;
>> +
>>   #ifdef CONFIG_SPL_OS_BOOT
>>          dram_init_banksize();
>>   #endif
>> @@ -450,6 +453,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
>>    */
>>   void preloader_console_init(void)
>>   {
>> +       if (!gd->bd)
>> +               gd->bd = &bdata;
>> +
> 
> It seems odd that enabling the console sets this data.
> 
> What was the impact of moving it later for your board?
> 

gd->bd is used to track the dram bank information. With this moved 
later, I cannot track the secure memory reserved. I need this available 
before memory is initialized.

York

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v2 1/7] spl: fix assignment of board info to global data
  2017-09-18 15:46     ` York Sun
@ 2017-09-20 15:20       ` York Sun
  2017-09-25  2:13         ` Simon Glass
  0 siblings, 1 reply; 18+ messages in thread
From: York Sun @ 2017-09-20 15:20 UTC (permalink / raw)
  To: u-boot

On 09/18/2017 08:47 AM, York Sun wrote:
> On 09/17/2017 10:55 AM, Simon Glass wrote:
>> Hi York,
>>
>> On 14 September 2017 at 13:01, York Sun <york.sun@nxp.com> wrote:
>>> This partially reverts commit 15eb1d43bf470b85e9031c2fce7e0ce7b27dd321
>>> which intended to move assignment of board info earlier, into
>>> board_init_r(). However, function preload_console_init() is called
>>> either from spl_board_init() or from board_init_f(). For the latter
>>> case, the board info assignment is much earlier than board_init_r().
>>> Moving such assignment to board_init_r() would be moving it later.
>>>
>>> Signed-off-by: York Sun <york.sun@nxp.com>
>>> CC: Lokesh Vutla <lokeshvutla@ti.com>
>>> CC: Ravi Babu <ravibabu@ti.com>
>>> CC: Lukasz Majewski <lukma@denx.de>
>>> CC: Tom Rini <trini@konsulko.com>
>>>
>>> ---
>>>
>>> Changes in v2:
>>> New patch to fix spl after rebasing to latest master.
>>>
>>>    common/spl/spl.c | 8 +++++++-
>>>    1 file changed, 7 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/common/spl/spl.c b/common/spl/spl.c
>>> index ce9819e..98b0ca0 100644
>>> --- a/common/spl/spl.c
>>> +++ b/common/spl/spl.c
>>> @@ -365,7 +365,10 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
>>>           struct spl_image_info spl_image;
>>>
>>>           debug(">>spl:board_init_r()\n");
>>> -       gd->bd = &bdata;
>>> +
>>> +       if (!gd->bd)
>>> +               gd->bd = &bdata;
>>> +
>>>    #ifdef CONFIG_SPL_OS_BOOT
>>>           dram_init_banksize();
>>>    #endif
>>> @@ -450,6 +453,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
>>>     */
>>>    void preloader_console_init(void)
>>>    {
>>> +       if (!gd->bd)
>>> +               gd->bd = &bdata;
>>> +
>>
>> It seems odd that enabling the console sets this data.
>>

I don't know the history of this line. But it seems this the common 
function called by board_init_f from various board level spl file.

>> What was the impact of moving it later for your board?
>>
> 
> gd->bd is used to track the dram bank information. With this moved
> later, I cannot track the secure memory reserved. I need this available
> before memory is initialized.

The intention of 15eb1d43b was to move it earlier. But it turns out 
function preloader_console_init() is called from different places. Some 
are very early in board_init_f(). I guess we can add a new function just 
to set gd->bd if it is empty, and call this function when needed. What's 
your suggestion here?

York

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v2 1/7] spl: fix assignment of board info to global data
  2017-09-20 15:20       ` York Sun
@ 2017-09-25  2:13         ` Simon Glass
  0 siblings, 0 replies; 18+ messages in thread
From: Simon Glass @ 2017-09-25  2:13 UTC (permalink / raw)
  To: u-boot

Hi York,

On 20 September 2017 at 09:20, York Sun <york.sun@nxp.com> wrote:
> On 09/18/2017 08:47 AM, York Sun wrote:
>> On 09/17/2017 10:55 AM, Simon Glass wrote:
>>> Hi York,
>>>
>>> On 14 September 2017 at 13:01, York Sun <york.sun@nxp.com> wrote:
>>>> This partially reverts commit 15eb1d43bf470b85e9031c2fce7e0ce7b27dd321
>>>> which intended to move assignment of board info earlier, into
>>>> board_init_r(). However, function preload_console_init() is called
>>>> either from spl_board_init() or from board_init_f(). For the latter
>>>> case, the board info assignment is much earlier than board_init_r().
>>>> Moving such assignment to board_init_r() would be moving it later.
>>>>
>>>> Signed-off-by: York Sun <york.sun@nxp.com>
>>>> CC: Lokesh Vutla <lokeshvutla@ti.com>
>>>> CC: Ravi Babu <ravibabu@ti.com>
>>>> CC: Lukasz Majewski <lukma@denx.de>
>>>> CC: Tom Rini <trini@konsulko.com>
>>>>
>>>> ---
>>>>
>>>> Changes in v2:
>>>> New patch to fix spl after rebasing to latest master.
>>>>
>>>>    common/spl/spl.c | 8 +++++++-
>>>>    1 file changed, 7 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/common/spl/spl.c b/common/spl/spl.c
>>>> index ce9819e..98b0ca0 100644
>>>> --- a/common/spl/spl.c
>>>> +++ b/common/spl/spl.c
>>>> @@ -365,7 +365,10 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
>>>>           struct spl_image_info spl_image;
>>>>
>>>>           debug(">>spl:board_init_r()\n");
>>>> -       gd->bd = &bdata;
>>>> +
>>>> +       if (!gd->bd)
>>>> +               gd->bd = &bdata;
>>>> +
>>>>    #ifdef CONFIG_SPL_OS_BOOT
>>>>           dram_init_banksize();
>>>>    #endif
>>>> @@ -450,6 +453,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
>>>>     */
>>>>    void preloader_console_init(void)
>>>>    {
>>>> +       if (!gd->bd)
>>>> +               gd->bd = &bdata;
>>>> +
>>>
>>> It seems odd that enabling the console sets this data.
>>>
>
> I don't know the history of this line. But it seems this the common
> function called by board_init_f from various board level spl file.
>
>>> What was the impact of moving it later for your board?
>>>
>>
>> gd->bd is used to track the dram bank information. With this moved
>> later, I cannot track the secure memory reserved. I need this available
>> before memory is initialized.
>
> The intention of 15eb1d43b was to move it earlier. But it turns out
> function preloader_console_init() is called from different places. Some
> are very early in board_init_f(). I guess we can add a new function just
> to set gd->bd if it is empty, and call this function when needed. What's
> your suggestion here?

Yes I think an explicit function is best.

Regards,
Simon

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v2 5/7] armv8: layerscape: Eanble falcon boot
  2017-09-14 19:01 ` [U-Boot] [PATCH v2 5/7] armv8: layerscape: Eanble falcon boot York Sun
  2017-09-17 17:54   ` Simon Glass
@ 2017-09-25 14:17   ` Łukasz Majewski
  2017-09-25 14:25     ` Marek Vasut
  2017-09-25 17:08     ` York Sun
  1 sibling, 2 replies; 18+ messages in thread
From: Łukasz Majewski @ 2017-09-25 14:17 UTC (permalink / raw)
  To: u-boot

Hi York,

If you don't mind, I would like to ask you for some help and 
clarification regarding your work.

> Add jump_to_image_linux() for arm64. Add "noreturn" flag to
> armv8_switch_to_el2(). Add hooks to fsl-layerscape to enable falcon
> boot.

I'm trying to do the same on imx6q board (armv7).

> 
> Signed-off-by: York Sun <york.sun@nxp.com>
> 
> ---
> 
> Changes in v2:
> Relace getenv_f() with env_get_f() after rebasing to latet master.
> 
>   .../arm/cpu/armv8/fsl-layerscape/doc/README.falcon | 140 +++++++++++++++++++++
>   arch/arm/cpu/armv8/fsl-layerscape/spl.c            |  29 +++++
>   arch/arm/include/asm/system.h                      |   2 +-
>   arch/arm/lib/spl.c                                 |  11 ++
>   4 files changed, 181 insertions(+), 1 deletion(-)
>   create mode 100644 arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon
> 
> diff --git a/arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon b/arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon
> new file mode 100644
> index 0000000..282b19f
> --- /dev/null
> +++ b/arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon
> @@ -0,0 +1,140 @@
> +Falcon boot option
> +------------------
> +Falcon boot is a short cut boot method for SD/eMMC targets. It skips loading the
> +RAM version U-Boot. Instead, it loads FIT image and boot directly to Linux.
> +CONFIG_SPL_OS_BOOT enables falcon boot. CONFIG_SPL_LOAD_FIT enables the FIT
					   ^^^^^^ - this is a bit cumbersome, since it requires some stub 
for dtb creation (but this can be fixed for boards not yet supporting 
dts u-boot configuration).

> +image support (also need CONFIG_SPL_OF_LIBFDT, CONFIG_SPL_FIT and optionally
> +CONFIG_SPL_GZIP).
> +
> +To enable falcon boot, a hook function spl_start_uboot() returns 0 to indicate
> +booting U-Boot is not the first choice. The kernel FIT image needs to be put
> +at CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR. SPL mmc driver reads the header to
> +determine if this is a FIT image. If true, FIT image components are parsed and
> +copied or decompressed (if applicable) to their desitinations. If FIT image is
> +not found, normal U-Boot flow will follow.

This part is similar to the one for old, venerable uImage.

> +
> +An important part of falcon boot is to prepare the device tree. A normal U-Boot
> +does FDT fixups when booting Linux. For falcon boot, Linux boots directly from
> +SPL, skipping the normal U-Boot. The device tree has to be prepared in advance.
> +A command "spl export" should be called under the normal RAM version U-Boot.
> +It is equivalent to go through "bootm" step-by-step until device tree fixup is
> +done. The device tree in memory is the one needed for falcon boot. Falcon boot
> +flow suggests to save this image to SD/eMMC at the location pointed by macro
> +CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR, with maximum size specified by macro
> +CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS. However, when FIT image is used for
> +Linux, the device tree stored in FIT image overwrites the memory loaded by spl
> +driver from these sectors. We could change this loading order to favor the
> +stored sectors. But when secure boot is enabled, these sectors are used for
> +signature header and needs to be loaded before the FIT image. So it is important
> +to understand the device tree in FIT image should be the one actually used, or
> +leave it abscent to favor the stored sectors. It is easier to deploy the FIT
> +image with embedded static device tree to multiple boards.
> +
> +Macro CONFIG_SYS_SPL_ARGS_ADDR serves two purposes. One is the pointer to load
> +the stored sectors to. Normally this is the static device tree. The second
> +purpose is the memory location of signature header for secure boot. After the
> +FIT image is loaded into memory, it is validated against the signature header
> +before individual components are extracted (and optionally decompressed) into
> +their final memory locations, respectivelly. After the validation, the header
> +is no longer used. The static device tree is copied into this location. So
> +this macro is passed as the location of device tree when booting Linux.

I've not yet go to this point -> Please look into below comments.

I'm just curious - how can I specify the DTBs precedence? I mean how to 
decide if one from FIT or from eMMC sector are used?


> +components. Otherwise U-Boot cannot load them correctly.
> +
> +Generate FIT image with static device tree
> +------------------------------------------
> +Example:
> +
> +/dts-v1/;

I'm trying to load fitImage (with kernel + 2 dtbs) from eMMC directly by 
SPL. The fitImage has been generated with OE-core recipe. The same 
results are with one generated with mkimage.

> +
> +/ {
> +	description = "Image file for the LS1043A Linux Kernel";
> +	#address-cells = <1>;
> +
> +	images {
> +		kernel at 1 {
> +			description = "ARM64 Linux kernel";
> +			data = /incbin/("./arch/arm64/boot/Image.gz");
> +			type = "kernel";
> +			arch = "arm64";
> +			os = "linux";
> +			compression = "gzip";
> +			load = <0x80080000>;
> +			entry = <0x80080000>;

			^^^^ common/spl/spl_fit.c - function spl_load_fit_image()
			requires "data-offset" and "data-size" properties to be defined - 
otherwise we exit with -ENOENT.

Even when creating my fitImage with u-boot's mkimage those properties 
haven't been added.


> +		};
> +		fdt at 1 {
> +			description = "Flattened Device Tree blob";
> +			data = /incbin/("./fsl-ls1043ardb-static.dtb");
> +			type = "flat_dt";
> +			arch = "arm64";
> +			compression = "none";
> +			load = <0x90000000>;
> +		};
> +		ramdisk at 1 {
> +			description = "LS1043 Ramdisk";
> +                        data = /incbin/("./rootfs.cpio.gz");
> +			type = "ramdisk";
> +			arch = "arm64";
> +			os = "linux";
> +			compression = "gzip";
> +			load = <0xa0000000>;
> +		};
> +	};
> +
> +	configurations {
> +		default = "config at 1";
> +		config at 1 {
> +			description = "Boot Linux kernel";
> +			kernel = "kernel at 1";
> +			fdt = "fdt at 1";
> +			ramdisk = "ramdisk at 1";
> +			loadables = "fdt", "ramdisk";

			^^^
			Isn't here loadables require "kernel", "fdt", "ramdisk" ?

Could you share how have you managed to load fitImage from SPL? Maybe 
I'm missing some patches? Is there any "reference" repo, so I could see 
the "complete" work?


> +		};
> +	};
> +};
> +
> +The "loadables" is not optional. It tells SPL which images to load into memory.
> +
> +Other things to consider
> +-----------------------
> +Falcon boot skips a lot of initialization in U-Boot. If Linux expects the
> +hardware to be initialized by U-Boot, the related code should be ported to SPL
> +build. For example, if Linux expect Ethernet PHY to be initialized in U-Boot
> +(which is not a common case), the PHY initialization has to be included in
> +falcon boot. This increases the SPL image size and should be handled carefully.
> +If Linux has PHY driver enabled, it still depends on the correct MDIO bus setup
> +in U-Boot. Normal U-Boot sets the MDC ratio to generate a proper clock signal.
> diff --git a/arch/arm/cpu/armv8/fsl-layerscape/spl.c b/arch/arm/cpu/armv8/fsl-layerscape/spl.c
> index 2776240..30b5432 100644
> --- a/arch/arm/cpu/armv8/fsl-layerscape/spl.c
> +++ b/arch/arm/cpu/armv8/fsl-layerscape/spl.c
> @@ -116,4 +116,33 @@ void board_init_f(ulong dummy)
>   	gd->arch.tlb_allocated = gd->arch.tlb_addr;
>   #endif	/* CONFIG_SPL_FSL_LS_PPA */
>   }
> +
> +#ifdef CONFIG_SPL_OS_BOOT
> +/*
> + * Return
> + * 0 if booting into OS is selected
> + * 1 if booting into U-Boot is selected
> + */
> +int spl_start_uboot(void)
> +{
> +	char s[8];
> +
> +	env_init();
> +	env_get_f("boot_os", s, sizeof(s));
> +	if ((s != NULL) && (*s != '0' && *s != 'n' && *s != 'N' &&
> +			    *s != 'f' && *s != 'F'))
> +		return 0;
> +
> +	return 1;
> +}
> +#endif	/* CONFIG_SPL_OS_BOOT */
> +#ifdef CONFIG_SPL_LOAD_FIT
> +int board_fit_config_name_match(const char *name)
> +{
> +	/* Just empty function now - can't decide what to choose */
> +	debug("%s: %s\n", __func__, name);
> +
> +	return 0;
> +}
> +#endif
>   #endif /* CONFIG_SPL_BUILD */
> diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
> index 79bd19a..7d8dc44 100644
> --- a/arch/arm/include/asm/system.h
> +++ b/arch/arm/include/asm/system.h
> @@ -215,7 +215,7 @@ void __asm_switch_ttbr(u64 new_ttbr);
>    * @entry_point: kernel entry point
>    * @es_flag:     execution state flag, ES_TO_AARCH64 or ES_TO_AARCH32
>    */
> -void armv8_switch_to_el2(u64 args, u64 mach_nr, u64 fdt_addr,
> +void __noreturn armv8_switch_to_el2(u64 args, u64 mach_nr, u64 fdt_addr,
>   			 u64 arg4, u64 entry_point, u64 es_flag);
>   /*
>    * Switch from EL2 to EL1 for ARMv8
> diff --git a/arch/arm/lib/spl.c b/arch/arm/lib/spl.c
> index 27d6682..ab5d227 100644
> --- a/arch/arm/lib/spl.c
> +++ b/arch/arm/lib/spl.c
> @@ -7,6 +7,7 @@
>    *
>    * SPDX-License-Identifier:	GPL-2.0+
>    */
> +
>   #include <common.h>
>   #include <config.h>
>   #include <spl.h>
> @@ -47,6 +48,15 @@ void __weak board_init_f(ulong dummy)
>    * image.
>    */
>   #ifdef CONFIG_SPL_OS_BOOT
> +#ifdef CONFIG_ARM64
> +void __noreturn jump_to_image_linux(struct spl_image_info *spl_image)
> +{
> +	debug("Entering kernel arg pointer: 0x%p\n", spl_image->arg);
> +	cleanup_before_linux();
> +	armv8_switch_to_el2((u64)spl_image->arg, 0, 0, 0,
> +			    spl_image->entry_point, ES_TO_AARCH64);
> +}
> +#else
>   void __noreturn jump_to_image_linux(struct spl_image_info *spl_image)
>   {
>   	unsigned long machid = 0xffffffff;
> @@ -62,4 +72,5 @@ void __noreturn jump_to_image_linux(struct spl_image_info *spl_image)
>   	cleanup_before_linux();
>   	image_entry(0, machid, spl_image->arg);
>   }
> +#endif	/* CONFIG_ARM64 */
>   #endif
> 


-- 
Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v2 5/7] armv8: layerscape: Eanble falcon boot
  2017-09-25 14:17   ` Łukasz Majewski
@ 2017-09-25 14:25     ` Marek Vasut
  2017-09-25 17:08     ` York Sun
  1 sibling, 0 replies; 18+ messages in thread
From: Marek Vasut @ 2017-09-25 14:25 UTC (permalink / raw)
  To: u-boot

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="windows-1254", Size: 125 bytes --]

On 09/25/2017 04:17 PM, Łukasz Majewski wrote:

Nit -- Eanble in subject .
        ^^.... Enable

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [U-Boot] [PATCH v2 5/7] armv8: layerscape: Eanble falcon boot
  2017-09-25 14:17   ` Łukasz Majewski
  2017-09-25 14:25     ` Marek Vasut
@ 2017-09-25 17:08     ` York Sun
  1 sibling, 0 replies; 18+ messages in thread
From: York Sun @ 2017-09-25 17:08 UTC (permalink / raw)
  To: u-boot

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="windows-1254", Size: 7530 bytes --]

On 09/25/2017 07:17 AM, Łukasz Majewski wrote:
> Hi York,
> 
> If you don't mind, I would like to ask you for some help and
> clarification regarding your work.
> 
>> Add jump_to_image_linux() for arm64. Add "noreturn" flag to
>> armv8_switch_to_el2(). Add hooks to fsl-layerscape to enable falcon
>> boot.
> 
> I'm trying to do the same on imx6q board (armv7).
> 
>>
>> Signed-off-by: York Sun <york.sun@nxp.com>
>>
>> ---
>>
>> Changes in v2:
>> Relace getenv_f() with env_get_f() after rebasing to latet master.
>>
>>    .../arm/cpu/armv8/fsl-layerscape/doc/README.falcon | 140 +++++++++++++++++++++
>>    arch/arm/cpu/armv8/fsl-layerscape/spl.c            |  29 +++++
>>    arch/arm/include/asm/system.h                      |   2 +-
>>    arch/arm/lib/spl.c                                 |  11 ++
>>    4 files changed, 181 insertions(+), 1 deletion(-)
>>    create mode 100644 arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon
>>
>> diff --git a/arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon b/arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon
>> new file mode 100644
>> index 0000000..282b19f
>> --- /dev/null
>> +++ b/arch/arm/cpu/armv8/fsl-layerscape/doc/README.falcon
>> @@ -0,0 +1,140 @@
>> +Falcon boot option
>> +------------------
>> +Falcon boot is a short cut boot method for SD/eMMC targets. It skips loading the
>> +RAM version U-Boot. Instead, it loads FIT image and boot directly to Linux.
>> +CONFIG_SPL_OS_BOOT enables falcon boot. CONFIG_SPL_LOAD_FIT enables the FIT
> 					   ^^^^^^ - this is a bit cumbersome, since it requires some stub
> for dtb creation (but this can be fixed for boards not yet supporting
> dts u-boot configuration).
> 
>> +image support (also need CONFIG_SPL_OF_LIBFDT, CONFIG_SPL_FIT and optionally
>> +CONFIG_SPL_GZIP).
>> +
>> +To enable falcon boot, a hook function spl_start_uboot() returns 0 to indicate
>> +booting U-Boot is not the first choice. The kernel FIT image needs to be put
>> +at CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR. SPL mmc driver reads the header to
>> +determine if this is a FIT image. If true, FIT image components are parsed and
>> +copied or decompressed (if applicable) to their desitinations. If FIT image is
>> +not found, normal U-Boot flow will follow.
> 
> This part is similar to the one for old, venerable uImage.
> 
>> +
>> +An important part of falcon boot is to prepare the device tree. A normal U-Boot
>> +does FDT fixups when booting Linux. For falcon boot, Linux boots directly from
>> +SPL, skipping the normal U-Boot. The device tree has to be prepared in advance.
>> +A command "spl export" should be called under the normal RAM version U-Boot.
>> +It is equivalent to go through "bootm" step-by-step until device tree fixup is
>> +done. The device tree in memory is the one needed for falcon boot. Falcon boot
>> +flow suggests to save this image to SD/eMMC at the location pointed by macro
>> +CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR, with maximum size specified by macro
>> +CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS. However, when FIT image is used for
>> +Linux, the device tree stored in FIT image overwrites the memory loaded by spl
>> +driver from these sectors. We could change this loading order to favor the
>> +stored sectors. But when secure boot is enabled, these sectors are used for
>> +signature header and needs to be loaded before the FIT image. So it is important
>> +to understand the device tree in FIT image should be the one actually used, or
>> +leave it abscent to favor the stored sectors. It is easier to deploy the FIT
>> +image with embedded static device tree to multiple boards.
>> +
>> +Macro CONFIG_SYS_SPL_ARGS_ADDR serves two purposes. One is the pointer to load
>> +the stored sectors to. Normally this is the static device tree. The second
>> +purpose is the memory location of signature header for secure boot. After the
>> +FIT image is loaded into memory, it is validated against the signature header
>> +before individual components are extracted (and optionally decompressed) into
>> +their final memory locations, respectivelly. After the validation, the header
>> +is no longer used. The static device tree is copied into this location. So
>> +this macro is passed as the location of device tree when booting Linux.
> 
> I've not yet go to this point -> Please look into below comments.
> 
> I'm just curious - how can I specify the DTBs precedence? I mean how to
> decide if one from FIT or from eMMC sector are used?

By the order of loading ARGS first, then FIT. If you have static device 
tree in FIT image, it can overwrite the image loaded from ARGS. For my 
testing, I have verified FIT image without device tree in which case the 
device tree is loaded from ARGS.

> 
> 
>> +components. Otherwise U-Boot cannot load them correctly.
>> +
>> +Generate FIT image with static device tree
>> +------------------------------------------
>> +Example:
>> +
>> +/dts-v1/;
> 
> I'm trying to load fitImage (with kernel + 2 dtbs) from eMMC directly by
> SPL. The fitImage has been generated with OE-core recipe. The same
> results are with one generated with mkimage.
> 
>> +
>> +/ {
>> +	description = "Image file for the LS1043A Linux Kernel";
>> +	#address-cells = <1>;
>> +
>> +	images {
>> +		kernel at 1 {
>> +			description = "ARM64 Linux kernel";
>> +			data = /incbin/("./arch/arm64/boot/Image.gz");
>> +			type = "kernel";
>> +			arch = "arm64";
>> +			os = "linux";
>> +			compression = "gzip";
>> +			load = <0x80080000>;
>> +			entry = <0x80080000>;
> 
> 			^^^^ common/spl/spl_fit.c - function spl_load_fit_image()
> 			requires "data-offset" and "data-size" properties to be defined -
> otherwise we exit with -ENOENT.

I thought we fixed that. In my previous patch set I added FIT support. 
The data-offset is used for external data (i.e. data is outside of FIT 
structure, eg. U-Boot). For Linux FIT image, the data is embedded. See 
spl_load_fit_image().

> 
> Even when creating my fitImage with u-boot's mkimage those properties
> haven't been added.

Because data-offset is not used for embedded data.

> 
> 
>> +		};
>> +		fdt at 1 {
>> +			description = "Flattened Device Tree blob";
>> +			data = /incbin/("./fsl-ls1043ardb-static.dtb");
>> +			type = "flat_dt";
>> +			arch = "arm64";
>> +			compression = "none";
>> +			load = <0x90000000>;
>> +		};
>> +		ramdisk at 1 {
>> +			description = "LS1043 Ramdisk";
>> +                        data = /incbin/("./rootfs.cpio.gz");
>> +			type = "ramdisk";
>> +			arch = "arm64";
>> +			os = "linux";
>> +			compression = "gzip";
>> +			load = <0xa0000000>;
>> +		};
>> +	};
>> +
>> +	configurations {
>> +		default = "config at 1";
>> +		config at 1 {
>> +			description = "Boot Linux kernel";
>> +			kernel = "kernel at 1";
>> +			fdt = "fdt at 1";
>> +			ramdisk = "ramdisk at 1";
>> +			loadables = "fdt", "ramdisk";
> 
> 			^^^
> 			Isn't here loadables require "kernel", "fdt", "ramdisk" ?
> 
> Could you share how have you managed to load fitImage from SPL? Maybe
> I'm missing some patches? Is there any "reference" repo, so I could see
> the "complete" work?

I put the FIT image at CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR, see 
patch 7 in this series. With correct configuration, U-Boot SPL code 
looks for FIT image at this location. If not found, it continues to boot 
U-Boot RAM version as before. If found, falcon boot kicks in.

I have a temporary repo for debugging. See 
https://github.com/yorksun/u-boot/commits/test_patches. The code base 
has changed so this one will not be there for long.

York

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2017-09-25 17:08 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-14 19:01 [U-Boot] [PATCH v2 0/7] Enable falcon boot for LS1043ARDB York Sun
2017-09-14 19:01 ` [U-Boot] [PATCH v2 1/7] spl: fix assignment of board info to global data York Sun
2017-09-17 17:54   ` Simon Glass
2017-09-18 15:46     ` York Sun
2017-09-20 15:20       ` York Sun
2017-09-25  2:13         ` Simon Glass
2017-09-14 19:01 ` [U-Boot] [PATCH v2 2/7] cmd: spl: fix compiling error when CONFIG_CMD_SPL_WRITE_SIZE not defined York Sun
2017-09-14 19:01 ` [U-Boot] [PATCH v2 3/7] armv8: fsl-layerscape: Avoid running dram_init_banksize again York Sun
2017-09-17 17:54   ` Simon Glass
2017-09-14 19:01 ` [U-Boot] [PATCH v2 4/7] armv8: ls1043ardb: Use static DDR setting for SPL boot York Sun
2017-09-14 19:01 ` [U-Boot] [PATCH v2 5/7] armv8: layerscape: Eanble falcon boot York Sun
2017-09-17 17:54   ` Simon Glass
2017-09-25 14:17   ` Łukasz Majewski
2017-09-25 14:25     ` Marek Vasut
2017-09-25 17:08     ` York Sun
2017-09-14 19:01 ` [U-Boot] [PATCH v2 6/7] armv8: ls1043ardb: Enable spl_board_init() function York Sun
2017-09-14 19:01 ` [U-Boot] [PATCH v2 7/7] armv8: ls1043ardb_sdcard: Enable falcon boot York Sun
2017-09-17 17:55   ` Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.