[U-Boot] [PATCH 1/2] image: add support for Android's boot image format

Wolfgang Denk wd at denx.de
Mon Nov 21 21:19:07 CET 2011


Dear Sebastian Andrzej Siewior,

In message <1321884575-2993-2-git-send-email-bigeasy at linutronix.de> you wrote:
> This patch adds support for the Android boot-image format. The header
> file is from the Android project and got slightly alterted so the struct +
> its defines are not generic but have something like a namespace. The
> header file is from bootloader/legacy/include/boot/bootimg.h. The header
> parsing has been written from scratch and I looked at
> bootloader/legacy/usbloader/usbloader.c for some details.
> The image contains the physical address (load address) of the kernel and
> ramdisk. This address is considered only for the kernel image.
> The "second image" is currently ignored. I haven't found anything that
> is creating this.

Please provide _exact_ reference where this code has been copied from,
see bullet 4 etc. at
http://www.denx.de/wiki/view/U-Boot/Patches#Attributing_Code_Copyrights_Sign

Also please provide exact information about the applicable licenses
for this copied code.

...
>  	/* get image parameters */
> -	switch (genimg_get_format(os_hdr)) {
> +	img_type = genimg_get_format(os_hdr);
> +	switch (img_type) {
...
> +#ifdef CONFIG_ANDROID_BOOT_IMAGE
> +	} else if (img_type == IMAGE_FORMAT_ANDROID) {
> +		images.ep = images.os.load;
> +#endif

Why don't you handle the Andoid image case inside the switch() ?

> +#ifdef CONFIG_ANDROID_BOOT_IMAGE
> +static char andr_tmp_str[ANDR_BOOT_ARGS_SIZE + 1];
> +static int android_image_get_kernel(struct andr_img_hdr *hdr, int verify)
> +{
> +	/*
> +	 * Not all Android tools use the id field for signing the image with
> +	 * sha1 (or anything) so we don't check it. It is not obvious that the
> +	 * string is null terminated so we take care of this.
> +	 */
> +	strncpy(andr_tmp_str, hdr->name, ANDR_BOOT_NAME_SIZE);
> +	andr_tmp_str[ANDR_BOOT_NAME_SIZE] = '\0';
> +	if (strlen(andr_tmp_str))
> +		printf("Android's image name: %s\n", andr_tmp_str);
> +
> +	printf("Kernel load addr 0x%08x size %u KiB\n",
> +			hdr->kernel_addr, DIV_ROUND_UP(hdr->kernel_size, 1024));
> +	strncpy(andr_tmp_str, hdr->cmdline, ANDR_BOOT_ARGS_SIZE);
> +	andr_tmp_str[ANDR_BOOT_ARGS_SIZE] = '\0';
> +	if (strlen(andr_tmp_str)) {
> +		printf("Kernel command line: %s\n", andr_tmp_str);
> +		setenv("bootargs", andr_tmp_str);
> +	}
> +	if (hdr->ramdisk_size)
> +		printf("RAM disk load addr 0x%08x size %u KiB\n",
> +				hdr->ramdisk_addr,
> +				DIV_ROUND_UP(hdr->ramdisk_size, 1024));
> +	return 0;
> +}
> +#endif

This and similar Android image related code shoudl eventually go into
a separate file, exposing only a few functions.


> +#ifdef CONFIG_ANDROID_BOOT_IMAGE
> +	if (format == IMAGE_FORMAT_INVALID) {
> +		const struct andr_img_hdr *ahdr = img_addr;
>  
> +		if (!memcmp(ANDR_BOOT_MAGIC, ahdr->magic, ANDR_BOOT_MAGIC_SIZE))
> +			format = IMAGE_FORMAT_ANDROID;
> +	}
> +#endif

This is all we have for testing for a valid image?

> index 0000000..b231b66
> --- /dev/null
> +++ b/include/android_image.h
> @@ -0,0 +1,89 @@
> +/*
> + * This is from the Android Project,
> + * bootloader/legacy/include/boot/bootimg.h
> + *
> + * Copyright (C) 2008 The Android Open Source Project
> + * All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + *  * Redistributions of source code must retain the above copyright
> + *    notice, this list of conditions and the following disclaimer.
> + *  * Redistributions in binary form must reproduce the above copyright
> + *    notice, this list of conditions and the following disclaimer in
> + *    the documentation and/or other materials provided with the
> + *    distribution.

Sorry, but this is not GPL compatible.



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
Making files is easy under  the  UNIX  operating  system.  Therefore,
users  tend  to  create  numerous  files  using large amounts of file
space. It has been said that the only standard thing about  all  UNIX
systems  is  the  message-of-the-day  telling users to clean up their
files.                             - System V.2 administrator's guide


More information about the U-Boot mailing list