Skip to contentSkip to conversation

Add support for Flattened Image Trees

PATCH Superseded Yegor Yefremov 3 participants 7 messages Sep 18, 2014 – Sep 22, 2014 VFS

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 Add support for Flattened Image Trees

This patch provides an option to specify a FIT source file (*.its), that will usually be stored in a board directory, and the resulting blob file name (*.itb).

---
Changes:
v3: fix syntax errors, remove itb name, add uboot-tools dependency
v2: moved configuration to fs infra instead of linux

 fs/Config.in     |  1 +
 fs/fit/Config.in | 23 +++++++++++++++++++++++
 fs/fit/fit.mk    | 23 +++++++++++++++++++++++
 3 files changed, 47 insertions(+)
 create mode 100644 fs/fit/Config.in
 create mode 100644 fs/fit/fit.mk
fs/Config.in +1 -0
index 5853113..8d882d0 100644
@@ -4,6 +4,7 @@ source "fs/cloop/Config.in"
 source "fs/cpio/Config.in"
 source "fs/cramfs/Config.in"
 source "fs/ext2/Config.in"
+source "fs/fit/Config.in"
 source "fs/initramfs/Config.in"
 source "fs/iso9660/Config.in"
 source "fs/jffs2/Config.in"
fs/fit/Config.in new file +23 -0
new file mode 100644
index 0000000..12e977b
@@ -0,0 +1,23 @@
+config BR2_TARGET_ROOTFS_FIT
+	bool "Flattened Image Tree support"
+	select BR2_PACKAGE_HOST_UBOOT_TOOLS
+	help
+	  Compile a flattened image tree source into a flattened
+	  image tree blob. Specify the *.its file to compile in the
+	  options below.
+
+if BR2_TARGET_ROOTFS_FIT
+
+config BR2_FIT_PATH
+	string "Flattened Image Tree source file path"
+	help
+	  Path to the image tree source files.
+
+config BR2_FIT_INSTALL_TARGET
+	bool "Install Flattened Image Tree blob to /boot in target"
+	depends on !BR2_TARGET_ROOTFS_INITRAMFS
+	help
+	  Select this option to have the FIT image installed to
+	  /boot in the target root filesystem.
+
+endif
fs/fit/fit.mk new file +23 -0
new file mode 100644
index 0000000..2283cd7
@@ -0,0 +1,23 @@
+################################################################################
+#
+# Build the FIT image
+#
+################################################################################
+
+ROOTFS_FIT_DEPENDENCIES = host-uboot-tools
+
+ifeq ($(BR2_FIT_INSTALL_TARGET),y)
+define ROOTFS_FIT_CMD
+	cp $(BR2_FIT_PATH) $(BINARIES_DIR) && \
+	$(HOST_DIR)/usr/bin/mkimage -f $(BINARIES_DIR)/$(notdir $(call qstrip,$(BR2_FIT_PATH))) $(BINARIES_DIR)/$(basename $(notdir $(call qstrip,$(BR2_FIT_PATH)))).itb && \
+	mkdir -p $(TARGET_DIR)/boot/ && \
+	cp $(BINARIES_DIR)/$(basename $(notdir $(call qstrip,$(BR2_FIT_PATH)))).itb $(TARGET_DIR)/boot/
+endef
+else
+define ROOTFS_FIT_CMD
+	cp $(BR2_FIT_PATH) $(BINARIES_DIR) && \
+	$(HOST_DIR)/usr/bin/mkimage -f $(BINARIES_DIR)/$(notdir $(call qstrip,$(BR2_FIT_PATH))) $(BINARIES_DIR)/$(basename $(notdir $(call qstrip,$(BR2_FIT_PATH)))).itb
+endef
+endif
+
+$(eval $(call ROOTFS_TARGET,fit))
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH v3 1/1 Add support for Flattened Image Trees

Dear Yegor Yefremov,

fs/fit/Config.in line 14

Quoted 4 lines · Yegor Yefremov
fs/fit/Config.in new file +4 -0
+config BR2_FIT_PATH
+	string "Flattened Image Tree source file path"
+	help
+	  Path to the image tree source files.

Which files will typically be listed here? Apparently your code assumes those files must all be located in $(BINARIES_DIR), right? If that's the case, it should be mentioned here.

Also, I'm worried about ordering: there is no ordering guarantee between filesystem image types. So if your FIT filesystem image logic depends on another filesystem image to be generated, this might be an issue.

Also you say "files" in the description, but your code doesn't seem to handle multiple "files". Can you explain?

fs/fit/fit.mk line 21

Quoted 13 lines
fs/fit/fit.mk new file +13 -0
+ifeq ($(BR2_FIT_INSTALL_TARGET),y)
+define ROOTFS_FIT_CMD
+	cp $(BR2_FIT_PATH) $(BINARIES_DIR) && \
+	$(HOST_DIR)/usr/bin/mkimage -f $(BINARIES_DIR)/$(notdir $(call qstrip,$(BR2_FIT_PATH))) $(BINARIES_DIR)/$(basename $(notdir $(call qstrip,$(BR2_FIT_PATH)))).itb && \
+	mkdir -p $(TARGET_DIR)/boot/ && \
+	cp $(BINARIES_DIR)/$(basename $(notdir $(call qstrip,$(BR2_FIT_PATH)))).itb $(TARGET_DIR)/boot/
+endef
+else
+define ROOTFS_FIT_CMD
+	cp $(BR2_FIT_PATH) $(BINARIES_DIR) && \
+	$(HOST_DIR)/usr/bin/mkimage -f $(BINARIES_DIR)/$(notdir $(call qstrip,$(BR2_FIT_PATH))) $(BINARIES_DIR)/$(basename $(notdir $(call qstrip,$(BR2_FIT_PATH)))).itb
+endef
+endif

Avoid duplication:

ROOTFS_FIT_FILE = $(BINARIES_DIR)/$(notdir $(call qstrip,$(BR2_FIT_PATH))) ROOTFS_FIT_ITB_PATH = $(ROOTFS_FIT_FILE).itb

ifeq ($(BR2_FIT_INSTALL_TARGET),y)
define ROOTFS_FIT_INSTALL_TARGET

	mkdir -p $(TARGET_DIR)/boot && cp $(ROOTFS_FIT_ITB_PATH) $(TARGET_DIR)/boot

endef
else
define ROOTFS_FIT_INSTALL_TARGET
true
endef
endif

define ROOTFS_FIT_CMD

	cp $(BR2_FIT_PATH) $(BINARIES_DIR) && \
	$(HOST_DIR)/usr/bin/mkimage -f $(ROOTFS_FILE_FILE) $(ROOTFS_FIT_ITB_PATH) && \
	$(ROOTFS_FIT_INSTALL_TARGET)

endef

But maybe we should change the ROOTFS_TARGET infrastructure to support multiple commands. There's also maybe the ROOTFS_xyz_POST_TARGETS mechanism that could be used (I haven't looked whether it applies properly here).

Can you give an example for the various Config.in options, so that others could test this and understand better how it's typically used?

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH v3 1/1 Add support for Flattened Image Trees

Quoted 4 lines · Thomas Petazzoni

Dear Yegor Yefremov,

On Thu, 18 Sep 2014 22:13:44 +0200, Yegor Yefremov wrote:

Quoted 8 lines

fs/fit/Config.in line 14

Quoted 4 lines
fs/fit/Config.in new file +4 -0
+config BR2_FIT_PATH
+     string "Flattened Image Tree source file path"
+     help
+       Path to the image tree source files.

Which files will typically be listed here? Apparently your code assumes those files must all be located in $(BINARIES_DIR), right? If that's the case, it should be mentioned here.

*.its files can be anywhere, but will be copied to $(BINARIES_DIR) to overcome mkimage/dtb compiler path issues (mkimage invokes dtb compiler at *.its location, so working directory changes).

Quoted 4 lines

Also, I'm worried about ordering: there is no ordering guarantee between filesystem image types. So if your FIT filesystem image logic depends on another filesystem image to be generated, this might be an issue.

This is the crucial moment. For me there are basically following cases:

1. create an image consisting of zImage + DTB and install it to boot
- in this case FIT must be invoked before file system packaging
2. create an image having cpio inside - in this case FIT must be the last action taken in fs stuff or at least after cpio archive is packaged
3. create an image with appended cpio as initramfs - in this case FIT must be invoked after cpio is embedded into kernel

What would be the best strategy to implement these cases?

Quoted 2 lines

Also you say "files" in the description, but your code doesn't seem to handle multiple "files". Can you explain?

See v4

Quoted 29 lines

fs/fit/fit.mk line 21

Quoted 13 lines
fs/fit/fit.mk new file +13 -0
+ifeq ($(BR2_FIT_INSTALL_TARGET),y)
+define ROOTFS_FIT_CMD
+     cp $(BR2_FIT_PATH) $(BINARIES_DIR) && \
+     $(HOST_DIR)/usr/bin/mkimage -f $(BINARIES_DIR)/$(notdir $(call qstrip,$(BR2_FIT_PATH))) $(BINARIES_DIR)/$(basename $(notdir $(call qstrip,$(BR2_FIT_PATH)))).itb && \
+     mkdir -p $(TARGET_DIR)/boot/ && \
+     cp $(BINARIES_DIR)/$(basename $(notdir $(call qstrip,$(BR2_FIT_PATH)))).itb $(TARGET_DIR)/boot/
+endef
+else
+define ROOTFS_FIT_CMD
+     cp $(BR2_FIT_PATH) $(BINARIES_DIR) && \
+     $(HOST_DIR)/usr/bin/mkimage -f $(BINARIES_DIR)/$(notdir $(call qstrip,$(BR2_FIT_PATH))) $(BINARIES_DIR)/$(basename $(notdir $(call qstrip,$(BR2_FIT_PATH)))).itb
+endef
+endif

Avoid duplication:

ROOTFS_FIT_FILE = $(BINARIES_DIR)/$(notdir $(call qstrip,$(BR2_FIT_PATH))) ROOTFS_FIT_ITB_PATH = $(ROOTFS_FIT_FILE).itb

ifeq ($(BR2_FIT_INSTALL_TARGET),y)
define ROOTFS_FIT_INSTALL_TARGET

        mkdir -p $(TARGET_DIR)/boot && cp $(ROOTFS_FIT_ITB_PATH) $(TARGET_DIR)/boot

endef
else
define ROOTFS_FIT_INSTALL_TARGET
true
endef
endif

Quoted 5 lines

define ROOTFS_FIT_CMD

        cp $(BR2_FIT_PATH) $(BINARIES_DIR) && \
        $(HOST_DIR)/usr/bin/mkimage -f $(ROOTFS_FILE_FILE) $(ROOTFS_FIT_ITB_PATH) && \
        $(ROOTFS_FIT_INSTALL_TARGET)

endef

Fixed so far in v4.

Quoted 7 lines

But maybe we should change the ROOTFS_TARGET infrastructure to support multiple commands. There's also maybe the ROOTFS_xyz_POST_TARGETS mechanism that could be used (I haven't looked whether it applies properly here).

Can you give an example for the various Config.in options, so that others could test this and understand better how it's typically used?

I think now the approach is straight forward: you specify one or more *.its files and you get *.itb files. The only option so far is to install *.itbs into /boot/ or not.

Yegor

#3 lore raw

PATCH v3 1/1 Add support for Flattened Image Trees

In reply to Yegor Yefremov

Hi Yegor,

Quoted 6 lines · Yegor Yefremov

This patch provides an option to specify a FIT source file (*.its), that will usually be stored in a board directory, and the resulting blob file name (*.itb).

---

[snip]

fs/fit/Config.in line 18

Quoted 3 lines
fs/fit/Config.in new file +3 -0
+config BR2_FIT_INSTALL_TARGET
+	bool "Install Flattened Image Tree blob to /boot in target"
+	depends on !BR2_TARGET_ROOTFS_INITRAMFS

I don't think it is reasonable to disable target FIT image install just because the user has enabled initramfs target generation. Wouldn't it be nicer to remove the /boot directory from the generated .cpio image? If this is too hard to do, I suggest to add a comment explaining this limitation to be displayed when BR2_TARGET_ROOTFS_INITRAMFS is enabled.

Thanks for working on this,
baruch

Quoted 5 lines
fs/fit/Config.in new file +5 -0
+	help
+	  Select this option to have the FIT image installed to
+	  /boot in the target root filesystem.
+
+endif
Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
#4 lore raw

PATCH v3 1/1 Add support for Flattened Image Trees

Quoted 16 lines · Baruch Siach

Hi Yegor,

Quoted 6 lines · Yegor Yefremov

This patch provides an option to specify a FIT source file (*.its), that will usually be stored in a board directory, and the resulting blob file name (*.itb).

---

[snip]

fs/fit/Config.in line 18

Quoted 3 lines
fs/fit/Config.in new file +3 -0
+config BR2_FIT_INSTALL_TARGET
+     bool "Install Flattened Image Tree blob to /boot in target"
+     depends on !BR2_TARGET_ROOTFS_INITRAMFS
Quoted 5 lines

I don't think it is reasonable to disable target FIT image install just because the user has enabled initramfs target generation. Wouldn't it be nicer to remove the /boot directory from the generated .cpio image? If this is too hard to do, I suggest to add a comment explaining this limitation to be displayed when BR2_TARGET_ROOTFS_INITRAMFS is enabled.

I've copied this dependency/restriction from kernel (linux.mk), because it has the same meaning. At least for me. So I'll try to add related warning.

Yegor

#5 lore raw

PATCH v4 1/1 Add support for Flattened Image Trees

This patch provides an option to specify a FIT source file (*.its), that will usually be stored in a board directory, and the resulting blob file name (*.itb).

---
Changes:
v4: add support for multiple *.its files, reduce code duplication
v3: fix syntax errors, remove itb name, add uboot-tools dependency
v2: moved configuration to fs infra instead of linux

 fs/Config.in     |  1 +
 fs/fit/Config.in | 31 +++++++++++++++++++++++++++++++
 fs/fit/fit.mk    | 29 +++++++++++++++++++++++++++++
 3 files changed, 61 insertions(+)
 create mode 100644 fs/fit/Config.in
 create mode 100644 fs/fit/fit.mk
fs/Config.in +1 -0
index 5853113..8d882d0 100644
@@ -4,6 +4,7 @@ source "fs/cloop/Config.in"
 source "fs/cpio/Config.in"
 source "fs/cramfs/Config.in"
 source "fs/ext2/Config.in"
+source "fs/fit/Config.in"
 source "fs/initramfs/Config.in"
 source "fs/iso9660/Config.in"
 source "fs/jffs2/Config.in"
fs/fit/Config.in new file +31 -0
new file mode 100644
index 0000000..f05b2a7
@@ -0,0 +1,31 @@
+config BR2_TARGET_ROOTFS_FIT
+       bool "Flattened Image Tree support"
+       select BR2_PACKAGE_HOST_UBOOT_TOOLS
+       help
+         Compile a flattened image tree sources into a flattened
+         image tree blobs. Specify the *.its files to compile in
+         the options below.
+
+         Please note, that all files referenced in *.its files,
+         should be available in output/images folder.
+
+if BR2_TARGET_ROOTFS_FIT
+
+config BR2_FIT_PATH
+       string "Flattened Image Tree source file paths"
+       help
+         Paths to the image tree source files. You can
+         provide a list of *.its paths to copy and build,
+         separated by spaces.
+
+         Please note, that all *.its files must be named uniquely,
+         otherwise the files with the same name will be overwritten.
+
+config BR2_FIT_INSTALL_TARGET
+       bool "Install Flattened Image Tree blobs to /boot in target"
+       depends on !BR2_TARGET_ROOTFS_INITRAMFS
+       help
+         Select this option to have the FIT images installed to
+         /boot in the target root filesystem.
+
+endif
fs/fit/fit.mk new file +9 -0
new file mode 100644
index 0000000..68a9557
@@ -0,0 +1,29 @@
+################################################################################
+#
+# Build the FIT image
+#
+################################################################################
+
+ROOTFS_FIT_DEPENDENCIES = host-uboot-tools
+
+FIT_SRCS = $(addprefix $(BINARIES_DIR)/,$(notdir $(call

qstrip,$(BR2_FIT_PATH))))
+FIT_BLOBS = $(addsuffix .itb, $(basename $(FIT_SRCS))) +
+ifeq ($(BR2_FIT_INSTALL_TARGET),y)
+define FIT_INSTALL_ITB_TARGET
+ mkdir -p $(TARGET_DIR)/boot/ && \
+ cp $(FIT_BLOBS) $(TARGET_DIR)/boot/
+endef
+else
+define FIT_INSTALL_ITB_TARGET
+ true
+endef
+endif
+
+define ROOTFS_FIT_CMD
+ cp $(BR2_FIT_PATH) $(BINARIES_DIR) && \
+ $(foreach its,$(FIT_SRCS),$(HOST_DIR)/usr/bin/mkimage -f
$(its) $(basename $(its)).itb &&) \
+ $(FIT_INSTALL_ITB_TARGET)
+endef
+
+$(eval $(call ROOTFS_TARGET,fit))
--
1.9.1

#6 lore raw

PATCH v4 1/1 Add support for Flattened Image Trees

Quoted 105 lines · Yegor Yefremov

This patch provides an option to specify a FIT source file (*.its), that will usually be stored in a board directory, and the resulting blob file name (*.itb).

---
Changes:
v4: add support for multiple *.its files, reduce code duplication
v3: fix syntax errors, remove itb name, add uboot-tools dependency
v2: moved configuration to fs infra instead of linux

 fs/Config.in     |  1 +
 fs/fit/Config.in | 31 +++++++++++++++++++++++++++++++
 fs/fit/fit.mk    | 29 +++++++++++++++++++++++++++++
 3 files changed, 61 insertions(+)
 create mode 100644 fs/fit/Config.in
 create mode 100644 fs/fit/fit.mk
fs/Config.in +1 -0
index 5853113..8d882d0 100644
@@ -4,6 +4,7 @@ source "fs/cloop/Config.in"
 source "fs/cpio/Config.in"
 source "fs/cramfs/Config.in"
 source "fs/ext2/Config.in"
+source "fs/fit/Config.in"
 source "fs/initramfs/Config.in"
 source "fs/iso9660/Config.in"
 source "fs/jffs2/Config.in"
fs/fit/Config.in new file +31 -0
new file mode 100644
index 0000000..f05b2a7
@@ -0,0 +1,31 @@
+config BR2_TARGET_ROOTFS_FIT
+       bool "Flattened Image Tree support"
+       select BR2_PACKAGE_HOST_UBOOT_TOOLS
+       help
+         Compile a flattened image tree sources into a flattened
+         image tree blobs. Specify the *.its files to compile in
+         the options below.
+
+         Please note, that all files referenced in *.its files,
+         should be available in output/images folder.
+
+if BR2_TARGET_ROOTFS_FIT
+
+config BR2_FIT_PATH
+       string "Flattened Image Tree source file paths"
+       help
+         Paths to the image tree source files. You can
+         provide a list of *.its paths to copy and build,
+         separated by spaces.
+
+         Please note, that all *.its files must be named uniquely,
+         otherwise the files with the same name will be overwritten.
+
+config BR2_FIT_INSTALL_TARGET
+       bool "Install Flattened Image Tree blobs to /boot in target"
+       depends on !BR2_TARGET_ROOTFS_INITRAMFS
+       help
+         Select this option to have the FIT images installed to
+         /boot in the target root filesystem.
+
+endif
fs/fit/fit.mk new file +9 -0
new file mode 100644
index 0000000..68a9557
@@ -0,0 +1,29 @@
+################################################################################
+#
+# Build the FIT image
+#
+################################################################################
+
+ROOTFS_FIT_DEPENDENCIES = host-uboot-tools
+
+FIT_SRCS = $(addprefix $(BINARIES_DIR)/,$(notdir $(call

qstrip,$(BR2_FIT_PATH))))

fs/fit/fit.mk new file +16 -0
+FIT_BLOBS = $(addsuffix .itb, $(basename $(FIT_SRCS)))
+
+ifeq ($(BR2_FIT_INSTALL_TARGET),y)
+define FIT_INSTALL_ITB_TARGET
+       mkdir -p $(TARGET_DIR)/boot/ && \
+       cp $(FIT_BLOBS) $(TARGET_DIR)/boot/
+endef
+else
+define FIT_INSTALL_ITB_TARGET
+       true
+endef
+endif
+
+define ROOTFS_FIT_CMD
+       cp $(BR2_FIT_PATH) $(BINARIES_DIR) && \
+       $(foreach its,$(FIT_SRCS),$(HOST_DIR)/usr/bin/mkimage -f

$(its) $(basename $(its)).itb &&) \

fs/fit/fit.mk new file +4 -1
+       $(FIT_INSTALL_ITB_TARGET)
+endef
+
+$(eval $(call ROOTFS_TARGET,fit))
--
Quoted 1 line

1.9.1

I'm still working on the problem with sending e-mails with corporate account, so the patch was just copypasted into GMail web interface and is intended for reviewing only.

Yegor