diff mbox series

[1/3] uboot-config: fix devtool modify with kernel-fitimage

Message ID 20240902203154.265515-1-adrian.freihofer@gmail.com
State Accepted, archived
Commit b23581a22619c52724c8e078f29e871e2ee74259
Headers show
Series [1/3] uboot-config: fix devtool modify with kernel-fitimage | expand

Commit Message

Adrian Freihofer Sept. 2, 2024, 8:31 p.m. UTC
From: Adrian Freihofer <adrian.freihofer@siemens.com>

How to reproduce:
- UBOOT_CONFIG must be used. With UBOOT_MACHINE it works fine.
  A simple example based on oe-core is to modify the
  beaglebone-yocto.conf file like this:
  -UBOOT_MACHINE = "am335x_evm_defconfig"
  +UBOOT_CONFIG = "foo"
  +UBOOT_CONFIG[foo] = "am335x_evm_defconfig"
- A build configuration which inherits the kernel-fitimage.bbclass is
  needed. For example:
  MACHINE = "beaglebone-yocto"
  KERNEL_IMAGETYPE = "Image"
  KERNEL_IMAGETYPES += " fitImage "
  KERNEL_CLASSES = " kernel-fitimage "

devtool modify linux-yocto
devtool build linux-yocto
...
| cp: cannot stat '.../linux-yocto-6.6.21+git/am335x_evm_defconfig/.config':
  No such file or directory
| WARNING: .../linux-yocto/6.6.21+git/temp/run.do_configure.2081673:172 exit 1
  from 'cp .../linux-yocto-6.6.21+git/am335x_evm_defconfig/.config
  .../build/workspace/sources/linux-yocto/.config.baseline'

The reason for this problem is that the uboot-config.bbclass sets the
variable KCONFIG_CONFIG_ROOTDIR to a path that makes sense for u-boot,
but not for other recipes. However, the kernel-fitimage.bbclasse, for
example, inherits the uboot-config.bbclass, which brings the
u-boot-specific path into the kernel build context.

This change removes the uboot-specific KCONFIG_CONFIG_ROOTDIR path from
recipes other than u-boot itself.

Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
 meta/classes-recipe/uboot-config.bbclass | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

Comments

Richard Purdie Sept. 3, 2024, 8:21 a.m. UTC | #1
On Mon, 2024-09-02 at 22:31 +0200, Adrian Freihofer via lists.openembedded.org wrote:
> From: Adrian Freihofer <adrian.freihofer@siemens.com>
> 
> How to reproduce:
> - UBOOT_CONFIG must be used. With UBOOT_MACHINE it works fine.
>   A simple example based on oe-core is to modify the
>   beaglebone-yocto.conf file like this:
>   -UBOOT_MACHINE = "am335x_evm_defconfig"
>   +UBOOT_CONFIG = "foo"
>   +UBOOT_CONFIG[foo] = "am335x_evm_defconfig"
> - A build configuration which inherits the kernel-fitimage.bbclass is
>   needed. For example:
>   MACHINE = "beaglebone-yocto"
>   KERNEL_IMAGETYPE = "Image"
>   KERNEL_IMAGETYPES += " fitImage "
>   KERNEL_CLASSES = " kernel-fitimage "
> 
> devtool modify linux-yocto
> devtool build linux-yocto
> ...
> > cp: cannot stat '.../linux-yocto-6.6.21+git/am335x_evm_defconfig/.config':
>   No such file or directory
> > WARNING: .../linux-yocto/6.6.21+git/temp/run.do_configure.2081673:172 exit 1
>   from 'cp .../linux-yocto-6.6.21+git/am335x_evm_defconfig/.config
>   .../build/workspace/sources/linux-yocto/.config.baseline'
> 
> The reason for this problem is that the uboot-config.bbclass sets the
> variable KCONFIG_CONFIG_ROOTDIR to a path that makes sense for u-boot,
> but not for other recipes. However, the kernel-fitimage.bbclasse, for
> example, inherits the uboot-config.bbclass, which brings the
> u-boot-specific path into the kernel build context.
> 
> This change removes the uboot-specific KCONFIG_CONFIG_ROOTDIR path from
> recipes other than u-boot itself.
> 
> Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
> ---
>  meta/classes-recipe/uboot-config.bbclass | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/meta/classes-recipe/uboot-config.bbclass b/meta/classes-recipe/uboot-config.bbclass
> index e55fc38b7c7..09001997d3d 100644
> --- a/meta/classes-recipe/uboot-config.bbclass
> +++ b/meta/classes-recipe/uboot-config.bbclass
> @@ -101,9 +101,9 @@ python () {
>      # The "doc" varflag is special, we don't want to see it here
>      ubootconfigflags.pop('doc', None)
>      ubootconfig = (d.getVar('UBOOT_CONFIG') or "").split()
> +    PN = d.getVar("PN")

Convention says uppercase strings are constants in python. I'd prefer
this to be something like recipename, particularly as the access isn't
immediately around the variable definition. This is mainly to try and
retain code consistency.


Cheers,

Richard
diff mbox series

Patch

diff --git a/meta/classes-recipe/uboot-config.bbclass b/meta/classes-recipe/uboot-config.bbclass
index e55fc38b7c7..09001997d3d 100644
--- a/meta/classes-recipe/uboot-config.bbclass
+++ b/meta/classes-recipe/uboot-config.bbclass
@@ -101,9 +101,9 @@  python () {
     # The "doc" varflag is special, we don't want to see it here
     ubootconfigflags.pop('doc', None)
     ubootconfig = (d.getVar('UBOOT_CONFIG') or "").split()
+    PN = d.getVar("PN")
 
     if not ubootmachine and not ubootconfig:
-        PN = d.getVar("PN")
         FILE = os.path.basename(d.getVar("FILE"))
         bb.debug(1, "To build %s, see %s for instructions on \
                  setting up your machine config" % (PN, FILE))
@@ -140,9 +140,12 @@  python () {
             if not found:
                 raise bb.parse.SkipRecipe("The selected UBOOT_CONFIG key %s has no match in %s." % (ubootconfig, ubootconfigflags.keys()))
 
-            if len(ubootconfig) == 1:
-                d.setVar('KCONFIG_CONFIG_ROOTDIR', os.path.join(d.getVar("B"), d.getVar("UBOOT_MACHINE").strip()))
-            else:
-                # Disable menuconfig for multiple configs
-                d.setVar('KCONFIG_CONFIG_ENABLE_MENUCONFIG', "false")
+            # This recipe might be inherited e.g. by the kernel recipe via kernel-fitimage.bbclass
+            # Ensure the uboot specific menuconfig settings do not leak into other recipes
+            if 'u-boot' in PN:
+                if len(ubootconfig) == 1:
+                    d.setVar('KCONFIG_CONFIG_ROOTDIR', os.path.join(d.getVar("B"), d.getVar("UBOOT_MACHINE").strip()))
+                else:
+                    # Disable menuconfig for multiple configs
+                    d.setVar('KCONFIG_CONFIG_ENABLE_MENUCONFIG', "false")
 }