[U-Boot] [RFC] Extend 'bootm' to support Linux kernel generated images

Tom Rini trini at ti.com
Wed May 21 21:58:24 CEST 2014


Hey all,

Something that Rob mentioned to me at ELC, and others have mentioned
before is that it would be nice if 'bootm' (which says "boot application
image stored in memory" in the help, even) would just work with zImage
or Image or whatever is spit directly out of the kernel.

The following shows roughly what I'm thinking about how we would handle
this:

diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index 0706086..14319b2 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -332,6 +332,17 @@ struct zimage_header {
 
 #define	LINUX_ARM_ZIMAGE_MAGIC	0x016f2818
 
+int check_image_linux_kernel(ulong image)
+{
+	struct zimage_header *zi;
+
+	zi = (struct zimage_header *)map_sysmem(image, 0);
+	if (zi->zi_magic == LINUX_ARM_ZIMAGE_MAGIC)
+		return 0;
+
+	return 1;
+}
+
 int bootz_setup(ulong image, ulong *start, ulong *end)
 {
 	struct zimage_header *zi;
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index 30fd643..6bed825 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -274,6 +274,11 @@ static int bootm_find_os(cmd_tbl_t *cmdtp, int flag, int argc,
 		}
 		break;
 #endif
+#ifdef CONFIG_BOOTM_LINUX_RAW
+	case IMAGE_FORMAT_LINUX:
+		/* Call something to set images.os.things */
+		return 0;
+#endif
 	default:
 		puts("ERROR: unknown image format type!\n");
 		return 1;
@@ -1002,6 +1007,11 @@ static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc,
 		images->fit_noffset_os = os_noffset;
 		break;
 #endif
+#ifdef CONFIG_BOOTM_LINUX_RAW
+	case IMAGE_FORMAT_LINUX:
+		/* Set loadaddr? */
+		return 0;
+#endif
 	default:
 		printf("Wrong Image Format for %s command\n", cmdtp->name);
 		bootstage_error(BOOTSTAGE_ID_FIT_KERNEL_INFO);
diff --git a/common/image.c b/common/image.c
index fcc5a9c..32237a3 100644
--- a/common/image.c
+++ b/common/image.c
@@ -665,6 +665,10 @@ int genimg_get_format(const void *img_addr)
 			format = IMAGE_FORMAT_FIT;
 	}
 #endif
+#ifdef CONFIG_BOOTM_LINUX_RAW
+	if (check_image_linux_kernel((ulong)img_addr) == 0)
+		return IMAGE_FORMAT_LINUX;
+#endif
 
 	return format;
 }
diff --git a/include/image.h b/include/image.h
index b278778..985c6f0 100644
--- a/include/image.h
+++ b/include/image.h
@@ -411,6 +411,7 @@ enum fit_load_op {
 #ifndef USE_HOSTCC
 /* Image format types, returned by _get_format() routine */
 #define IMAGE_FORMAT_INVALID	0x00
+#define IMAGE_FORMAT_LINUX	0xFF	/* Linux kernel defined formats */
 #define IMAGE_FORMAT_LEGACY	0x01	/* legacy image_header based format */
 #define IMAGE_FORMAT_FIT	0x02	/* new, libfdt based format */
 
@@ -660,6 +661,15 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob,
 int image_setup_linux(bootm_headers_t *images);
 
 /**
+ * Check if the given location has some form of Linux-kernel generated
+ * image.
+ *
+ * @param image		Potential image location
+ * @return 0 if OK, 1 if not a known Linux-kernel generated image.
+ */
+int check_image_linux_kernel(ulong image);
+
+/**
  * bootz_setup() - Extract stat and size of a Linux xImage
  *
  * @image: Address of image


It of course doesn't work and just shows where I think we would need to
fill things in and probably provide some __weak functions for other
arches.  Looking over how we do bootz today, and how I wrote booti for
arm64, it should be possible to do the correct callouts at the correct
places for "oh, we don't have a legacy or FIT header, we have a per
Linux architecture defined header".

What does everyone think about extending things in this direction?

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140521/9b392459/attachment.pgp>


More information about the U-Boot mailing list