Patchwork [1/1] fs: add uimage support w/ example for cpio

login
register
mail settings
Submitter Spenser Gilliland
Date April 17, 2013, 8:15 p.m.
Message ID <1366229731-13024-1-git-send-email-spenser@gillilanding.com>
Download mbox | patch
Permalink /patch/237358/
State Superseded
Headers show

Comments

Spenser Gilliland - April 17, 2013, 8:15 p.m.
From: Spenser Gilliland <Spenser309@gmail.com>

Adds uimage support for various root filesystems.  Uimage support is needed when
using the bootm command in uboot.  This provides both a simple infrastructure
similar to the current BR2_TARGET_ROOTFS_$(2)_GZ for adding compression. To
define the a rootfs should have a UIMAGE wrapper simply create the
BR2_TARGET_ROOTFS_$(2)_UIMAGE symbol.

Signed-off-by: Spenser Gilliland <spenser@gillilanding.com>
---
 fs/common.mk      |   20 +++++++++++++++++++-
 fs/cpio/Config.in |    7 +++++++
 2 files changed, 26 insertions(+), 1 deletion(-)
Spenser Gilliland - April 17, 2013, 8:19 p.m.
Soren,

Yes, you were right.  The patch did not have the whitespace fixes.
Either git format-patch doesn't overwrite old patches or I used the
old ref when I rebased for the whitespace fix.  Still very new to git
send-email and format-patch.

Anyways my bad; thanks for catching the error.

Spenser

On Wed, Apr 17, 2013 at 3:15 PM, Spenser Gilliland
<spenser@gillilanding.com> wrote:
> From: Spenser Gilliland <Spenser309@gmail.com>
>
> Adds uimage support for various root filesystems.  Uimage support is needed when
> using the bootm command in uboot.  This provides both a simple infrastructure
> similar to the current BR2_TARGET_ROOTFS_$(2)_GZ for adding compression. To
> define the a rootfs should have a UIMAGE wrapper simply create the
> BR2_TARGET_ROOTFS_$(2)_UIMAGE symbol.
>
> Signed-off-by: Spenser Gilliland <spenser@gillilanding.com>
> ---
>  fs/common.mk      |   20 +++++++++++++++++++-
>  fs/cpio/Config.in |    7 +++++++
>  2 files changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/fs/common.mk b/fs/common.mk
> index a0b7b39..10520bc 100644
> --- a/fs/common.mk
> +++ b/fs/common.mk
> @@ -31,6 +31,8 @@
>  # BR2_TARGET_ROOTFS_$(FSTYPE)_LZMA exist and are enabled, then the
>  # macro will automatically generate a compressed filesystem image.
>
> +MKIMAGE_RAMDISK = $(HOST_DIR)/usr/bin/mkimage -A $(BR2_ARCH) -T ramdisk -C $(1) -d $(2) $(2).uboot
> +
>  FAKEROOT_SCRIPT = $(BUILD_DIR)/_fakeroot.fs
>  FULL_DEVICE_TABLE = $(BUILD_DIR)/_device_table.txt
>  ROOTFS_DEVICE_TABLES = $(call qstrip,$(BR2_ROOTFS_DEVICE_TABLE) \
> @@ -39,7 +41,9 @@ ROOTFS_DEVICE_TABLES = $(call qstrip,$(BR2_ROOTFS_DEVICE_TABLE) \
>  define ROOTFS_TARGET_INTERNAL
>
>  # extra deps
> -ROOTFS_$(2)_DEPENDENCIES += host-fakeroot host-makedevs $$(if $$(BR2_TARGET_ROOTFS_$(2)_LZMA),host-lzma)
> +ROOTFS_$(2)_DEPENDENCIES += host-fakeroot host-makedevs \
> +   $$(if $$(BR2_TARGET_ROOTFS_$(2)_LZMA),host-lzma) \
> +   $$(if $$(BR2_TARGET_ROOTFS_$(2)_UIMAGE),host-uboot-tools)
>
>  $$(BINARIES_DIR)/rootfs.$(1): $$(ROOTFS_$(2)_DEPENDENCIES)
>         @$$(call MESSAGE,"Generating root filesystem image rootfs.$(1)")
> @@ -70,6 +74,20 @@ endif
>  ifeq ($$(BR2_TARGET_ROOTFS_$(2)_LZMA),y)
>         $$(LZMA) -9 -c $$@ > $$@.lzma
>  endif
> +ifeq ($$(BR2_TARGET_ROOTFS_$(2)_UIMAGE),y)
> +ifeq ($$(BR2_TARGET_ROOTFS_$(2)_NONE),y)
> +       $$(call MKIMAGE_RAMDISK,none,$$@)
> +endif
> +ifeq ($$(BR2_TARGET_ROOTFS_$(2)_GZIP),y)
> +       $$(call MKIMAGE_RAMDISK,gzip,$$@.gz)
> +endif
> +ifeq ($$(BR2_TARGET_ROOTFS_$(2)_BZIP2),y)
> +       $$(call MKIMAGE_RAMDISK,bzip2,$$@.bz2)
> +endif
> +ifeq ($$(BR2_TARGET_ROOTFS_$(2)_LZMA),y)
> +       $$(call MKIMAGE_RAMDISK,lzma,$$@.lzma)
> +endif
> +endif
>
>  rootfs-$(1)-show-depends:
>         @echo $$(ROOTFS_$(2)_DEPENDENCIES)
> diff --git a/fs/cpio/Config.in b/fs/cpio/Config.in
> index 0669a44..036862c 100644
> --- a/fs/cpio/Config.in
> +++ b/fs/cpio/Config.in
> @@ -5,6 +5,13 @@ config BR2_TARGET_ROOTFS_CPIO
>           used for an initial RAM filesystem that is passed to the kernel
>           by the bootloader.
>
> +config BR2_TARGET_ROOTFS_CPIO_UIMAGE
> +       bool "Add U-Boot header to the root filesystem"
> +       depends on BR2_TARGET_ROOTFS_CPIO
> +       help
> +         Add a u-boot header to the cpio root filesystem.  This allows
> +         the image to be booted by the bootm command in uboot.
> +
>  choice
>          prompt "Compression method"
>          default BR2_TARGET_ROOTFS_CPIO_NONE
> --
> 1.7.9.5
>
Soren Brinkmann - April 17, 2013, 8:47 p.m.
On Wed, Apr 17, 2013 at 03:15:30PM -0500, Spenser Gilliland wrote:
> From: Spenser Gilliland <Spenser309@gmail.com>
> 
> Adds uimage support for various root filesystems.  Uimage support is needed when
> using the bootm command in uboot.  This provides both a simple infrastructure
> similar to the current BR2_TARGET_ROOTFS_$(2)_GZ for adding compression. To
> define the a rootfs should have a UIMAGE wrapper simply create the
> BR2_TARGET_ROOTFS_$(2)_UIMAGE symbol.
> 
> Signed-off-by: Spenser Gilliland <spenser@gillilanding.com>
Tested-by: Soren Brinkmann <soren.brinkmann@xilinx.com>

	Sören
Soren Brinkmann - April 17, 2013, 8:56 p.m.
Hi Spenser,

On Wed, Apr 17, 2013 at 03:19:40PM -0500, Spenser Gilliland wrote:
> Soren,
> 
> Yes, you were right.  The patch did not have the whitespace fixes.
> Either git format-patch doesn't overwrite old patches or I used the
> old ref when I rebased for the whitespace fix.  Still very new to git
> send-email and format-patch.
Okay, then as further tips:
It is usually good practice to mark new revisions of a patch as such, by
adding a 'v2' (for the second version) to the subject. Either by specifying
'--subject-prefix' or on later git versions '--reroll-count' when running
format-patch.

And a changelog should be sent with the patch and usually goes after the
line with the three dashes in the same email. The text after the '---'
is not part of the commit message.

	Regards,
	Sören
Spenser Gilliland - April 17, 2013, 8:57 p.m.
Soren,

Thanks for the tips.  I appreciate the tips. I'll be sure to use those
options in the future.

Spenser

On Wed, Apr 17, 2013 at 3:56 PM, Sören Brinkmann
<soren.brinkmann@xilinx.com> wrote:
> Hi Spenser,
>
> On Wed, Apr 17, 2013 at 03:19:40PM -0500, Spenser Gilliland wrote:
>> Soren,
>>
>> Yes, you were right.  The patch did not have the whitespace fixes.
>> Either git format-patch doesn't overwrite old patches or I used the
>> old ref when I rebased for the whitespace fix.  Still very new to git
>> send-email and format-patch.
> Okay, then as further tips:
> It is usually good practice to mark new revisions of a patch as such, by
> adding a 'v2' (for the second version) to the subject. Either by specifying
> '--subject-prefix' or on later git versions '--reroll-count' when running
> format-patch.
>
> And a changelog should be sent with the patch and usually goes after the
> line with the three dashes in the same email. The text after the '---'
> is not part of the commit message.
>
>         Regards,
>         Sören
>
>

Patch

diff --git a/fs/common.mk b/fs/common.mk
index a0b7b39..10520bc 100644
--- a/fs/common.mk
+++ b/fs/common.mk
@@ -31,6 +31,8 @@ 
 # BR2_TARGET_ROOTFS_$(FSTYPE)_LZMA exist and are enabled, then the
 # macro will automatically generate a compressed filesystem image.
 
+MKIMAGE_RAMDISK = $(HOST_DIR)/usr/bin/mkimage -A $(BR2_ARCH) -T ramdisk -C $(1) -d $(2) $(2).uboot
+
 FAKEROOT_SCRIPT = $(BUILD_DIR)/_fakeroot.fs
 FULL_DEVICE_TABLE = $(BUILD_DIR)/_device_table.txt
 ROOTFS_DEVICE_TABLES = $(call qstrip,$(BR2_ROOTFS_DEVICE_TABLE) \
@@ -39,7 +41,9 @@  ROOTFS_DEVICE_TABLES = $(call qstrip,$(BR2_ROOTFS_DEVICE_TABLE) \
 define ROOTFS_TARGET_INTERNAL
 
 # extra deps
-ROOTFS_$(2)_DEPENDENCIES += host-fakeroot host-makedevs $$(if $$(BR2_TARGET_ROOTFS_$(2)_LZMA),host-lzma)
+ROOTFS_$(2)_DEPENDENCIES += host-fakeroot host-makedevs \
+   $$(if $$(BR2_TARGET_ROOTFS_$(2)_LZMA),host-lzma) \
+   $$(if $$(BR2_TARGET_ROOTFS_$(2)_UIMAGE),host-uboot-tools)
 
 $$(BINARIES_DIR)/rootfs.$(1): $$(ROOTFS_$(2)_DEPENDENCIES)
 	@$$(call MESSAGE,"Generating root filesystem image rootfs.$(1)")
@@ -70,6 +74,20 @@  endif
 ifeq ($$(BR2_TARGET_ROOTFS_$(2)_LZMA),y)
 	$$(LZMA) -9 -c $$@ > $$@.lzma
 endif
+ifeq ($$(BR2_TARGET_ROOTFS_$(2)_UIMAGE),y)
+ifeq ($$(BR2_TARGET_ROOTFS_$(2)_NONE),y)
+	$$(call MKIMAGE_RAMDISK,none,$$@)
+endif
+ifeq ($$(BR2_TARGET_ROOTFS_$(2)_GZIP),y)
+	$$(call MKIMAGE_RAMDISK,gzip,$$@.gz)
+endif
+ifeq ($$(BR2_TARGET_ROOTFS_$(2)_BZIP2),y)
+	$$(call MKIMAGE_RAMDISK,bzip2,$$@.bz2)
+endif
+ifeq ($$(BR2_TARGET_ROOTFS_$(2)_LZMA),y)
+	$$(call MKIMAGE_RAMDISK,lzma,$$@.lzma)
+endif
+endif
 
 rootfs-$(1)-show-depends:
 	@echo $$(ROOTFS_$(2)_DEPENDENCIES)
diff --git a/fs/cpio/Config.in b/fs/cpio/Config.in
index 0669a44..036862c 100644
--- a/fs/cpio/Config.in
+++ b/fs/cpio/Config.in
@@ -5,6 +5,13 @@  config BR2_TARGET_ROOTFS_CPIO
 	  used for an initial RAM filesystem that is passed to the kernel
 	  by the bootloader.
 
+config BR2_TARGET_ROOTFS_CPIO_UIMAGE
+	bool "Add U-Boot header to the root filesystem"
+	depends on BR2_TARGET_ROOTFS_CPIO
+	help
+	  Add a u-boot header to the cpio root filesystem.  This allows
+	  the image to be booted by the bootm command in uboot.
+
 choice
         prompt "Compression method"
         default BR2_TARGET_ROOTFS_CPIO_NONE