
Hi Michal,
On Wed, 3 Jan 2024 at 18:24, Michal Simek michal.simek@amd.com wrote:
On 12/28/23 12:57, Sumit Garg wrote:
Changes in v3:
- Patch #4: Minor commit message update
- Patch #5: Replace CONFIG_* with Kconfig options
- Patch #7: Dropped Makefile portion and enabled OF_UPSTREAM for SoC instead.
- Patch #1, #3, #6 and #8: Picked up review tags
Changes in v2:
- Patch #1: excluded gitab CI config check and added commit description.
- Patch #3: s/UBOOT_DTSI_LOC/u_boot_dtsi_loc/
- Patch #4: s/DEVICE_TREE_LOC/dt_dir/ and s/U-boot/U-Boot/
- Patch #5: s/U-boot/U-Boot/
- Patch #6 and #7: Picked up review tags
Prerequisite
This patch series requires devicetree-rebasing git repo to be added as a subtree to the main U-Boot repo via:
$ git subtree add --prefix devicetree-rebasing \ git://git.kernel.org/pub/scm/linux/kernel/git/devicetree/devicetree-rebasing.git \ v6.6-dts --squash
Background
This effort started while I was reviewing patch series corresponding to Qcom platforms [1] which was about to import modified devicetree source files from Linux kernel. I suppose keeping devicetree files sync with Linux kernel without any DT bindings schema validation has been a pain for U-Boot SoC/platform maintainers. There has been past discussions about a single DT repo but that hasn't come up and Linux kernel remained the place where DT source files as well as bindings are placed and maintained.
However, Linux kernel DT maintainers proposed [2] for U-Boot to rather use devicetree-rebasing repo [3] which is a forked copy from Linux kernel for DT source files as well as bindings. It is tagged at every Linux kernel major release or intermideate release candidates. So here I have tried to reuse that to bring DT bingings compliance as well as a standard way to maintain a regular sync of DT source files with Linux kernel.
In order to maintain devicetree files sync, U-Boot will maintains a Git subtree for devicetee-rebasing repo as `devicetee-rebasing/` sub-directory. It will be regularly updated with every new kernel major release via subtree pull as follows:
$ git subtree pull --prefix devicetree-rebasing \ git://git.kernel.org/pub/scm/linux/kernel/git/devicetree/devicetree-rebasing.git \ <release-tag> --squash
The RFC/prototype for this series has been discussed with Linux DT maintainers as well as U-Boot maintainers here [4]. Now we would like to reach out to wider U-Boot community to seek feedback.
[1] https://lore.kernel.org/all/CAFA6WYMLUD9cnkr=R0Uur+1UeTMkKjM2zDdMJtXb3nmrLk+... [2] https://lore.kernel.org/all/CAL_JsqKEjv2tSGmT+0ZiO7_qbBfhTycbGnhJhYpKDFzfO9j... [3] https://git.kernel.org/pub/scm/linux/kernel/git/devicetree/devicetree-rebasi... [4] https://github.com/u-boot/u-boot/pull/451
Changes
Traditionally, U-Boot placed copies of devicetree source files from Linux kernel into `arch/<arch>/dts/<name>.dts`, which can be selected via:
CONFIG_DEFAULT_DEVICE_TREE "<name>"
SoC/board maintainers are encouraged to migrate to using mirrored copies from `devicetree-rebasing/` into `dts/arch/<arch>/<vendor>` via:
CONFIG_OF_UPSTREAM=y CONFIG_DEFAULT_DEVICE_TREE "<vendor>/<name>"
An example have been shown for Amlogic meson-gxbb SoC and corresponding derived boards via patch #7 and #8.
Devicetree bindings schema checks
With devicetee-rebasing Git subtree, the devicetree bindings are also regularly synced with Linux kernel as `devicetree-rebasing/Bindings/` sub-directory. This allows U-Boot to run devicetree bindings schema checks which will bring compliance to U-Boot core/drivers regarding usage of devicetree.
Dependencies
The DT schema project must be installed in order to validate the DT schema binding documents and validate DTS files using the DT schema. The DT schema project can be installed with pip:
$ pip3 install dtschema
Note that 'dtschema' installation requires 'swig' and Python development files installed first. On Debian/Ubuntu systems:
$ apt install swig python3-dev
Several executables (dt-doc-validate, dt-mk-schema, dt-validate) will be installed. Ensure they are in your PATH (~/.local/bin by default).
Recommended is also to install yamllint (used by dtschema when present).
Running checks
In order to perform validation of DTB files, use the ``dtbs_check`` target:
$ make dtbs_check
I have been following your guidance here and I have also seen it to work but not sure why. Anyway I have strong suspicious that any Makefile rule is not right.
Thanks for taking time to test DT schema checks. It looks like your suspicion is correct.
I am getting this issue.
/bin/sh: line 1: @: command not found make[1]: *** [devicetree-rebasing/Bindings/Makefile:68: devicetree-rebasing/Bindings/processed-schema.json] Error 127 make: *** [Makefile:1181: dt_binding_check] Error 2
I was able to reproduce this issue once I installed yamllint on my Ubuntu machine.
devicetree-rebasing/Bindings/processed-schema.json is not generated properly
I am using the latest dt schema $ dt-validate -V 2023.12.dev6+gfb80ec43c204
and no issue to run it from Linux source code that's why I expect it is not issue with my PC in general. Do you know what can be wrong?
The issue here is basically due to old U-Boot Kbuild infrastructure which isn't in sync with Linux kernel. This Kbuild commit [1] changes aren't present in U-Boot leading to this issue.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...
Following change to adapt bindings Makefile to old U-Boot Kbuild expectation should resolve this issue:
diff --git a/devicetree-rebasing/Bindings/Makefile b/devicetree-rebasing/Bindings/Makefile index 8b395893bd8..7d08372691c 100644 --- a/devicetree-rebasing/Bindings/Makefile +++ b/devicetree-rebasing/Bindings/Makefile @@ -47,9 +47,9 @@ quiet_cmd_mk_schema = SCHEMA $@ rm -f $$f
define rule_chkdt - $(if $(DT_SCHEMA_LINT),$(call cmd,yamllint),) - $(call cmd,chk_bindings) - $(call cmd,mk_schema) + $(if $(DT_SCHEMA_LINT),$(call echo-cmd,yamllint) $(cmd_yamllint),); \ + $(call echo-cmd,chk_bindings) $(cmd_chk_bindings); \ + $(call echo-cmd,mk_schema) $(cmd_mk_schema) endef
DT_DOCS = $(patsubst $(srctree)/%,%,$(shell $(find_all_cmd)))
If this works for you then I will include it as a separate patch for v4.
-Sumit
Thanks, Michal