All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Kiernan <alex.kiernan@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC PATCH v2 15/20] fastboot: Merge boot common across USB and UDP
Date: Mon, 30 Apr 2018 08:32:49 +0000	[thread overview]
Message-ID: <1525077174-6211-16-git-send-email-alex.kiernan@gmail.com> (raw)
In-Reply-To: <1525077174-6211-1-git-send-email-alex.kiernan@gmail.com>

Merge USB and UDP boot code. The USB implementation stays the same, but
UDP no longer passes an fdt. We introduce a new environment variable
'fastbootcmd' which if set overrides the hardcoded boot command, setting
this then allows the UDP implementation to remain the same. If after
running 'fastbootcmd' the board has not booted, control is returned
to U-Boot and the fastboot process ends.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
---

Changes in v2: None

 drivers/fastboot/fb_common.c    | 27 +++++++++++++++++++++++++++
 drivers/usb/gadget/f_fastboot.c | 22 +++++++---------------
 include/fastboot.h              |  1 +
 net/fastboot.c                  | 16 ++--------------
 4 files changed, 37 insertions(+), 29 deletions(-)

diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c
index 36ef669..73d8f94 100644
--- a/drivers/fastboot/fb_common.c
+++ b/drivers/fastboot/fb_common.c
@@ -107,3 +107,30 @@ int __weak fb_set_reboot_flag(void)
 {
 	return -1;
 }
+
+void fastboot_boot(void *addr)
+{
+	char *s;
+
+	s = env_get("fastbootcmd");
+	if (s) {
+		run_command(s, CMD_FLAG_ENV);
+	} else {
+		static char boot_addr_start[12];
+		static char *const bootm_args[] = {
+			"bootm", boot_addr_start, NULL
+		};
+
+		snprintf(boot_addr_start, sizeof(boot_addr_start) - 1,
+			 "0x%lx", (long)addr);
+		printf("Booting kernel at %s...\n\n\n", boot_addr_start);
+
+		do_bootm(NULL, 0, 2, bootm_args);
+
+		/* This only happens if image is somehow faulty so we start
+		 * over. We deliberately leave this policy to the invocation
+		 * of fastbootcmd if that's what's being run
+		 */
+		do_reset(NULL, 0, 0, NULL);
+	}
+}
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 84515da..1dca4dd 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -480,18 +480,15 @@ static void cb_download(struct usb_ep *ep, struct usb_request *req)
 	fastboot_tx_write_str(response);
 }
 
-static void do_bootm_on_complete(struct usb_ep *ep, struct usb_request *req)
+static void do_exit_on_complete(struct usb_ep *ep, struct usb_request *req)
 {
-	char boot_addr_start[12];
-	char *bootm_args[] = { "bootm", boot_addr_start, NULL };
-
-	puts("Booting kernel..\n");
-
-	sprintf(boot_addr_start, "0x%lx", (long)CONFIG_FASTBOOT_BUF_ADDR);
-	do_bootm(NULL, 0, 2, bootm_args);
+	g_dnl_trigger_detach();
+}
 
-	/* This only happens if image is somehow faulty so we start over */
-	do_reset(NULL, 0, 0, NULL);
+static void do_bootm_on_complete(struct usb_ep *ep, struct usb_request *req)
+{
+	fastboot_boot((void *)CONFIG_FASTBOOT_BUF_ADDR);
+	do_exit_on_complete(ep, req);
 }
 
 static void cb_boot(struct usb_ep *ep, struct usb_request *req)
@@ -500,11 +497,6 @@ static void cb_boot(struct usb_ep *ep, struct usb_request *req)
 	fastboot_tx_write_str("OKAY");
 }
 
-static void do_exit_on_complete(struct usb_ep *ep, struct usb_request *req)
-{
-	g_dnl_trigger_detach();
-}
-
 static void cb_continue(struct usb_ep *ep, struct usb_request *req)
 {
 	fastboot_func->in_req->complete = do_exit_on_complete;
diff --git a/include/fastboot.h b/include/fastboot.h
index 9767065..64f9939 100644
--- a/include/fastboot.h
+++ b/include/fastboot.h
@@ -76,4 +76,5 @@ int strcmp_l1(const char *s1, const char *s2);
 
 int fastboot_lookup_command(const char *cmd_string);
 int fb_set_reboot_flag(void);
+void fastboot_boot(void *addr);
 #endif /* _FASTBOOT_H_ */
diff --git a/net/fastboot.c b/net/fastboot.c
index ad8c101..119011c 100644
--- a/net/fastboot.c
+++ b/net/fastboot.c
@@ -383,20 +383,8 @@ static void cb_reboot_bootloader(char *cmd_parameter, char *fastboot_data,
  */
 static void boot_downloaded_image(void)
 {
-	char kernel_addr[12];
-	char *fdt_addr = env_get("fdt_addr_r");
-	char *const bootm_args[] = {
-		"bootm", kernel_addr, "-", fdt_addr, NULL
-	};
-
-	sprintf(kernel_addr, "0x%lx", (long)CONFIG_FASTBOOT_BUF_ADDR);
-
-	printf("\nBooting kernel at %s with fdt at %s...\n\n\n",
-	       kernel_addr, fdt_addr);
-	do_bootm(NULL, 0, 4, bootm_args);
-
-	/* This only happens if image is faulty so we start over. */
-	do_reset(NULL, 0, 0, NULL);
+	fastboot_boot((void *)CONFIG_FASTBOOT_BUF_ADDR);
+	net_set_state(NETLOOP_SUCCESS);
 }
 
 /**
-- 
2.7.4

  parent reply	other threads:[~2018-04-30  8:32 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-30  8:32 [U-Boot] [RFC PATCH v2 00/20] Add fastboot UDP support Alex Kiernan
2018-04-30  8:32 ` [U-Boot] [RFC PATCH v2 01/20] fastboot: Move fastboot to drivers/fastboot Alex Kiernan
2018-04-30 23:12   ` Simon Glass
2018-04-30  8:32 ` [U-Boot] [RFC PATCH v2 02/20] fastboot: Switch dependencies on FASTBOOT to USB_FUNCTION_FASTBOOT Alex Kiernan
2018-05-03 18:19   ` Joe Hershberger
2018-04-30  8:32 ` [U-Boot] [RFC PATCH v2 03/20] fastboot: Refactor fastboot_okay/fail to take response Alex Kiernan
2018-05-03 18:24   ` Joe Hershberger
2018-04-30  8:32 ` [U-Boot] [RFC PATCH v2 04/20] fastboot: Extract fastboot_okay/fail to fb_common.c Alex Kiernan
2018-05-03 18:26   ` Joe Hershberger
2018-04-30  8:32 ` [U-Boot] [RFC PATCH v2 05/20] fastboot: Introduce fastboot_response and refactor fastboot_okay/fail Alex Kiernan
2018-05-03 18:28   ` Joe Hershberger
2018-04-30  8:32 ` [U-Boot] [RFC PATCH v2 06/20] fastboot: Correct dependencies in FASTBOOT_FLASH Alex Kiernan
2018-05-03 18:34   ` Joe Hershberger
2018-04-30  8:32 ` [U-Boot] [RFC PATCH v2 07/20] net: fastboot: Merge AOSP UDP fastboot Alex Kiernan
2018-05-01  6:28   ` Jocelyn Bohr
2018-05-03 20:38   ` Joe Hershberger
2018-05-08  9:11     ` Alex Kiernan
2018-05-08 15:24       ` Joe Hershberger
2018-05-08 15:51         ` Alex Kiernan
2018-04-30  8:32 ` [U-Boot] [RFC PATCH v2 08/20] net: fastboot: Support building without MMC Alex Kiernan
2018-05-03 20:39   ` Joe Hershberger
2018-05-04  6:06     ` Jocelyn Bohr
2018-04-30  8:32 ` [U-Boot] [RFC PATCH v2 09/20] fastboot: Refactor write_fb_response into fastboot_okay/fail/response Alex Kiernan
2018-05-03 20:48   ` Joe Hershberger
2018-05-04  6:00     ` Jocelyn Bohr
2018-04-30  8:32 ` [U-Boot] [RFC PATCH v2 10/20] fastboot: Merge USB and UDP getvar implementation Alex Kiernan
2018-05-03 20:56   ` Joe Hershberger
2018-04-30  8:32 ` [U-Boot] [RFC PATCH v2 11/20] fastboot: net: Change 'continue' so it matches USB fastboot Alex Kiernan
2018-05-03 20:58   ` Joe Hershberger
2018-05-04  6:18     ` Jocelyn Bohr
2018-05-08  9:20     ` Alex Kiernan
2018-05-08 15:32       ` Joe Hershberger
2018-04-30  8:32 ` [U-Boot] [RFC PATCH v2 12/20] fastboot: net: Convert command lookup to a table Alex Kiernan
2018-05-03 21:08   ` Joe Hershberger
2018-05-04  9:14     ` Alex Kiernan
2018-04-30  8:32 ` [U-Boot] [RFC PATCH v2 13/20] fastboot: Merge reboot-bootloader handling Alex Kiernan
2018-05-01  6:49   ` Jocelyn Bohr
2018-05-01  7:23     ` Alex Kiernan
2018-05-01  8:21       ` Alex Kiernan
2018-05-02  5:46         ` Jocelyn Bohr
2018-05-02  5:51           ` Jocelyn Bohr
2018-05-02  8:24             ` Alex Kiernan
2018-05-03 21:15   ` Joe Hershberger
2018-05-04  7:34     ` Alex Kiernan
2018-05-04  7:44       ` Joe Hershberger
2018-04-30  8:32 ` [U-Boot] [RFC PATCH v2 14/20] fastboot: Avoid re-parsing cmd_string for boot/reboot Alex Kiernan
2018-05-03 21:17   ` Joe Hershberger
2018-05-07 21:20     ` Jocelyn Bohr
2018-04-30  8:32 ` Alex Kiernan [this message]
2018-05-03 21:21   ` [U-Boot] [RFC PATCH v2 15/20] fastboot: Merge boot common across USB and UDP Joe Hershberger
2018-05-07 21:59     ` Jocelyn Bohr
2018-05-08  6:08       ` Joe Hershberger
2018-05-08  6:54         ` Alex Kiernan
2018-04-30  8:32 ` [U-Boot] [RFC PATCH v2 16/20] fastboot: net: Add NAND support Alex Kiernan
2018-05-03 21:24   ` Joe Hershberger
2018-05-08 16:38     ` Jocelyn Bohr
2018-05-08  6:53   ` Jocelyn Bohr
2018-05-08  7:19     ` Joe Hershberger
2018-05-08  9:09       ` Alex Kiernan
2018-05-08 16:37         ` Jocelyn Bohr
2018-04-30  8:32 ` [U-Boot] [RFC PATCH v2 17/20] fastboot: Guard getvar:partition-type/size with MMC Alex Kiernan
2018-05-03 21:26   ` Joe Hershberger
2018-04-30  8:32 ` [U-Boot] [RFC PATCH v2 18/20] fastboot: Check if part_name is NULL before using it Alex Kiernan
2018-05-03 21:26   ` Joe Hershberger
2018-05-08  6:55     ` Jocelyn Bohr
2018-04-30  8:32 ` [U-Boot] [RFC PATCH v2 19/20] fastboot: Add missing newlines Alex Kiernan
2018-05-03 21:26   ` Joe Hershberger
2018-05-08  6:56     ` Jocelyn Bohr
2018-04-30  8:32 ` [U-Boot] [RFC PATCH v2 20/20] fastboot: net: Split fastboot protocol out from net Alex Kiernan
2018-05-03 21:29   ` Joe Hershberger
2018-05-04  6:05     ` Alex Kiernan
2018-05-02  6:33 ` [U-Boot] [RFC PATCH v2 00/20] Add fastboot UDP support Jocelyn Bohr
2018-05-02  8:14   ` Alex Kiernan
2018-05-08  7:13     ` Jocelyn Bohr

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=1525077174-6211-16-git-send-email-alex.kiernan@gmail.com \
    --to=alex.kiernan@gmail.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.