diff mbox

[U-Boot,1/3] ARM: don't panic if no flash is there

Message ID 7edfdbf8df20140ad93f0a967fc526f8cef5360d.1303028702.git.rubini@gnudd.com
State Rejected
Headers show

Commit Message

Alessandro Rubini April 17, 2011, 8:27 a.m. UTC
From: Alessandro Rubini <rubini@gnudd.com>

Commit f1d2b313c9eb6808d30c16a9eb5251240452a56c, which
introduced relocation, also added some ifdef to panic
for no flash is found but some is expected.  This is policy,
in my opinion, and should not be part of the boot loader
like it wasn't there earlier.

This is mandatory to have the versatile port work on qemu,
where flash has never been correctly identified without any
side effect on the usefulness of the emulation.

Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
---
 arch/arm/lib/board.c |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)

Comments

Wolfgang Denk April 17, 2011, 12:34 p.m. UTC | #1
Dear Alessandro Rubini,

In message <7edfdbf8df20140ad93f0a967fc526f8cef5360d.1303028702.git.rubini@gnudd.com> you wrote:
> From: Alessandro Rubini <rubini@gnudd.com>
> 
> Commit f1d2b313c9eb6808d30c16a9eb5251240452a56c, which
> introduced relocation, also added some ifdef to panic
> for no flash is found but some is expected.  This is policy,
> in my opinion, and should not be part of the boot loader
> like it wasn't there earlier.
> 
> This is mandatory to have the versatile port work on qemu,
> where flash has never been correctly identified without any
> side effect on the usefulness of the emulation.
> 
> Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
> ---
>  arch/arm/lib/board.c |    7 -------
>  1 files changed, 0 insertions(+), 7 deletions(-)

Sorry, but I reject this patch.  This is common code that has always
been there (at least in the reference implementation on Power; it was
a bug that got fixed that this was missing before in ARM).

If you do not have NOR flash, then you should not enable it (and
define CONFIG_SYS_NO_FLASH). Otherwise, you are supposed to have
flash memory.

If there are problems with the Qemu emulation of NOR flash these
should be fixed there.

Best regards,

Wolfgang Denk
Alessandro Rubini April 17, 2011, 5:32 p.m. UTC | #2
> Sorry, but I reject this patch.

Please let me restate the point once more. Maybe i've not been clear.

> If you do not have NOR flash, then you should not enable it (and
> define CONFIG_SYS_NO_FLASH). Otherwise, you are supposed to have
> flash memory.

I expect a serious boot loader to work in all possible situations and
to be a development tool, the thing that was called a monitor ages ago
(why do you have "mw" and "md" otherwise?). I've always loved u-boot
usefulness as opposed to the crappy "do nothing at all" wince or
freecale boot loaders.

Thus, I see three reasons to revert the older behaviour.

- even if flash got broken over time, the machine should be useable.
hang() here gains nothing, as I may still be able to boot though the net
and see what happens, without the need to recompile and reflesh a special
recovery boot loader

- during initial development it's common to have some parameter
misconfigured (and thus see no flash) while still using u-boot to
md/mw/whatever and see how's flash really mapepd.  It makes no sense
to be being forced to flash twice at each development loop (one trying
new code and hang() and another to get an interactive session).

- there may be board build both with and without NOR flash. On one
side you added relocation to support boards with different memory
sizes with a single u-boot binary, on the other you are now forbidding
a single binary to work on two similar boards with a different set of
peripherals.

This is policy to me, and I see no reason to force policy in a boot
loader.  I expect only simple and uniform behaviour: do we hang() if
no network is found?

> If there are problems with the Qemu emulation of NOR flash these
> should be fixed there.

Sure, if you want flash. I'm not asking non-compliant code the be added
in u-boot to deal with a flaky implementation elsewhere. I'd love a
perfectly working, though incomplete, emulation to be supported just
like real hardware prototypes with production bugs in the NOR mounting.

Amicalment (even though this message sounds harsh it isn't meant to be)
/alessandro
Wolfgang Denk April 17, 2011, 6:50 p.m. UTC | #3
Dear Alessandro Rubini,

In message <20110417173205.GA28105@mail.gnudd.com> you wrote:
> 
> > If you do not have NOR flash, then you should not enable it (and
> > define CONFIG_SYS_NO_FLASH). Otherwise, you are supposed to have
> > flash memory.
> 
> I expect a serious boot loader to work in all possible situations and
> to be a development tool, the thing that was called a monitor ages ago
> (why do you have "mw" and "md" otherwise?). I've always loved u-boot
> usefulness as opposed to the crappy "do nothing at all" wince or
> freecale boot loaders.

You know that all this is just polemics, as in your special case none
of your arguments actually applies.

> Thus, I see three reasons to revert the older behaviour.

We want to unify the code across architectures.  The behavior we have
now is what we have in U-Boot (and PPCBoot) since day one, i. e. for
well over a decade.  The problem was just that some architectures
incorrectly implemented this, and such bugs got finally fixed.

> - even if flash got broken over time, the machine should be useable.
> hang() here gains nothing, as I may still be able to boot though the net
> and see what happens, without the need to recompile and reflesh a special
> recovery boot loader

If you have a system with NOR flash, you usually boot from NOR.  If
NOR is so broken that it fails the detection, you cannot make any
assumptions about which code might be running, and which not.  You
have fully undefined behaviour then.  In such a situation it is best
to shut the system down and halt in a safe mode, instead of running
any random code.  Many of these devices actually control hardware,
where uncontrolled misfunction might be dangerous.

I'm sorry, but my decision is made.

Best regards,

Wolfgang Denk
Loïc Minier April 18, 2011, 9:40 a.m. UTC | #4
Would it be possible to introduce a QEMU Versatile board in U-Boot
 derived from the regular Versatile board's config?  It would disable
 the things that aren't (yet) supported in QEMU or too painful to
 support.
Albert ARIBAUD April 18, 2011, 11:11 a.m. UTC | #5
Le 18/04/2011 11:40, Loïc Minier a écrit :
>   Would it be possible to introduce a QEMU Versatile board in U-Boot
>   derived from the regular Versatile board's config?  It would disable
>   the things that aren't (yet) supported in QEMU or too painful to
>   support.

Either that or introduce a config option for versatile that will allow 
the same code to support both the real and the QEMUed version -- 
although I tend to side with Wolfgang in saying that the interest of 
QEMU is its ability to emulate systems, so if the real versatile has 
NOR, it should have it too under QEMU.

Amicalement,
Wolfgang Denk April 21, 2011, 11:29 p.m. UTC | #6
Dear =?iso-8859-1?Q?Lo=EFc?= Minier,

In message <20110418094025.GC11828@bee.dooz.org> you wrote:
>  Would it be possible to introduce a QEMU Versatile board in U-Boot
>  derived from the regular Versatile board's config?  It would disable
>  the things that aren't (yet) supported in QEMU or too painful to
>  support.

Sure.  Please feel free to submit a patch.

Best regards,

Wolfgang Denk
diff mbox

Patch

diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index dc46e21..bc8b589 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -431,10 +431,6 @@  void board_init_f (ulong bootflag)
 	/* NOTREACHED - relocate_code() does not return */
 }
 
-#if !defined(CONFIG_SYS_NO_FLASH)
-static char *failed = "*** failed ***\n";
-#endif
-
 /************************************************************************
  *
  * This is the next part if the initialization sequence: we are now
@@ -501,9 +497,6 @@  void board_init_r (gd_t *id, ulong dest_addr)
 # else	/* !CONFIG_SYS_FLASH_CHECKSUM */
 		print_size (flash_size, "\n");
 # endif /* CONFIG_SYS_FLASH_CHECKSUM */
-	} else {
-		puts (failed);
-		hang ();
 	}
 #endif