linux4sam / meta-atmel

OpenEmbedded/Yocto Project layer for for Microchip SoC (aka AT91)
https://www.linux4sam.org/bin/view/Linux4SAM/YoctoProject
MIT License
91 stars 120 forks source link

Using KBUILD_DEFCONFIG not straightforward #225

Closed rob-baily closed 1 year ago

rob-baily commented 2 years ago

I have been trying to use a custom defconfig in the Linux kernel build for Yocto using KBUILD_DEFCONFIG in a bbappend file and have been struggling with it. I believe I finally got to the root of the issue. In the recipes-kernel linux.inc there is this code:

do_configure_prepend() {
    if [ ! -f "${WORKDIR}/defconfig" ] && [ -n "${KBUILD_DEFCONFIG}" ]; then
        if [ -f "${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG}" ]; then  
            cp -f ${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG} ${WORKDIR}/defconfig
                else
                        bbfatal "A KBUILD_DEFCONFIG '${KBUILD_DEFCONFIG}' was specified, but not present in the source tree"
                fi
        fi
}

There are 2 issues that I had:

I had to work around this issue by including the line SRC_URI_remove_sama5 += "file://defconfig" in my bbappend file to be able to to use KBUILD_DEFCONFIG but this was not obvious based on what I saw in the recipe and include file. I still think this does not address the second bullet where the file already exists.

I am thinking that it would be best to remove the first check on whether the defconfig exists so that if KBUILD_DEFCONFIG it is always processed. Thoughts or questions? If it seems good I can submit a pull request. Another option might be to put a KBUILD_DEFCONFIG file straight to ,config because in the core poky meta kernel.bbclass there is a note in the kernel_do_configure function:


# Copy defconfig to .config if .config does not exist. This allows
# recipes to manage the .config themselves in do_configure_prepend().
rob-baily commented 2 years ago

@noglitch I was wondering if you had a chance to review this? I would be happy to submit a pull request. I am thinking now that the second option I put forth to copy the KBUILD_DEFCONFIG defined file to .config would match up better with the kernel class recipe.

Dharma-B commented 1 year ago

Hi @rob-baily, It was intentionally set that In case KBUILD_DEFCONFIG is set and defconfig file is present, the defconfig file takes priority and KBUILD_DEFCONFIG is ignored, because the defconfig file in meta-atmel may contain some necessary configs for the specified board that are not upstreamed yet.

If you want to use a custom defconfig you can simply include the line SRC_URI:append:sama5 = " file://defconfig" in your bbappend file by introducing a custom defconfig in your layer which would probably replace the defconfig from meta-atmel layer.

@gehariprasath your thoughts?

alexandrebelloni commented 1 year ago

I've submitted https://github.com/linux4sam/meta-atmel/pull/229 which removes KBUILD_DEFCONFIG but keeps the same functionality. I'd love SoC vendors to stop rolling out their custom do_config...

Dharma-B commented 1 year ago

Thanks for the PR @alexandrebelloni, It has been merged, hence closing this issue.