All of lore.kernel.org
 help / color / mirror / Atom feed
From: Schrempf Frieder <frieder.schrempf@kontron.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] Cannot boot mx6qsabred with 2019.07-rc2
Date: Thu, 23 May 2019 17:26:00 +0000	[thread overview]
Message-ID: <48eb0829-c0c7-ba04-07a5-9e5e113ce7dd@kontron.de> (raw)
In-Reply-To: <CAMty3ZBjWwUddtkPSw-8BrBzwJjQKh-Sk6OOt2HFavfA7PYxEw@mail.gmail.com>

On 23.05.19 19:07, Jagan Teki wrote:
> On Thu, May 23, 2019 at 10:18 PM Fabio Estevam <festevam@gmail.com> wrote:
>>
>> On Thu, May 23, 2019 at 1:11 PM Jagan Teki <jagan@amarulasolutions.com> wrote:
>>
>>> Don't know whether this is SPL size issue or not? can you try
>>> SPL_OF_PLATDATA and TINY* I can see the size reduced with 64512 bytes
>>> (one build issue on fdtdec_get_int undefined)
>>
>> Yes, it does not build with CONFIG_SPL_OF_PLATDATA:
>>
>> lib/built-in.o: In function `fdtdec_parse_phandle_with_args':
>> /home/fabio/u-boot/lib/fdtdec.c:788: undefined reference to `fdtdec_get_int'
> 
> Couldn't dig much here, would be happy someone can find this?
> 
>> drivers/built-in.o: In function `fsl_esdhc_probe':
>> /home/fabio/u-boot/drivers/mmc/fsl_esdhc.c:1480: undefined reference
>> to `fdtdec_get_int'
>> /home/fabio/u-boot/drivers/mmc/fsl_esdhc.c:1482: undefined reference
>> to `fdtdec_get_int'
>> /home/fabio/u-boot/drivers/mmc/fsl_esdhc.c:1485: undefined reference
> 
> These we can fix, by supporting platdata support into driver.
> 
>> to `fdtdec_get_int'
>> scripts/Makefile.spl:404: recipe for target 'spl/u-boot-spl' failed
>> make[1]: *** [spl/u-boot-spl] Error 1
>>
>> Thanks for the suggestions, but at this point I prefer to go with the
>> removal of CONFIG_SPL_DM.
> 
> We have 45 days to release, I think we can make these fixes quite
> normally what do you think? fsl_esdhc.c build I can mark a patch in
> few days if required.
> 
>>
>> For 2019.07 it would be really nice if we could fix these two issues:
>>
>> 1. Allow to load a FIT image via Serial Download Protocol
>>
>> 2. Detect the SPL size overflow in build-time
> 
> 1) We are working on this, 2) can be done.

As luck would have it, I needed to load a FIT via SDP today, so I came 
up with a quick patch (see below). There are probably better ways to do 
this, but it works.

#############################

commit 408b9d26eea48e6f85dd087750629f7a4095c73d
Author: Frieder Schrempf <frieder.schrempf@kontron.de>
Date:   Thu May 23 14:52:47 2019 +0200

     Allow SPL to load and boot FIT via SDP

diff --git a/common/spl/spl_sdp.c b/common/spl/spl_sdp.c
index 807256e908..8f990a83a3 100644
--- a/common/spl/spl_sdp.c
+++ b/common/spl/spl_sdp.c
@@ -25,10 +25,13 @@ static int spl_sdp_load_image(struct spl_image_info 
*spl_image,
  		return -ENODEV;
  	}

-	/* This command typically does not return but jumps to an image */
-	sdp_handle(controller_index);
-	pr_err("SDP ended\n");
+	/*
+	 * This command either loads a legacy image, jumps and never returns,
+	 * or it loads a FIT image and returns it to be handled by the SPL code.
+	 */
+	ret = sdp_handle(controller_index, spl_image);
+	debug("SDP ended\n");

-	return -EINVAL;
+	return ret;
  }
  SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_BOARD, 
spl_sdp_load_image);
diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
index ae97ab2b49..5690060a2f 100644
--- a/drivers/usb/gadget/f_sdp.c
+++ b/drivers/usb/gadget/f_sdp.c
@@ -638,7 +638,18 @@ static u32 sdp_jump_imxheader(void *address)
  	return 0;
  }

-static void sdp_handle_in_ep(void)
+#ifdef CONFIG_SPL_LOAD_FIT
+static ulong sdp_fit_read(struct spl_load_info *load, ulong sector,
+			  ulong count, void *buf)
+{
+	debug("%s: sector %lx, count %lx, buf %lx\n",
+	      __func__, sector, count, (ulong)buf);
+	memcpy(buf, (void *)(load->dev + sector), count);
+	return count;
+}
+#endif
+
+static void sdp_handle_in_ep(struct spl_image_info *spl_image)
  {
  	u8 *data = sdp_func->in_req->buf;
  	u32 status;
@@ -689,11 +700,25 @@ static void sdp_handle_in_ep(void)

  		/* If imx header fails, try some U-Boot specific headers */
  		if (status) {
+			image_header_t *header =
+				(void *)(u64)sdp_func->jmp_address;
  #ifdef CONFIG_SPL_BUILD
+#ifdef CONFIG_SPL_LOAD_FIT
+			if (image_get_magic(header) == FDT_MAGIC) {
+				struct spl_load_info load;
+
+				printf("Found FIT\n");
+				load.dev = (void *)(u64)sdp_func->jmp_address;
+				load.bl_len = 1;
+				load.read = sdp_fit_read;
+				spl_load_simple_fit(spl_image, &load, 0,
+						    header);
+				return;
+			}
+#endif
  			/* In SPL, allow jumps to U-Boot images */
  			struct spl_image_info spl_image = {};
-			spl_parse_image_header(&spl_image,
-				(struct image_header *)sdp_func->jmp_address);
+			spl_parse_image_header(&spl_image, header);
  			jump_to_image_no_args(&spl_image);
  #else
  			/* In U-Boot, allow jumps to scripts */
@@ -715,19 +740,23 @@ static void sdp_handle_in_ep(void)
  	};
  }

-void sdp_handle(int controller_index)
+int sdp_handle(int controller_index, struct spl_image_info *spl_image)
  {
  	printf("SDP: handle requests...\n");
  	while (1) {
  		if (ctrlc()) {
  			puts("\rCTRL+C - Operation aborted.\n");
-			return;
+			return -EINVAL;
+		}
+
+		if (spl_image->flags & SPL_FIT_FOUND) {
+			return 0;
  		}

  		WATCHDOG_RESET();
  		usb_gadget_handle_interrupts(controller_index);

-		sdp_handle_in_ep();
+		sdp_handle_in_ep(spl_image);
  	}
  }

diff --git a/include/sdp.h b/include/sdp.h
index f6252d027f..f30e2bca19 100644
--- a/include/sdp.h
+++ b/include/sdp.h
@@ -9,7 +9,9 @@
  #ifndef __SDP_H_
  #define __SDP_H_

+#include <spl.h>
+
  int sdp_init(int controller_index);
-void sdp_handle(int controller_index);
+int sdp_handle(int controller_index, struct spl_image_info *spl_image);

  #endif /* __SDP_H_ */

  parent reply	other threads:[~2019-05-23 17:26 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-16 17:32 [U-Boot] Cannot boot mx6qsabred with 2019.07-rc2 Fabio Estevam
2019-05-16 17:37 ` Jagan Teki
2019-05-16 18:23   ` Fabio Estevam
2019-05-16 19:40 ` Fabio Estevam
2019-05-16 21:49   ` Lukasz Majewski
2019-05-17  2:21     ` Fabio Estevam
2019-05-17  2:17 ` Peng Fan
2019-05-17  2:22   ` Fabio Estevam
2019-05-17  2:29     ` Peng Fan
2019-05-17 12:39       ` Fabio Estevam
2019-05-17 12:57         ` Lukasz Majewski
2019-05-20 14:07           ` Fabio Estevam
2019-05-20 14:15             ` Jagan Teki
2019-05-23 16:11         ` Jagan Teki
2019-05-23 16:48           ` Fabio Estevam
2019-05-23 17:07             ` Jagan Teki
2019-05-23 17:09               ` Fabio Estevam
2019-05-23 17:26               ` Schrempf Frieder [this message]
2019-05-23 17:45                 ` Fabio Estevam
2019-05-23 17:54                   ` Marek Vasut
2019-05-23 17:59                     ` Fabio Estevam
2019-05-23 18:00                       ` Jagan Teki
2019-05-23 18:03                         ` Fabio Estevam
2019-05-23 18:28                       ` Adam Ford
2019-05-23 18:35                         ` Fabio Estevam
2019-05-23 18:37                           ` Adam Ford
2019-05-23 22:03                             ` Marek Vasut
2019-05-23 22:04                       ` Marek Vasut
2019-05-23 22:08                         ` Fabio Estevam
2019-05-23 22:11                           ` Marek Vasut
2019-05-23 23:14                             ` Fabio Estevam
2019-05-27  6:40                   ` Schrempf Frieder
2019-05-28  0:01                     ` Fabio Estevam
2019-05-31  9:10                     ` Shyam Saini
2019-06-03  6:55                       ` Schrempf Frieder
2019-05-31  6:04               ` Peng Fan
2019-05-24 17:43             ` Tom Rini
2019-05-24 20:08               ` Simon Goldschmidt
2019-05-30 10:06             ` Peng Fan
2019-05-21 13:23       ` Fabio Estevam
2019-05-22  1:38         ` Peng Fan
2019-05-22  2:34           ` Tom Rini
2019-05-22  5:52             ` Lukasz Majewski
2019-05-22 14:23             ` Fabio Estevam
2019-05-22 15:15               ` Tom Rini
2019-05-22 15:49                 ` Marek Vasut
2019-05-22 18:39                 ` Ezequiel Garcia
2019-05-23 13:49           ` Fabio Estevam
2019-05-23 13:59             ` Tom Rini
2019-05-23 14:04               ` Marek Vasut
2019-05-23 15:17                 ` Tom Rini
2019-05-23 17:52                   ` Marek Vasut
2019-05-31  3:21                   ` Peng Fan
2019-05-23 14:08               ` Abel Vesa
2019-05-23 14:33                 ` Tom Rini
2019-05-23 14:47                   ` Michael Nazzareno Trimarchi
2019-05-23 14:50                     ` Tom Rini
2019-05-23 17:51                       ` Marek Vasut

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=48eb0829-c0c7-ba04-07a5-9e5e113ce7dd@kontron.de \
    --to=frieder.schrempf@kontron.de \
    --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.