diff mbox

[1/2] linux: install firmware to staging.

Message ID 1373239866-18076-1-git-send-email-spenser@gillilanding.com
State Superseded
Headers show

Commit Message

Spenser Gilliland July 7, 2013, 11:31 p.m. UTC
Install firmware to staging when the hidden option
BR2_LINUX_KERNEL_INSTALL_FIRMWARE is selected.  This allows parts of the
firmware provided by the linux kernel to be installed in the target.

Signed-off-by: Spenser Gilliland <spenser@gillilanding.com>
---
 linux/Config.in |  5 +++++
 linux/linux.mk  | 13 +++++++++++++
 2 files changed, 18 insertions(+)

Comments

Yann E. MORIN July 8, 2013, 5:52 p.m. UTC | #1
On 2013-07-07 18:31 -0500, Spenser Gilliland spake thusly:
> Install firmware to staging when the hidden option
> BR2_LINUX_KERNEL_INSTALL_FIRMWARE is selected.  This allows parts of the
> firmware provided by the linux kernel to be installed in the target.
> 
> Signed-off-by: Spenser Gilliland <spenser@gillilanding.com>
> ---
>  linux/Config.in |  5 +++++
>  linux/linux.mk  | 13 +++++++++++++
>  2 files changed, 18 insertions(+)
> 
> diff --git a/linux/Config.in b/linux/Config.in
> index f58e714..b733019 100644
> --- a/linux/Config.in
> +++ b/linux/Config.in
> @@ -297,6 +297,11 @@ config BR2_LINUX_KERNEL_INSTALL_TARGET
>  	  /boot in the target root filesystem, as is typically done on
>  	  x86/x86_64 systems.
>  
> +# This option is used to install firmware to staging. Other packages such as
> +# beagle-capes then install the firmware into the target. This avoids
> +# installing all linux firmware.

I would also states that this applies to special firmware files that are
*not* distributed with the linux-firmware package. All 'standard'
firmwares should be installed via linux-firmware. This knob is for very
special cases such as the BBB capes. Waht about:

# This option can be selected by other packages that require special
# firmwares bundled in some fiorks of the Linux kernell (eg. the BBB
# capes firmwares (.dtbo) as distributed in the TI Linux kernel fork).
# To install other firmwares, please use the linux-firmware package.

> +config BR2_LINUX_KERNEL_INSTALL_FIRMWARE
> +	bool
>  
>  # Linux extensions
>  source "linux/Config.ext.in"
> diff --git a/linux/linux.mk b/linux/linux.mk
> index befef16..88c954d 100644
> --- a/linux/linux.mk
> +++ b/linux/linux.mk
> @@ -256,6 +256,15 @@ define LINUX_INSTALL_KERNEL_IMAGE_TO_TARGET
>  endef
>  endif
>  
> +ifeq ($(BR2_LINUX_KERNEL_INSTALL_FIRMWARE),y)
> +
> +LINUX_INSTALL_STAGING = YES
> +
> +define LINUX_INSTALL_FIRMWARE_TO_STAGING
> +	$(TARGET_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) firmware_install \
> +		INSTALL_FW_PATH=$(STAGING_DIR)/lib/firmware/
> +endef
> +endif
>  
>  define LINUX_INSTALL_HOST_TOOLS
>  	# Installing dtc (device tree compiler) as host tool, if selected
> @@ -269,6 +278,10 @@ define LINUX_INSTALL_IMAGES_CMDS
>  	cp $(LINUX_IMAGE_PATH) $(BINARIES_DIR)
>  endef
>  
> +define LINUX_INSTALL_STAGING_CMDS
> +	$(LINUX_INSTALL_FIRMWARE_TO_STAGING)
> +endef
> +
>  define LINUX_INSTALL_TARGET_CMDS
>  	$(LINUX_INSTALL_KERNEL_IMAGE_TO_TARGET)
>  	$(LINUX_INSTALL_DTB)

Otherwise, LGTM.

Peter, Thomas, what do you thiink of this scheme? Should we puruse this
series, or do you have a better idea?

Regards,
Yann E. MORIN.
Thomas Petazzoni July 9, 2013, 10:54 a.m. UTC | #2
Dear Yann E. MORIN,

On Mon, 8 Jul 2013 19:52:21 +0200, Yann E. MORIN wrote:

> > +# This option is used to install firmware to staging. Other packages such as
> > +# beagle-capes then install the firmware into the target. This avoids
> > +# installing all linux firmware.
> 
> I would also states that this applies to special firmware files that are
> *not* distributed with the linux-firmware package. All 'standard'
> firmwares should be installed via linux-firmware. This knob is for very
> special cases such as the BBB capes. Waht about:
> 
> # This option can be selected by other packages that require special
> # firmwares bundled in some fiorks of the Linux kernell (eg. the BBB
> # capes firmwares (.dtbo) as distributed in the TI Linux kernel fork).
> # To install other firmwares, please use the linux-firmware package.

The thing that worries me here is that this .dtbo thing for capes is
custom to the BBB kernel, and as far as I know, not in the upstream
kernel. So it annoys me a bit to have this within the linux/linux.mk
logic, because if we started to add vendor-specific logic in this
generic kernel .mk file, where are we going to end?

In order to have a better understanding of the problem, could someone
summarize how things work with those .dtbo? Where are they located
source wise, how they are built, where they should be installed,
how/when they are loaded/used in the system, etc.

Thanks,

Thomas
Spenser Gilliland July 9, 2013, 2:03 p.m. UTC | #3
Dear Thomas,

>> # This option can be selected by other packages that require special
>> # firmwares bundled in some fiorks of the Linux kernell (eg. the BBB
>> # capes firmwares (.dtbo) as distributed in the TI Linux kernel fork).
>> # To install other firmwares, please use the linux-firmware package.
>
> The thing that worries me here is that this .dtbo thing for capes is
> custom to the BBB kernel, and as far as I know, not in the upstream
> kernel. So it annoys me a bit to have this within the linux/linux.mk
> logic, because if we started to add vendor-specific logic in this
> generic kernel .mk file, where are we going to end?

This should be the only change required to support any in-kernel
firmware.  It's very vendor agnostic and can be useful for more than
just beagle-capes.  This also establishes precedent for how to handle
non-mainlined in-kernel firmware.

> In order to have a better understanding of the problem, could someone
> summarize how things work with those .dtbo? Where are they located
> source wise, how they are built, where they should be installed,
> how/when they are loaded/used in the system, etc.

The .dtbo are device tree overlay files, the device tree sources from
which they are made are located in <kernel>/firmware/capes.  They are
built using the device tree compiler (dtc). They should be installed
in /lib/firmware and are used by the in-kernel capebus manager on boot
to add support for the capes.  The kernel installs these dtbo when the
firmware_install target is built.

In the kernel, the capebus manager uses eeproms to determine which
capes are installed on the target and installs the needed dtbo for the
cape.  This creates the needed platform devices in the kernel.

Thanks,
Spenser


--
Spenser Gilliland
Computer Engineer
Doctoral Candidate
diff mbox

Patch

diff --git a/linux/Config.in b/linux/Config.in
index f58e714..b733019 100644
--- a/linux/Config.in
+++ b/linux/Config.in
@@ -297,6 +297,11 @@  config BR2_LINUX_KERNEL_INSTALL_TARGET
 	  /boot in the target root filesystem, as is typically done on
 	  x86/x86_64 systems.
 
+# This option is used to install firmware to staging. Other packages such as
+# beagle-capes then install the firmware into the target. This avoids
+# installing all linux firmware.
+config BR2_LINUX_KERNEL_INSTALL_FIRMWARE
+	bool
 
 # Linux extensions
 source "linux/Config.ext.in"
diff --git a/linux/linux.mk b/linux/linux.mk
index befef16..88c954d 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -256,6 +256,15 @@  define LINUX_INSTALL_KERNEL_IMAGE_TO_TARGET
 endef
 endif
 
+ifeq ($(BR2_LINUX_KERNEL_INSTALL_FIRMWARE),y)
+
+LINUX_INSTALL_STAGING = YES
+
+define LINUX_INSTALL_FIRMWARE_TO_STAGING
+	$(TARGET_MAKE_ENV) $(MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) firmware_install \
+		INSTALL_FW_PATH=$(STAGING_DIR)/lib/firmware/
+endef
+endif
 
 define LINUX_INSTALL_HOST_TOOLS
 	# Installing dtc (device tree compiler) as host tool, if selected
@@ -269,6 +278,10 @@  define LINUX_INSTALL_IMAGES_CMDS
 	cp $(LINUX_IMAGE_PATH) $(BINARIES_DIR)
 endef
 
+define LINUX_INSTALL_STAGING_CMDS
+	$(LINUX_INSTALL_FIRMWARE_TO_STAGING)
+endef
+
 define LINUX_INSTALL_TARGET_CMDS
 	$(LINUX_INSTALL_KERNEL_IMAGE_TO_TARGET)
 	$(LINUX_INSTALL_DTB)