All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Delaunay <patrick.delaunay@foss.st.com>
To: u-boot@lists.denx.de
Subject: [PATCH 03/10] stm32mp: stm32prog: add support of initrd in flashlayout
Date: Tue, 18 May 2021 15:12:06 +0200	[thread overview]
Message-ID: <20210518151206.3.I6f9c5a83cfe16a49ab3f724cc0be3b59f4bcd05c@changeid> (raw)
In-Reply-To: <20210518131213.20343-1-patrick.delaunay@foss.st.com>

Add the support in command stm32prog of kernel load and start
with initrd file, identify by the partition Type "Binary" in
the flashlayout.tsv, for example:

- 0x01 fsbl	Binary none 0x0 tfa.stm32
- 0x03 fip	Binary none 0x0 fip.bin
P 0x10 kernel System ram0 0xC2000000 uImage.bin
P 0x11 dtb FileSystem ram0 0xC4000000 board.dtb
P 0x12 initrd Binary ram0 0xC4400000 <initrd>

The <initrd> file can be a legacy image "uInitrd", generated
with mkimage, or a RAW initrd image "initrd.gz".

After a DFU detach the bootm command with be executed
with the associated address, for example:

$> bootm 0xC2000000 0xC4400000:<size> 0xC4000000

When the "Binary" partition type is absent, the 'bootm'
command starts the kernel without ramdisk, for example:

$> bootm 0xC2000000 - 0xC4000000

With this paths, it is no more mandatory to generate FIT
including the kernel, DT and initrd:

- 0x01 fsbl Binary none 0x0 tfa.stm32
- 0x03 fip Binary none 0x0 fip.bin
P 0x10 fit System ram0 0xC2000000 fit.bin

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
---

 .../cmd_stm32prog/cmd_stm32prog.c             | 22 +++++++++++++------
 .../mach-stm32mp/cmd_stm32prog/stm32prog.c    | 10 ++++++---
 .../mach-stm32mp/cmd_stm32prog/stm32prog.h    |  2 ++
 3 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
index e36501a86b..e584bb52bd 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
@@ -45,7 +45,6 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, int argc,
 	bool reset = false;
 	struct image_header_s header;
 	struct stm32prog_data *data;
-	u32 uimage, dtb;
 
 	if (argc < 3 ||  argc > 5)
 		return CMD_RET_USAGE;
@@ -119,21 +118,23 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, int argc,
 		goto cleanup;
 	}
 
-	uimage = data->uimage;
-	dtb = data->dtb;
-
 	stm32prog_clean(data);
 	free(stm32prog_data);
 	stm32prog_data = NULL;
 
 	puts("Download done\n");
 
-	if (uimage) {
+	if (data->uimage) {
 		char boot_addr_start[20];
 		char dtb_addr[20];
+		char initrd_addr[40];
 		char *bootm_argv[5] = {
 			"bootm", boot_addr_start, "-", dtb_addr, NULL
 		};
+		u32 uimage = data->uimage;
+		u32 dtb = data->dtb;
+		u32 initrd = data->initrd;
+
 		if (!dtb)
 			bootm_argv[3] = env_get("fdtcontroladdr");
 		else
@@ -142,8 +143,15 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, int argc,
 
 		snprintf(boot_addr_start, sizeof(boot_addr_start) - 1,
 			 "0x%x", uimage);
-		printf("Booting kernel at %s - %s...\n\n\n",
-		       boot_addr_start, bootm_argv[3]);
+
+		if (initrd) {
+			snprintf(initrd_addr, sizeof(initrd_addr) - 1, "0x%x:0x%x",
+				 initrd, data->initrd_size);
+			bootm_argv[2] = initrd_addr;
+		}
+
+		printf("Booting kernel at %s %s %s...\n\n\n",
+		       boot_addr_start, bootm_argv[2], bootm_argv[3]);
 		/* Try bootm for legacy and FIT format image */
 		if (genimg_get_format((void *)uimage) != IMAGE_FORMAT_INVALID)
 			do_bootm(cmdtp, 0, 4, bootm_argv);
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
index 84b880261a..ea69d5dd16 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
@@ -1473,7 +1473,7 @@ error:
 	return ret;
 }
 
-static void stm32prog_end_phase(struct stm32prog_data *data)
+static void stm32prog_end_phase(struct stm32prog_data *data, u64 offset)
 {
 	if (data->phase == PHASE_FLASHLAYOUT) {
 		if (parse_flash_layout(data, STM32_DDR_BASE, 0))
@@ -1489,6 +1489,10 @@ static void stm32prog_end_phase(struct stm32prog_data *data)
 			data->uimage = data->cur_part->addr;
 		if (data->cur_part->part_type == PART_FILESYSTEM)
 			data->dtb = data->cur_part->addr;
+		if (data->cur_part->part_type == PART_BINARY) {
+			data->initrd = data->cur_part->addr;
+			data->initrd_size = offset;
+		}
 	}
 
 	if (CONFIG_IS_ENABLED(MMC) &&
@@ -1747,7 +1751,7 @@ void dfu_flush_callback(struct dfu_entity *dfu)
 	if (dfu->dev_type == DFU_DEV_RAM) {
 		if (dfu->alt == 0 &&
 		    stm32prog_data->phase == PHASE_FLASHLAYOUT) {
-			stm32prog_end_phase(stm32prog_data);
+			stm32prog_end_phase(stm32prog_data, dfu->offset);
 			/* waiting DFU DETACH for reenumeration */
 		}
 	}
@@ -1756,7 +1760,7 @@ void dfu_flush_callback(struct dfu_entity *dfu)
 		return;
 
 	if (dfu->alt == stm32prog_data->cur_part->alt_id) {
-		stm32prog_end_phase(stm32prog_data);
+		stm32prog_end_phase(stm32prog_data, dfu->offset);
 		stm32prog_next_phase(stm32prog_data);
 	}
 }
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
index ad404879a7..efb51a3022 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.h
@@ -142,6 +142,8 @@ struct stm32prog_data {
 	/* bootm information */
 	u32	uimage;
 	u32	dtb;
+	u32	initrd;
+	u32	initrd_size;
 };
 
 extern struct stm32prog_data *stm32prog_data;
-- 
2.17.1

  parent reply	other threads:[~2021-05-18 13:12 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-18 13:12 [PATCH 00/10] stm32mp: stm32prog: several features and fixes Patrick Delaunay
2021-05-18 13:12 ` [PATCH 01/10] stm32mp: stm32prog: remove all the header check for UART download Patrick Delaunay
2021-05-28 12:53   ` Patrice CHOTARD
2021-06-18  7:57     ` [Uboot-stm32] " Patrice CHOTARD
2021-05-18 13:12 ` [PATCH 02/10] stm32mp: stm32prog: add timeout in stm32prog_serial_get_buffer Patrick Delaunay
2021-05-28 12:53   ` Patrice CHOTARD
2021-06-18  7:57     ` [Uboot-stm32] " Patrice CHOTARD
2021-05-18 13:12 ` Patrick Delaunay [this message]
2021-05-28 12:53   ` [PATCH 03/10] stm32mp: stm32prog: add support of initrd in flashlayout Patrice CHOTARD
2021-06-18  7:57     ` [Uboot-stm32] " Patrice CHOTARD
2021-05-18 13:12 ` [PATCH 04/10] stm32mp: stm32prog: solve compilation with CONFIG_FIT_SIGNATURE Patrick Delaunay
2021-05-28 12:53   ` Patrice CHOTARD
2021-06-18  7:57     ` [Uboot-stm32] " Patrice CHOTARD
2021-05-18 13:12 ` [PATCH 05/10] stm32mp: stm32prog: handle the next phase after USB re-enumeration Patrick Delaunay
2021-05-28 12:53   ` Patrice CHOTARD
2021-06-18  7:57     ` [Uboot-stm32] " Patrice CHOTARD
2021-05-18 13:12 ` [PATCH 06/10] stm32mp: stm32prog: correctly handle DM_PMIC Patrick Delaunay
2021-05-28 12:54   ` Patrice CHOTARD
2021-05-30 21:44     ` Jaehoon Chung
2021-06-18  7:57     ` [Uboot-stm32] " Patrice CHOTARD
2021-05-18 13:12 ` [PATCH 07/10] stm32mp: stm32prog: use get_cpu_dev for GetID command Patrick Delaunay
2021-05-28 12:54   ` Patrice CHOTARD
2021-06-18  7:56     ` [Uboot-stm32] " Patrice CHOTARD
2021-05-18 13:12 ` [PATCH 08/10] stm32mp: stm32prog: change one message level to debug Patrick Delaunay
2021-05-28 12:54   ` Patrice CHOTARD
2021-06-18  7:56     ` [Uboot-stm32] " Patrice CHOTARD
2021-05-18 13:12 ` [PATCH 09/10] dfu: add error callback Patrick Delaunay
2021-05-28 12:54   ` [Uboot-stm32] " Patrice CHOTARD
2021-06-18  7:56     ` Patrice CHOTARD
2021-05-18 13:12 ` [PATCH 10/10] stm32mp: stm32prog: handle dfu error Patrick Delaunay
2021-05-28 12:54   ` Patrice CHOTARD
2021-06-18  7:56     ` Patrice CHOTARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210518151206.3.I6f9c5a83cfe16a49ab3f724cc0be3b59f4bcd05c@changeid \
    --to=patrick.delaunay@foss.st.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.