invalid choice: 'kernel_add_dts' in yocto build
Asked Answered
P

1

1

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> ...
Preservative answered 20/6, 2021 at 18:1 Comment(0)
C
3

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:

  • (MACHINE): Your build machine name
  • (PATH/TO/LAYER): The path to the layer that you want the linux-xx_%.bbappend file with the new DTS will be created
  • (PATH/TO/DTS): The path to the new DTS file
  • (YOUR_DTS_NAME): The DTS file name

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 ..."
Chericheria answered 21/6, 2021 at 11:39 Comment(12)
Thanks !! in which file we have to add this : KERNEL_DEVICETREE += "(NEW_DTS_NAME).dtb" ??? also my DTS is actually the modified DTS of the platform.Is it fine? Also in your above answer SRC_URI += .....example.dts . is it correcct? or it has to be the name fo my dts. PLease clarify.Preservative
KERNEL_DEVICETREE += "(NEW_DTS_NAME).dtb" must be added to your machine configuration file, if you are using a custom machine (meta-custom/conf/machine/custom-machine.conf) or if you are using a machine located in an official layer, you can add it to local.conf, SRC_URI is auto generated with recipetool and example.dts is compied to the new custom linux recipe, check run test output. You need to specify the path to your DTS and it will generate it according to your DTS.Chericheria
strangely i get this : patching file arch/arm/boot/dts/myplatform.dts Hunk #1 FAILED at 11. Hunk #2 FAILED at 27. Hunk #3 FAILED at 49. Hunk #4 FAILED at 65. Hunk #5 FAILED at 73. Hunk #6 FAILED at 88.Preservative
why it is patching?myplatform.dts name is same as platform dts.Why it is not taking this new one?Preservative
When you changed the DTS, another patch expected some lines in a particular way, and that failed because you changed it, I edited the reply with a solution to add your final desired DTS file despite patches.Chericheria
bitbake virtual/kernel -c patch still gives the same error - HUNK Failed, I didnt try steps after it . I didnt take a fresh clone but did on my previous build which was failing . May I know which is the path of the patch it is applying and which is the kernel source? i see 2 folders . work and work-shared?. Which is the kernel source on which it is applying the pathc?Preservative
Now all patches are applied, go to tmp/work/../linux-(PROVIDER)/../git and: > I think this step is to be done before recipetool appendsrcfilePreservative
Don't use recipetool in the final solution, just follow one of the 2 last suggestions without recipetool (remove old recipetool output and follow the solution)Chericheria
ohh ok , also do you know if there is a command to undo what recipe tool did earlierPreservative
Also can you please edit the answer accordingly , it will help others as well. thanksPreservative
why this line : cp ${WORKDIR}/myplatform.dts ${S}/arch/(ARCH)/boot/dts/.... inside this : /path/to/meta-custom/recipes-kernel/linux/linux-(PROVIDER)_%.bbappend I have to do this? This cp line is complete? 3 dots...Preservative
Let us continue this discussion in chat.Chericheria

© 2022 - 2024 — McMap. All rights reserved.