Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] package/freescale-imx/firmware-imx: fix installation with merged usr dirs
@ 2022-12-20 13:34 Christian Hitz
  2022-12-21  8:32 ` Gary Bisson
  2022-12-21  9:48 ` Yann E. MORIN
  0 siblings, 2 replies; 5+ messages in thread
From: Christian Hitz @ 2022-12-20 13:34 UTC (permalink / raw)
  To: buildroot; +Cc: Gary Bisson, Christian Hitz, Refik Tuzakli

From: Christian Hitz <christian.hitz@bbv.ch>

Currently, the firmware files are installed to /lib/firmware/imx. With
BR2_ROOTFS_MERGED_USR=y /lib is replaced with a symlink to /usr/lib
effectively deleting the installed firmware files.

Install the firmware files into the /usr/lib/firmware/imx prefix instead.

Signed-off-by: Christian Hitz <christian.hitz@bbv.ch>
---
Backport to: 2022.02.x, 2022.11.x
---
 .../firmware-imx/firmware-imx.mk              | 29 ++++++++++++-------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/package/freescale-imx/firmware-imx/firmware-imx.mk b/package/freescale-imx/firmware-imx/firmware-imx.mk
index 99fe71a91c..2171ce592e 100644
--- a/package/freescale-imx/firmware-imx/firmware-imx.mk
+++ b/package/freescale-imx/firmware-imx/firmware-imx.mk
@@ -128,14 +128,21 @@ define FIRMWARE_IMX_INSTALL_IMAGE_HDMI_FW
 endef
 endif
 
+# /lib is really /usr/lib with merged /usr, so adjust path
+ifeq ($(BR2_ROOTFS_MERGED_USR),y)
+FIRMWARE_IMX_TARGET_LIBRARY_PATH = $(TARGET_DIR)/usr/lib/firmware
+else
+FIRMWARE_IMX_TARGET_LIBRARY_PATH = $(TARGET_DIR)/lib/firmware
+endif
+
 #
 # EASRC firmware
 #
 
 ifeq ($(BR2_PACKAGE_FIRMWARE_IMX_NEEDS_EASRC_FW),y)
 define FIRMWARE_IMX_INSTALL_TARGET_EASRC_FW
-	mkdir -p $(TARGET_DIR)/lib/firmware/imx
-	cp -r $(@D)/firmware/easrc $(TARGET_DIR)/lib/firmware/imx
+	mkdir -p $(FIRMWARE_IMX_TARGET_LIBRARY_PATH)/imx
+	cp -r $(@D)/firmware/easrc $(FIRMWARE_IMX_TARGET_LIBRARY_PATH)/imx
 endef
 endif
 
@@ -145,10 +152,10 @@ endif
 
 ifeq ($(BR2_PACKAGE_FIRMWARE_IMX_NEEDS_EPDC_FW),y)
 define FIRMWARE_IMX_INSTALL_TARGET_EPDC_FW
-	mkdir -p $(TARGET_DIR)/lib/firmware/imx
-	cp -r $(@D)/firmware/epdc $(TARGET_DIR)/lib/firmware/imx
-	mv $(TARGET_DIR)/lib/firmware/imx/epdc/epdc_ED060XH2C1.fw.nonrestricted \
-		$(TARGET_DIR)/lib/firmware/imx/epdc/epdc_ED060XH2C1.fw
+	mkdir -p $(FIRMWARE_IMX_TARGET_LIBRARY_PATH)/imx
+	cp -r $(@D)/firmware/epdc $(FIRMWARE_IMX_TARGET_LIBRARY_PATH)/imx
+	mv $(FIRMWARE_IMX_TARGET_LIBRARY_PATH)/imx/epdc/epdc_ED060XH2C1.fw.nonrestricted \
+		$(FIRMWARE_IMX_TARGET_LIBRARY_PATH)/imx/epdc/epdc_ED060XH2C1.fw
 endef
 endif
 
@@ -159,9 +166,9 @@ endif
 FIRMWARE_IMX_SDMA_FW_NAME = $(call qstrip,$(BR2_PACKAGE_FIRMWARE_IMX_SDMA_FW_NAME))
 ifneq ($(FIRMWARE_IMX_SDMA_FW_NAME),)
 define FIRMWARE_IMX_INSTALL_TARGET_SDMA_FW
-	mkdir -p $(TARGET_DIR)/lib/firmware/imx/sdma
+	mkdir -p $(FIRMWARE_IMX_TARGET_LIBRARY_PATH)/imx/sdma
 	cp -r $(@D)/firmware/sdma/sdma-$(FIRMWARE_IMX_SDMA_FW_NAME)*.bin \
-	       $(TARGET_DIR)/lib/firmware/imx/sdma/
+	       $(FIRMWARE_IMX_TARGET_LIBRARY_PATH)/imx/sdma/
 endef
 endif
 
@@ -172,10 +179,10 @@ endif
 FIRMWARE_IMX_VPU_FW_NAME = $(call qstrip,$(BR2_PACKAGE_FIRMWARE_IMX_VPU_FW_NAME))
 ifneq ($(FIRMWARE_IMX_VPU_FW_NAME),)
 define FIRMWARE_IMX_INSTALL_TARGET_VPU_FW
-	mkdir -p $(TARGET_DIR)/lib/firmware/vpu
+	mkdir -p $(FIRMWARE_IMX_TARGET_LIBRARY_PATH)/vpu
 	for i in $$(find $(@D)/firmware/vpu/vpu_fw_$(FIRMWARE_IMX_VPU_FW_NAME)*.bin); do \
-		cp $$i $(TARGET_DIR)/lib/firmware/vpu/ ; \
-		ln -sf vpu/$$(basename $$i) $(TARGET_DIR)/lib/firmware/$$(basename $$i) ; \
+		cp $$i $(FIRMWARE_IMX_TARGET_LIBRARY_PATH)/vpu/ ; \
+		ln -sf vpu/$$(basename $$i) $(FIRMWARE_IMX_TARGET_LIBRARY_PATH)/$$(basename $$i) ; \
 	done
 endef
 endif
-- 
2.38.2

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Buildroot] [PATCH] package/freescale-imx/firmware-imx: fix installation with merged usr dirs
  2022-12-20 13:34 [Buildroot] [PATCH] package/freescale-imx/firmware-imx: fix installation with merged usr dirs Christian Hitz
@ 2022-12-21  8:32 ` Gary Bisson
  2022-12-21  9:54   ` Yann E. MORIN
  2022-12-21  9:48 ` Yann E. MORIN
  1 sibling, 1 reply; 5+ messages in thread
From: Gary Bisson @ 2022-12-21  8:32 UTC (permalink / raw)
  To: Christian Hitz
  Cc: Gary Bisson, Christian Hitz, Refik Tuzakli, thomas.petazzoni,
	buildroot

Hi Christian,

On Tue, Dec 20, 2022 at 02:34:53PM +0100, Christian Hitz wrote:
> From: Christian Hitz <christian.hitz@bbv.ch>
> 
> Currently, the firmware files are installed to /lib/firmware/imx. With
> BR2_ROOTFS_MERGED_USR=y /lib is replaced with a symlink to /usr/lib
> effectively deleting the installed firmware files.
> 
> Install the firmware files into the /usr/lib/firmware/imx prefix instead.
> 
> Signed-off-by: Christian Hitz <christian.hitz@bbv.ch>
> ---
> Backport to: 2022.02.x, 2022.11.x
> ---

Thanks for your contribution, looks good to me! That brings the question
about linux-firmware that doesn't seem to handle that case either.
Thomas, should we have a generic TARGET_FIRMWARE_DIR that switches from
/lib/firmware to /usr/lib/firmware automatically? That way it would fix
it for all packages at once.

Otherwise:
Reviewed-by: Gary Bisson <gary.bisson@boundarydevices.com>

Regards,
Gary
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Buildroot] [PATCH] package/freescale-imx/firmware-imx: fix installation with merged usr dirs
  2022-12-20 13:34 [Buildroot] [PATCH] package/freescale-imx/firmware-imx: fix installation with merged usr dirs Christian Hitz
  2022-12-21  8:32 ` Gary Bisson
@ 2022-12-21  9:48 ` Yann E. MORIN
  1 sibling, 0 replies; 5+ messages in thread
From: Yann E. MORIN @ 2022-12-21  9:48 UTC (permalink / raw)
  To: Christian Hitz; +Cc: Gary Bisson, Christian Hitz, Refik Tuzakli, buildroot

Christian, All,

On 2022-12-20 14:34 +0100, Christian Hitz spake thusly:
> From: Christian Hitz <christian.hitz@bbv.ch>
> 
> Currently, the firmware files are installed to /lib/firmware/imx. With
> BR2_ROOTFS_MERGED_USR=y /lib is replaced with a symlink to /usr/lib
> effectively deleting the installed firmware files.

That does not make sense: the /lib symlink is created by the skeleton,
which is the very first package to be installed, and so all packages to
get to see the symlink. /lib as a directory is never deleted, because it
never existed in the first place.

And indeed, with the current master, so without your patch applied, I
just tried the following defconfig:

    BR2_arm=y
    BR2_TOOLCHAIN_EXTERNAL=y
    BR2_ROOTFS_MERGED_USR=y
    BR2_PACKAGE_FREESCALE_IMX=y
    BR2_PACKAGE_FREESCALE_IMX_PLATFORM_IMX8MN=y
    BR2_PACKAGE_FIRMWARE_IMX=y

And I do get the firmware file as expected in /usr/lib/firmware:

    $ tar tf images/rootfs.tar |grep firmware |sort
    ./usr/lib/firmware/
    ./usr/lib/firmware/imx/
    ./usr/lib/firmware/imx/easrc/
    ./usr/lib/firmware/imx/easrc/easrc-imx8mn.bin
    ./usr/lib/firmware/imx/sdma/
    ./usr/lib/firmware/imx/sdma/sdma-imx7d.bin

And this is the same files that are installed without merged usr.

Could you provide a defconfig that exhibits the issue, please?

Regards,
Yann E. MORIN.

> Install the firmware files into the /usr/lib/firmware/imx prefix instead.
> 
> Signed-off-by: Christian Hitz <christian.hitz@bbv.ch>
> ---
> Backport to: 2022.02.x, 2022.11.x
> ---
>  .../firmware-imx/firmware-imx.mk              | 29 ++++++++++++-------
>  1 file changed, 18 insertions(+), 11 deletions(-)
> 
> diff --git a/package/freescale-imx/firmware-imx/firmware-imx.mk b/package/freescale-imx/firmware-imx/firmware-imx.mk
> index 99fe71a91c..2171ce592e 100644
> --- a/package/freescale-imx/firmware-imx/firmware-imx.mk
> +++ b/package/freescale-imx/firmware-imx/firmware-imx.mk
> @@ -128,14 +128,21 @@ define FIRMWARE_IMX_INSTALL_IMAGE_HDMI_FW
>  endef
>  endif
>  
> +# /lib is really /usr/lib with merged /usr, so adjust path
> +ifeq ($(BR2_ROOTFS_MERGED_USR),y)
> +FIRMWARE_IMX_TARGET_LIBRARY_PATH = $(TARGET_DIR)/usr/lib/firmware
> +else
> +FIRMWARE_IMX_TARGET_LIBRARY_PATH = $(TARGET_DIR)/lib/firmware
> +endif
> +
>  #
>  # EASRC firmware
>  #
>  
>  ifeq ($(BR2_PACKAGE_FIRMWARE_IMX_NEEDS_EASRC_FW),y)
>  define FIRMWARE_IMX_INSTALL_TARGET_EASRC_FW
> -	mkdir -p $(TARGET_DIR)/lib/firmware/imx
> -	cp -r $(@D)/firmware/easrc $(TARGET_DIR)/lib/firmware/imx
> +	mkdir -p $(FIRMWARE_IMX_TARGET_LIBRARY_PATH)/imx
> +	cp -r $(@D)/firmware/easrc $(FIRMWARE_IMX_TARGET_LIBRARY_PATH)/imx
>  endef
>  endif
>  
> @@ -145,10 +152,10 @@ endif
>  
>  ifeq ($(BR2_PACKAGE_FIRMWARE_IMX_NEEDS_EPDC_FW),y)
>  define FIRMWARE_IMX_INSTALL_TARGET_EPDC_FW
> -	mkdir -p $(TARGET_DIR)/lib/firmware/imx
> -	cp -r $(@D)/firmware/epdc $(TARGET_DIR)/lib/firmware/imx
> -	mv $(TARGET_DIR)/lib/firmware/imx/epdc/epdc_ED060XH2C1.fw.nonrestricted \
> -		$(TARGET_DIR)/lib/firmware/imx/epdc/epdc_ED060XH2C1.fw
> +	mkdir -p $(FIRMWARE_IMX_TARGET_LIBRARY_PATH)/imx
> +	cp -r $(@D)/firmware/epdc $(FIRMWARE_IMX_TARGET_LIBRARY_PATH)/imx
> +	mv $(FIRMWARE_IMX_TARGET_LIBRARY_PATH)/imx/epdc/epdc_ED060XH2C1.fw.nonrestricted \
> +		$(FIRMWARE_IMX_TARGET_LIBRARY_PATH)/imx/epdc/epdc_ED060XH2C1.fw
>  endef
>  endif
>  
> @@ -159,9 +166,9 @@ endif
>  FIRMWARE_IMX_SDMA_FW_NAME = $(call qstrip,$(BR2_PACKAGE_FIRMWARE_IMX_SDMA_FW_NAME))
>  ifneq ($(FIRMWARE_IMX_SDMA_FW_NAME),)
>  define FIRMWARE_IMX_INSTALL_TARGET_SDMA_FW
> -	mkdir -p $(TARGET_DIR)/lib/firmware/imx/sdma
> +	mkdir -p $(FIRMWARE_IMX_TARGET_LIBRARY_PATH)/imx/sdma
>  	cp -r $(@D)/firmware/sdma/sdma-$(FIRMWARE_IMX_SDMA_FW_NAME)*.bin \
> -	       $(TARGET_DIR)/lib/firmware/imx/sdma/
> +	       $(FIRMWARE_IMX_TARGET_LIBRARY_PATH)/imx/sdma/
>  endef
>  endif
>  
> @@ -172,10 +179,10 @@ endif
>  FIRMWARE_IMX_VPU_FW_NAME = $(call qstrip,$(BR2_PACKAGE_FIRMWARE_IMX_VPU_FW_NAME))
>  ifneq ($(FIRMWARE_IMX_VPU_FW_NAME),)
>  define FIRMWARE_IMX_INSTALL_TARGET_VPU_FW
> -	mkdir -p $(TARGET_DIR)/lib/firmware/vpu
> +	mkdir -p $(FIRMWARE_IMX_TARGET_LIBRARY_PATH)/vpu
>  	for i in $$(find $(@D)/firmware/vpu/vpu_fw_$(FIRMWARE_IMX_VPU_FW_NAME)*.bin); do \
> -		cp $$i $(TARGET_DIR)/lib/firmware/vpu/ ; \
> -		ln -sf vpu/$$(basename $$i) $(TARGET_DIR)/lib/firmware/$$(basename $$i) ; \
> +		cp $$i $(FIRMWARE_IMX_TARGET_LIBRARY_PATH)/vpu/ ; \
> +		ln -sf vpu/$$(basename $$i) $(FIRMWARE_IMX_TARGET_LIBRARY_PATH)/$$(basename $$i) ; \
>  	done
>  endef
>  endif
> -- 
> 2.38.2
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Buildroot] [PATCH] package/freescale-imx/firmware-imx: fix installation with merged usr dirs
  2022-12-21  8:32 ` Gary Bisson
@ 2022-12-21  9:54   ` Yann E. MORIN
  2022-12-21  9:57     ` Gary Bisson
  0 siblings, 1 reply; 5+ messages in thread
From: Yann E. MORIN @ 2022-12-21  9:54 UTC (permalink / raw)
  To: Gary Bisson
  Cc: Gary Bisson, Christian Hitz, Refik Tuzakli, thomas.petazzoni,
	buildroot, Christian Hitz

Gary, All,

On 2022-12-21 09:32 +0100, Gary Bisson spake thusly:
> On Tue, Dec 20, 2022 at 02:34:53PM +0100, Christian Hitz wrote:
> > From: Christian Hitz <christian.hitz@bbv.ch>
> > 
> > Currently, the firmware files are installed to /lib/firmware/imx. With
> > BR2_ROOTFS_MERGED_USR=y /lib is replaced with a symlink to /usr/lib
> > effectively deleting the installed firmware files.
> > 
> > Install the firmware files into the /usr/lib/firmware/imx prefix instead.
> > 
> > Signed-off-by: Christian Hitz <christian.hitz@bbv.ch>
> > ---
> > Backport to: 2022.02.x, 2022.11.x
> > ---
> Thanks for your contribution, looks good to me! That brings the question
> about linux-firmware that doesn't seem to handle that case either.
> Thomas, should we have a generic TARGET_FIRMWARE_DIR that switches from
> /lib/firmware to /usr/lib/firmware automatically? That way it would fix
> it for all packages at once.

As I explained in my reply to Christian: this should not be needed,
because the /lib symlink is created by the skeleton, which are installed
before any other package. So, all packages should see the proper /lib
symlink.

Note that we've introduced merged-usr quite a long time ago now (more
than 7 years ago!), and it has been used by many people (I included)
without that issue surfacing so far for linux-firmware, so I'd be
surprised that there is an actual issue for any of the (well behaved!)
firmware packages... ;-)

Regards,
Yann E. MORIN.

> Otherwise:
> Reviewed-by: Gary Bisson <gary.bisson@boundarydevices.com>
> 
> Regards,
> Gary
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Buildroot] [PATCH] package/freescale-imx/firmware-imx: fix installation with merged usr dirs
  2022-12-21  9:54   ` Yann E. MORIN
@ 2022-12-21  9:57     ` Gary Bisson
  0 siblings, 0 replies; 5+ messages in thread
From: Gary Bisson @ 2022-12-21  9:57 UTC (permalink / raw)
  To: Yann E. MORIN
  Cc: Gary Bisson, Christian Hitz, Refik Tuzakli, thomas.petazzoni,
	buildroot, Christian Hitz

Hi Yann,

On Wed, Dec 21, 2022 at 10:54:31AM +0100, Yann E. MORIN wrote:
> Gary, All,
> 
> On 2022-12-21 09:32 +0100, Gary Bisson spake thusly:
> > On Tue, Dec 20, 2022 at 02:34:53PM +0100, Christian Hitz wrote:
> > > From: Christian Hitz <christian.hitz@bbv.ch>
> > > 
> > > Currently, the firmware files are installed to /lib/firmware/imx. With
> > > BR2_ROOTFS_MERGED_USR=y /lib is replaced with a symlink to /usr/lib
> > > effectively deleting the installed firmware files.
> > > 
> > > Install the firmware files into the /usr/lib/firmware/imx prefix instead.
> > > 
> > > Signed-off-by: Christian Hitz <christian.hitz@bbv.ch>
> > > ---
> > > Backport to: 2022.02.x, 2022.11.x
> > > ---
> > Thanks for your contribution, looks good to me! That brings the question
> > about linux-firmware that doesn't seem to handle that case either.
> > Thomas, should we have a generic TARGET_FIRMWARE_DIR that switches from
> > /lib/firmware to /usr/lib/firmware automatically? That way it would fix
> > it for all packages at once.
> 
> As I explained in my reply to Christian: this should not be needed,
> because the /lib symlink is created by the skeleton, which are installed
> before any other package. So, all packages should see the proper /lib
> symlink.
> 
> Note that we've introduced merged-usr quite a long time ago now (more
> than 7 years ago!), and it has been used by many people (I included)
> without that issue surfacing so far for linux-firmware, so I'd be
> surprised that there is an actual issue for any of the (well behaved!)
> firmware packages... ;-)

Indeed it makes sense. I wasn't aware of that option so I never tried
it. So my suggestion was only applicable if the problem does exist
indeed. Next time I'll make sure to give it a try ;)

Thanks,
Gary
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-12-21  9:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-20 13:34 [Buildroot] [PATCH] package/freescale-imx/firmware-imx: fix installation with merged usr dirs Christian Hitz
2022-12-21  8:32 ` Gary Bisson
2022-12-21  9:54   ` Yann E. MORIN
2022-12-21  9:57     ` Gary Bisson
2022-12-21  9:48 ` Yann E. MORIN

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox