All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Delaunay <patrick.delaunay@st.com>
To: u-boot@lists.denx.de
Subject: [PATCH 17/18] stm32mp: stm32prog: support for script
Date: Wed, 18 Mar 2020 09:25:02 +0100	[thread overview]
Message-ID: <20200318082503.8025-18-patrick.delaunay@st.com> (raw)
In-Reply-To: <20200318082503.8025-1-patrick.delaunay@st.com>

Support an U-Boot script included in uimage instead of flashlayout file
(text file in tsv format).

This feature is used to execute this script directly when U-Boot is
loaded in DDR (for update without STM32CubeProgrammer for example).

A simple example with dfu-util only is:

$> echo "dfu 0" > script.cmd
$> mkimage -C none -A arm -T script -d script.cmd script.uimg
$> mkimage -T stm32image -a 0xC0000000 -e 0xC0000000 -d script.uimg \
  script.stm32

$> dfu-util -d 0483:df11 -a 1 -D tf-a.stm32
$> dfu-util -d 0483:df11 -a 0 -D script.stm32
$> dfu-util -d 0483:df11 -a 0 -D u-boot.stm32
$> dfu-util -d 0483:df11 -a 0 -e

Then you can used dfu-utils to update your device

To increase speed, you can also switch to fastboot protocol with:
  echo "fastboot 0" > script.cmd

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

 .../arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
index 15bbdc2cb6..baf9b6bd1e 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <command.h>
 #include <dfu.h>
+#include <image.h>
 #include <asm/arch/stm32prog.h>
 #include "stm32prog.h"
 
@@ -44,6 +45,7 @@ static int do_stm32prog(cmd_tbl_t *cmdtp, int flag, int argc,
 	int dev, ret;
 	enum stm32prog_link_t link = LINK_UNDEFINED;
 	bool reset = false;
+	struct image_header_s header;
 	struct stm32prog_data *data;
 
 	if (argc < 3 ||  argc > 5)
@@ -71,6 +73,18 @@ static int do_stm32prog(cmd_tbl_t *cmdtp, int flag, int argc,
 	if (argc > 4)
 		size = simple_strtoul(argv[4], NULL, 16);
 
+	/* check STM32IMAGE presence */
+	if (size == 0 &&
+	    !stm32prog_header_check((struct raw_header_s *)addr, &header)) {
+		size = header.image_length + BL_HEADER_SIZE;
+
+		/* uImage detected in STM32IMAGE, execute the script */
+		if (IMAGE_FORMAT_LEGACY ==
+		    genimg_get_format((void *)(addr + BL_HEADER_SIZE)))
+			return image_source_script(addr + BL_HEADER_SIZE,
+						   "script at 1");
+	}
+
 	enable_vidconsole();
 
 	data = (struct stm32prog_data *)malloc(sizeof(*data));
-- 
2.17.1

  parent reply	other threads:[~2020-03-18  8:25 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-18  8:24 [PATCH 00/18] stm32mp1: add command stm32prog Patrick Delaunay
2020-03-18  8:24 ` [PATCH 01/18] usb: gadget: g_dnl: add function g_dnl_set_product Patrick Delaunay
2020-04-14 12:57   ` [Uboot-stm32] " Patrice CHOTARD
2020-03-18  8:24 ` [PATCH 02/18] dfu: add prototype for dfu_transaction_initiate/cleanup Patrick Delaunay
2020-04-14 12:58   ` [Uboot-stm32] " Patrice CHOTARD
2020-03-18  8:24 ` [PATCH 03/18] stm32mp: add function get_cpu_dev Patrick Delaunay
2020-04-14 12:59   ` Patrice CHOTARD
2020-03-18  8:24 ` [PATCH 04/18] stm32mp: add the command stm32prog Patrick Delaunay
2020-04-14 13:00   ` Patrice CHOTARD
2020-04-14 13:03   ` Patrice CHOTARD
2020-03-18  8:24 ` [PATCH 05/18] stm32mp: stm32prog: add flash layout parsing Patrick Delaunay
2020-04-14 13:03   ` Patrice CHOTARD
2020-03-18  8:24 ` [PATCH 06/18] stm32mp: stm32prog: add MMC device Patrick Delaunay
2020-04-14 13:04   ` Patrice CHOTARD
2020-04-14 13:04   ` Patrice CHOTARD
2020-03-18  8:24 ` [PATCH 07/18] stm32mp: stm32prog: add support of boot partition for eMMC device Patrick Delaunay
2020-04-14 13:05   ` Patrice CHOTARD
2020-03-18  8:24 ` [PATCH 08/18] stm32mp: stm32prog: add upport of partial update Patrick Delaunay
2020-04-14 13:05   ` Patrice CHOTARD
2020-03-18  8:24 ` [PATCH 09/18] stm32mp: stm32prog: add MTD devices support Patrick Delaunay
2020-04-14 13:06   ` Patrice CHOTARD
2020-03-18  8:24 ` [PATCH 10/18] stm32mp: stm32prog: adapt the MTD partitions Patrick Delaunay
2020-04-14 13:07   ` Patrice CHOTARD
2020-03-18  8:24 ` [PATCH 11/18] stm32mp: stm32prog: add support of ssbl copy Patrick Delaunay
2020-04-14 13:07   ` Patrice CHOTARD
2020-03-18  8:24 ` [PATCH 12/18] stm32mp: stm32prog: add support for delete option in flashlayout Patrick Delaunay
2020-04-14 13:08   ` Patrice CHOTARD
2020-03-18  8:24 ` [PATCH 13/18] stm32mp: stm32prog: add otp update support Patrick Delaunay
2020-04-14 13:09   ` Patrice CHOTARD
2020-03-18  8:24 ` [PATCH 14/18] stm32mp: stm32prog: add pmic NVM " Patrick Delaunay
2020-04-14 13:09   ` Patrice CHOTARD
2020-03-18  8:25 ` [PATCH 15/18] stm32mp: stm32prog: add serial link support Patrick Delaunay
2020-04-14 13:10   ` Patrice CHOTARD
2020-03-18  8:25 ` [PATCH 16/18] stm32mp: stm32prog: enable videoconsole Patrick Delaunay
2020-04-14 13:11   ` Patrice CHOTARD
2020-03-18  8:25 ` Patrick Delaunay [this message]
2020-04-14 13:11   ` [PATCH 17/18] stm32mp: stm32prog: support for script Patrice CHOTARD
2020-03-18  8:25 ` [PATCH 18/18] stm32mp: stm32prog: add support of RAM target Patrick Delaunay
2020-04-14 13:11   ` Patrice CHOTARD
2020-05-14  9:28 ` [PATCH 00/18] stm32mp1: add command stm32prog Patrick DELAUNAY

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=20200318082503.8025-18-patrick.delaunay@st.com \
    --to=patrick.delaunay@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.