diff mbox

spl_mmc: allow to load raw image

Message ID 1456745517-19797-1-git-send-email-yamada.masahiro@socionext.com
State New
Headers show

Commit Message

Masahiro Yamada Feb. 29, 2016, 11:31 a.m. UTC
The function spl_parse_image_header() falls back to a raw image
if the U-Boot header is missing and CONFIG_SPL_PANIC_ON_RAW_IMAGE
is undefined.  While, the bad magic checking here makes the
spl_parse_image_header() unreachable in case of the missing header.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

---

 common/spl/spl_mmc.c | 5 -----
 1 file changed, 5 deletions(-)

-- 
1.9.1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Comments

Masahiro Yamada March 16, 2016, 3:10 a.m. UTC | #1
Hi Tom,


2016-03-16 4:23 GMT+09:00 Tom Rini <trini@konsulko.com>:
> On Mon, Feb 29, 2016 at 08:31:57PM +0900, Masahiro Yamada wrote:

>

>> The function spl_parse_image_header() falls back to a raw image

>> if the U-Boot header is missing and CONFIG_SPL_PANIC_ON_RAW_IMAGE

>> is undefined.  While, the bad magic checking here makes the

>> spl_parse_image_header() unreachable in case of the missing header.

>>

>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

>> Reviewed-by: Tom Rini <trini@konsulko.com>

>

> OK, but now with Simon's series that adds FIT support to SPL this just

> doesn't work as is, please rework and resend, thanks!

>

>


Done.

http://patchwork.ozlabs.org/patch/598113/


-- 
Best Regards
Masahiro Yamada
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Masahiro Yamada March 17, 2016, 4:07 p.m. UTC | #2
Hi Tom,

2016-03-17 11:04 GMT+09:00 Tom Rini <trini@konsulko.com>:
> On Mon, Feb 29, 2016 at 08:31:57PM +0900, Masahiro Yamada wrote:

>

>> The function spl_parse_image_header() falls back to a raw image

>> if the U-Boot header is missing and CONFIG_SPL_PANIC_ON_RAW_IMAGE

>> is undefined.  While, the bad magic checking here makes the

>> spl_parse_image_header() unreachable in case of the missing header.

>>

>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

>> Reviewed-by: Tom Rini <trini@konsulko.com>

>

> Applied to u-boot/master, thanks!


I guess this is false.

This is v1 that you said does not work as is.




-- 
Best Regards
Masahiro Yamada
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Masahiro Yamada May 1, 2016, 8:37 a.m. UTC | #3
Hi Adam,


2016-04-30 3:06 GMT+09:00 Adam Ford <aford173@gmail.com>:
> On Fri, Apr 29, 2016 at 12:53 PM, Tom Rini <trini@konsulko.com> wrote:

>> On Fri, Apr 29, 2016 at 09:59:00AM -0500, Adam Ford wrote:

>>

>>> Does anyone with an OMAP3 board have any issues with this patch?  I

>>> will admit I haven't stayed on top of stuff due to moving, and other

>>> issues at home, but I pulled down the master to reviews some on

>>> related stuff, and found that master doesn't boot.  I used git bisect

>>> this morning and it narrowed down a problem with booting to this

>>> patch.

>>>

>>> With the patch, I get:

>>>

>>> U-Boot SPL 2016.03-00378-g4976f48 (Apr 29 2016 - 09:25:27)

>>> Trying to boot from MMC

>>

>> OK.  Do you have u-boot.bin or u-boot.img (which?) written to the raw

>> offset in MMC or from filesystem?  Based on the log it looks like

>> filesystem.

>

> I have u-boot.img copied to the fatfs on the card, but I didn't put it

> in a specific location.

>

> I never used to have to do that.  Is this a new behavior and is it

> documented somewhere?

>

> adam



You are expecting to boot it from FAT,
but I think spl_boot_mode() on your board returns MMCSD_MODE_RAW.

Can you fix the function to return MMCSD_MODE_FS?



This commit changed to allow to load raw U-Boot image,
so MMCSD_MODE_RAW never fails.

So, you can no longer rely on the former behavior
"try MMCSD_MODE_RAW first, and fallback to MMCSD_MODE_FS".

-- 
Best Regards
Masahiro Yamada
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
Masahiro Yamada May 2, 2016, 2:04 a.m. UTC | #4
2016-05-02 10:57 GMT+09:00 Tom Rini <trini@konsulko.com>:
> On Sun, May 01, 2016 at 08:32:48PM -0500, Derald D. Woods wrote:

>> On 05/01/2016 03:37 AM, Masahiro Yamada wrote:

>> >Hi Adam,

>> >

>> >

>> >2016-04-30 3:06 GMT+09:00 Adam Ford <aford173@gmail.com>:

>> >>On Fri, Apr 29, 2016 at 12:53 PM, Tom Rini <trini@konsulko.com> wrote:

>> >>>On Fri, Apr 29, 2016 at 09:59:00AM -0500, Adam Ford wrote:

>> >>>

>> >>>>Does anyone with an OMAP3 board have any issues with this patch?  I

>> >>>>will admit I haven't stayed on top of stuff due to moving, and other

>> >>>>issues at home, but I pulled down the master to reviews some on

>> >>>>related stuff, and found that master doesn't boot.  I used git bisect

>> >>>>this morning and it narrowed down a problem with booting to this

>> >>>>patch.

>> >>>>

>> >>>>With the patch, I get:

>> >>>>

>> >>>>U-Boot SPL 2016.03-00378-g4976f48 (Apr 29 2016 - 09:25:27)

>> >>>>Trying to boot from MMC

>> >>>OK.  Do you have u-boot.bin or u-boot.img (which?) written to the raw

>> >>>offset in MMC or from filesystem?  Based on the log it looks like

>> >>>filesystem.

>> >>I have u-boot.img copied to the fatfs on the card, but I didn't put it

>> >>in a specific location.

>> >>

>> >>I never used to have to do that.  Is this a new behavior and is it

>> >>documented somewhere?

>> >>

>> >>adam

>> >

>> >You are expecting to boot it from FAT,

>> >but I think spl_boot_mode() on your board returns MMCSD_MODE_RAW.

>> >

>> >Can you fix the function to return MMCSD_MODE_FS?

>> >

>> >

>> >

>> >This commit changed to allow to load raw U-Boot image,

>> >so MMCSD_MODE_RAW never fails.

>> >

>> >So, you can no longer rely on the former behavior

>> >"try MMCSD_MODE_RAW first, and fallback to MMCSD_MODE_FS".

>> >

>>

>> So everyone loading MLO from the FAT filesystem is now wrong? I am

>> trying to understand how this came into being the default.

>

> ... yes, we can't break the case of SPL+U-Boot being on FS on MMC1.  I

> wonder if:

> commit 22d90d560a2b01c47f180e196e6c6485eb8e65db

> Author: Alexander Graf <agraf@suse.de>

> Date:   Tue Mar 1 09:56:34 2016 +0100

>

>     omap3: Use raw SPL by default for mmc1

>

> Isn't part of what's going wrong now.

>



Also, I think spl_mmc_load_image() is a bit odd.



   case MMCSD_MODE_RAW:

         /* If RAW mode fails, try FS mode. */
   case MMCSD_MODE_FS:


should be



   case MMCSD_MODE_FS:

         /* If FS mode fails, try RAW mode. */
   case MMCSD_MODE_RAW:




File system is generally higher requirement than
raw block access.



-- 
Best Regards
Masahiro Yamada
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
diff mbox

Patch

diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index c27a250..df406e3 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -33,11 +33,6 @@  static int mmc_load_image_raw_sector(struct mmc *mmc, unsigned long sector)
 	if (count == 0)
 		goto end;
 
-	if (image_get_magic(header) != IH_MAGIC) {
-		puts("bad magic\n");
-		return -1;
-	}
-
 	spl_parse_image_header(header);
 
 	/* convert size to sectors - round up */