-
First convert a Devicetree '.txt' to yaml. Let's take my patch for example : https://lore.kernel.org/all/20240423115749.15786-1-sheharyaar48@gmail.com/
-
Check which architecture use the related drivers. In my patch the related drivers are (under the compatible) :
+ compatible:
+ const: nvidia,tegra20-ac97
- Search the
dts
anddtsi
files wherenvidia,tegra20-ac97
have been used. I userg
program (Github link) instead of grep :
$ rg "nvidia,tegra20-ac97"
sound/soc/tegra/tegra20_ac97.c
441: { .compatible = "nvidia,tegra20-ac97", },
Documentation/devicetree/bindings/sound/nvidia,tegra20-ac97.yaml
4:$id: http://devicetree.org/schemas/sound/nvidia,tegra20-ac97.yaml#
15: const: nvidia,tegra20-ac97
71: compatible = "nvidia,tegra20-ac97";
Next/merge.log
10540: .../bindings/sound/nvidia,tegra20-ac97.txt | 36 -
10541: .../bindings/sound/nvidia,tegra20-ac97.yaml | 82 +
10981: delete mode 100644 Documentation/devicetree/bindings/sound/nvidia,tegra20-ac97.txt
10982: create mode 100644 Documentation/devicetree/bindings/sound/nvidia,tegra20-ac97.yaml
arch/arm/boot/dts/nvidia/tegra20.dtsi --> this here is a 'dtsi' file
379: compatible = "nvidia,tegra20-ac97";
The architecture for this dts file is arm
(from the file path).
dtsi files are included by other files, so we need to find those files as well
- Search dts files associated with the dtsi files (if any) :
$ rg "tegra20.dtsi"
arch/arm/boot/dts/nvidia/tegra20-acer-a500-picasso.dts
9:#include "tegra20.dtsi"
arch/arm/boot/dts/nvidia/tegra20-asus-tf101.dts
9:#include "tegra20.dtsi"
arch/arm/boot/dts/nvidia/tegra20-colibri.dtsi
2:#include "tegra20.dtsi"
arch/arm/boot/dts/nvidia/tegra20-tamonten.dtsi
2:#include "tegra20.dtsi"
arch/arm/boot/dts/nvidia/tegra20-paz00.dts
7:#include "tegra20.dtsi"
arch/arm/boot/dts/nvidia/tegra20-trimslice.dts
5:#include "tegra20.dtsi"
arch/arm/boot/dts/nvidia/tegra20-ventana.dts
6:#include "tegra20.dtsi"
arch/arm/boot/dts/nvidia/tegra20-harmony.dts
5:#include "tegra20.dtsi"
arch/arm/boot/dts/nvidia/tegra20-seaboard.dts
5:#include "tegra20.dtsi"
You can see a lot of files refer to this dtsi
file. All these files must build without errors for making a correct patch.
-
I have
x86_64
but I need to build forarm
, so I need a cross-compiler. On Arch Linux, I needaarch64-linux-gnu-gcc
package from AUR for this. -
After installing the required compiler you need to do the following to cross-compile :
-
First run :
make clean && make mrproper
-
Then run :
export CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm KBUILD_OUTPUT=out/
. This configuresmake
to cross compile forarm
usingaarch64-linux-gnu-
we installed earlier and the output files will be inout/
folder -
Now we need to make sure everything is clean and ready for the new arch, run :
make clean && make mrproper
-
Now we need a default config :
make defconfig
-
Now we are ready to test our binding.
-
First we test our yaml file by :
# to test a single file
make clean && make -j8 dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/sound/nvidia,tegra30-i2s.yaml
# to test a directory
make clean && make dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/usb/
- I use
make clean
to be sure that my changes are being built. In the term-j8
replace 8 with the number of threads your cpu has :lscpu | egrep 'Model name|Socket|Thread|NUMA|CPU\(s\)'
- Look at DT_SCHEMA_FILES, it should have the path oof your yaml file :
DT_SCHEMA_FILES=<path to your yaml>
- Now we will test this yaml file against the dtb files which will be built using (Don't run make clean in the following commands) :
# to test against all the dtbs
$ make -j8 dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/sound/nvidia,tegra30-i2s.yaml
# to test only against a directory (here : arch/arm/boot/aspeed)
$ make -j8 dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/usb/usb-uhci.yaml arch/arm/boot/aspeed
- explain any new changes or if any variable you may have removed in the commit description
- sometimes the dts and dtso files may have deprecated labels, you should fix them rather than modifying the yaml.
- do not add too much examples in the yaml file, a single example is fine.
- make sure to look around similar yamls for code inspiration and try to follow the pattern.
- when making patches make sure to read the rules regarding commit message from the kernel documentation.
- A blog by Krzysztof Kozlowski (maintainer of devicetree bindings) : https://www.linaro.org/blog/tips-and-tricks-for-validating-devicetree-sources-with-the-devicetree-schema/
- A blog by Javier Carrasco : https://javiercarrascocruz.github.io/dt-bindings