linux-kernelyoctobitbakedevice-treerecipe

invalid choice: 'kernel_add_dts' in yocto build


Whats wrong with the argument, is there is no kernel_add_dts subcommand.

I get this below error whenever i try to run $ recipetool kernel_add_dts meta-local /path/to/my.dts

recipetool: error: argument <subcommand>: invalid choice: 'kernel_add_dts' (choose from 'edit', 'create', 'newappend', 'appendfile', 'appendsrcfiles', 'appendsrcfile', 'setvar')
usage: recipetool [-d] [-q] [--color COLOR] [-h] <subcommand> ...

Solution

  • Use recipetool to add a new device tree to your custom layer following this syntax:

    recipetool appendsrcfile -wm (MACHINE) (PATH/TO/LAYER) virtual/kernel (PATH/TO/DTS) 'arch/${ARCH}/boot/dts/(YOUR_DTS_NAME).dts'
    

    Details:

    Important note:

    If the default device tree name is the same as the one you are adding it is not a problem, if not, please make sure that you add it to KERNEL_DEVICETREE variable so that it will be shipped with all the DTS files in the boot partition.

    KERNEL_DEVICETREE += "(NEW_DTS_NAME).dtb"
    

    After that you can stop Uboot (if you are using Uboot) and specify the new DTS file with:

    setenv fdt_file (NEW_DTS_NAME).dtb
    saveenv (If you want to save it for every boot)
    

    Please run "printenv" to make sure of the "fdt_file" variable's name.

    Real run test:

    recipetool appendsrcfile -wm imx8mmddr3lval /home/talel/Desktop/final_git/meta-node virtual/kernel /home/talel/Desktop/example.dts 'arch/${ARCH}/boot/dts/example.dts'
    ...
    NOTE: Writing append file /home/talel/Desktop/final_git/meta-node/recipes-kernel/linux/linux-imx_%.bbappend
    NOTE: Copying /home/talel/Desktop/example.dts to /home/talel/Desktop/final_git/meta-node/recipes-kernel/linux/linux-imx/imx8mmddr3lval/example.dts
    

    The new bbappend file is:

    $ cat /home/talel/Desktop/final_git/meta-node/recipes-kernel/linux/linux-imx_%.bbappend
    
    SRC_URI += "file://example.dts;subdir=git/arch/${ARCH}/boot/dts"
    
    FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
    
    PACKAGE_ARCH = "${MACHINE_ARCH}"
    

    With "virtual/kernel" it will detect what provides it (linux-imx, linux-yocto, ...) and it will create linux-imx_%.append file.

    The -w flag will create "_%" as for any version number.

    Solution to avoid any patch for the DTS file:

    If there is patches for your Linux kernel they will fail if you are updating the DTS with new modifications that override some lines that the patch expects, so you can do it cleanly in 2 ways:

    bitbake virtual/kernel -c cleansstate
    bitbake virtual/kernel -c patch
    

    Now all patches are applied, go to tmp/work/../linux-(PROVIDER)/../git and:

    git add .
    git commit -m "commiting old patches"
    

    Now edit the DTS file and:

    git add arch/../boot/dts/../myplatform.dts
    git commit -m "changes"
    git format-patch -1 -o /path/to/meta-custom/recipes-kernel/linux/files
    

    Now add it to /path/to/meta-custom/recipes-kernel/linux/linux-(PROVIDER)_%.bbappend:

    SRC_URI_append = " file://patch_file.patch"
    

    Or, the other way is to add your final DTS after the patch is done:

    SRC_URI_append = " file://myplatform.dts"
    do_configure_append(){
      cp ${WORKDIR}/myplatform.dts ${S}/arch/(ARCH)/boot/dts/....
    }
    

    and copy your myplatform.dts to /path/to/meta-custom/recipes-kernel/linux/files.

    Now, that's your final DTS file.

    Remove what recipetool added:

    Actually, no undo subcommand in recipetool, you just need to delete the files that recipetool deployed, recipetool copy the file you specified and create a bbappend file, so remove those two files.

    Example: you used recipetool to add example.dts file, recipetool copied example.dts to:

    meta-custom/recipes-kernel/linux/(MACHINE)/example.dts
    

    and created bbappend file in which it added example.dts to SRC_URI variable.

    If you need to keep the bbappend file because you are using it in other way, just modify it and remove the line added by recipetool which contains:

    SRC_URI ... "file://example.dts ..."