All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH V3] BOOT: Add "bootz" command to boot Linux zImage
@ 2012-03-12 21:34 ` Marek Vasut
  2012-03-12 22:03   ` Wolfgang Denk
  2012-03-13  2:03   ` Mike Frysinger
  0 siblings, 2 replies; 48+ messages in thread
From: Marek Vasut @ 2012-03-12 21:34 UTC (permalink / raw)
  To: u-boot

From: Marek Vasut <marek.vasut@gmail.com>

This command boots Linux zImage from where the zImage is loaded to. Passing
initrd and fdt is supported.

Tested on i.MX28 based DENX M28EVK
Tested on PXA270 based Voipac PXA270.

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Cc: Tom Warren <TWarren@nvidia.com>
Cc: albert.u.boot at aribaud.net
Cc: afleming at gmail.com,
Cc: Simon Glass <sjg@chromium.org>,
Cc: Stephen Warren <swarren@nvidia.com>
Cc: Nicolas Pitre <nico@fluxnic.net>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Detlev Zundel <dzu@denx.de>
---
 common/Makefile    |    1 +
 common/cmd_bootm.c |   29 +--------
 common/cmd_bootz.c |  175 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 common/image.c     |   25 ++++++++
 include/image.h    |    8 +++
 5 files changed, 210 insertions(+), 28 deletions(-)
 create mode 100644 common/cmd_bootz.c

V2: Use CONFIG_BOOTZ_MAX_KERNEL_LMB_SIZE to reserve kernel LMB
V3: Compute the LMB size at runtime (obsoletes V2)
    Move shared code to image.c/image.h
    Sync with latest U-Boot

Note: The FDT works ok, but I don't know about ramdisk, this might be a subject
of subsequent patch (to support raw ramdisk image).

diff --git a/common/Makefile b/common/Makefile
index 0189aac..3e20889 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -39,6 +39,7 @@ COBJS-y += xyzModem.o
 # core command
 COBJS-y += cmd_boot.o
 COBJS-$(CONFIG_CMD_BOOTM) += cmd_bootm.o
+COBJS-$(CONFIG_CMD_BOOTZ) += cmd_bootz.o
 COBJS-y += cmd_help.o
 COBJS-y += cmd_nvedit.o
 COBJS-y += cmd_version.o
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index d5745b1..eeb57df 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -160,35 +160,8 @@ static boot_os_fn *boot_os[] = {
 
 bootm_headers_t images;		/* pointers to os/initrd/fdt images */
 
-/* Allow for arch specific config before we boot */
-void __arch_preboot_os(void)
-{
-	/* please define platform specific arch_preboot_os() */
-}
-void arch_preboot_os(void) __attribute__((weak, alias("__arch_preboot_os")));
-
 #define IH_INITRD_ARCH IH_ARCH_DEFAULT
 
-static void bootm_start_lmb(void)
-{
-#ifdef CONFIG_LMB
-	ulong		mem_start;
-	phys_size_t	mem_size;
-
-	lmb_init(&images.lmb);
-
-	mem_start = getenv_bootm_low();
-	mem_size = getenv_bootm_size();
-
-	lmb_add(&images.lmb, (phys_addr_t)mem_start, mem_size);
-
-	arch_lmb_reserve(&images.lmb);
-	board_lmb_reserve(&images.lmb);
-#else
-# define lmb_reserve(lmb, base, size)
-#endif
-}
-
 static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	void		*os_hdr;
@@ -197,7 +170,7 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
 	memset((void *)&images, 0, sizeof(images));
 	images.verify = getenv_yesno("verify");
 
-	bootm_start_lmb();
+	boot_start_lmb(&images);
 
 	/* get kernel image header, start address and length */
 	os_hdr = boot_get_kernel(cmdtp, flag, argc, argv,
diff --git a/common/cmd_bootz.c b/common/cmd_bootz.c
new file mode 100644
index 0000000..0ccd4c7
--- /dev/null
+++ b/common/cmd_bootz.c
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
+ *
+ * Based on code:
+ * (C) Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <watchdog.h>
+#include <command.h>
+#include <image.h>
+#include <malloc.h>
+#include <u-boot/zlib.h>
+#include <bzlib.h>
+#include <environment.h>
+#include <lmb.h>
+#include <linux/ctype.h>
+#include <asm/byteorder.h>
+
+#if defined(CONFIG_CMD_USB)
+#include <usb.h>
+#endif
+
+#if defined(CONFIG_SYS_HUSH_PARSER)
+#include <hush.h>
+#endif
+
+#if defined(CONFIG_OF_LIBFDT)
+#include <fdt.h>
+#include <libfdt.h>
+#include <fdt_support.h>
+#endif
+
+#define IH_INITRD_ARCH IH_ARCH_DEFAULT
+
+extern int do_bootm_linux(int flag, int argc, char * const argv[],
+			bootm_headers_t *images);
+
+struct zimage_header {
+	uint32_t	code[9];
+	uint32_t	zi_magic;
+	uint32_t	zi_start;
+	uint32_t	zi_end;
+};
+
+#define	LINUX_ARM_ZIMAGE_MAGIC	0x016f2818
+
+static int bootz_start(cmd_tbl_t *cmdtp, int flag, int argc,
+			char * const argv[], bootm_headers_t *images)
+{
+	int ret;
+	struct zimage_header *zi;
+
+	memset(images, 0, sizeof(bootm_headers_t));
+
+	boot_start_lmb(images);
+
+	/* Setup Linux kernel zImage entry point */
+	if (argc < 2) {
+		images->ep = load_addr;
+		debug("*  kernel: default image load address = 0x%08lx\n",
+				load_addr);
+	} else {
+		images->ep = simple_strtoul(argv[1], NULL, 16);
+		debug("*  kernel: cmdline image address = 0x%08lx\n",
+			images->ep);
+	}
+
+	zi = (struct zimage_header *)images->ep;
+
+	if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC) {
+		puts("Bad Linux ARM zImage magic!\n");
+		return 1;
+	}
+
+	lmb_reserve(&images->lmb, images->ep, zi->zi_end - zi->zi_start);
+
+	/* Find ramdisk */
+	ret = boot_get_ramdisk(argc, argv, images, IH_INITRD_ARCH,
+			&images->rd_start, &images->rd_end);
+	if (ret) {
+		puts("Ramdisk image is corrupt or invalid\n");
+		return 1;
+	}
+
+#if defined(CONFIG_OF_LIBFDT)
+	/* find flattened device tree */
+	ret = boot_get_fdt(flag, argc, argv, images,
+			   &images->ft_addr, &images->ft_len);
+	if (ret) {
+		puts("Could not find a valid device tree\n");
+		return 1;
+	}
+
+	set_working_fdt_addr(images->ft_addr);
+#endif
+
+	return 0;
+}
+
+int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	ulong		iflag;
+	bootm_headers_t	images;
+
+	if (bootz_start(cmdtp, flag, argc, argv, &images))
+		return 1;
+
+	/*
+	 * We have reached the point of no return: we are going to
+	 * overwrite all exception vector code, so we cannot easily
+	 * recover from any failures any more...
+	 */
+	iflag = disable_interrupts();
+
+#if defined(CONFIG_CMD_USB)
+	/*
+	 * turn off USB to prevent the host controller from writing to the
+	 * SDRAM while Linux is booting. This could happen (at least for OHCI
+	 * controller), because the HCCA (Host Controller Communication Area)
+	 * lies within the SDRAM and the host controller writes continously to
+	 * this area (as busmaster!). The HccaFrameNumber is for example
+	 * updated every 1 ms within the HCCA structure in SDRAM! For more
+	 * details see the OpenHCI specification.
+	 */
+	usb_stop();
+#endif
+
+#ifdef CONFIG_SILENT_CONSOLE
+	fixup_silent_linux();
+#endif
+	arch_preboot_os();
+
+	do_bootm_linux(0, argc, argv, &images);
+#ifdef DEBUG
+	puts("\n## Control returned to monitor - resetting...\n");
+#endif
+	do_reset(cmdtp, flag, argc, argv);
+
+	return 1;
+}
+
+U_BOOT_CMD(
+	bootz,	CONFIG_SYS_MAXARGS,	1,	do_bootz,
+	"boot Linux zImage image from memory",
+	"[addr [initrd] [fdt]]\n    - boot Linux zImage stored in memory\n"
+	"\tThe argument 'initrd' is optional and specifies the address\n"
+	"\tof the initrd in memory.\n"
+#if defined(CONFIG_OF_LIBFDT)
+	"\tWhen booting a Linux kernel which requires a flat device-tree\n"
+	"\ta third argument is required which is the address of the\n"
+	"\tdevice-tree blob. To boot that kernel without an initrd image,\n"
+	"\tuse a '-' for the second argument. If you do not pass a third\n"
+	"\ta bd_info struct will be passed instead\n"
+#endif
+);
diff --git a/common/image.c b/common/image.c
index fbdc40a..5752bf5 100644
--- a/common/image.c
+++ b/common/image.c
@@ -3190,3 +3190,28 @@ static int fit_check_ramdisk(const void *fit, int rd_noffset, uint8_t arch,
 }
 #endif /* USE_HOSTCC */
 #endif /* CONFIG_FIT */
+
+#ifdef	CONFIG_LMB
+void boot_start_lmb(bootm_headers_t *images)
+{
+	ulong		mem_start;
+	phys_size_t	mem_size;
+
+	lmb_init(&images->lmb);
+
+	mem_start = getenv_bootm_low();
+	mem_size = getenv_bootm_size();
+
+	lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);
+
+	arch_lmb_reserve(&images->lmb);
+	board_lmb_reserve(&images->lmb);
+}
+#endif
+
+/* Allow for arch specific config before we boot */
+void __arch_preboot_os(void)
+{
+	/* please define platform specific arch_preboot_os() */
+}
+void arch_preboot_os(void) __attribute__((weak, alias("__arch_preboot_os")));
diff --git a/include/image.h b/include/image.h
index bbf80f0..26b8a20 100644
--- a/include/image.h
+++ b/include/image.h
@@ -486,6 +486,14 @@ void image_multi_getimg(const image_header_t *hdr, ulong idx,
 
 void image_print_contents(const void *hdr);
 
+#ifdef CONFIG_LMB
+void boot_start_lmb(bootm_headers_t *images);
+#else
+static inline void boot_start_lmb(bootm_headers_t *image) { }
+#endif
+
+extern void arch_preboot_os(void);
+
 #ifndef USE_HOSTCC
 static inline int image_check_target_arch(const image_header_t *hdr)
 {
-- 
1.7.9

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V3] BOOT: Add "bootz" command to boot Linux zImage
  2012-03-12 21:34 ` [U-Boot] [PATCH V3] BOOT: Add "bootz" command to boot Linux zImage Marek Vasut
@ 2012-03-12 22:03   ` Wolfgang Denk
  2012-03-12 22:08     ` Marek Vasut
  2012-03-13  2:03   ` Mike Frysinger
  1 sibling, 1 reply; 48+ messages in thread
From: Wolfgang Denk @ 2012-03-12 22:03 UTC (permalink / raw)
  To: u-boot

Dear Marek Vasut,

In message <1331588061-21546-1-git-send-email-marex@denx.de> you wrote:
> 
> This command boots Linux zImage from where the zImage is loaded to. Passing
> initrd and fdt is supported.

I have but a few formal questions / issues.

...
> --- a/common/cmd_bootm.c
> +++ b/common/cmd_bootm.c
> @@ -160,35 +160,8 @@ static boot_os_fn *boot_os[] = {
>  
>  bootm_headers_t images;		/* pointers to os/initrd/fdt images */
>  
> -/* Allow for arch specific config before we boot */
> -void __arch_preboot_os(void)
> -{
> -	/* please define platform specific arch_preboot_os() */
> -}
> -void arch_preboot_os(void) __attribute__((weak, alias("__arch_preboot_os")));
> -
>  #define IH_INITRD_ARCH IH_ARCH_DEFAULT
>  
> -static void bootm_start_lmb(void)
> -{
...

Note: this is bootm (or boot*) related code.


> --- a/common/image.c
> +++ b/common/image.c
> @@ -3190,3 +3190,28 @@ static int fit_check_ramdisk(const void *fit, int rd_noffset, uint8_t arch,

This is a file that deals with U-Boot images etc.  It is in no way
related to any of the "boot*" commands.

> +#ifdef	CONFIG_LMB
> +void boot_start_lmb(bootm_headers_t *images)
> +{
> +	ulong		mem_start;
> +	phys_size_t	mem_size;
> +
> +	lmb_init(&images->lmb);
> +
> +	mem_start = getenv_bootm_low();
> +	mem_size = getenv_bootm_size();
> +
> +	lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);
> +
> +	arch_lmb_reserve(&images->lmb);
> +	board_lmb_reserve(&images->lmb);
> +}
> +#endif
> +
> +/* Allow for arch specific config before we boot */
> +void __arch_preboot_os(void)
> +{
> +	/* please define platform specific arch_preboot_os() */
> +}
> +void arch_preboot_os(void) __attribute__((weak, alias("__arch_preboot_os")));

Putting this code here makes no sense.  You could chose any othewr
random file as well.

> diff --git a/include/image.h b/include/image.h
> index bbf80f0..26b8a20 100644
> --- a/include/image.h
> +++ b/include/image.h
> @@ -486,6 +486,14 @@ void image_multi_getimg(const image_header_t *hdr, ulong idx,
>  
>  void image_print_contents(const void *hdr);
>  
> +#ifdef CONFIG_LMB
> +void boot_start_lmb(bootm_headers_t *images);
> +#else
> +static inline void boot_start_lmb(bootm_headers_t *image) { }
> +#endif
> +
> +extern void arch_preboot_os(void);

Sorry, no.  image.[ch] is definitely not the right place for this
stuff.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
How many QA engineers does it take to screw in a lightbulb? 3:  1  to
screw it in and 2 to say "I told you so" when it doesn't work.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V3] BOOT: Add "bootz" command to boot Linux zImage
  2012-03-12 22:03   ` Wolfgang Denk
@ 2012-03-12 22:08     ` Marek Vasut
  2012-03-12 22:42       ` Wolfgang Denk
  0 siblings, 1 reply; 48+ messages in thread
From: Marek Vasut @ 2012-03-12 22:08 UTC (permalink / raw)
  To: u-boot

Dear Wolfgang Denk,

> Dear Marek Vasut,
> 
> In message <1331588061-21546-1-git-send-email-marex@denx.de> you wrote:
> > This command boots Linux zImage from where the zImage is loaded to.
> > Passing initrd and fdt is supported.
> 
> I have but a few formal questions / issues.

I had a dilemma about the image.[ch] indeed. I was quite unsure where to put 
those, can you suggest proper location? I didn't want to create new file only 
for that matter.

> 
> ...
> 
> > --- a/common/cmd_bootm.c
> > +++ b/common/cmd_bootm.c
> > @@ -160,35 +160,8 @@ static boot_os_fn *boot_os[] = {
> > 
> >  bootm_headers_t images;		/* pointers to os/initrd/fdt images */
> > 
> > -/* Allow for arch specific config before we boot */
> > -void __arch_preboot_os(void)
> > -{
> > -	/* please define platform specific arch_preboot_os() */
> > -}
> > -void arch_preboot_os(void) __attribute__((weak,
> > alias("__arch_preboot_os"))); -
> > 
> >  #define IH_INITRD_ARCH IH_ARCH_DEFAULT
> > 
> > -static void bootm_start_lmb(void)
> > -{
> 
> ...
> 
> Note: this is bootm (or boot*) related code.
> 
> > --- a/common/image.c
> > +++ b/common/image.c
> > @@ -3190,3 +3190,28 @@ static int fit_check_ramdisk(const void *fit, int
> > rd_noffset, uint8_t arch,
> 
> This is a file that deals with U-Boot images etc.  It is in no way
> related to any of the "boot*" commands.
> 
> > +#ifdef	CONFIG_LMB
> > +void boot_start_lmb(bootm_headers_t *images)
> > +{
> > +	ulong		mem_start;
> > +	phys_size_t	mem_size;
> > +
> > +	lmb_init(&images->lmb);
> > +
> > +	mem_start = getenv_bootm_low();
> > +	mem_size = getenv_bootm_size();
> > +
> > +	lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);
> > +
> > +	arch_lmb_reserve(&images->lmb);
> > +	board_lmb_reserve(&images->lmb);
> > +}
> > +#endif
> > +
> > +/* Allow for arch specific config before we boot */
> > +void __arch_preboot_os(void)
> > +{
> > +	/* please define platform specific arch_preboot_os() */
> > +}
> > +void arch_preboot_os(void) __attribute__((weak,
> > alias("__arch_preboot_os")));
> 
> Putting this code here makes no sense.  You could chose any othewr
> random file as well.
> 
> > diff --git a/include/image.h b/include/image.h
> > index bbf80f0..26b8a20 100644
> > --- a/include/image.h
> > +++ b/include/image.h
> > @@ -486,6 +486,14 @@ void image_multi_getimg(const image_header_t *hdr,
> > ulong idx,
> > 
> >  void image_print_contents(const void *hdr);
> > 
> > +#ifdef CONFIG_LMB
> > +void boot_start_lmb(bootm_headers_t *images);
> > +#else
> > +static inline void boot_start_lmb(bootm_headers_t *image) { }
> > +#endif
> > +
> > +extern void arch_preboot_os(void);
> 
> Sorry, no.  image.[ch] is definitely not the right place for this
> stuff.
> 
> Best regards,
> 
> Wolfgang Denk

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V3] BOOT: Add "bootz" command to boot Linux zImage
  2012-03-12 22:08     ` Marek Vasut
@ 2012-03-12 22:42       ` Wolfgang Denk
  2012-03-13  0:13         ` Marek Vasut
  0 siblings, 1 reply; 48+ messages in thread
From: Wolfgang Denk @ 2012-03-12 22:42 UTC (permalink / raw)
  To: u-boot

Dear Marek Vasut,

btw - there is no need to full-quote.

In message <201203122308.54249.marex@denx.de> you wrote:
> 
> > I have but a few formal questions / issues.
> 
> I had a dilemma about the image.[ch] indeed. I was quite unsure where to put 
> those, can you suggest proper location? I didn't want to create new file only 
> for that matter.

Sorry, I have no good idea either.

If you omit comment header and includes, common/cmd_bootz.c adds less
than 10% to common/cmd_bootm.c - unless we extrace more common code
from other boot* commands, you might even add it to cmd_bootm.c (with
#ifdef's).


While we are at it:

+	zi = (struct zimage_header *)images->ep;
+
+	if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC) {

Do we have to care about endianess here?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Now here's something you're really going to like!"
- Rocket J. Squirrel

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V3] BOOT: Add "bootz" command to boot Linux zImage
  2012-03-12 22:42       ` Wolfgang Denk
@ 2012-03-13  0:13         ` Marek Vasut
  2012-03-13  0:22           ` Graeme Russ
  2012-03-13  4:25           ` Wolfgang Denk
  0 siblings, 2 replies; 48+ messages in thread
From: Marek Vasut @ 2012-03-13  0:13 UTC (permalink / raw)
  To: u-boot

Dear Wolfgang Denk,

> Dear Marek Vasut,
> 
> btw - there is no need to full-quote.
> 
> In message <201203122308.54249.marex@denx.de> you wrote:
> > > I have but a few formal questions / issues.
> > 
> > I had a dilemma about the image.[ch] indeed. I was quite unsure where to
> > put those, can you suggest proper location? I didn't want to create new
> > file only for that matter.
> 
> Sorry, I have no good idea either.
> 
> If you omit comment header and includes, common/cmd_bootz.c adds less
> than 10% to common/cmd_bootm.c - unless we extrace more common code
> from other boot* commands, you might even add it to cmd_bootm.c (with
> #ifdef's).
> 
> 
> While we are at it:
> 
> +	zi = (struct zimage_header *)images->ep;
> +
> +	if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC) {

This gave me an idea ... this might be how to check for zImage inside bootm and 
be done with it. Simply squash those two together.

> 
> Do we have to care about endianess here?

We should make bootz arm-specific until more people (with different arches) step 
up and verify it works for them.

> 
> Best regards,
> 
> Wolfgang Denk

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V3] BOOT: Add "bootz" command to boot Linux zImage
  2012-03-13  0:13         ` Marek Vasut
@ 2012-03-13  0:22           ` Graeme Russ
  2012-03-13  4:30             ` Wolfgang Denk
  2012-03-13  4:25           ` Wolfgang Denk
  1 sibling, 1 reply; 48+ messages in thread
From: Graeme Russ @ 2012-03-13  0:22 UTC (permalink / raw)
  To: u-boot

Hi Marek, Wolfgang,

On Tue, Mar 13, 2012 at 11:13 AM, Marek Vasut <marex@denx.de> wrote:
> Dear Wolfgang Denk,
>
>>
>> While we are at it:
>>
>> + ? ? zi = (struct zimage_header *)images->ep;
>> +
>> + ? ? if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC) {
>
> This gave me an idea ... this might be how to check for zImage inside bootm and
> be done with it. Simply squash those two together.

While we are on the subject - Do either of you think support for the x86
zimage/bzImage format should end up here in common code? Not that the x86
(b)zImage header is unique (see arch/x86/include/asm/bootparam.h) and
decompressing vmlinux out of an x86 (b)zImage is non-trivial given the
header and decompression stub

Regards,

Graeme

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V3] BOOT: Add "bootz" command to boot Linux zImage
  2012-03-12 21:34 ` [U-Boot] [PATCH V3] BOOT: Add "bootz" command to boot Linux zImage Marek Vasut
  2012-03-12 22:03   ` Wolfgang Denk
@ 2012-03-13  2:03   ` Mike Frysinger
  1 sibling, 0 replies; 48+ messages in thread
From: Mike Frysinger @ 2012-03-13  2:03 UTC (permalink / raw)
  To: u-boot

On Monday 12 March 2012 17:34:21 Marek Vasut wrote:
>  common/Makefile    |    1 +
>  common/cmd_bootm.c |   29 +--------
>  common/cmd_bootz.c |  175
>  include/image.h    |    8 +++

new commands should be in include/config_cmd_all.h and the top level README

> --- /dev/null
> +++ b/common/cmd_bootz.c
>
> + * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>

it's 2012 now

> +#include <watchdog.h>
> +#include <malloc.h>
> +#include <u-boot/zlib.h>
> +#include <bzlib.h>
> +#include <environment.h>
> +#include <linux/ctype.h>
> +#include <asm/byteorder.h>
> +#if defined(CONFIG_SYS_HUSH_PARSER)
> +#include <hush.h>
> +#endif

seems like these are all unused

> +#define IH_INITRD_ARCH IH_ARCH_DEFAULT

this gets used in one place.  just inline its usage

> +extern int do_bootm_linux(int flag, int argc, char * const argv[],
> +			bootm_headers_t *images);

should get moved to include/command.h instead of copying it to more places

> --- a/common/image.c
> +++ b/common/image.c
>
> +#ifdef	CONFIG_LMB

should be a space after #ifdef, not a tab

> +void __arch_preboot_os(void)

static
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120312/56d7bd6e/attachment.pgp>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V3] BOOT: Add "bootz" command to boot Linux zImage
  2012-03-13  0:13         ` Marek Vasut
  2012-03-13  0:22           ` Graeme Russ
@ 2012-03-13  4:25           ` Wolfgang Denk
  2012-03-13  4:50             ` Marek Vasut
  1 sibling, 1 reply; 48+ messages in thread
From: Wolfgang Denk @ 2012-03-13  4:25 UTC (permalink / raw)
  To: u-boot

Dear Marek Vasut,

In message <201203130113.19092.marex@denx.de> you wrote:
> 
> > +	zi = (struct zimage_header *)images->ep;
> > +
> > +	if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC) {
> 
> This gave me an idea ... this might be how to check for zImage inside bootm and 
> be done with it. Simply squash those two together.

Hm... but this must not be the only test, then, or you will run the
risk of false positives...

> > Do we have to care about endianess here?
> 
> We should make bootz arm-specific until more people (with different arches) step 
> up and verify it works for them.

NAK.  Please implement in an architecture independent way right from
the beginning.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The only perfect science is hind-sight.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V3] BOOT: Add "bootz" command to boot Linux zImage
  2012-03-13  0:22           ` Graeme Russ
@ 2012-03-13  4:30             ` Wolfgang Denk
  2012-03-13  4:46               ` Graeme Russ
  2012-03-13  4:47               ` Marek Vasut
  0 siblings, 2 replies; 48+ messages in thread
From: Wolfgang Denk @ 2012-03-13  4:30 UTC (permalink / raw)
  To: u-boot

Dear Graeme Russ,

In message <CALButCLDyKZnsZqGXhxcu-UEv9nySg77f1XwaUvmgb9gc7BPNQ@mail.gmail.com> you wrote:
> 
> While we are on the subject - Do either of you think support for the x86
> zimage/bzImage format should end up here in common code? Not that the x86

The common coe should be architecture-neutral.  It might cann
architecture-specific routines, which may (or may not) get added
later, depending if somebody cares about adding such support.

> (b)zImage header is unique (see arch/x86/include/asm/bootparam.h) and
> decompressing vmlinux out of an x86 (b)zImage is non-trivial given the
> header and decompression stub

I have to admit that I never understood the fuzz about being able to
boot zImages.  I see more disadvanatges than advantages for this, but
some ARM people go frenzy when this topic pops up - see recent
discussions about removal of uImage support on the AKML.

Frankly: I see no benefit in adding x86 support.

I see no benefit in adding ARM support either, but YMMV...

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Prof:        So the American government went to IBM to come up with a
             data encryption standard and they came up with ...
Student:     EBCDIC!

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V3] BOOT: Add "bootz" command to boot Linux zImage
  2012-03-13  4:30             ` Wolfgang Denk
@ 2012-03-13  4:46               ` Graeme Russ
  2012-03-15 15:03                 ` Wolfgang Denk
  2012-03-13  4:47               ` Marek Vasut
  1 sibling, 1 reply; 48+ messages in thread
From: Graeme Russ @ 2012-03-13  4:46 UTC (permalink / raw)
  To: u-boot

Hi Wolfgang,

On Tue, Mar 13, 2012 at 3:30 PM, Wolfgang Denk <wd@denx.de> wrote:
> Dear Graeme Russ,
>
> In message <CALButCLDyKZnsZqGXhxcu-UEv9nySg77f1XwaUvmgb9gc7BPNQ@mail.gmail.com> you wrote:
>>
>> While we are on the subject - Do either of you think support for the x86
>> zimage/bzImage format should end up here in common code? Not that the x86
>
> The common coe should be architecture-neutral. ?It might cann
> architecture-specific routines, which may (or may not) get added
> later, depending if somebody cares about adding such support.
>
>> (b)zImage header is unique (see arch/x86/include/asm/bootparam.h) and
>> decompressing vmlinux out of an x86 (b)zImage is non-trivial given the
>> header and decompression stub
>
> I have to admit that I never understood the fuzz about being able to
> boot zImages. ?I see more disadvanatges than advantages for this, but

Ah grasshopper - remember from whence Linux evolved ;)

Bootable zImage for x86 came from the desire to write the image to a
floppy (using dd) and have it boot. This was way before GRUB and LILO

I remember the days of the kernel on one floppy and the root fs on a
second floppy and you would be prompted to change disks :)

And then the kernel grew too big, so it got compressed and to still
allow booting from a floppy, the decompression stub was added to the
kernel image

And then came loadlin so you could boot linux from DOS (or Winodws)
and the header was used to tell loadlin where to load the kernel in
memory - but the decompression routine was already in the zImage and
DOS ran in real-mode so there was no need to change how it booted

And then the kernel grew some more and the limitations of the zImage
format were reached - bzImage (Big zImage) format was born, but the
header and decompression stub pretty much remained intact so existing
bootloaders did need to jump through hoops to handle the change

And in the mix is loadable modules and initial ram disks et al.

And then someone decided it would be a pretty neat idea to shove linux
into a tiny little box running an ARM processor :P

> some ARM people go frenzy when this topic pops up - see recent
> discussions about removal of uImage support on the AKML.
>
> Frankly: I see no benefit in adding x86 support.

Ouch! - Do you mean in common code or in general?

> I see no benefit in adding ARM support either, but YMMV...

Hmm, methinks the Android guys might have a bone to pick with that
statement ;)

Regards,

Graeme

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V3] BOOT: Add "bootz" command to boot Linux zImage
  2012-03-13  4:30             ` Wolfgang Denk
  2012-03-13  4:46               ` Graeme Russ
@ 2012-03-13  4:47               ` Marek Vasut
  2012-03-15 15:06                 ` Wolfgang Denk
  1 sibling, 1 reply; 48+ messages in thread
From: Marek Vasut @ 2012-03-13  4:47 UTC (permalink / raw)
  To: u-boot

Dear Wolfgang Denk,

> Dear Graeme Russ,
> 
> In message <CALButCLDyKZnsZqGXhxcu-
UEv9nySg77f1XwaUvmgb9gc7BPNQ@mail.gmail.com> you wrote:
> > While we are on the subject - Do either of you think support for the x86
> > zimage/bzImage format should end up here in common code? Not that the x86
> 
> The common coe should be architecture-neutral.  It might cann
> architecture-specific routines, which may (or may not) get added
> later, depending if somebody cares about adding such support.
> 
> > (b)zImage header is unique (see arch/x86/include/asm/bootparam.h) and
> > decompressing vmlinux out of an x86 (b)zImage is non-trivial given the
> > header and decompression stub
> 
> I have to admit that I never understood the fuzz about being able to
> boot zImages.  I see more disadvanatges than advantages for this, but
> some ARM people go frenzy when this topic pops up - see recent
> discussions about removal of uImage support on the AKML.

Sure, but let's try to offer them a compromise. Everyone will be happy that way 
at least to some extent.

> 
> Frankly: I see no benefit in adding x86 support.
> 
> I see no benefit in adding ARM support either, but YMMV...
> 
> Best regards,
> 
> Wolfgang Denk

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V3] BOOT: Add "bootz" command to boot Linux zImage
  2012-03-13  4:25           ` Wolfgang Denk
@ 2012-03-13  4:50             ` Marek Vasut
  2012-03-13  5:32               ` Graeme Russ
  0 siblings, 1 reply; 48+ messages in thread
From: Marek Vasut @ 2012-03-13  4:50 UTC (permalink / raw)
  To: u-boot

Dear Wolfgang Denk,

> Dear Marek Vasut,
> 
> In message <201203130113.19092.marex@denx.de> you wrote:
> > > +	zi = (struct zimage_header *)images->ep;
> > > +
> > > +	if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC) {
> > 
> > This gave me an idea ... this might be how to check for zImage inside
> > bootm and be done with it. Simply squash those two together.
> 
> Hm... but this must not be the only test, then, or you will run the
> risk of false positives...

Certainly.

> 
> > > Do we have to care about endianess here?
> > 
> > We should make bootz arm-specific until more people (with different
> > arches) step up and verify it works for them.
> 
> NAK.  Please implement in an architecture independent way right from
> the beginning.

Can someone tell if the the zImage format differs per-arch or is it the same? 
Graeme, what is it about that x86 stuff?

> 
> Best regards,
> 
> Wolfgang Denk

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V3] BOOT: Add "bootz" command to boot Linux zImage
  2012-03-13  4:50             ` Marek Vasut
@ 2012-03-13  5:32               ` Graeme Russ
  0 siblings, 0 replies; 48+ messages in thread
From: Graeme Russ @ 2012-03-13  5:32 UTC (permalink / raw)
  To: u-boot

Hi Marek,

On Tue, Mar 13, 2012 at 3:50 PM, Marek Vasut <marex@denx.de> wrote:
> Dear Wolfgang Denk,
>
>> Dear Marek Vasut,
>>
>> In message <201203130113.19092.marex@denx.de> you wrote:
>> > > + zi = (struct zimage_header *)images->ep;
>> > > +
>> > > + if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC) {
>> >
>> > This gave me an idea ... this might be how to check for zImage inside
>> > bootm and be done with it. Simply squash those two together.
>>
>> Hm... but this must not be the only test, then, or you will run the
>> risk of false positives...
>
> Certainly.
>
>>
>> > > Do we have to care about endianess here?
>> >
>> > We should make bootz arm-specific until more people (with different
>> > arches) step up and verify it works for them.
>>
>> NAK. ?Please implement in an architecture independent way right from
>> the beginning.
>
> Can someone tell if the the zImage format differs per-arch or is it the same?
> Graeme, what is it about that x86 stuff?

Do you really want to know? How long have you got ;)

There are three options:
 1 Keep the kernel packaged up in the bzImage
 2 Extract the 'header' externally to U-Boot and put it, the corresponding
   vmlinux (compressed) and an initrd (compressed) in a uImage
 3 Extract the 'header' and vmlinux from a bzImage within U-Boot

Option 1 means I have to keep the crappy 16-bit Real Mode BIOS stub in
U-Boot which is a PITA. It also means more memory copy operations to get
the kernel up and running - I've spoken to Gabe Black who did the coreboot
patches for U-Boot and he is fine with us dropping this (his patches added
code to bypass it anyway)

Option 2 is messy

Option 3 is nice - If you have enough onboard NAND flash, you can but the
bzImage there and decompress it straight to its 'in RAM' resting place.
Boot times are brutal!

I may be wrong, but I zImages are generally a header followed by a
compressed vmlinux (x86 has a built-in decompression stub). So if the
U-Boot zImage code called an arch-specific function that passed in the
location of the (b)zImage and reference variables for the:

 - Location of the compressed vmlinux
 - Compression algorith used to compress vmlinux (although U-Boot could
   figure this out from the first few bytes)
 - Length of the compressed data
 - Length of the decompressed data (if known)

And a functions to process the header, command line, initrd etc I think
we would have an arch-neutral way forward

Regards,

Graeme

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V4] BOOT: Add "bootz" command to boot Linux zImage on ARM
       [not found] <Message-Id: <1331588061-21546-1-git-send-email-marex@denx.de>
  2012-03-12 21:34 ` [U-Boot] [PATCH V3] BOOT: Add "bootz" command to boot Linux zImage Marek Vasut
@ 2012-03-14  1:38 ` Marek Vasut
  2012-03-14  2:03   ` Mike Frysinger
  1 sibling, 1 reply; 48+ messages in thread
From: Marek Vasut @ 2012-03-14  1:38 UTC (permalink / raw)
  To: u-boot

From: Marek Vasut <marek.vasut@gmail.com>

This command boots Linux zImage from where the zImage is loaded to. Passing
initrd and fdt is supported.

Tested on i.MX28 based DENX M28EVK
Tested on PXA270 based Voipac PXA270.

NOTE: This currently only supports ARM, but other architectures can be easily
added by defining bootz_setup().

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Cc: Tom Warren <TWarren@nvidia.com>
Cc: albert.u.boot at aribaud.net
Cc: afleming at gmail.com,
Cc: Simon Glass <sjg@chromium.org>,
Cc: Stephen Warren <swarren@nvidia.com>
Cc: Nicolas Pitre <nico@fluxnic.net>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Detlev Zundel <dzu@denx.de>
---
 arch/arm/lib/bootm.c     |   30 ++++++++++
 common/cmd_bootm.c       |  141 +++++++++++++++++++++++++++++++++++++++++++---
 include/config_cmd_all.h |    1 +
 3 files changed, 163 insertions(+), 9 deletions(-)

V2: Use CONFIG_BOOTZ_MAX_KERNEL_LMB_SIZE to reserve kernel LMB
V3: Compute the LMB size at runtime (obsoletes V2)
    Move shared code to image.c/image.h
    Sync with latest U-Boot
V4: Add all this into cmd_bootm. Therefore, this is part of cmd_bootm (basically
    it's stripped-down version). Also, separate out arm-specific component into
    arm-specific location.

diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index afa0093..b7a74a8 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -344,3 +344,33 @@ static ulong get_sp(void)
 	asm("mov %0, sp" : "=r"(ret) : );
 	return ret;
 }
+
+#ifdef	CONFIG_CMD_BOOTZ
+
+struct zimage_header {
+	uint32_t	code[9];
+	uint32_t	zi_magic;
+	uint32_t	zi_start;
+	uint32_t	zi_end;
+};
+
+#define	LINUX_ARM_ZIMAGE_MAGIC	0x016f2818
+
+int bootz_setup(void *image, void **start, void **end)
+{
+	struct zimage_header *zi = (struct zimage_header *)image;
+
+	if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC) {
+		puts("Bad Linux ARM zImage magic!\n");
+		return 1;
+	}
+
+	*start = (void *)zi->zi_start;
+	*end = (void *)zi->zi_end;
+
+	debug("Kernel image @ 0x%08x [ 0x%08x - 0x%08x ]\n",
+		(uint32_t)image, (uint32_t)*start, (uint32_t)*end);
+
+	return 0;
+}
+#endif	/* CONFIG_CMD_BOOTZ */
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index d5745b1..67588b2 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -169,25 +169,25 @@ void arch_preboot_os(void) __attribute__((weak, alias("__arch_preboot_os")));
 
 #define IH_INITRD_ARCH IH_ARCH_DEFAULT
 
-static void bootm_start_lmb(void)
-{
 #ifdef CONFIG_LMB
+static void boot_start_lmb(bootm_headers_t *images)
+{
 	ulong		mem_start;
 	phys_size_t	mem_size;
 
-	lmb_init(&images.lmb);
+	lmb_init(&images->lmb);
 
 	mem_start = getenv_bootm_low();
 	mem_size = getenv_bootm_size();
 
-	lmb_add(&images.lmb, (phys_addr_t)mem_start, mem_size);
+	lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);
 
-	arch_lmb_reserve(&images.lmb);
-	board_lmb_reserve(&images.lmb);
+	arch_lmb_reserve(&images->lmb);
+	board_lmb_reserve(&images->lmb);
+}
 #else
-# define lmb_reserve(lmb, base, size)
+static inline void boot_start_lmb(bootm_headers_t *images) { }
 #endif
-}
 
 static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
@@ -197,7 +197,7 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
 	memset((void *)&images, 0, sizeof(images));
 	images.verify = getenv_yesno("verify");
 
-	bootm_start_lmb();
+	boot_start_lmb(&images);
 
 	/* get kernel image header, start address and length */
 	os_hdr = boot_get_kernel(cmdtp, flag, argc, argv,
@@ -1523,3 +1523,126 @@ static int do_bootm_integrity(int flag, int argc, char * const argv[],
 	return 1;
 }
 #endif
+
+#ifdef CONFIG_CMD_BOOTZ
+
+int __bootz_setup(void *image, void **start, void **end)
+{
+	/* Please define bootz_setup() for your platform */
+
+	puts("Your platform's zImage format isn't supported yet!\n");
+	return -1;
+}
+int bootz_setup(void *image, void **start, void **end)
+	__attribute__((weak, alias("__bootz_setup")));
+
+/*
+ * zImage booting support
+ */
+static int bootz_start(cmd_tbl_t *cmdtp, int flag, int argc,
+			char * const argv[], bootm_headers_t *images)
+{
+	int ret;
+	void *zi_start, *zi_end;
+
+	memset(images, 0, sizeof(bootm_headers_t));
+
+	boot_start_lmb(images);
+
+	/* Setup Linux kernel zImage entry point */
+	if (argc < 2) {
+		images->ep = load_addr;
+		debug("*  kernel: default image load address = 0x%08lx\n",
+				load_addr);
+	} else {
+		images->ep = simple_strtoul(argv[1], NULL, 16);
+		debug("*  kernel: cmdline image address = 0x%08lx\n",
+			images->ep);
+	}
+
+	ret = bootz_setup((void *)images->ep, &zi_start, &zi_end);
+	if (ret != 0)
+		return 1;
+
+	lmb_reserve(&images->lmb, images->ep, zi_end - zi_start);
+
+	/* Find ramdisk */
+	ret = boot_get_ramdisk(argc, argv, images, IH_INITRD_ARCH,
+			&images->rd_start, &images->rd_end);
+	if (ret) {
+		puts("Ramdisk image is corrupt or invalid\n");
+		return 1;
+	}
+
+#if defined(CONFIG_OF_LIBFDT)
+	/* find flattened device tree */
+	ret = boot_get_fdt(flag, argc, argv, images,
+			   &images->ft_addr, &images->ft_len);
+	if (ret) {
+		puts("Could not find a valid device tree\n");
+		return 1;
+	}
+
+	set_working_fdt_addr(images->ft_addr);
+#endif
+
+	return 0;
+}
+
+int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	ulong		iflag;
+	bootm_headers_t	images;
+
+	if (bootz_start(cmdtp, flag, argc, argv, &images))
+		return 1;
+
+	/*
+	 * We have reached the point of no return: we are going to
+	 * overwrite all exception vector code, so we cannot easily
+	 * recover from any failures any more...
+	 */
+	iflag = disable_interrupts();
+
+#if defined(CONFIG_CMD_USB)
+	/*
+	 * turn off USB to prevent the host controller from writing to the
+	 * SDRAM while Linux is booting. This could happen (at least for OHCI
+	 * controller), because the HCCA (Host Controller Communication Area)
+	 * lies within the SDRAM and the host controller writes continously to
+	 * this area (as busmaster!). The HccaFrameNumber is for example
+	 * updated every 1 ms within the HCCA structure in SDRAM! For more
+	 * details see the OpenHCI specification.
+	 */
+	usb_stop();
+#endif
+
+#ifdef CONFIG_SILENT_CONSOLE
+	fixup_silent_linux();
+#endif
+	arch_preboot_os();
+
+	do_bootm_linux(0, argc, argv, &images);
+#ifdef DEBUG
+	puts("\n## Control returned to monitor - resetting...\n");
+#endif
+	do_reset(cmdtp, flag, argc, argv);
+
+	return 1;
+}
+
+U_BOOT_CMD(
+	bootz,	CONFIG_SYS_MAXARGS,	1,	do_bootz,
+	"boot Linux zImage image from memory",
+	"[addr [initrd] [fdt]]\n    - boot Linux zImage stored in memory\n"
+	"\tThe argument 'initrd' is optional and specifies the address\n"
+	"\tof the initrd in memory.\n"
+#if defined(CONFIG_OF_LIBFDT)
+	"\tWhen booting a Linux kernel which requires a flat device-tree\n"
+	"\ta third argument is required which is the address of the\n"
+	"\tdevice-tree blob. To boot that kernel without an initrd image,\n"
+	"\tuse a '-' for the second argument. If you do not pass a third\n"
+	"\ta bd_info struct will be passed instead\n"
+#endif
+);
+#endif	/* CONFIG_CMD_BOOTZ */
diff --git a/include/config_cmd_all.h b/include/config_cmd_all.h
index 9716f9c..2c6b829 100644
--- a/include/config_cmd_all.h
+++ b/include/config_cmd_all.h
@@ -20,6 +20,7 @@
 #define CONFIG_CMD_BEDBUG	/* Include BedBug Debugger	*/
 #define CONFIG_CMD_BMP		/* BMP support			*/
 #define CONFIG_CMD_BOOTD	/* bootd			*/
+#define CONFIG_CMD_BOOTZ	/* boot zImage			*/
 #define CONFIG_CMD_BSP		/* Board Specific functions	*/
 #define CONFIG_CMD_CACHE	/* icache, dcache		*/
 #define CONFIG_CMD_CDP		/* Cisco Discovery Protocol	*/
-- 
1.7.9

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V4] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-14  1:38 ` [U-Boot] [PATCH V4] BOOT: Add "bootz" command to boot Linux zImage on ARM Marek Vasut
@ 2012-03-14  2:03   ` Mike Frysinger
  2012-03-14  2:40     ` Marek Vasut
  0 siblings, 1 reply; 48+ messages in thread
From: Mike Frysinger @ 2012-03-14  2:03 UTC (permalink / raw)
  To: u-boot

On Tuesday 13 March 2012 21:38:13 Marek Vasut wrote:
>  arch/arm/lib/bootm.c     |   30 ++++++++++
>  common/cmd_bootm.c       |  141
>  include/config_cmd_all.h | 

still missing README

> --- a/arch/arm/lib/bootm.c
> +++ b/arch/arm/lib/bootm.c
>
> +#ifdef	CONFIG_CMD_BOOTZ

don't use tabs to indent these tokens

> --- a/common/cmd_bootm.c
> +++ b/common/cmd_bootm.c
>
> +int __bootz_setup(void *image, void **start, void **end)

static

> +int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])

static
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120313/91c1d6ee/attachment.pgp>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V4] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-14  2:03   ` Mike Frysinger
@ 2012-03-14  2:40     ` Marek Vasut
  2012-03-14  3:07       ` Mike Frysinger
  0 siblings, 1 reply; 48+ messages in thread
From: Marek Vasut @ 2012-03-14  2:40 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

> On Tuesday 13 March 2012 21:38:13 Marek Vasut wrote:
> >  arch/arm/lib/bootm.c     |   30 ++++++++++
> >  common/cmd_bootm.c       |  141
> >  include/config_cmd_all.h |
> 
> still missing README

Where exactly would you squash it in there?
> 
> > --- a/arch/arm/lib/bootm.c
> > +++ b/arch/arm/lib/bootm.c
> > 
> > +#ifdef	CONFIG_CMD_BOOTZ
> 
> don't use tabs to indent these tokens
> 
> > --- a/common/cmd_bootm.c
> > +++ b/common/cmd_bootm.c
> > 
> > +int __bootz_setup(void *image, void **start, void **end)
> 
> static
> 
> > +int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> 
> static
> -mike

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V4] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-14  2:40     ` Marek Vasut
@ 2012-03-14  3:07       ` Mike Frysinger
  0 siblings, 0 replies; 48+ messages in thread
From: Mike Frysinger @ 2012-03-14  3:07 UTC (permalink / raw)
  To: u-boot

On Tuesday 13 March 2012 22:40:05 Marek Vasut wrote:
> > On Tuesday 13 March 2012 21:38:13 Marek Vasut wrote:
> > >  arch/arm/lib/bootm.c     |   30 ++++++++++
> > >  common/cmd_bootm.c       |  141
> > >  include/config_cmd_all.h |
> > 
> > still missing README
> 
> Where exactly would you squash it in there?

there should at least be mention in Monitor Functions and Monitor Commands.  
grepping for "bootm" shows other perhaps relevant sections like Boot Linux.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120313/bcc394ce/attachment.pgp>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V5] BOOT: Add "bootz" command to boot Linux zImage on ARM
       [not found] <Message-Id: <1331689093-19211-1-git-send-email-marex@denx.de>
@ 2012-03-14  3:47 ` Marek Vasut
  2012-03-14  5:07   ` Mike Frysinger
  2012-03-14 16:45   ` Stephen Warren
  0 siblings, 2 replies; 48+ messages in thread
From: Marek Vasut @ 2012-03-14  3:47 UTC (permalink / raw)
  To: u-boot

From: Marek Vasut <marek.vasut@gmail.com>

This command boots Linux zImage from where the zImage is loaded to. Passing
initrd and fdt is supported.

Tested on i.MX28 based DENX M28EVK
Tested on PXA270 based Voipac PXA270.

NOTE: This currently only supports ARM, but other architectures can be easily
added by defining bootz_setup().

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Cc: Tom Warren <TWarren@nvidia.com>
Cc: albert.u.boot at aribaud.net
Cc: afleming at gmail.com,
Cc: Simon Glass <sjg@chromium.org>,
Cc: Stephen Warren <swarren@nvidia.com>
Cc: Nicolas Pitre <nico@fluxnic.net>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Detlev Zundel <dzu@denx.de>
---
 README                   |    8 +++
 arch/arm/lib/bootm.c     |   30 ++++++++++
 common/cmd_bootm.c       |  141 +++++++++++++++++++++++++++++++++++++++++++---
 include/config_cmd_all.h |    1 +
 4 files changed, 171 insertions(+), 9 deletions(-)

V2: Use CONFIG_BOOTZ_MAX_KERNEL_LMB_SIZE to reserve kernel LMB
V3: Compute the LMB size at runtime (obsoletes V2)
    Move shared code to image.c/image.h
    Sync with latest U-Boot
V4: Add all this into cmd_bootm. Therefore, this is part of cmd_bootm (basically
    it's stripped-down version). Also, separate out arm-specific component into
    arm-specific location.
V5: Staticize bootz_setup(), add information into README.

diff --git a/README b/README
index 4021715..b273070 100644
--- a/README
+++ b/README
@@ -3594,6 +3594,7 @@ go	- start application at address 'addr'
 run	- run commands in an environment variable
 bootm	- boot application image from memory
 bootp	- boot image via network using BootP/TFTP protocol
+bootz   - boot zImage from memory
 tftpboot- boot image via network using TFTP protocol
 	       and env variables "ipaddr" and "serverip"
 	       (and eventually "gatewayip")
@@ -4414,6 +4415,13 @@ U-Boot supports the following image types:
 	useful when you configure U-Boot to use a real shell (hush)
 	as command interpreter.
 
+Booting the Linux zImage:
+-------------------------
+
+On some platforms, it's possible to boot Linux zImage. This is done
+using the "bootz" command. The syntax of "bootz" command is the same
+as the syntax of "bootm" command.
+
 
 Standalone HOWTO:
 =================
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index afa0093..ec46d76 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -344,3 +344,33 @@ static ulong get_sp(void)
 	asm("mov %0, sp" : "=r"(ret) : );
 	return ret;
 }
+
+#ifdef CONFIG_CMD_BOOTZ
+
+struct zimage_header {
+	uint32_t	code[9];
+	uint32_t	zi_magic;
+	uint32_t	zi_start;
+	uint32_t	zi_end;
+};
+
+#define	LINUX_ARM_ZIMAGE_MAGIC	0x016f2818
+
+int bootz_setup(void *image, void **start, void **end)
+{
+	struct zimage_header *zi = (struct zimage_header *)image;
+
+	if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC) {
+		puts("Bad Linux ARM zImage magic!\n");
+		return 1;
+	}
+
+	*start = (void *)zi->zi_start;
+	*end = (void *)zi->zi_end;
+
+	debug("Kernel image @ 0x%08x [ 0x%08x - 0x%08x ]\n",
+		(uint32_t)image, (uint32_t)*start, (uint32_t)*end);
+
+	return 0;
+}
+#endif	/* CONFIG_CMD_BOOTZ */
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index d5745b1..4249831 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -169,25 +169,25 @@ void arch_preboot_os(void) __attribute__((weak, alias("__arch_preboot_os")));
 
 #define IH_INITRD_ARCH IH_ARCH_DEFAULT
 
-static void bootm_start_lmb(void)
-{
 #ifdef CONFIG_LMB
+static void boot_start_lmb(bootm_headers_t *images)
+{
 	ulong		mem_start;
 	phys_size_t	mem_size;
 
-	lmb_init(&images.lmb);
+	lmb_init(&images->lmb);
 
 	mem_start = getenv_bootm_low();
 	mem_size = getenv_bootm_size();
 
-	lmb_add(&images.lmb, (phys_addr_t)mem_start, mem_size);
+	lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);
 
-	arch_lmb_reserve(&images.lmb);
-	board_lmb_reserve(&images.lmb);
+	arch_lmb_reserve(&images->lmb);
+	board_lmb_reserve(&images->lmb);
+}
 #else
-# define lmb_reserve(lmb, base, size)
+static inline void boot_start_lmb(bootm_headers_t *images) { }
 #endif
-}
 
 static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
@@ -197,7 +197,7 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
 	memset((void *)&images, 0, sizeof(images));
 	images.verify = getenv_yesno("verify");
 
-	bootm_start_lmb();
+	boot_start_lmb(&images);
 
 	/* get kernel image header, start address and length */
 	os_hdr = boot_get_kernel(cmdtp, flag, argc, argv,
@@ -1523,3 +1523,126 @@ static int do_bootm_integrity(int flag, int argc, char * const argv[],
 	return 1;
 }
 #endif
+
+#ifdef CONFIG_CMD_BOOTZ
+
+static int __bootz_setup(void *image, void **start, void **end)
+{
+	/* Please define bootz_setup() for your platform */
+
+	puts("Your platform's zImage format isn't supported yet!\n");
+	return -1;
+}
+int bootz_setup(void *image, void **start, void **end)
+	__attribute__((weak, alias("__bootz_setup")));
+
+/*
+ * zImage booting support
+ */
+static int bootz_start(cmd_tbl_t *cmdtp, int flag, int argc,
+			char * const argv[], bootm_headers_t *images)
+{
+	int ret;
+	void *zi_start, *zi_end;
+
+	memset(images, 0, sizeof(bootm_headers_t));
+
+	boot_start_lmb(images);
+
+	/* Setup Linux kernel zImage entry point */
+	if (argc < 2) {
+		images->ep = load_addr;
+		debug("*  kernel: default image load address = 0x%08lx\n",
+				load_addr);
+	} else {
+		images->ep = simple_strtoul(argv[1], NULL, 16);
+		debug("*  kernel: cmdline image address = 0x%08lx\n",
+			images->ep);
+	}
+
+	ret = bootz_setup((void *)images->ep, &zi_start, &zi_end);
+	if (ret != 0)
+		return 1;
+
+	lmb_reserve(&images->lmb, images->ep, zi_end - zi_start);
+
+	/* Find ramdisk */
+	ret = boot_get_ramdisk(argc, argv, images, IH_INITRD_ARCH,
+			&images->rd_start, &images->rd_end);
+	if (ret) {
+		puts("Ramdisk image is corrupt or invalid\n");
+		return 1;
+	}
+
+#if defined(CONFIG_OF_LIBFDT)
+	/* find flattened device tree */
+	ret = boot_get_fdt(flag, argc, argv, images,
+			   &images->ft_addr, &images->ft_len);
+	if (ret) {
+		puts("Could not find a valid device tree\n");
+		return 1;
+	}
+
+	set_working_fdt_addr(images->ft_addr);
+#endif
+
+	return 0;
+}
+
+int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	ulong		iflag;
+	bootm_headers_t	images;
+
+	if (bootz_start(cmdtp, flag, argc, argv, &images))
+		return 1;
+
+	/*
+	 * We have reached the point of no return: we are going to
+	 * overwrite all exception vector code, so we cannot easily
+	 * recover from any failures any more...
+	 */
+	iflag = disable_interrupts();
+
+#if defined(CONFIG_CMD_USB)
+	/*
+	 * turn off USB to prevent the host controller from writing to the
+	 * SDRAM while Linux is booting. This could happen (at least for OHCI
+	 * controller), because the HCCA (Host Controller Communication Area)
+	 * lies within the SDRAM and the host controller writes continously to
+	 * this area (as busmaster!). The HccaFrameNumber is for example
+	 * updated every 1 ms within the HCCA structure in SDRAM! For more
+	 * details see the OpenHCI specification.
+	 */
+	usb_stop();
+#endif
+
+#ifdef CONFIG_SILENT_CONSOLE
+	fixup_silent_linux();
+#endif
+	arch_preboot_os();
+
+	do_bootm_linux(0, argc, argv, &images);
+#ifdef DEBUG
+	puts("\n## Control returned to monitor - resetting...\n");
+#endif
+	do_reset(cmdtp, flag, argc, argv);
+
+	return 1;
+}
+
+U_BOOT_CMD(
+	bootz,	CONFIG_SYS_MAXARGS,	1,	do_bootz,
+	"boot Linux zImage image from memory",
+	"[addr [initrd] [fdt]]\n    - boot Linux zImage stored in memory\n"
+	"\tThe argument 'initrd' is optional and specifies the address\n"
+	"\tof the initrd in memory.\n"
+#if defined(CONFIG_OF_LIBFDT)
+	"\tWhen booting a Linux kernel which requires a flat device-tree\n"
+	"\ta third argument is required which is the address of the\n"
+	"\tdevice-tree blob. To boot that kernel without an initrd image,\n"
+	"\tuse a '-' for the second argument. If you do not pass a third\n"
+	"\ta bd_info struct will be passed instead\n"
+#endif
+);
+#endif	/* CONFIG_CMD_BOOTZ */
diff --git a/include/config_cmd_all.h b/include/config_cmd_all.h
index 9716f9c..2c6b829 100644
--- a/include/config_cmd_all.h
+++ b/include/config_cmd_all.h
@@ -20,6 +20,7 @@
 #define CONFIG_CMD_BEDBUG	/* Include BedBug Debugger	*/
 #define CONFIG_CMD_BMP		/* BMP support			*/
 #define CONFIG_CMD_BOOTD	/* bootd			*/
+#define CONFIG_CMD_BOOTZ	/* boot zImage			*/
 #define CONFIG_CMD_BSP		/* Board Specific functions	*/
 #define CONFIG_CMD_CACHE	/* icache, dcache		*/
 #define CONFIG_CMD_CDP		/* Cisco Discovery Protocol	*/
-- 
1.7.9

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V5] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-14  3:47 ` [U-Boot] [PATCH V5] " Marek Vasut
@ 2012-03-14  5:07   ` Mike Frysinger
  2012-03-14  5:38     ` Marek Vasut
  2012-03-14 16:45   ` Stephen Warren
  1 sibling, 1 reply; 48+ messages in thread
From: Mike Frysinger @ 2012-03-14  5:07 UTC (permalink / raw)
  To: u-boot

On Tuesday 13 March 2012 23:47:56 Marek Vasut wrote:
> This command boots Linux zImage from where the zImage is loaded to. Passing
> initrd and fdt is supported.

i've got no opinion on the matter of supporting zImage directly (although, i 
guess it'd be nice since some legacy platforms still use it like netwinders)

> +int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])

static
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120314/c939c10f/attachment.pgp>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V5] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-14  5:07   ` Mike Frysinger
@ 2012-03-14  5:38     ` Marek Vasut
  2012-03-14 18:35       ` Mike Frysinger
  2012-03-15 16:09       ` Wolfgang Denk
  0 siblings, 2 replies; 48+ messages in thread
From: Marek Vasut @ 2012-03-14  5:38 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

> On Tuesday 13 March 2012 23:47:56 Marek Vasut wrote:
> > This command boots Linux zImage from where the zImage is loaded to.
> > Passing initrd and fdt is supported.
> 
> i've got no opinion on the matter of supporting zImage directly (although,
> i guess it'd be nice since some legacy platforms still use it like
> netwinders)

Does anyone else but RMK have a working netwinder these days? >:-)

> 
> > +int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> 
> static

NAK, compiler won't chew that

> -mike

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V5] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-14  3:47 ` [U-Boot] [PATCH V5] " Marek Vasut
  2012-03-14  5:07   ` Mike Frysinger
@ 2012-03-14 16:45   ` Stephen Warren
  2012-03-14 17:23     ` Marek Vasut
  1 sibling, 1 reply; 48+ messages in thread
From: Stephen Warren @ 2012-03-14 16:45 UTC (permalink / raw)
  To: u-boot

On 03/13/2012 09:47 PM, Marek Vasut wrote:
> From: Marek Vasut <marek.vasut@gmail.com>
> 
> This command boots Linux zImage from where the zImage is loaded to. Passing
> initrd and fdt is supported.
> 
> Tested on i.MX28 based DENX M28EVK
> Tested on PXA270 based Voipac PXA270.
> 
> NOTE: This currently only supports ARM, but other architectures can be easily
> added by defining bootz_setup().
> 
> Signed-off-by: Marek Vasut <marek.vasut@gmail.com>

On Tegra20 Harmony with and without device tree (against mainline) and
Tegra30 Cardhu with device tree (against an NVIDIA-internal U-Boot tree),

Tested-by: Stephen Warren <swarren@wwwdotorg.org>

The code looks good too; I believe you've take care of any comments I
had on the first very you posted.

Thanks very much - this is awesome!

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V5] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-14 16:45   ` Stephen Warren
@ 2012-03-14 17:23     ` Marek Vasut
  0 siblings, 0 replies; 48+ messages in thread
From: Marek Vasut @ 2012-03-14 17:23 UTC (permalink / raw)
  To: u-boot

Dear Stephen Warren,

> On 03/13/2012 09:47 PM, Marek Vasut wrote:
> > From: Marek Vasut <marek.vasut@gmail.com>
> > 
> > This command boots Linux zImage from where the zImage is loaded to.
> > Passing initrd and fdt is supported.
> > 
> > Tested on i.MX28 based DENX M28EVK
> > Tested on PXA270 based Voipac PXA270.
> > 
> > NOTE: This currently only supports ARM, but other architectures can be
> > easily added by defining bootz_setup().
> > 
> > Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> 
> On Tegra20 Harmony with and without device tree (against mainline) and
> Tegra30 Cardhu with device tree (against an NVIDIA-internal U-Boot tree),
> 
> Tested-by: Stephen Warren <swarren@wwwdotorg.org>
> 
> The code looks good too; I believe you've take care of any comments I
> had on the first very you posted.
> 
> Thanks very much - this is awesome!

You're welcome :) I'm glad we're finally going to squash one of the biggest 
sources of friction between linux-arm and uboot :)

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V5] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-14  5:38     ` Marek Vasut
@ 2012-03-14 18:35       ` Mike Frysinger
  2012-03-14 19:27         ` Marek Vasut
  2012-03-15 16:09       ` Wolfgang Denk
  1 sibling, 1 reply; 48+ messages in thread
From: Mike Frysinger @ 2012-03-14 18:35 UTC (permalink / raw)
  To: u-boot

On Wednesday 14 March 2012 01:38:45 Marek Vasut wrote:
> > On Tuesday 13 March 2012 23:47:56 Marek Vasut wrote:
> > > This command boots Linux zImage from where the zImage is loaded to.
> > > Passing initrd and fdt is supported.
> > 
> > i've got no opinion on the matter of supporting zImage directly
> > (although, i guess it'd be nice since some legacy platforms still use it
> > like netwinders)
> 
> Does anyone else but RMK have a working netwinder these days? >:-)

i've got 3, but only one is actively running

> > > +int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const
> > > argv[])
> > 
> > static
> 
> NAK, compiler won't chew that

what are you talking about ?  you need to provide real details when making 
statements like this.  plenty of other cmd's in u-boot mark their do_xxx func 
static and they work just fine.  this do_bootz isn't used externally, so it 
makes no sense to have it be public.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120314/abc179b9/attachment.pgp>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V5] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-14 18:35       ` Mike Frysinger
@ 2012-03-14 19:27         ` Marek Vasut
  0 siblings, 0 replies; 48+ messages in thread
From: Marek Vasut @ 2012-03-14 19:27 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

> On Wednesday 14 March 2012 01:38:45 Marek Vasut wrote:
> > > On Tuesday 13 March 2012 23:47:56 Marek Vasut wrote:
> > > > This command boots Linux zImage from where the zImage is loaded to.
> > > > Passing initrd and fdt is supported.
> > > 
> > > i've got no opinion on the matter of supporting zImage directly
> > > (although, i guess it'd be nice since some legacy platforms still use
> > > it like netwinders)
> > 
> > Does anyone else but RMK have a working netwinder these days? >:-)
> 
> i've got 3, but only one is actively running

You should run DNA test on yourself against RMK's bloodsample :)

> 
> > > > +int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const
> > > > argv[])
> > > 
> > > static
> > 
> > NAK, compiler won't chew that
> 
> what are you talking about ?  you need to provide real details when making
> statements like this.  plenty of other cmd's in u-boot mark their do_xxx
> func static and they work just fine.  this do_bootz isn't used externally,
> so it makes no sense to have it be public.

Oh you mean staticize the function, not the weak stuff, ok.

> -mike

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V6] BOOT: Add "bootz" command to boot Linux zImage on ARM
       [not found] <Message-Id: <1331696876-20903-1-git-send-email-marex@denx.de>
@ 2012-03-15  7:52 ` Marek Vasut
  2012-03-15 18:51   ` Rob Herring
                     ` (2 more replies)
  0 siblings, 3 replies; 48+ messages in thread
From: Marek Vasut @ 2012-03-15  7:52 UTC (permalink / raw)
  To: u-boot

From: Marek Vasut <marek.vasut@gmail.com>

This command boots Linux zImage from where the zImage is loaded to. Passing
initrd and fdt is supported.

Tested on i.MX28 based DENX M28EVK
Tested on PXA270 based Voipac PXA270.

NOTE: This currently only supports ARM, but other architectures can be easily
added by defining bootz_setup().

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Cc: Tom Warren <TWarren@nvidia.com>
Cc: albert.u.boot at aribaud.net
Cc: afleming at gmail.com,
Cc: Simon Glass <sjg@chromium.org>,
Cc: Stephen Warren <swarren@nvidia.com>
Cc: Nicolas Pitre <nico@fluxnic.net>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Detlev Zundel <dzu@denx.de>
---
 README                   |    8 +++
 arch/arm/lib/bootm.c     |   30 ++++++++++
 common/cmd_bootm.c       |  141 +++++++++++++++++++++++++++++++++++++++++++---
 include/config_cmd_all.h |    1 +
 4 files changed, 171 insertions(+), 9 deletions(-)

V2: Use CONFIG_BOOTZ_MAX_KERNEL_LMB_SIZE to reserve kernel LMB
V3: Compute the LMB size at runtime (obsoletes V2)
    Move shared code to image.c/image.h
    Sync with latest U-Boot
V4: Add all this into cmd_bootm. Therefore, this is part of cmd_bootm (basically
    it's stripped-down version). Also, separate out arm-specific component into
    arm-specific location.
V5: Staticize bootz_setup(), add information into README.
V6: Make cmd_bootz() static.

diff --git a/README b/README
index 4021715..b273070 100644
--- a/README
+++ b/README
@@ -3594,6 +3594,7 @@ go	- start application at address 'addr'
 run	- run commands in an environment variable
 bootm	- boot application image from memory
 bootp	- boot image via network using BootP/TFTP protocol
+bootz   - boot zImage from memory
 tftpboot- boot image via network using TFTP protocol
 	       and env variables "ipaddr" and "serverip"
 	       (and eventually "gatewayip")
@@ -4414,6 +4415,13 @@ U-Boot supports the following image types:
 	useful when you configure U-Boot to use a real shell (hush)
 	as command interpreter.
 
+Booting the Linux zImage:
+-------------------------
+
+On some platforms, it's possible to boot Linux zImage. This is done
+using the "bootz" command. The syntax of "bootz" command is the same
+as the syntax of "bootm" command.
+
 
 Standalone HOWTO:
 =================
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index afa0093..ec46d76 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -344,3 +344,33 @@ static ulong get_sp(void)
 	asm("mov %0, sp" : "=r"(ret) : );
 	return ret;
 }
+
+#ifdef CONFIG_CMD_BOOTZ
+
+struct zimage_header {
+	uint32_t	code[9];
+	uint32_t	zi_magic;
+	uint32_t	zi_start;
+	uint32_t	zi_end;
+};
+
+#define	LINUX_ARM_ZIMAGE_MAGIC	0x016f2818
+
+int bootz_setup(void *image, void **start, void **end)
+{
+	struct zimage_header *zi = (struct zimage_header *)image;
+
+	if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC) {
+		puts("Bad Linux ARM zImage magic!\n");
+		return 1;
+	}
+
+	*start = (void *)zi->zi_start;
+	*end = (void *)zi->zi_end;
+
+	debug("Kernel image @ 0x%08x [ 0x%08x - 0x%08x ]\n",
+		(uint32_t)image, (uint32_t)*start, (uint32_t)*end);
+
+	return 0;
+}
+#endif	/* CONFIG_CMD_BOOTZ */
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index d5745b1..b49d4f7 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -169,25 +169,25 @@ void arch_preboot_os(void) __attribute__((weak, alias("__arch_preboot_os")));
 
 #define IH_INITRD_ARCH IH_ARCH_DEFAULT
 
-static void bootm_start_lmb(void)
-{
 #ifdef CONFIG_LMB
+static void boot_start_lmb(bootm_headers_t *images)
+{
 	ulong		mem_start;
 	phys_size_t	mem_size;
 
-	lmb_init(&images.lmb);
+	lmb_init(&images->lmb);
 
 	mem_start = getenv_bootm_low();
 	mem_size = getenv_bootm_size();
 
-	lmb_add(&images.lmb, (phys_addr_t)mem_start, mem_size);
+	lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);
 
-	arch_lmb_reserve(&images.lmb);
-	board_lmb_reserve(&images.lmb);
+	arch_lmb_reserve(&images->lmb);
+	board_lmb_reserve(&images->lmb);
+}
 #else
-# define lmb_reserve(lmb, base, size)
+static inline void boot_start_lmb(bootm_headers_t *images) { }
 #endif
-}
 
 static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
@@ -197,7 +197,7 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
 	memset((void *)&images, 0, sizeof(images));
 	images.verify = getenv_yesno("verify");
 
-	bootm_start_lmb();
+	boot_start_lmb(&images);
 
 	/* get kernel image header, start address and length */
 	os_hdr = boot_get_kernel(cmdtp, flag, argc, argv,
@@ -1523,3 +1523,126 @@ static int do_bootm_integrity(int flag, int argc, char * const argv[],
 	return 1;
 }
 #endif
+
+#ifdef CONFIG_CMD_BOOTZ
+
+static int __bootz_setup(void *image, void **start, void **end)
+{
+	/* Please define bootz_setup() for your platform */
+
+	puts("Your platform's zImage format isn't supported yet!\n");
+	return -1;
+}
+int bootz_setup(void *image, void **start, void **end)
+	__attribute__((weak, alias("__bootz_setup")));
+
+/*
+ * zImage booting support
+ */
+static int bootz_start(cmd_tbl_t *cmdtp, int flag, int argc,
+			char * const argv[], bootm_headers_t *images)
+{
+	int ret;
+	void *zi_start, *zi_end;
+
+	memset(images, 0, sizeof(bootm_headers_t));
+
+	boot_start_lmb(images);
+
+	/* Setup Linux kernel zImage entry point */
+	if (argc < 2) {
+		images->ep = load_addr;
+		debug("*  kernel: default image load address = 0x%08lx\n",
+				load_addr);
+	} else {
+		images->ep = simple_strtoul(argv[1], NULL, 16);
+		debug("*  kernel: cmdline image address = 0x%08lx\n",
+			images->ep);
+	}
+
+	ret = bootz_setup((void *)images->ep, &zi_start, &zi_end);
+	if (ret != 0)
+		return 1;
+
+	lmb_reserve(&images->lmb, images->ep, zi_end - zi_start);
+
+	/* Find ramdisk */
+	ret = boot_get_ramdisk(argc, argv, images, IH_INITRD_ARCH,
+			&images->rd_start, &images->rd_end);
+	if (ret) {
+		puts("Ramdisk image is corrupt or invalid\n");
+		return 1;
+	}
+
+#if defined(CONFIG_OF_LIBFDT)
+	/* find flattened device tree */
+	ret = boot_get_fdt(flag, argc, argv, images,
+			   &images->ft_addr, &images->ft_len);
+	if (ret) {
+		puts("Could not find a valid device tree\n");
+		return 1;
+	}
+
+	set_working_fdt_addr(images->ft_addr);
+#endif
+
+	return 0;
+}
+
+static int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	ulong		iflag;
+	bootm_headers_t	images;
+
+	if (bootz_start(cmdtp, flag, argc, argv, &images))
+		return 1;
+
+	/*
+	 * We have reached the point of no return: we are going to
+	 * overwrite all exception vector code, so we cannot easily
+	 * recover from any failures any more...
+	 */
+	iflag = disable_interrupts();
+
+#if defined(CONFIG_CMD_USB)
+	/*
+	 * turn off USB to prevent the host controller from writing to the
+	 * SDRAM while Linux is booting. This could happen (at least for OHCI
+	 * controller), because the HCCA (Host Controller Communication Area)
+	 * lies within the SDRAM and the host controller writes continously to
+	 * this area (as busmaster!). The HccaFrameNumber is for example
+	 * updated every 1 ms within the HCCA structure in SDRAM! For more
+	 * details see the OpenHCI specification.
+	 */
+	usb_stop();
+#endif
+
+#ifdef CONFIG_SILENT_CONSOLE
+	fixup_silent_linux();
+#endif
+	arch_preboot_os();
+
+	do_bootm_linux(0, argc, argv, &images);
+#ifdef DEBUG
+	puts("\n## Control returned to monitor - resetting...\n");
+#endif
+	do_reset(cmdtp, flag, argc, argv);
+
+	return 1;
+}
+
+U_BOOT_CMD(
+	bootz,	CONFIG_SYS_MAXARGS,	1,	do_bootz,
+	"boot Linux zImage image from memory",
+	"[addr [initrd] [fdt]]\n    - boot Linux zImage stored in memory\n"
+	"\tThe argument 'initrd' is optional and specifies the address\n"
+	"\tof the initrd in memory.\n"
+#if defined(CONFIG_OF_LIBFDT)
+	"\tWhen booting a Linux kernel which requires a flat device-tree\n"
+	"\ta third argument is required which is the address of the\n"
+	"\tdevice-tree blob. To boot that kernel without an initrd image,\n"
+	"\tuse a '-' for the second argument. If you do not pass a third\n"
+	"\ta bd_info struct will be passed instead\n"
+#endif
+);
+#endif	/* CONFIG_CMD_BOOTZ */
diff --git a/include/config_cmd_all.h b/include/config_cmd_all.h
index 9716f9c..2c6b829 100644
--- a/include/config_cmd_all.h
+++ b/include/config_cmd_all.h
@@ -20,6 +20,7 @@
 #define CONFIG_CMD_BEDBUG	/* Include BedBug Debugger	*/
 #define CONFIG_CMD_BMP		/* BMP support			*/
 #define CONFIG_CMD_BOOTD	/* bootd			*/
+#define CONFIG_CMD_BOOTZ	/* boot zImage			*/
 #define CONFIG_CMD_BSP		/* Board Specific functions	*/
 #define CONFIG_CMD_CACHE	/* icache, dcache		*/
 #define CONFIG_CMD_CDP		/* Cisco Discovery Protocol	*/
-- 
1.7.9

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V3] BOOT: Add "bootz" command to boot Linux zImage
  2012-03-13  4:46               ` Graeme Russ
@ 2012-03-15 15:03                 ` Wolfgang Denk
  2012-03-15 17:08                   ` Marek Vasut
  0 siblings, 1 reply; 48+ messages in thread
From: Wolfgang Denk @ 2012-03-15 15:03 UTC (permalink / raw)
  To: u-boot

Dear Graeme Russ,

In message <CALButCL4xxwfaLf1XDpsRgJV4V8YHYnX_dVD9bSU3AXuhYzsig@mail.gmail.com> you wrote:
> 
> > Frankly: I see no benefit in adding x86 support.
> 
> Ouch! - Do you mean in common code or in general?

I mean: I see no benefit in adding support for a "bootz" command for
x86 systems - and I don't see it on Power Architecture either.

> > I see no benefit in adding ARM support either, but YMMV...
> 
> Hmm, methinks the Android guys might have a bone to pick with that
> statement ;)

Andoid? What or who is that? ;-)

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"It's like deja vu all over again."                      - Yogi Berra

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V3] BOOT: Add "bootz" command to boot Linux zImage
  2012-03-13  4:47               ` Marek Vasut
@ 2012-03-15 15:06                 ` Wolfgang Denk
  2012-03-15 17:18                   ` Marek Vasut
  0 siblings, 1 reply; 48+ messages in thread
From: Wolfgang Denk @ 2012-03-15 15:06 UTC (permalink / raw)
  To: u-boot

Dear Marek Vasut,

In message <201203130547.30788.marex@denx.de> you wrote:
>
> > I have to admit that I never understood the fuzz about being able to
> > boot zImages.  I see more disadvanatges than advantages for this, but
> > some ARM people go frenzy when this topic pops up - see recent
> > discussions about removal of uImage support on the AKML.
> 
> Sure, but let's try to offer them a compromise. Everyone will be happy that way 
> at least to some extent.

I have nothing against compromizes.  But are you soure about the
"everyone" in the second sentence?  I think we know a few guys who
mightnot.

And actually it might backfire as well - I see JC argumenting: now
they (finally!) support the one true image format, no let's throw out
their stupid uImage support, nobody needs this any more.

Just like nobody needs to be able to use a ramdisk image from NOR
flash without loading it to RAM before, etc.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
G's Third Law:             In spite of all evidence  to  the  contra-
ry,  the  entire  universe  is composed of only two basic substances:
magic and bullshit.
H's Dictum:                There is no magic ...

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V5] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-14  5:38     ` Marek Vasut
  2012-03-14 18:35       ` Mike Frysinger
@ 2012-03-15 16:09       ` Wolfgang Denk
  2012-03-15 17:08         ` Marek Vasut
  2012-03-15 17:36         ` Mike Frysinger
  1 sibling, 2 replies; 48+ messages in thread
From: Wolfgang Denk @ 2012-03-15 16:09 UTC (permalink / raw)
  To: u-boot

Dear Marek Vasut,

In message <201203140638.45430.marex@denx.de> you wrote:
> 
> > i've got no opinion on the matter of supporting zImage directly (although,
> > i guess it'd be nice since some legacy platforms still use it like
> > netwinders)
> 
> Does anyone else but RMK have a working netwinder these days? >:-)

And I bet a crate of beer that _him_ is not using U-Boot to boot it.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Disobedience:  The silver lining to the cloud of servitude.
- Ambrose Bierce

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V5] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-15 16:09       ` Wolfgang Denk
@ 2012-03-15 17:08         ` Marek Vasut
  2012-03-15 17:36         ` Mike Frysinger
  1 sibling, 0 replies; 48+ messages in thread
From: Marek Vasut @ 2012-03-15 17:08 UTC (permalink / raw)
  To: u-boot

Dear Wolfgang Denk,

> Dear Marek Vasut,
> 
> In message <201203140638.45430.marex@denx.de> you wrote:
> > > i've got no opinion on the matter of supporting zImage directly
> > > (although, i guess it'd be nice since some legacy platforms still use
> > > it like netwinders)
> > 
> > Does anyone else but RMK have a working netwinder these days? >:-)
> 
> And I bet a crate of beer that _him_ is not using U-Boot to boot it.

Dang, that'd be hard to convince him to switch to uboot to win this one ;-)
> 
> Best regards,
> 
> Wolfgang Denk

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V3] BOOT: Add "bootz" command to boot Linux zImage
  2012-03-15 15:03                 ` Wolfgang Denk
@ 2012-03-15 17:08                   ` Marek Vasut
  0 siblings, 0 replies; 48+ messages in thread
From: Marek Vasut @ 2012-03-15 17:08 UTC (permalink / raw)
  To: u-boot

Dear Wolfgang Denk,

> Dear Graeme Russ,
> 
> In message 
<CALButCL4xxwfaLf1XDpsRgJV4V8YHYnX_dVD9bSU3AXuhYzsig@mail.gmail.com> you wrote:
> > > Frankly: I see no benefit in adding x86 support.
> > 
> > Ouch! - Do you mean in common code or in general?
> 
> I mean: I see no benefit in adding support for a "bootz" command for
> x86 systems - and I don't see it on Power Architecture either.

Well x86 might benefit from it ;-)
> 
> > > I see no benefit in adding ARM support either, but YMMV...
> > 
> > Hmm, methinks the Android guys might have a bone to pick with that
> > statement ;)
> 
> Andoid? What or who is that? ;-)

Google SpyOS :)
> 
> Best regards,
> 
> Wolfgang Denk

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V3] BOOT: Add "bootz" command to boot Linux zImage
  2012-03-15 15:06                 ` Wolfgang Denk
@ 2012-03-15 17:18                   ` Marek Vasut
  0 siblings, 0 replies; 48+ messages in thread
From: Marek Vasut @ 2012-03-15 17:18 UTC (permalink / raw)
  To: u-boot

Dear Wolfgang Denk,

> Dear Marek Vasut,
> 
> In message <201203130547.30788.marex@denx.de> you wrote:
> > > I have to admit that I never understood the fuzz about being able to
> > > boot zImages.  I see more disadvanatges than advantages for this, but
> > > some ARM people go frenzy when this topic pops up - see recent
> > > discussions about removal of uImage support on the AKML.
> > 
> > Sure, but let's try to offer them a compromise. Everyone will be happy
> > that way at least to some extent.
> 
> I have nothing against compromizes.  But are you soure about the
> "everyone" in the second sentence?  I think we know a few guys who
> mightnot.

That's like in calculus, the epsilon might be infinitelly small :)
> 
> And actually it might backfire as well - I see JC argumenting: now
> they (finally!) support the one true image format, no let's throw out
> their stupid uImage support, nobody needs this any more.

I believe there is a way to avoid this.
> 
> Just like nobody needs to be able to use a ramdisk image from NOR
> flash without loading it to RAM before, etc.

:-)

> Best regards,
> 
> Wolfgang Denk

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V5] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-15 16:09       ` Wolfgang Denk
  2012-03-15 17:08         ` Marek Vasut
@ 2012-03-15 17:36         ` Mike Frysinger
  2012-03-15 17:40           ` Marek Vasut
  1 sibling, 1 reply; 48+ messages in thread
From: Mike Frysinger @ 2012-03-15 17:36 UTC (permalink / raw)
  To: u-boot

On Thursday 15 March 2012 12:09:43 Wolfgang Denk wrote:
> Marek Vasut wrote:
> > > i've got no opinion on the matter of supporting zImage directly
> > > (although, i guess it'd be nice since some legacy platforms still use
> > > it like netwinders)
> > 
> > Does anyone else but RMK have a working netwinder these days? >:-)
> 
> And I bet a crate of beer that _him_ is not using U-Boot to boot it.

i'm still using nettrom on my netwinder.  the main guy (Ralph) has the source 
to it iirc, but wasn't able to release it.  a u-boot port at this point 
wouldn't work without those board details :(.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120315/5cbbae1b/attachment.pgp>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V5] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-15 17:36         ` Mike Frysinger
@ 2012-03-15 17:40           ` Marek Vasut
  0 siblings, 0 replies; 48+ messages in thread
From: Marek Vasut @ 2012-03-15 17:40 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

> On Thursday 15 March 2012 12:09:43 Wolfgang Denk wrote:
> > Marek Vasut wrote:
> > > > i've got no opinion on the matter of supporting zImage directly
> > > > (although, i guess it'd be nice since some legacy platforms still use
> > > > it like netwinders)
> > > 
> > > Does anyone else but RMK have a working netwinder these days? >:-)
> > 
> > And I bet a crate of beer that _him_ is not using U-Boot to boot it.
> 
> i'm still using nettrom on my netwinder.  the main guy (Ralph) has the
> source to it iirc, but wasn't able to release it.  a u-boot port at this
> point wouldn't work without those board details :(.

But a crete of beer is a good motivation to do it :-)

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V6] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-15  7:52 ` [U-Boot] [PATCH V6] BOOT: Add "bootz" command to boot Linux zImage on ARM Marek Vasut
@ 2012-03-15 18:51   ` Rob Herring
  2012-03-15 19:05     ` Marek Vasut
  2012-03-30 20:59   ` Wolfgang Denk
  2012-03-31 19:10   ` Mike Frysinger
  2 siblings, 1 reply; 48+ messages in thread
From: Rob Herring @ 2012-03-15 18:51 UTC (permalink / raw)
  To: u-boot

On 03/15/2012 02:52 AM, Marek Vasut wrote:
> From: Marek Vasut <marek.vasut@gmail.com>
> 
> This command boots Linux zImage from where the zImage is loaded to. Passing
> initrd and fdt is supported.
> 

This is great! However, the initrd is still in the u-boot image format,
right?

If a raw initrd is supported, then we could get rid of flash-kernel on
disk-based debian/ubuntu systems. The file size is known from the
filesystem, but then needs to get to the bootz command somehow.

Rob

> Tested on i.MX28 based DENX M28EVK
> Tested on PXA270 based Voipac PXA270.
> 
> NOTE: This currently only supports ARM, but other architectures can be easily
> added by defining bootz_setup().
> 
> Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> Cc: Tom Warren <TWarren@nvidia.com>
> Cc: albert.u.boot at aribaud.net
> Cc: afleming at gmail.com,
> Cc: Simon Glass <sjg@chromium.org>,
> Cc: Stephen Warren <swarren@nvidia.com>
> Cc: Nicolas Pitre <nico@fluxnic.net>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Detlev Zundel <dzu@denx.de>
> ---
>  README                   |    8 +++
>  arch/arm/lib/bootm.c     |   30 ++++++++++
>  common/cmd_bootm.c       |  141 +++++++++++++++++++++++++++++++++++++++++++---
>  include/config_cmd_all.h |    1 +
>  4 files changed, 171 insertions(+), 9 deletions(-)
> 
> V2: Use CONFIG_BOOTZ_MAX_KERNEL_LMB_SIZE to reserve kernel LMB
> V3: Compute the LMB size at runtime (obsoletes V2)
>     Move shared code to image.c/image.h
>     Sync with latest U-Boot
> V4: Add all this into cmd_bootm. Therefore, this is part of cmd_bootm (basically
>     it's stripped-down version). Also, separate out arm-specific component into
>     arm-specific location.
> V5: Staticize bootz_setup(), add information into README.
> V6: Make cmd_bootz() static.
> 
> diff --git a/README b/README
> index 4021715..b273070 100644
> --- a/README
> +++ b/README
> @@ -3594,6 +3594,7 @@ go	- start application at address 'addr'
>  run	- run commands in an environment variable
>  bootm	- boot application image from memory
>  bootp	- boot image via network using BootP/TFTP protocol
> +bootz   - boot zImage from memory
>  tftpboot- boot image via network using TFTP protocol
>  	       and env variables "ipaddr" and "serverip"
>  	       (and eventually "gatewayip")
> @@ -4414,6 +4415,13 @@ U-Boot supports the following image types:
>  	useful when you configure U-Boot to use a real shell (hush)
>  	as command interpreter.
>  
> +Booting the Linux zImage:
> +-------------------------
> +
> +On some platforms, it's possible to boot Linux zImage. This is done
> +using the "bootz" command. The syntax of "bootz" command is the same
> +as the syntax of "bootm" command.
> +
>  
>  Standalone HOWTO:
>  =================
> diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
> index afa0093..ec46d76 100644
> --- a/arch/arm/lib/bootm.c
> +++ b/arch/arm/lib/bootm.c
> @@ -344,3 +344,33 @@ static ulong get_sp(void)
>  	asm("mov %0, sp" : "=r"(ret) : );
>  	return ret;
>  }
> +
> +#ifdef CONFIG_CMD_BOOTZ
> +
> +struct zimage_header {
> +	uint32_t	code[9];
> +	uint32_t	zi_magic;
> +	uint32_t	zi_start;
> +	uint32_t	zi_end;
> +};
> +
> +#define	LINUX_ARM_ZIMAGE_MAGIC	0x016f2818
> +
> +int bootz_setup(void *image, void **start, void **end)
> +{
> +	struct zimage_header *zi = (struct zimage_header *)image;
> +
> +	if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC) {
> +		puts("Bad Linux ARM zImage magic!\n");
> +		return 1;
> +	}
> +
> +	*start = (void *)zi->zi_start;
> +	*end = (void *)zi->zi_end;
> +
> +	debug("Kernel image @ 0x%08x [ 0x%08x - 0x%08x ]\n",
> +		(uint32_t)image, (uint32_t)*start, (uint32_t)*end);
> +
> +	return 0;
> +}
> +#endif	/* CONFIG_CMD_BOOTZ */
> diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
> index d5745b1..b49d4f7 100644
> --- a/common/cmd_bootm.c
> +++ b/common/cmd_bootm.c
> @@ -169,25 +169,25 @@ void arch_preboot_os(void) __attribute__((weak, alias("__arch_preboot_os")));
>  
>  #define IH_INITRD_ARCH IH_ARCH_DEFAULT
>  
> -static void bootm_start_lmb(void)
> -{
>  #ifdef CONFIG_LMB
> +static void boot_start_lmb(bootm_headers_t *images)
> +{
>  	ulong		mem_start;
>  	phys_size_t	mem_size;
>  
> -	lmb_init(&images.lmb);
> +	lmb_init(&images->lmb);
>  
>  	mem_start = getenv_bootm_low();
>  	mem_size = getenv_bootm_size();
>  
> -	lmb_add(&images.lmb, (phys_addr_t)mem_start, mem_size);
> +	lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);
>  
> -	arch_lmb_reserve(&images.lmb);
> -	board_lmb_reserve(&images.lmb);
> +	arch_lmb_reserve(&images->lmb);
> +	board_lmb_reserve(&images->lmb);
> +}
>  #else
> -# define lmb_reserve(lmb, base, size)
> +static inline void boot_start_lmb(bootm_headers_t *images) { }
>  #endif
> -}
>  
>  static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>  {
> @@ -197,7 +197,7 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
>  	memset((void *)&images, 0, sizeof(images));
>  	images.verify = getenv_yesno("verify");
>  
> -	bootm_start_lmb();
> +	boot_start_lmb(&images);
>  
>  	/* get kernel image header, start address and length */
>  	os_hdr = boot_get_kernel(cmdtp, flag, argc, argv,
> @@ -1523,3 +1523,126 @@ static int do_bootm_integrity(int flag, int argc, char * const argv[],
>  	return 1;
>  }
>  #endif
> +
> +#ifdef CONFIG_CMD_BOOTZ
> +
> +static int __bootz_setup(void *image, void **start, void **end)
> +{
> +	/* Please define bootz_setup() for your platform */
> +
> +	puts("Your platform's zImage format isn't supported yet!\n");
> +	return -1;
> +}
> +int bootz_setup(void *image, void **start, void **end)
> +	__attribute__((weak, alias("__bootz_setup")));
> +
> +/*
> + * zImage booting support
> + */
> +static int bootz_start(cmd_tbl_t *cmdtp, int flag, int argc,
> +			char * const argv[], bootm_headers_t *images)
> +{
> +	int ret;
> +	void *zi_start, *zi_end;
> +
> +	memset(images, 0, sizeof(bootm_headers_t));
> +
> +	boot_start_lmb(images);
> +
> +	/* Setup Linux kernel zImage entry point */
> +	if (argc < 2) {
> +		images->ep = load_addr;
> +		debug("*  kernel: default image load address = 0x%08lx\n",
> +				load_addr);
> +	} else {
> +		images->ep = simple_strtoul(argv[1], NULL, 16);
> +		debug("*  kernel: cmdline image address = 0x%08lx\n",
> +			images->ep);
> +	}
> +
> +	ret = bootz_setup((void *)images->ep, &zi_start, &zi_end);
> +	if (ret != 0)
> +		return 1;
> +
> +	lmb_reserve(&images->lmb, images->ep, zi_end - zi_start);
> +
> +	/* Find ramdisk */
> +	ret = boot_get_ramdisk(argc, argv, images, IH_INITRD_ARCH,
> +			&images->rd_start, &images->rd_end);
> +	if (ret) {
> +		puts("Ramdisk image is corrupt or invalid\n");
> +		return 1;
> +	}
> +
> +#if defined(CONFIG_OF_LIBFDT)
> +	/* find flattened device tree */
> +	ret = boot_get_fdt(flag, argc, argv, images,
> +			   &images->ft_addr, &images->ft_len);
> +	if (ret) {
> +		puts("Could not find a valid device tree\n");
> +		return 1;
> +	}
> +
> +	set_working_fdt_addr(images->ft_addr);
> +#endif
> +
> +	return 0;
> +}
> +
> +static int do_bootz(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> +{
> +	ulong		iflag;
> +	bootm_headers_t	images;
> +
> +	if (bootz_start(cmdtp, flag, argc, argv, &images))
> +		return 1;
> +
> +	/*
> +	 * We have reached the point of no return: we are going to
> +	 * overwrite all exception vector code, so we cannot easily
> +	 * recover from any failures any more...
> +	 */
> +	iflag = disable_interrupts();
> +
> +#if defined(CONFIG_CMD_USB)
> +	/*
> +	 * turn off USB to prevent the host controller from writing to the
> +	 * SDRAM while Linux is booting. This could happen (at least for OHCI
> +	 * controller), because the HCCA (Host Controller Communication Area)
> +	 * lies within the SDRAM and the host controller writes continously to
> +	 * this area (as busmaster!). The HccaFrameNumber is for example
> +	 * updated every 1 ms within the HCCA structure in SDRAM! For more
> +	 * details see the OpenHCI specification.
> +	 */
> +	usb_stop();
> +#endif
> +
> +#ifdef CONFIG_SILENT_CONSOLE
> +	fixup_silent_linux();
> +#endif
> +	arch_preboot_os();
> +
> +	do_bootm_linux(0, argc, argv, &images);
> +#ifdef DEBUG
> +	puts("\n## Control returned to monitor - resetting...\n");
> +#endif
> +	do_reset(cmdtp, flag, argc, argv);
> +
> +	return 1;
> +}
> +
> +U_BOOT_CMD(
> +	bootz,	CONFIG_SYS_MAXARGS,	1,	do_bootz,
> +	"boot Linux zImage image from memory",
> +	"[addr [initrd] [fdt]]\n    - boot Linux zImage stored in memory\n"
> +	"\tThe argument 'initrd' is optional and specifies the address\n"
> +	"\tof the initrd in memory.\n"
> +#if defined(CONFIG_OF_LIBFDT)
> +	"\tWhen booting a Linux kernel which requires a flat device-tree\n"
> +	"\ta third argument is required which is the address of the\n"
> +	"\tdevice-tree blob. To boot that kernel without an initrd image,\n"
> +	"\tuse a '-' for the second argument. If you do not pass a third\n"
> +	"\ta bd_info struct will be passed instead\n"
> +#endif
> +);
> +#endif	/* CONFIG_CMD_BOOTZ */
> diff --git a/include/config_cmd_all.h b/include/config_cmd_all.h
> index 9716f9c..2c6b829 100644
> --- a/include/config_cmd_all.h
> +++ b/include/config_cmd_all.h
> @@ -20,6 +20,7 @@
>  #define CONFIG_CMD_BEDBUG	/* Include BedBug Debugger	*/
>  #define CONFIG_CMD_BMP		/* BMP support			*/
>  #define CONFIG_CMD_BOOTD	/* bootd			*/
> +#define CONFIG_CMD_BOOTZ	/* boot zImage			*/
>  #define CONFIG_CMD_BSP		/* Board Specific functions	*/
>  #define CONFIG_CMD_CACHE	/* icache, dcache		*/
>  #define CONFIG_CMD_CDP		/* Cisco Discovery Protocol	*/

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V6] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-15 18:51   ` Rob Herring
@ 2012-03-15 19:05     ` Marek Vasut
  2012-03-15 19:48       ` Rob Herring
  0 siblings, 1 reply; 48+ messages in thread
From: Marek Vasut @ 2012-03-15 19:05 UTC (permalink / raw)
  To: u-boot

Dear Rob Herring,

> On 03/15/2012 02:52 AM, Marek Vasut wrote:
> > From: Marek Vasut <marek.vasut@gmail.com>
> > 
> > This command boots Linux zImage from where the zImage is loaded to.
> > Passing initrd and fdt is supported.
> 
> This is great! However, the initrd is still in the u-boot image format,
> right?
> 
> If a raw initrd is supported, then we could get rid of flash-kernel on
> disk-based debian/ubuntu systems. The file size is known from the
> filesystem, but then needs to get to the bootz command somehow.

Yes. Initrd still needs a bit of work, ideas?

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V6] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-15 19:05     ` Marek Vasut
@ 2012-03-15 19:48       ` Rob Herring
  2012-03-15 20:29         ` Marek Vasut
  2012-03-15 20:39         ` Wolfgang Denk
  0 siblings, 2 replies; 48+ messages in thread
From: Rob Herring @ 2012-03-15 19:48 UTC (permalink / raw)
  To: u-boot

On 03/15/2012 02:05 PM, Marek Vasut wrote:
> Dear Rob Herring,
> 
>> On 03/15/2012 02:52 AM, Marek Vasut wrote:
>>> From: Marek Vasut <marek.vasut@gmail.com>
>>>
>>> This command boots Linux zImage from where the zImage is loaded to.
>>> Passing initrd and fdt is supported.
>>
>> This is great! However, the initrd is still in the u-boot image format,
>> right?
>>
>> If a raw initrd is supported, then we could get rid of flash-kernel on
>> disk-based debian/ubuntu systems. The file size is known from the
>> filesystem, but then needs to get to the bootz command somehow.
> 
> Yes. Initrd still needs a bit of work, ideas?

How about:

bootz <kern addr> [<fdt addr> [<initrd addr> [<initrd size>]]]

I changed the order so the size can be optional without resorting to
using a "-". Then no size means u-boot image format.

File load commands would need to set loadsize env var.

Another idea is to prepend the u-boot image header on file loading. This
would need some way to disable the crc check and specify any other data.
It would probably be hard to do without changing existing commands.

Rob

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V6] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-15 19:48       ` Rob Herring
@ 2012-03-15 20:29         ` Marek Vasut
  2012-03-15 21:10           ` Rob Herring
  2012-03-15 20:39         ` Wolfgang Denk
  1 sibling, 1 reply; 48+ messages in thread
From: Marek Vasut @ 2012-03-15 20:29 UTC (permalink / raw)
  To: u-boot

Dear Rob Herring,

> On 03/15/2012 02:05 PM, Marek Vasut wrote:
> > Dear Rob Herring,
> > 
> >> On 03/15/2012 02:52 AM, Marek Vasut wrote:
> >>> From: Marek Vasut <marek.vasut@gmail.com>
> >>> 
> >>> This command boots Linux zImage from where the zImage is loaded to.
> >>> Passing initrd and fdt is supported.
> >> 
> >> This is great! However, the initrd is still in the u-boot image format,
> >> right?
> >> 
> >> If a raw initrd is supported, then we could get rid of flash-kernel on
> >> disk-based debian/ubuntu systems. The file size is known from the
> >> filesystem, but then needs to get to the bootz command somehow.
> > 
> > Yes. Initrd still needs a bit of work, ideas?
> 

You lost some people in the Cc ;-)

> How about:
> 
> bootz <kern addr> [<fdt addr> [<initrd addr> [<initrd size>]]]

What about bootz <kern addr> <initrd addr>[:<initrd size>] <fdt addr>

example: bootz 0x12000000 0x13000000:0x40000 0x14000000

> 
> I changed the order so the size can be optional without resorting to
> using a "-". Then no size means u-boot image format.
> 
> File load commands would need to set loadsize env var.

If you load kernel after initrd, that's screw things up.
> 
> Another idea is to prepend the u-boot image header on file loading. This
> would need some way to disable the crc check and specify any other data.
> It would probably be hard to do without changing existing commands.

Naw, this is weird. What do you think about my idea with the addr:size stuff?
> 
> Rob

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V6] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-15 19:48       ` Rob Herring
  2012-03-15 20:29         ` Marek Vasut
@ 2012-03-15 20:39         ` Wolfgang Denk
  1 sibling, 0 replies; 48+ messages in thread
From: Wolfgang Denk @ 2012-03-15 20:39 UTC (permalink / raw)
  To: u-boot

Dear Rob,

In message <4F62479F.8070509@gmail.com> you wrote:
> 
> How about:
> 
> bootz <kern addr> [<fdt addr> [<initrd addr> [<initrd size>]]]

No.  We hav ebeen used for 12 years to the order first kernel address,
then ramdisk address (and a little less longer ), then dtb address.

Don't change this now, and don;t make it inconsistent for different
commands.

> I changed the order so the size can be optional without resorting to
> using a "-". Then no size means u-boot image format.
> 
> File load commands would need to set loadsize env var.

What's "loadsize"? 

> Another idea is to prepend the u-boot image header on file loading. This
> would need some way to disable the crc check and specify any other data.

CRC checking can be disabled by setting "verify" to "no" (RTFM).
The rest of the data is not really relevant here.  Also note that we
have enverything in place to compute the CRC, so you could implement a
real "mkimage" commands.  Assuming someone thinks this makes sense.

What is the problem of running this on the host?

> It would probably be hard to do without changing existing commands.

How so?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
EMACS belongs in <sys/errno.h>: Editor too big!

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V6] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-15 20:29         ` Marek Vasut
@ 2012-03-15 21:10           ` Rob Herring
  2012-03-15 22:02             ` Rob Herring
  0 siblings, 1 reply; 48+ messages in thread
From: Rob Herring @ 2012-03-15 21:10 UTC (permalink / raw)
  To: u-boot

On 03/15/2012 03:29 PM, Marek Vasut wrote:
> Dear Rob Herring,
> 
>> On 03/15/2012 02:05 PM, Marek Vasut wrote:
>>> Dear Rob Herring,
>>>
>>>> On 03/15/2012 02:52 AM, Marek Vasut wrote:
>>>>> From: Marek Vasut <marek.vasut@gmail.com>
>>>>>
>>>>> This command boots Linux zImage from where the zImage is loaded to.
>>>>> Passing initrd and fdt is supported.
>>>>
>>>> This is great! However, the initrd is still in the u-boot image format,
>>>> right?
>>>>
>>>> If a raw initrd is supported, then we could get rid of flash-kernel on
>>>> disk-based debian/ubuntu systems. The file size is known from the
>>>> filesystem, but then needs to get to the bootz command somehow.
>>>
>>> Yes. Initrd still needs a bit of work, ideas?
>>
> 
> You lost some people in the Cc ;-)
> 

They weren't in the original email header, only in the commit log as Cc's.

>> How about:
>>
>> bootz <kern addr> [<fdt addr> [<initrd addr> [<initrd size>]]]
> 
> What about bootz <kern addr> <initrd addr>[:<initrd size>] <fdt addr>
> 
> example: bootz 0x12000000 0x13000000:0x40000 0x14000000
> 

Sure. That works for me.

>>
>> I changed the order so the size can be optional without resorting to
>> using a "-". Then no size means u-boot image format.
>>
>> File load commands would need to set loadsize env var.
> 
> If you load kernel after initrd, that's screw things up.

Yes, but you already have to be aware of some commands which will change
env vars. This has to be script-able to be useful. The only other way I
see is adding a command to get the size of a file. Perhaps the ls
commands when given a single file can do that.

Rob

>>
>> Another idea is to prepend the u-boot image header on file loading. This
>> would need some way to disable the crc check and specify any other data.
>> It would probably be hard to do without changing existing commands.
> 
> Naw, this is weird. What do you think about my idea with the addr:size stuff?
>>
>> Rob
> 
> Best regards,
> Marek Vasut

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V6] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-15 21:10           ` Rob Herring
@ 2012-03-15 22:02             ` Rob Herring
  2012-03-16  0:53               ` Marek Vasut
  2012-03-16  7:16               ` Wolfgang Denk
  0 siblings, 2 replies; 48+ messages in thread
From: Rob Herring @ 2012-03-15 22:02 UTC (permalink / raw)
  To: u-boot

On 03/15/2012 04:10 PM, Rob Herring wrote:
> On 03/15/2012 03:29 PM, Marek Vasut wrote:
>> Dear Rob Herring,
>>
>>> On 03/15/2012 02:05 PM, Marek Vasut wrote:
>>>> Dear Rob Herring,
>>>>
>>>>> On 03/15/2012 02:52 AM, Marek Vasut wrote:
>>>>>> From: Marek Vasut <marek.vasut@gmail.com>
>>>>>>
>>>>>> This command boots Linux zImage from where the zImage is loaded to.
>>>>>> Passing initrd and fdt is supported.
>>>>>
>>>>> This is great! However, the initrd is still in the u-boot image format,
>>>>> right?
>>>>>
>>>>> If a raw initrd is supported, then we could get rid of flash-kernel on
>>>>> disk-based debian/ubuntu systems. The file size is known from the
>>>>> filesystem, but then needs to get to the bootz command somehow.
>>>>
>>>> Yes. Initrd still needs a bit of work, ideas?
>>>
>>
>> You lost some people in the Cc ;-)
>>
> 
> They weren't in the original email header, only in the commit log as Cc's.
> 
>>> How about:
>>>
>>> bootz <kern addr> [<fdt addr> [<initrd addr> [<initrd size>]]]
>>
>> What about bootz <kern addr> <initrd addr>[:<initrd size>] <fdt addr>
>>
>> example: bootz 0x12000000 0x13000000:0x40000 0x14000000
>>
> 
> Sure. That works for me.
> 
>>>
>>> I changed the order so the size can be optional without resorting to
>>> using a "-". Then no size means u-boot image format.
>>>
>>> File load commands would need to set loadsize env var.
>>
>> If you load kernel after initrd, that's screw things up.
> 
> Yes, but you already have to be aware of some commands which will change
> env vars. This has to be script-able to be useful. The only other way I
> see is adding a command to get the size of a file. Perhaps the ls
> commands when given a single file can do that.

Turns out there is already a filesize variable that gets set on file
load commands.

And RTFM didn't help as that one is not documented... ;)

Rob

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V6] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-15 22:02             ` Rob Herring
@ 2012-03-16  0:53               ` Marek Vasut
  2012-03-16  7:16               ` Wolfgang Denk
  1 sibling, 0 replies; 48+ messages in thread
From: Marek Vasut @ 2012-03-16  0:53 UTC (permalink / raw)
  To: u-boot

Dear Rob Herring,

> On 03/15/2012 04:10 PM, Rob Herring wrote:
> > On 03/15/2012 03:29 PM, Marek Vasut wrote:
> >> Dear Rob Herring,
> >> 
> >>> On 03/15/2012 02:05 PM, Marek Vasut wrote:
> >>>> Dear Rob Herring,
> >>>> 
> >>>>> On 03/15/2012 02:52 AM, Marek Vasut wrote:
> >>>>>> From: Marek Vasut <marek.vasut@gmail.com>
> >>>>>> 
> >>>>>> This command boots Linux zImage from where the zImage is loaded to.
> >>>>>> Passing initrd and fdt is supported.
> >>>>> 
> >>>>> This is great! However, the initrd is still in the u-boot image
> >>>>> format, right?
> >>>>> 
> >>>>> If a raw initrd is supported, then we could get rid of flash-kernel
> >>>>> on disk-based debian/ubuntu systems. The file size is known from the
> >>>>> filesystem, but then needs to get to the bootz command somehow.
> >>>> 
> >>>> Yes. Initrd still needs a bit of work, ideas?
> >> 
> >> You lost some people in the Cc ;-)
> > 
> > They weren't in the original email header, only in the commit log as
> > Cc's.
> > 
> >>> How about:
> >>> 
> >>> bootz <kern addr> [<fdt addr> [<initrd addr> [<initrd size>]]]
> >> 
> >> What about bootz <kern addr> <initrd addr>[:<initrd size>] <fdt addr>
> >> 
> >> example: bootz 0x12000000 0x13000000:0x40000 0x14000000
> > 
> > Sure. That works for me.
> > 
> >>> I changed the order so the size can be optional without resorting to
> >>> using a "-". Then no size means u-boot image format.
> >>> 
> >>> File load commands would need to set loadsize env var.
> >> 
> >> If you load kernel after initrd, that's screw things up.
> > 
> > Yes, but you already have to be aware of some commands which will change
> > env vars. This has to be script-able to be useful. The only other way I
> > see is adding a command to get the size of a file. Perhaps the ls
> > commands when given a single file can do that.
> 
> Turns out there is already a filesize variable that gets set on file
> load commands.
> 
> And RTFM didn't help as that one is not documented... ;)

Rob, I just send in support for RAW initrd. Can you give it a go?

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V6] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-15 22:02             ` Rob Herring
  2012-03-16  0:53               ` Marek Vasut
@ 2012-03-16  7:16               ` Wolfgang Denk
  2012-03-16 18:20                 ` Rob Herring
  1 sibling, 1 reply; 48+ messages in thread
From: Wolfgang Denk @ 2012-03-16  7:16 UTC (permalink / raw)
  To: u-boot

Dear Rob Herring,

In message <4F626711.8030808@gmail.com> you wrote:
>
> Turns out there is already a filesize variable that gets set on file
> load commands.
> 
> And RTFM didn't help as that one is not documented... ;)

Are you sure?  I'm pretty sure I can see it in the section of the
manual that deals with environment variables.  See
http://www.denx.de/wiki/view/DULG/UBootEnvVariables

You may have to scroll down to the end of the file.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Repeat after me:
Usenet is not a word processor; it's a medium where aesthetics count.
Mozilla is not a newsreader; it's a web browser.
Windows is not an operating system; it's a GUI on a program loader.
         -- Tom Christiansen in <6bq0g5$lr4$2@csnews.cs.colorado.edu>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V6] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-16  7:16               ` Wolfgang Denk
@ 2012-03-16 18:20                 ` Rob Herring
  0 siblings, 0 replies; 48+ messages in thread
From: Rob Herring @ 2012-03-16 18:20 UTC (permalink / raw)
  To: u-boot

On 03/16/2012 02:16 AM, Wolfgang Denk wrote:
> Dear Rob Herring,
> 
> In message <4F626711.8030808@gmail.com> you wrote:
>>
>> Turns out there is already a filesize variable that gets set on file
>> load commands.
>>
>> And RTFM didn't help as that one is not documented... ;)
> 
> Are you sure?  I'm pretty sure I can see it in the section of the
> manual that deals with environment variables.  See
> http://www.denx.de/wiki/view/DULG/UBootEnvVariables
> 
> You may have to scroll down to the end of the file.

Okay. I was referring to the README and any other docs in the source tree.

Regards,
Rob

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V6] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-15  7:52 ` [U-Boot] [PATCH V6] BOOT: Add "bootz" command to boot Linux zImage on ARM Marek Vasut
  2012-03-15 18:51   ` Rob Herring
@ 2012-03-30 20:59   ` Wolfgang Denk
  2012-03-31 19:10   ` Mike Frysinger
  2 siblings, 0 replies; 48+ messages in thread
From: Wolfgang Denk @ 2012-03-30 20:59 UTC (permalink / raw)
  To: u-boot

Dear Marek Vasut,

In message <1331797965-7415-1-git-send-email-marex@denx.de> you wrote:
> From: Marek Vasut <marek.vasut@gmail.com>
> 
> This command boots Linux zImage from where the zImage is loaded to. Passing
> initrd and fdt is supported.
> 
> Tested on i.MX28 based DENX M28EVK
> Tested on PXA270 based Voipac PXA270.
> 
> NOTE: This currently only supports ARM, but other architectures can be easily
> added by defining bootz_setup().
> 
> Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> Cc: Tom Warren <TWarren@nvidia.com>
> Cc: albert.u.boot at aribaud.net
> Cc: afleming at gmail.com,
> Cc: Simon Glass <sjg@chromium.org>,
> Cc: Stephen Warren <swarren@nvidia.com>
> Cc: Nicolas Pitre <nico@fluxnic.net>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Detlev Zundel <dzu@denx.de>
> ---
>  README                   |    8 +++
>  arch/arm/lib/bootm.c     |   30 ++++++++++
>  common/cmd_bootm.c       |  141 +++++++++++++++++++++++++++++++++++++++++++---
>  include/config_cmd_all.h |    1 +
>  4 files changed, 171 insertions(+), 9 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Hi there! This is just a note from me, to you, to tell you, the  per-
son  reading this note, that I can't think up any more famous quotes,
jokes, nor bizarre stories, so you may as well go home.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V6] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-15  7:52 ` [U-Boot] [PATCH V6] BOOT: Add "bootz" command to boot Linux zImage on ARM Marek Vasut
  2012-03-15 18:51   ` Rob Herring
  2012-03-30 20:59   ` Wolfgang Denk
@ 2012-03-31 19:10   ` Mike Frysinger
  2012-03-31 19:27     ` Marek Vasut
  2 siblings, 1 reply; 48+ messages in thread
From: Mike Frysinger @ 2012-03-31 19:10 UTC (permalink / raw)
  To: u-boot

On Thursday 15 March 2012 03:52:45 Marek Vasut wrote:
> --- a/common/cmd_bootm.c
> +++ b/common/cmd_bootm.c
> 
> -static void bootm_start_lmb(void)
> -{
>  #ifdef CONFIG_LMB
> +static void boot_start_lmb(bootm_headers_t *images)
> +{
>  	ulong		mem_start;
>  	phys_size_t	mem_size;
> 
> -	lmb_init(&images.lmb);
> +	lmb_init(&images->lmb);
> 
>  	mem_start = getenv_bootm_low();
>  	mem_size = getenv_bootm_size();
> 
> -	lmb_add(&images.lmb, (phys_addr_t)mem_start, mem_size);
> +	lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);
> 
> -	arch_lmb_reserve(&images.lmb);
> -	board_lmb_reserve(&images.lmb);
> +	arch_lmb_reserve(&images->lmb);
> +	board_lmb_reserve(&images->lmb);
> +}
>  #else
> -# define lmb_reserve(lmb, base, size)
> +static inline void boot_start_lmb(bootm_headers_t *images) { }
>  #endif
> -}

this breaks all non-lmb configs.  before, lmb_reverse() was stubbed out, but 
now it's not, leading to build failures:

cmd_bootm.c: In function ?do_bootm_subcommand?:
cmd_bootm.c:518:23: error: ?bootm_headers_t? has no member named ?lmb?
cmd_bootm.c: In function ?do_bootm?:
cmd_bootm.c:665:21: error: ?bootm_headers_t? has no member named ?lmb?
make[2]: *** [cmd_bootm.o] Error 1
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120331/853a7adb/attachment.pgp>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V6] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-31 19:10   ` Mike Frysinger
@ 2012-03-31 19:27     ` Marek Vasut
  2012-04-01 11:25       ` Graeme Russ
  0 siblings, 1 reply; 48+ messages in thread
From: Marek Vasut @ 2012-03-31 19:27 UTC (permalink / raw)
  To: u-boot

Dear Mike Frysinger,

> On Thursday 15 March 2012 03:52:45 Marek Vasut wrote:
> > --- a/common/cmd_bootm.c
> > +++ b/common/cmd_bootm.c
> > 
> > -static void bootm_start_lmb(void)
> > -{
> > 
> >  #ifdef CONFIG_LMB
> > 
> > +static void boot_start_lmb(bootm_headers_t *images)
> > +{
> > 
> >  	ulong		mem_start;
> >  	phys_size_t	mem_size;
> > 
> > -	lmb_init(&images.lmb);
> > +	lmb_init(&images->lmb);
> > 
> >  	mem_start = getenv_bootm_low();
> >  	mem_size = getenv_bootm_size();
> > 
> > -	lmb_add(&images.lmb, (phys_addr_t)mem_start, mem_size);
> > +	lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);
> > 
> > -	arch_lmb_reserve(&images.lmb);
> > -	board_lmb_reserve(&images.lmb);
> > +	arch_lmb_reserve(&images->lmb);
> > +	board_lmb_reserve(&images->lmb);
> > +}
> > 
> >  #else
> > 
> > -# define lmb_reserve(lmb, base, size)
> > +static inline void boot_start_lmb(bootm_headers_t *images) { }
> > 
> >  #endif
> > 
> > -}
> 
> this breaks all non-lmb configs.  before, lmb_reverse() was stubbed out,
> but now it's not, leading to build failures:
> 
> cmd_bootm.c: In function ?do_bootm_subcommand?:
> cmd_bootm.c:518:23: error: ?bootm_headers_t? has no member named ?lmb?
> cmd_bootm.c: In function ?do_bootm?:
> cmd_bootm.c:665:21: error: ?bootm_headers_t? has no member named ?lmb?
> make[2]: *** [cmd_bootm.o] Error 1
> -mike

Well tested on arm/ppc ... can you submit patch for these platforms please ?

I'll be able to run mips/x86 next week.

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V6] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-03-31 19:27     ` Marek Vasut
@ 2012-04-01 11:25       ` Graeme Russ
  2012-04-01 14:02         ` Marek Vasut
  0 siblings, 1 reply; 48+ messages in thread
From: Graeme Russ @ 2012-04-01 11:25 UTC (permalink / raw)
  To: u-boot

Hi Marek,

On 04/01/2012 05:27 AM, Marek Vasut wrote:
> Dear Mike Frysinger,
> 
>> On Thursday 15 March 2012 03:52:45 Marek Vasut wrote:
>>> --- a/common/cmd_bootm.c
>>> +++ b/common/cmd_bootm.c
>>>
>>> -static void bootm_start_lmb(void)
>>> -{
>>>
>>>  #ifdef CONFIG_LMB
>>>
>>> +static void boot_start_lmb(bootm_headers_t *images)
>>> +{
>>>
>>>  	ulong		mem_start;
>>>  	phys_size_t	mem_size;
>>>
>>> -	lmb_init(&images.lmb);
>>> +	lmb_init(&images->lmb);
>>>
>>>  	mem_start = getenv_bootm_low();
>>>  	mem_size = getenv_bootm_size();
>>>
>>> -	lmb_add(&images.lmb, (phys_addr_t)mem_start, mem_size);
>>> +	lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);
>>>
>>> -	arch_lmb_reserve(&images.lmb);
>>> -	board_lmb_reserve(&images.lmb);
>>> +	arch_lmb_reserve(&images->lmb);
>>> +	board_lmb_reserve(&images->lmb);
>>> +}
>>>
>>>  #else
>>>
>>> -# define lmb_reserve(lmb, base, size)
>>> +static inline void boot_start_lmb(bootm_headers_t *images) { }
>>>
>>>  #endif
>>>
>>> -}
>>
>> this breaks all non-lmb configs.  before, lmb_reverse() was stubbed out,
>> but now it's not, leading to build failures:
>>
>> cmd_bootm.c: In function ?do_bootm_subcommand?:
>> cmd_bootm.c:518:23: error: ?bootm_headers_t? has no member named ?lmb?
>> cmd_bootm.c: In function ?do_bootm?:
>> cmd_bootm.c:665:21: error: ?bootm_headers_t? has no member named ?lmb?
>> make[2]: *** [cmd_bootm.o] Error 1
>> -mike
> 
> Well tested on arm/ppc ... can you submit patch for these platforms please ?

I think the 'You Break, You Fix' rule applies ;)

> I'll be able to run mips/x86 next week.

Dang, I need it building now :P

I'm going to but in some really dodgy hacks just to get my build going
again, but I would appreciate a fix ASAP

Regards,

Graeme

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [U-Boot] [PATCH V6] BOOT: Add "bootz" command to boot Linux zImage on ARM
  2012-04-01 11:25       ` Graeme Russ
@ 2012-04-01 14:02         ` Marek Vasut
  0 siblings, 0 replies; 48+ messages in thread
From: Marek Vasut @ 2012-04-01 14:02 UTC (permalink / raw)
  To: u-boot

Dear Graeme Russ,

> Hi Marek,
> 
> On 04/01/2012 05:27 AM, Marek Vasut wrote:
> > Dear Mike Frysinger,
> > 
> >> On Thursday 15 March 2012 03:52:45 Marek Vasut wrote:
> >>> --- a/common/cmd_bootm.c
> >>> +++ b/common/cmd_bootm.c
> >>> 
> >>> -static void bootm_start_lmb(void)
> >>> -{
> >>> 
> >>>  #ifdef CONFIG_LMB
> >>> 
> >>> +static void boot_start_lmb(bootm_headers_t *images)
> >>> +{
> >>> 
> >>>  	ulong		mem_start;
> >>>  	phys_size_t	mem_size;
> >>> 
> >>> -	lmb_init(&images.lmb);
> >>> +	lmb_init(&images->lmb);
> >>> 
> >>>  	mem_start = getenv_bootm_low();
> >>>  	mem_size = getenv_bootm_size();
> >>> 
> >>> -	lmb_add(&images.lmb, (phys_addr_t)mem_start, mem_size);
> >>> +	lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);
> >>> 
> >>> -	arch_lmb_reserve(&images.lmb);
> >>> -	board_lmb_reserve(&images.lmb);
> >>> +	arch_lmb_reserve(&images->lmb);
> >>> +	board_lmb_reserve(&images->lmb);
> >>> +}
> >>> 
> >>>  #else
> >>> 
> >>> -# define lmb_reserve(lmb, base, size)
> >>> +static inline void boot_start_lmb(bootm_headers_t *images) { }
> >>> 
> >>>  #endif
> >>> 
> >>> -}
> >> 
> >> this breaks all non-lmb configs.  before, lmb_reverse() was stubbed out,
> >> but now it's not, leading to build failures:
> >> 
> >> cmd_bootm.c: In function ?do_bootm_subcommand?:
> >> cmd_bootm.c:518:23: error: ?bootm_headers_t? has no member named ?lmb?
> >> cmd_bootm.c: In function ?do_bootm?:
> >> cmd_bootm.c:665:21: error: ?bootm_headers_t? has no member named ?lmb?
> >> make[2]: *** [cmd_bootm.o] Error 1
> >> -mike
> > 
> > Well tested on arm/ppc ... can you submit patch for these platforms
> > please ?
> 
> I think the 'You Break, You Fix' rule applies ;)
> 
> > I'll be able to run mips/x86 next week.
> 
> Dang, I need it building now :P
> 
> I'm going to but in some really dodgy hacks just to get my build going
> again, but I would appreciate a fix ASAP
> 
> Regards,
> 
> Graeme

Sent.

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 48+ messages in thread

end of thread, other threads:[~2012-04-01 14:02 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <Message-Id: <1331696876-20903-1-git-send-email-marex@denx.de>
2012-03-15  7:52 ` [U-Boot] [PATCH V6] BOOT: Add "bootz" command to boot Linux zImage on ARM Marek Vasut
2012-03-15 18:51   ` Rob Herring
2012-03-15 19:05     ` Marek Vasut
2012-03-15 19:48       ` Rob Herring
2012-03-15 20:29         ` Marek Vasut
2012-03-15 21:10           ` Rob Herring
2012-03-15 22:02             ` Rob Herring
2012-03-16  0:53               ` Marek Vasut
2012-03-16  7:16               ` Wolfgang Denk
2012-03-16 18:20                 ` Rob Herring
2012-03-15 20:39         ` Wolfgang Denk
2012-03-30 20:59   ` Wolfgang Denk
2012-03-31 19:10   ` Mike Frysinger
2012-03-31 19:27     ` Marek Vasut
2012-04-01 11:25       ` Graeme Russ
2012-04-01 14:02         ` Marek Vasut
     [not found] <Message-Id: <1331689093-19211-1-git-send-email-marex@denx.de>
2012-03-14  3:47 ` [U-Boot] [PATCH V5] " Marek Vasut
2012-03-14  5:07   ` Mike Frysinger
2012-03-14  5:38     ` Marek Vasut
2012-03-14 18:35       ` Mike Frysinger
2012-03-14 19:27         ` Marek Vasut
2012-03-15 16:09       ` Wolfgang Denk
2012-03-15 17:08         ` Marek Vasut
2012-03-15 17:36         ` Mike Frysinger
2012-03-15 17:40           ` Marek Vasut
2012-03-14 16:45   ` Stephen Warren
2012-03-14 17:23     ` Marek Vasut
     [not found] <Message-Id: <1331588061-21546-1-git-send-email-marex@denx.de>
2012-03-12 21:34 ` [U-Boot] [PATCH V3] BOOT: Add "bootz" command to boot Linux zImage Marek Vasut
2012-03-12 22:03   ` Wolfgang Denk
2012-03-12 22:08     ` Marek Vasut
2012-03-12 22:42       ` Wolfgang Denk
2012-03-13  0:13         ` Marek Vasut
2012-03-13  0:22           ` Graeme Russ
2012-03-13  4:30             ` Wolfgang Denk
2012-03-13  4:46               ` Graeme Russ
2012-03-15 15:03                 ` Wolfgang Denk
2012-03-15 17:08                   ` Marek Vasut
2012-03-13  4:47               ` Marek Vasut
2012-03-15 15:06                 ` Wolfgang Denk
2012-03-15 17:18                   ` Marek Vasut
2012-03-13  4:25           ` Wolfgang Denk
2012-03-13  4:50             ` Marek Vasut
2012-03-13  5:32               ` Graeme Russ
2012-03-13  2:03   ` Mike Frysinger
2012-03-14  1:38 ` [U-Boot] [PATCH V4] BOOT: Add "bootz" command to boot Linux zImage on ARM Marek Vasut
2012-03-14  2:03   ` Mike Frysinger
2012-03-14  2:40     ` Marek Vasut
2012-03-14  3:07       ` Mike Frysinger

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.