[U-Boot] [PATCH V3] BOOT: Add "bootz" command to boot Linux zImage

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@aribaud.net Cc: afleming@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@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) {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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
participants (5)
-
Graeme Russ
-
Marek Vasut
-
Marek Vasut
-
Mike Frysinger
-
Wolfgang Denk