This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM625: How to create a custom defconfig under yocto compilation

Part Number: AM625

Hi TI's expert,

I am doing the custom board with AM6254

with MACHINE=am62xx-evm bitbake tisdk-default-imag will generate full image.

and the kernel will generate the tisdk_am62xx-evm_defconfig which is not inside the original git repo. I mean that this file is generated under kernel compiling.

If I want to custom a defconfig for my custom board and yocto will get this file when build the kernel. How can I do it.

I could do that by cross compile on SDK package, but I need to issue it on yocto for imag.wic file.

Thank

Brian

  • Hi Brian,

    yes the defconfig part of out Yocto builds is generated on-the-fly using some scripting. To use a custom Kernel defconfig you could either amend the config fragment scheme employed by the TI SDK build mechanism, or "fork" the initial defconfig generated by the SDK, modify it to your needs (via menuconfig) and then update the build process to use your own defconfig directly. Let me find some time to dig into this more and get back to you in a few days. I think that is probably also an area our SDK documentation could be improved.

    Regards, Andreas

  • Hi Brian,

    to build the TI Kernel as part of our Yocto image builds with a custom defconfig there are several ways to do that, all of which have their own advantages or disadvantages.

    For example if you would like to keep a custom defconfig as part of the TI Kernel bitbake recipe, you can do something like shown in the following steps, directly updating the linux-ti-staging-5.10 recipe part of the meta-ti layer. The example shows how to modify a Kernel config, create a new defconfig, and make it part of the TI Kernel recipe, all with minimal changes to the Yocto sources needed.

    # Enter Yocto build folder (see SDK guide)
    cd ~/tisdk/am62/build
    
    # Setup Yocto build environment variables (see SDK guide)
    source conf/setenv
    
    # Clean TI Kernel build target
    MACHINE=am62xx-evm bitbake -c clean linux-ti-staging
    
    # Perform the bitbake 'configure' step on the TI Kernel build target to establish a baseline
    # Kernel configuration that can then be used for further customization. Note that this triggers
    # the default defconfig_builder.sh (a TI tool) based process to generate a Kernel config.
    MACHINE=am62xx-evm bitbake -c configure linux-ti-staging
    
    # Now enter the bitbake devshell so we can explore and work on the TI Kernel
    MACHINE=am62xx-evm bitbake -c devshell linux-ti-staging
    
    # Open the Kernel menuconfig tool. There, look for the CONFIG_LOCALVERSION setting and populate
    # it with a custom test string of "defconfig-test". Then, exit the tool.
    make menuconfig
    
    # Verify the changes to the Kernel config that were made
    diff $KBUILD_OUTPUT/.config.old $KBUILD_OUTPUT/.config
    24c24
    < CONFIG_LOCALVERSION=""
    ---
    > CONFIG_LOCALVERSION="defconfig-test"
    
    # Create a new 'defconfig' file based off the current Kernel config
    make savedefconfig
    
    # Verify that a new 'defconfig' file was created in the Kernel build output directory
    ll $KBUILD_OUTPUT
    
    # Copy newly created 'defconfig' into the TI Kernel recipe folder that is part of the meta-ti layer,
    # overwriting the existing 'defconfig' file which is nornally used to trigger defconfig_builder.sh mechanism.
    cp $KBUILD_OUTPUT/defconfig ~/tisdk/am62/sources/meta-ti/recipes-kernel/linux/linux-ti-staging-5.10/k3
    
    # Close the bitbake devshell
    exit
    
    # Clean TI Kernel build target once more so we can witness the build environment to be
    # setup on our new custom defconfig part of the TI Kernel recipe in the next step
    MACHINE=am62xx-evm bitbake -c clean linux-ti-staging
    
    # Build the TI Kernel from scratch
    MACHINE=am62xx-evm bitbake linux-ti-staging
    
    # Parse the strings contained in the Kernel image to see if our custom CONFIG_LOCALVERSION
    # setting got picked up (a crude but simple check)
    strings ~/tisdk/am62/build/arago-tmp-external-arm-glibc/deploy/images/am62xx-evm/Image | grep defconfig-test
    Linux version 5.10.109defconfig-test-g9e58028f94 (oe-user@oe-host) (aarch64-none-linux-gnu-gcc (GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10)) 9.2.1 20191025, GNU ld (GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10)) 2.33.1.20191209) #1 SMP PREEMPT Thu Jun 16 12:28:52 UTC 2022
    5.10.109defconfig-test-g9e58028f94 SMP preempt mod_unload modversions aarch64
    5.10.109defconfig-test-g9e58028f94
    /lib/firmware/updates/5.10.109defconfig-test-g9e58028f94
    /lib/firmware/5.10.109defconfig-test-g9e58028f94
    5.10.109defconfig-test-g9e58028f94

    If you want to keep and maintain your custom defconfig file as part of your own Kernel tree (probably a good idea if you have a custom Kernel tree to keep things together to allow builds from other places), you can also update the ~/tisdk/am62/sources/meta-ti/recipes-kernel/linux/linux-ti-staging-5.10/k3/defconfig file to contain a single entry of use-kernel-config=your_config_name_here (without _defconfig). If you look at the ~/tisdk/am62/sources/meta-ti/recipes-kernel/linux/setup-defconfig.inc file you can see how this works, and what other ways you can use to customize the Kernel configuration.

    You can of course also create your own recipe based off the TI Kernel recipe, or the standard oe-core Kernel recipe. Hope this gives you some pointers on how to proceed.

    Regards, Andreas

  • Hello Andreas,

    Thank you so much. It's very helpful.

    It is done. I keep the custom defconfig from my kernel tree, and modify the function do_configure() in order to use defconfig from Kernel tree in setup-defconfig.inc for my system.

    Regards,

    Brian

  • Hi Brian,

    glad you found a way. I'd probably not modify those functions directly in the original recipe (if this is what you did) as this may make things harder to maintain/forward-migrate in the future. So rather than doing that you could also implement a do_configure_append() function in one of your layers "fix up" the defconfig situation however you like it, this way keeping the original recipe intact. But as said earlier, there are many ways to accomplish what you need, and all have their own trade-offs.

    Regards, Andreas

  • Hello Andreas,

    Many thank you. the keyword _append() for custom layer.

    I will create a meta-custom layer for all things of our product.

    Thanks you for your recommendations.

    Brian.