devicetree-org / dt-schema Goto Github PK
View Code? Open in Web Editor NEWThis project forked from robherring/dt-schema
Devicetree schema tools
Home Page: http://www.devicetree.org
License: BSD 2-Clause "Simplified" License
This project forked from robherring/dt-schema
Devicetree schema tools
Home Page: http://www.devicetree.org
License: BSD 2-Clause "Simplified" License
Hello!
I see that 188cca9 mentions there were some issues with jsonschema 4.18. Would it be possible to test if those still remain? I can also offer some time on this too if you remember some details on what went wrong last time.
The link given in here:
dt-schema/dtschema/schemas/pci/pci-bus-common.yaml
Lines 16 to 17 in e170c2a
The /chosen
node YAML schema is missing a property for stdin-path
, while it is defined in the Devicetree specification.
The two other /chosen
node properties defined in the specification, bootargs
and stdout-path
, do indeed have a corresponding property in the YAML schema.
With the dt-schema 2023.1 and Python 3.11 (Debian testing) I'm getting the following erorr now:
$ PATH=~/.local/bin/:$PATH make -C ../build-64/ ARCH=arm64 CROSS_COMPILE="ccache aarch64-linux-gnu-" dt_binding_check DT_SCHEMA_FILES=msm/gpu.yaml
make: Entering directory '/home/lumag/Projects/Qcomm/build-64'
LINT Documentation/devicetree/bindings
CHKDT Documentation/devicetree/bindings/processed-schema.json
SCHEMA Documentation/devicetree/bindings/processed-schema.json
Traceback (most recent call last):
File "/home/lumag/.local/bin//dt-mk-schema", line 38, in <module>
schemas = dtschema.set_schemas(args.schemas, core_schema=(not args.useronly))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lumag/.local/lib/python3.11/site-packages/dtschema/lib.py", line 1087, in set_schemas
schema_cache = process_schemas(schema_files, core_schema)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lumag/.local/lib/python3.11/site-packages/dtschema/lib.py", line 735, in process_schemas
sch = process_schema(os.path.abspath(filename))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lumag/.local/lib/python3.11/site-packages/dtschema/lib.py", line 713, in process_schema
DTValidator.check_schema(schema, strict=False)
File "/home/lumag/.local/lib/python3.11/site-packages/dtschema/lib.py", line 1238, in check_schema
fixup_schema(schema)
File "/home/lumag/.local/lib/python3.11/site-packages/dtschema/lib.py", line 434, in fixup_schema
add_select_schema(schema)
File "/home/lumag/.local/lib/python3.11/site-packages/dtschema/lib.py", line 599, in add_select_schema
compatible_list = extract_node_compatibles(schema['properties']['compatible'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/lumag/.local/lib/python3.11/site-packages/dtschema/lib.py", line 531, in extract_node_compatibles
compatible_list.update(l)
TypeError: unhashable type: 'dict'
make[1]: *** [/home/lumag/Projects/Qcomm/kernel/Documentation/devicetree/bindings/Makefile:68: Documentation/devicetree/bindings/processed-schema.json] Error 1
make[1]: *** Deleting file 'Documentation/devicetree/bindings/processed-schema.json'
make: *** [/home/lumag/Projects/Qcomm/kernel/Makefile:1511: dt_binding_check] Error 2
make: Leaving directory '/home/lumag/Projects/Qcomm/build-64'
Reproducer: linux-next (e.g. 20240429). make ARCH=arm64 qcom/apq8016-sbc.dtb CHECK_DTBS=y DT_SCHEMA_FILES=qcom,pmic-gpio.yaml
I'm currently getting the following error:
/home/lumag/Projects/Qcomm/build-64/arch/arm64/boot/dts/qcom/apq8016-sbc.dtb: gpio@c000: gpio-line-names: ['USR_LED_3_CTRL', 'USR_LED_4_CTRL', 'USB_HUB_RESET_N_PM', 'USB_SW_SEL_PM'] is too short
from schema $id: http://devicetree.org/schemas/pinctrl/qcom,pmic-gpio.yaml#
With the https://lore.kernel.org/linux-arm-msm/[email protected]/ I can no longer reproduce the issue. However the patch fixes a branch which should be false anyway.
I was able to limit it to the following reproducer:
allOf:
- if:
properties:
compatible:
contains:
enum:
- qcom,pm8916-gpio
then:
properties:
gpio-line-names:
minItems: 4
maxItems: 4
- if:
properties:
comptaible:
contains:
enum:
- qcom,pmih0108-gpio
then:
properties:
gpio-line-names:
minItems: 18
maxItems: 18
Note, changing allOf
to oneOf
results in the following warning, which shows that second branch evaluated to true:
/home/lumag/Projects/Qcomm/build-64/arch/arm64/boot/dts/qcom/apq8016-sbc.dtb: gpio@c000: More than one condition true in oneOf schema:
cc @krzk
I'm trying to get MIPS loongson/loongson64g_4core_ls7a.dtb
passing dt schema checks.
After fixing #100 I fall into errors like:
/home/flygoat/linux-next/arch/mips/boot/dts/loongson/loongson64g_4core_ls7a.dtb: pci@1a000000: ohci@4,0:interrupts-extended:0: [4, 49, 4] is too long
from schema $id: http://devicetree.org/schemas/pci/loongson.yaml#
On nodes like:
ohci@4,0 {
compatible = "pci0014,7a24.0",
"pci0014,7a24",
"pciclass0c0310",
"pciclass0c03";
reg = <0x2000 0x0 0x0 0x0 0x0>;
interrupts-extended = <&pic 49 IRQ_TYPE_LEVEL_HIGH>;
};
This is because in our pci device schema pci-device.yaml
, we assumed interrupts
must be one of the PCI legacy interrupt:
interrupts:
items:
- items:
- enum: [1, 2, 3, 4] # INTA, INTB, INTC, INTD
I do think loongson64g_4core_ls7a.dtb
's use case is somehow legitimate, how can we reasonably accommodate in schema?
Thanks
Version: There is a tag v0.1
but both that tag's and master's setup.py
specify it as 0.0.1
.
Could you please bump it to 0.2.0
and push some new v0.2
tag? README.md
makes it sound like one could do an installation into .local
, but pip
actually tries to install stuff to global /usr
. Thus a saner way to create a distro package than 0.0.1~git<date-and-or-commit>
would be appreciated, now that the Linux kernel has started using it as dependency.
URL: The Linux kernel's writing-schema.rst
points to this devicetree-org/dt-schema.git
repo, but setup.py
says https://github.com/robherring/yaml-bindings
(which redirects to https://github.com/robherring/dt-schema
). Which one is the official one to use?
Tests: Can test/test-dt-validate.py
be integrated into setup.py
so that setup.py test
just works and one does not need to call that file explicitly? (Makefile doesn't work well in a multi-version Python build environment such as OBS.)
Dependencies: Please don't hardcode dependency versions. jsonschema
3.0.2 appears to work just fine with latest master, so can you please change from jsonschema==3.0.1
to jsonschema>=3.0.1
to allow installation on distros with newer packages?
I see this on Linux ommit:
I see this with Linux -next:
f017d9a92a73 (tag: next-20231024, next/master) Add linux-next specific files for 20231024
make dt_binding_check -s -j30
/home/sglass/cosarm/linux/Documentation/devicetree/bindings/mfd/qcom-pm8xxx.yaml:
Error in referenced schema matching $id: http://devicetree.org/schemas/input/qcom,pm8921-keypad.yaml
Traceback (most recent call last):
File "/home/sglass/.local/bin/dt-doc-validate", line 64, in
ret |= check_doc(f)
File "/home/sglass/.local/bin/dt-doc-validate", line 32, in check_doc
for error in sorted(dtsch.iter_errors(), key=lambda e: e.linecol):
File "/home/sglass/.local/lib/python3.10/site-packages/dtschema/schema.py", line 125, in iter_errors
self.annotate_error(scherr, meta_schema, scherr.schema_path)
File "/home/sglass/.local/lib/python3.10/site-packages/dtschema/schema.py", line 104, in annotate_error
schema = schema[p]
KeyError: 'type'
Traceback (most recent call last):
File "/home/sglass/.local/bin/dt-doc-validate", line 64, in
ret |= check_doc(f)
File "/home/sglass/.local/bin/dt-doc-validate", line 32, in check_doc
for error in sorted(dtsch.iter_errors(), key=lambda e: e.linecol):
File "/home/sglass/.local/lib/python3.10/site-packages/dtschema/schema.py", line 125, in iter_errors
self.annotate_error(scherr, meta_schema, scherr.schema_path)
File "/home/sglass/.local/lib/python3.10/site-packages/dtschema/schema.py", line 104, in annotate_error
schema = schema[p]
KeyError: 'type'
/home/sglass/.local/lib/python3.10/site-packages/dtschema/schemas/reserved-memory/shared-dma-pool.yaml: warning: ignoring duplicate '$id' value 'http://devicetree.org/schemas/reserved-memory/shared-dma-pool.yaml#'
/home/sglass/.local/lib/python3.10/site-packages/dtschema/schemas/reserved-memory/memory-region.yaml: warning: ignoring duplicate '$id' value 'http://devicetree.org/schemas/reserved-memory/memory-region.yaml#'
/home/sglass/.local/lib/python3.10/site-packages/dtschema/schemas/reserved-memory/reserved-memory.yaml: warning: ignoring duplicate '$id' value 'http://devicetree.org/schemas/reserved-memory/reserved-memory.yaml#'
/home/sglass/.local/lib/python3.10/site-packages/dtschema/schemas/reserved-memory/framebuffer.yaml: warning: ignoring duplicate '$id' value 'http://devicetree.org/schemas/reserved-memory/framebuffer.yaml#'
/home/sglass/cosarm/linux/Documentation/devicetree/bindings/sound/renesas,rsnd.example.dtb: sound@ec500000: port:endpoint: Unevaluated properties are not allowed ('phandle' was unexpected)
from schema $id: http://devicetree.org/schemas/sound/renesas,rsnd.yaml#
/home/sglass/cosarm/linux/Documentation/devicetree/bindings/sound/renesas,rsnd.example.dtb: sound@ec500000: Unevaluated properties are not allowed ('port' was unexpected)
from schema $id: http://devicetree.org/schemas/sound/renesas,rsnd.yaml#
Hi, at OpenWrt there are sometimes badly styled DT files which waste human time to comment and fix, it would be nice to have some automatic checks for that. Is there a tool like astyle or clang-format for device tree files?
On recent next (e.g. next-20230720):
cd out
dt-validate -l /bindings/extcon/siliconmitus,sm5502-muic.yaml -u ../Documentation/devicetree/bindings -p ./Documentation/devicetree/bindings/processed-schema.json arch/arm64/boot/dts/qcom/msm8916-samsung-serranove.dtb
Expected:
/home/krzk/dev/linux/linux/out/arch/arm64/boot/dts/qcom/msm8916-samsung-serranove.dtb: extcon@14: 'connector' does not match any of the regexes: 'pinctrl-[0-9]+'
From schema: /home/krzk/dev/linux/linux/Documentation/devicetree/bindings/extcon/siliconmitus,sm5502-muic.yaml
Result:
Nothing (success)
Bisection pointed to dtschema commit: bc164f9 ("Split DTValidator class into 2 classes")
$ dt-doc-validate -u Documentation/devicetree/bindings Documentation/devicetree/bindings/i2c/nvidia,tegra-i2c.yaml
Traceback (most recent call last):
File "/home/okias/.local/bin/dt-doc-validate", line 67, in <module>
ret = check_doc(f)
File "/home/okias/.local/bin/dt-doc-validate", line 33, in check_doc
for error in sorted(dtschema.DTValidator.iter_schema_errors(testtree), key=lambda e: e.linecol):
File "/home/okias/.local/lib/python3.9/site-packages/dtschema/lib.py", line 724, in iter_schema_errors
cls(meta_schema).annotate_error(error, meta_schema, error.schema_path)
File "/home/okias/.local/lib/python3.9/site-packages/dtschema/lib.py", line 707, in annotate_error
schema = schema[p]
KeyError: 'properties'
content of nvidia,tegra-i2c.yaml
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/i2c/nvidia,tegra-i2c.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: NVIDIA Tegra I2C controller driver
maintainers:
- No-one <[email protected]>
allOf:
- $ref: /schemas/i2c/i2c-controller.yaml#
- if:
properties:
compatible:
contains:
enum:
- nvidia,tegra20-i2c
- nvidia,tegra30-i2c
then:
properties:
clock-names:
items:
- const: div-clk
- const: fast-clk
- if:
properties:
compatible:
contains:
enum:
- nvidia,tegra114-i2c
- nvidia,tegra210-i2c
then:
properties:
clock-names:
items:
- const: div-clk
- if:
properties:
compatible:
contains:
- const: nvidia,tegra210-i2c-vi
then:
properties:
clock-names:
items:
- const: div-clk
- const: slow
properties:
compatible:
oneOf:
- description: |
Tegra20 has 4 generic I2C controller. This can support
master and slave mode of I2C communication. The i2c-tegra driver
only support master mode of I2C communication.
items:
- const: nvidia,tegra20-i2c
- description: |
Tegra20 has specific I2C controller called as DVC I2C
controller. This only support master mode of I2C communication.
Register interface/offset and interrupts handling are different
than generic I2C controller.
items:
- const: nvidia,tegra20-i2c-dvc
- description: |
Tegra30 has 5 generic I2C controller. This controller is
very much similar to Tegra20 I2C controller with additional feature:
Continue Transfer Support. This feature helps to implement M_NO_START
as per I2C core API transfer flags. Driver of I2C controller is
compatible with "nvidia,tegra30-i2c" to enable the continue transfer
support. This is also compatible with "nvidia,tegra20-i2c" without
continue transfer support.
items:
- const: nvidia,tegra30-i2c
- const: nvidia,tegra20-i2c
- description: |
Tegra114 has 5 generic I2C controller. This controller is very
much similar to Tegra30 I2C controller with some hardware modification:
- Tegra30/Tegra20 I2C controller has 2 clock source called div-clk and
fast-clk. Tegra114 has only one clock source called as div-clk and
hence clock mechanism is changed in I2C controller.
- Tegra30/Tegra20 I2C controller has enabled per packet transfer by
default and there is no way to disable it. Tegra114 has this
interrupt disable by default and SW need to enable explicitly.
Due to above changes, Tegra114 I2C driver makes incompatible with
previous hardware driver.
items:
- const: nvidia,tegra114-i2c
- items:
- const: nvidia,tegra124-i2c
- const: nvidia,tegra114-i2c
- items:
- const: nvidia,tegra210-i2c
- const: nvidia,tegra124-i2c
- description: |
Tegra210 has one I2C controller that is on host1x bus
and is part of VE power domain and typically used for camera use-cases.
This VI I2C controller is mostly compatible with the programming model
of the regular I2C controllers with a few exceptions. The I2C registers
start at an offset of 0xc00 (instead of 0), registers are 16 bytes
apart (rather than 4) and the controller does not support slave mode.
items:
- const: nvidia,tegra210-i2c-vi
- items:
- const: nvidia,tegra186-i2c
- const: nvidia,tegra210-i2c
reg: true
interrupts: true
'#address-cells':
const: 1
'#size-cells':
const: 0
clocks: true
clock-names: true
resets: true
reset-names:
items:
- i2c
power-domains:
description: |
Only for nvidia,tegra210-i2c-vi compatible node and must
include venc powergate node as vi i2c is part of VE power domain.
tegra210-i2c-vi:
- pd_venc
dmas:
description: |
Must contain an entry for each entry in clock-names.
dma-names:
items:
- rx
- tx
required:
- compatible
- clocks
- clock-names
additionalProperties: false
examples:
- |
i2c@7000c000 {
compatible = "nvidia,tegra20-i2c";
reg = <0x7000c000 0x100>;
interrupts = <0 38 0x04>;
#address-cells = <1>;
#size-cells = <0>;
clocks = <&tegra_car 12>, <&tegra_car 124>;
clock-names = "div-clk", "fast-clk";
resets = <&tegra_car 12>;
reset-names = "i2c";
dmas = <&apbdma 16>, <&apbdma 16>;
dma-names = "rx", "tx";
};
I'm pretty sure the YAML file is wrong, just reporting the dt-doc-validate
crash
$ dt-validate --version
2023.10.dev5+g5d76ad1
In dtschema.fixups.is_int_array_schema()
it is possible to crash on line 98 if item
is a string instead of an array.
Lines 97 to 98 in 5d76ad1
This can be reproduced by taking a valid binding with the pattern:
allOf:
- $ref: /schemas/simple-bus.yaml#
and removing the -
so that it is no longer an array
allOf:
$ref: /schemas/simple-bus.yaml#
Here is an example stack trace from a crash:
Traceback (most recent call last):
File "/home/david/.local/bin/dt-mk-schema", line 38, in <module>
schemas = dtschema.DTValidator(args.schemas).schemas
File "/home/david/.local/pipx/venvs/dtschema/lib/python3.10/site-packages/dtschema/validator.py", line 358, in __init__
self.schemas = process_schemas(schema_files)
File "/home/david/.local/pipx/venvs/dtschema/lib/python3.10/site-packages/dtschema/validator.py", line 275, in process_schemas
sch = process_schema(os.path.abspath(filename))
File "/home/david/.local/pipx/venvs/dtschema/lib/python3.10/site-packages/dtschema/validator.py", line 259, in process_schema
schema = dtsch.fixup()
File "/home/david/.local/pipx/venvs/dtschema/lib/python3.10/site-packages/dtschema/schema.py", line 151, in fixup
dtschema.fixups.fixup_schema(processed_schema)
File "/home/david/.local/pipx/venvs/dtschema/lib/python3.10/site-packages/dtschema/fixups.py", line 483, in fixup_schema
fixup_sub_schema(schema)
File "/home/david/.local/pipx/venvs/dtschema/lib/python3.10/site-packages/dtschema/fixups.py", line 368, in fixup_sub_schema
walk_properties(prop, v[prop])
File "/home/david/.local/pipx/venvs/dtschema/lib/python3.10/site-packages/dtschema/fixups.py", line 296, in walk_properties
fixup_vals(propname, schema)
File "/home/david/.local/pipx/venvs/dtschema/lib/python3.10/site-packages/dtschema/fixups.py", line 273, in fixup_vals
_fixup_int_array_min_max_to_matrix(propname, schema)
File "/home/david/.local/pipx/venvs/dtschema/lib/python3.10/site-packages/dtschema/fixups.py", line 112, in _fixup_int_array_min_max_to_matrix
if not is_int_array_schema(propname, subschema):
File "/home/david/.local/pipx/venvs/dtschema/lib/python3.10/site-packages/dtschema/fixups.py", line 98, in is_int_array_schema
return int_array_re.search(item['$ref'])
TypeError: string indices must be integers
The validation error messages are hard to understand. Part of the problem is how track down what schema causes an error.
We have the top schema file already available, but any $ref is not followed.
-m argument stopped working on 2023.09 and 2023.11 (did not look earlier).
make DT_CHECKER_FLAGS=-m dt_binding_check DT_SCHEMA_FILES=qcom,sm4450-tlmm.yaml
Result: everything fine
Expected result: warning for unmatched compatible (qcom,sm4450-pinctrl is documented, not qcom,sm4450-tlmm)
Most schema don't need values quoted except if they begin with '#'.
As the quoting is stripped from the python dict, the ruamel data will have to be used.
Currently, /schemas/interrupt-controller.yaml allows the node names to match:
"^interrupt-controller(@[0-9a-f,]+)*$"
Which means that for non-MMIO-mapped nodes we can only use interrupt-controller
.
But then, a property with an identical name (interrupt-controller;
) is required.
Trying to create such a node emits a warning in dtc:
Warning (node_name_vs_property_name): /example-0/interrupt-controller: node name and property name conflict
Before updating to the latest dtschema
I was using 2021.2 or 2021.3 release to work with in-Linux YAML files. That left me with some foo.example.dt.yaml
files.
After switching to the latest Linux sources & updating dtschema
Linux's dtbs_check
stopped working for me without printing any meaningful error. I had to install dt-schema
locally and debug it.
dt-doc-validate
In my Linux sources directory I have following file:
> cat Documentation/devicetree/bindings/pinctrl/qcom,mdm9607-pinctrl.example.dt.yaml
---
- compatible: ["foo"]
model: ["foo"]
interrupt-parent: [[!phandle 0xffffffff]]
'#address-cells': [[0x1]]
'#size-cells': [[0x1]]
example-0:
'#address-cells': [[0x1]]
'#size-cells': [[0x1]]
pinctrl@1000000:
compatible: ["qcom,mdm9607-tlmm"]
reg: [[0x1000000, 0x300000]]
interrupts: [[0x0, 0xd0, 0x4]]
gpio-controller: true
gpio-ranges: [[!phandle 0xffffffff, 0x0, 0x0, 0x50]]
'#gpio-cells': [[0x2]]
interrupt-controller: true
'#interrupt-cells': [[0x2]]
__fixups__:
foo: ["/:interrupt-parent:0"]
msmgpio: ["/example-0/pinctrl@1000000:gpio-ranges:0"]
...
It causes:
Traceback (most recent call last):
File "/home/rmilecki/.local/bin/dt-doc-validate", line 7, in <module>
exec(compile(f.read(), __file__, 'exec'))
File "/home/rmilecki/dt-schema/tools/dt-doc-validate", line 71, in <module>
ret = check_doc(f)
File "/home/rmilecki/dt-schema/tools/dt-doc-validate", line 37, in check_doc
for error in sorted(dtschema.DTValidator.iter_schema_errors(testtree), key=lambda e: e.linecol):
File "/home/rmilecki/dt-schema/dtschema/lib.py", line 1019, in iter_schema_errors
meta_schema = cls.resolver.resolve_from_url(schema['$schema'])
TypeError: list indices must be integers or slices, not str
It's because in case of above YAML file variable schema
is not dict
but a following list:
[{'compatible': ['foo'], 'model': ['foo'], 'interrupt-parent': [[4294967295]], '#address-cells': [[1]], '#size-cells': [[1]], 'example-0': {'#address-cells': [[1]], '#size-cells': [[1]], 'pinctrl@1000000': {'compatible': ['qcom,mdm9607-tlmm'], 'reg': [[16777216, 3145728]], 'interrupts': [[0, 208, 4]], 'gpio-controller': True, 'gpio-ranges': [[4294967295, 0, 0, 80]], '#gpio-cells': [[2]], 'interrupt-controller': True, '#interrupt-cells': [[2]]}}, '__fixups__': {'foo': ['/:interrupt-parent:0'], 'msmgpio': ['/example-0/pinctrl@1000000:gpio-ranges:0']}}]
In my Linux sources directory I have following file:
> cat Documentation/devicetree/bindings/mtd/partitions/brcm,trx.example.dt.yaml
---
- compatible: ["foo"]
model: ["foo"]
interrupt-parent: [[!phandle 0xffffffff]]
'#address-cells': [[0x1]]
'#size-cells': [[0x1]]
example-0:
'#address-cells': [[0x1]]
'#size-cells': [[0x1]]
partitions:
compatible: ["brcm,trx"]
__fixups__:
foo: ["/:interrupt-parent:0"]
...
It causes:
Traceback (most recent call last):
File "/home/rmilecki/.local/bin/dt-mk-schema", line 7, in <module>
exec(compile(f.read(), __file__, 'exec'))
File "/home/rmilecki/dt-schema/tools/dt-mk-schema", line 38, in <module>
schemas = dtschema.process_schemas(args.schemas, core_schema=(not args.useronly))
File "/home/rmilecki/dt-schema/dtschema/lib.py", line 719, in process_schemas
sch = process_schema(os.path.abspath(filename))
File "/home/rmilecki/dt-schema/dtschema/lib.py", line 695, in process_schema
DTValidator.check_schema(schema)
File "/home/rmilecki/dt-schema/dtschema/lib.py", line 1036, in check_schema
meta_schema = cls.resolver.resolve_from_url(schema['$schema'])
TypeError: list indices must be integers or slices, not str
make[1]: *** [Documentation/devicetree/bindings/Makefile:70: Documentation/devicetree/bindings/processed-schema.json] Error 1
It's because in case of above YAML file variable schema
is not dict
but a following list:
[{'compatible': ['foo'], 'model': ['foo'], 'interrupt-parent': [[4294967295]], '#address-cells': [[1]], '#size-cells': [[1]], 'example-0': {'#address-cells': [[1]], '#size-cells': [[1]], 'partitions': {'compatible': ['brcm,trx']}}, '__fixups__': {'foo': ['/:interrupt-parent:0']}}]
setup.py
(setuptools_scm
) appears to be looking for some version metadata that the released GitHub dt-schema-2020.05.tar.gz
tarball from the Releases tab does not contain:
[ 30s] + /usr/bin/python3 setup.py build '--executable=/usr/bin/python3 -s'
[ 30s] Traceback (most recent call last):
[ 30s] File "setup.py", line 20, in <module>
[ 30s] setuptools.setup(
[ 30s] File "/usr/lib/python3.8/site-packages/setuptools/__init__.py", line 145, in setup
[ 30s] return distutils.core.setup(**attrs)
[ 30s] File "/usr/lib/python3.8/distutils/core.py", line 108, in setup
[ 30s] _setup_distribution = dist = klass(attrs)
[ 30s] File "/usr/lib/python3.8/site-packages/setuptools/dist.py", line 447, in __init__
[ 30s] _Distribution.__init__(self, {
[ 30s] File "/usr/lib/python3.8/distutils/dist.py", line 292, in __init__
[ 30s] self.finalize_options()
[ 30s] File "/usr/lib/python3.8/site-packages/setuptools/dist.py", line 740, in finalize_options
[ 30s] ep.load()(self)
[ 31s] File "/usr/lib/python3.8/site-packages/setuptools/dist.py", line 747, in _finalize_setup_keywords
[ 31s] ep.load()(self, ep.name, value)
[ 31s] File "/usr/lib/python3.8/site-packages/setuptools_scm/integration.py", line 17, in version_keyword
[ 31s] dist.metadata.version = _get_version(config)
[ 31s] File "/usr/lib/python3.8/site-packages/setuptools_scm/__init__.py", line 147, in _get_version
[ 31s] parsed_version = _do_parse(config)
[ 31s] File "/usr/lib/python3.8/site-packages/setuptools_scm/__init__.py", line 110, in _do_parse
[ 31s] raise LookupError(
[ 31s] LookupError: setuptools-scm was unable to detect version for '/home/abuild/rpmbuild/BUILD/dt-schema-2020.05'.
[ 31s]
[ 31s] Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.
[ 31s]
[ 31s] For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj
On the other hand, #35 indicates that a PyPI tarball is not available yet, seemingly leaving us with no buildable tarball. Since the tarball is not just from some tag but also announced under Releases, I would expect it to be usable as is.
By sed -i "s|'setuptools_scm'||" setup.py
and echo '__version__ = "2020.5"' > dtschema/version.py
I can get the build to finish.
I think the README could be updated with more concrete examples as I have forgotten how to use this. I get:
f2b7cbf (HEAD, us/master) dtschema: Relax validation of schemas when processed
$ tools/dt-mk-schema >asc
$ tools/dt-validate -s asc test/schemas/good-example.yaml
Traceback (most recent call last):
File "/scratch/sglass/cosarm/dt-schema/tools/dt-validate", line 175, in
sg.check_trees(filename, testtree)
File "/scratch/sglass/cosarm/dt-schema/tools/dt-validate", line 122, in check_trees
self.check_subtree(dt, subtree, False, "/", "/", filename)
File "/scratch/sglass/cosarm/dt-schema/tools/dt-validate", line 106, in check_subtree
self.check_node(tree, subtree, disabled, nodename, fullname, filename)
File "/scratch/sglass/cosarm/dt-schema/tools/dt-validate", line 38, in check_node
node['$nodename'] = [ nodename ]
TypeError: 'str' object does not support item assignment
Ignores all problems inside structures as:
allOf:
- if:
....
then:
_CODE_PLACED_HERE_ISN'T_CHECKED
with commit:
99646e2 (HEAD, us/master, us/main) meta-schemas: Restrict 'const' to scalar values
Perhaps I am doing it wrong but I thought this use to work:
Traceback (most recent call last):
File "/scratch/sglass/cosarm/dt-schema/tools/dt-doc-validate", line 65, in
ret = check_doc(filename)
File "/scratch/sglass/cosarm/dt-schema/tools/dt-doc-validate", line 39, in check_doc
dtschema.DTValidator.check_schema_refs(filename, testtree)
File "/scratch/sglass/cosarm/dt-schema/dtschema/lib.py", line 1260, in check_schema_refs
self._check_schema_refs(schema)
File "/scratch/sglass/cosarm/dt-schema/dtschema/lib.py", line 1248, in _check_schema_refs
self._check_schema_refs(v)
File "/scratch/sglass/cosarm/dt-schema/dtschema/lib.py", line 1248, in _check_schema_refs
self._check_schema_refs(v)
File "/scratch/sglass/cosarm/dt-schema/dtschema/lib.py", line 1248, in _check_schema_refs
self._check_schema_refs(v)
File "/scratch/sglass/cosarm/dt-schema/dtschema/lib.py", line 1245, in _check_schema_refs
self.resolver.resolve(schema['$ref'])
File "/home/sglass/.local/lib/python3.10/site-packages/jsonschema/validators.py", line 881, in resolve
url = self._urljoin_cache(self.resolution_scope, ref).rstrip("/")
File "/usr/lib/python3.10/urllib/parse.py", line 532, in urljoin
base, url, _coerce_result = _coerce_args(base, url)
File "/usr/lib/python3.10/urllib/parse.py", line 125, in _coerce_args
raise TypeError("Cannot mix str and non-str arguments")
TypeError: Cannot mix str and non-str arguments
pip3 install -e .
Defaulting to user installation because normal site-packages is not writeable
Obtaining file:///home/conor/stuff/dt-schema
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
ERROR: Project file:///home/conor/stuff/dt-schema has a 'pyproject.toml' and its build backend is missing the 'build_editable' hook. Since it does not have a 'setup.py' nor a 'setup.cfg', it cannot be installed in editable mode. Consider using a build backend that supports PEP 660.
I dunno jack about pyproject.toml etc so I do not know the fix. I just dropped the -e to install the thing locally :)
The commit message swapping over says:
When last looked at pyproject.toml, editable installs weren't supported,
but they are now. So let's move over to the latest and greatest to avoid
this warning.
So I suppose there is a way to do this, but the documentation needs an update?
On my gentoo dt checks works with jsonschema-3.2.0
But after upgrading on 4.3.3 I got:
Traceback (most recent call last):
File "/usr/lib/python-exec/python3.9/dt-mk-schema", line 38, in
schemas = dtschema.process_schemas(args.schemas, core_schema=(not args.useronly))
File "/usr/lib/python3.9/site-packages/dtschema/lib.py", line 587, in process_schemas
sch = process_schema(os.path.abspath(filename))
File "/usr/lib/python3.9/site-packages/dtschema/lib.py", line 568, in process_schema
DTValidator.check_schema(schema)
File "/usr/lib/python3.9/site-packages/dtschema/lib.py", line 699, in check_schema
for error in cls(meta_schema).iter_errors(schema):
File "/usr/lib/python3.9/site-packages/dtschema/lib.py", line 681, in init
jsonschema.Draft7Validator.init(self, schema, types, resolver=self.resolver,
TypeError: init() got multiple values for argument 'resolver'
make[2]: *** [/usr/src/linux-next/Documentation/devicetree/bindings/Makefile:76 : Documentation/devicetree/bindings/processed-schema-examples.json] Erreur 1
make[2]: *** Suppression du fichier « Documentation/devicetree/bindings/processed-schema-examples.json »
make[1]: *** [/usr/src/linux-next/Makefile:1471 : dt_binding_check] Erreur 2
I'm trying to contribute some devicetree documentation and trying to verify my example. May naive usage:
dt-validate Documentation/devicetree/bindings/auxdisplay/hit,hd44780+nxp,pcf8575.yaml
produces:
Traceback (most recent call last):
File "/usr/local/bin/dt-validate", line 164, in <module>
sg.check_trees(filename, testtree)
File "/usr/local/bin/dt-validate", line 113, in check_trees
self.check_subtree(dt, subtree, "/", "/", filename)
File "/usr/local/bin/dt-validate", line 99, in check_subtree
self.check_node(tree, subtree, nodename, fullname, filename)
File "/usr/local/bin/dt-validate", line 39, in check_node
node['$nodename'] = [ nodename ]
TypeError: 'str' object does not support item assignment
Now I'm quite sure this is an error in my usage of the tool (but the tool should help me with a message and not throw a traceback). Can you give me (or preferrably add this to the documentation on this page) a quick start how to verify a single yaml file against the schemata in-kernel?
I'm trying to get some documentation into the kernel and I'm at the point where it produces a warning that I cannot reproduce locally.
clock-output-names will most of the time (always?) be a list of strings that is under control of the device tree itself, so we cannot really mandate a list of values.
Therefore, using something like
clock-output-names:
items:
- description: First clock to name
- description: Second clock to name
However, the meta-schema seems to reject it
Running make dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/trivial-devices.yaml
on a recent linux kernel yields TypeError: __init__() got an unexpected keyword argument 'resolver'
. What is going wrong?
EDIT it really doesn't seem to matter on what files I am trying to run dt-doc-validate: dt-doc-validate -u Documentation/devicetree/bindings Documentation/devicetree/bindings/i2c/i2c-owl.yaml
yields exactly the same error.
the phy-provider pattern matches against ...phy@... but for example
on some Rockchip socs the actual phy node might be in a subnode of it,
like when the phy is composed of multiple phys.
Which then triggers an error about #phy-cells being missing.
For example in arch/arm64/boot/dts/rockchip/rk3399.dtsi:
u2phy0: usb2-phy@e450 { compatible = "rockchip,rk3399-usb2phy"; reg = <0xe450 0x10>; clocks = <&cru SCLK_USB2PHY0_REF>; clock-names = "phyclk"; #clock-cells = <0>; clock-output-names = "clk_usbphy0_480m"; status = "disabled"; u2phy0_host: host-port { #phy-cells = <0>; interrupts = <GIC_SPI 27 IRQ_TYPE_LEVEL_HIGH 0>; interrupt-names = "linestate"; status = "disabled"; }; u2phy0_otg: otg-port { #phy-cells = <0>; interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH 0>, <GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH 0>, <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH 0>; interrupt-names = "otg-bvalid", "otg-id", "linestate"; status = "disabled"; }; };
Not sure how to solve this though
Hi,
the license of the project is not clear (would be nice if it had a LICENSE
file).
If you publish this on PyPi it would make packaging easier as well.
So jsonschema 4.18 is changing the way referencing works: https://github.com/python-jsonschema/jsonschema/blob/main/CHANGELOG.rst#v4180
Already dt-schema requires <4.18
to work: 188cca9
I made this issue to track the progress of getting this to work. I don't really understand what the problem is, but there are 2 general paths:
referencing
libraryI might be able to help with either of those, but some help in terms of what's the hack dt-schema requires that is now off limits would be nice.
P.S: I'm maintainer of alpine's py3-dt-schema
package, so I spend a few hours banging my head to figure out it was jsonschema's fault all along.
Commit 99646e2 doesn't take into account the possibility of having an if condition based on the value of a boolean.
Do we want this, or should I work around it (can't really think of how)?
allOf:
- if:
properties:
adi,single-ended:
const: true
then:
properties:
reg:
minimum: 1
I try to validate a device-tree in yaml format.
a.yaml.txt
Unfortunately this results in an error:
$ dt-validate /tmp/a.yaml
Traceback (most recent call last):
File "/usr/local/bin/dt-validate", line 4, in <module>
__import__('pkg_resources').run_script('dtschema==2020.8.2.dev11+gf66186d', 'dt-validate')
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 650, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1446, in run_script
exec(code, namespace, namespace)
File "/usr/local/lib/python3.8/dist-packages/dtschema-2020.8.2.dev11+gf66186d-py3.8.egg/EGG-INFO/scripts/dt-validate", line 159, in <module>
sg.check_trees(filename, testtree)
File "/usr/local/lib/python3.8/dist-packages/dtschema-2020.8.2.dev11+gf66186d-py3.8.egg/EGG-INFO/scripts/dt-validate", line 108, in check_trees
self.check_subtree(dt, subtree, "/", "/", filename)
File "/usr/local/lib/python3.8/dist-packages/dtschema-2020.8.2.dev11+gf66186d-py3.8.egg/EGG-INFO/scripts/dt-validate", line 94, in check_subtree
self.check_node(tree, subtree, nodename, fullname, filename)
File "/usr/local/lib/python3.8/dist-packages/dtschema-2020.8.2.dev11+gf66186d-py3.8.egg/EGG-INFO/scripts/dt-validate", line 39, in check_node
node['$nodename'] = [ nodename ]
TypeError: 'str' object does not support item assignment
I have been using DTC 1.4.4 to convert the dtb to dts (a.dts.txt) and dts2yaml (https://github.com/pantoniou/yamldt) to convert the dts to yaml
As per the docs:
https://github.com/devicetree-org/dt-schema
it is possible to install the latest from github:
pip3 install git+https://github.com/devicetree-org/dt-schema.git@main
This is what I get:
Defaulting to user installation because normal site-packages is not writeable
Collecting git+https://github.com/devicetree-org/dt-schema.git@main
Cloning https://github.com/devicetree-org/dt-schema.git (to revision main) to /tmp/pip-req-build-60tnocl4
Running command git clone --filter=blob:none --quiet https://github.com/devicetree-org/dt-schema.git /tmp/pip-req-build-60tnocl4
Resolved https://github.com/devicetree-org/dt-schema.git to commit 411c305
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
It does not seem to install anything, so (without noticing) I was still on the 'PyPI' version
While this seems like a logical way to have a base schema and additional constraints:
a-prop:
$ref: types.yaml#/definitions/a-type
enum: [1,2,3,4]
It doesn't actually work. Google 'json-schema sub classing' for more details. The correct form requires the $ref to be either alone (description can be ignored) or under an 'allOf':
a-prop:
allOf:
- $ref: types.yaml#/definitions/a-type
enum: [1,2,3,4]
Required property warnings are filtered out for disabled nodes we've matched on, but not for disabled child nodes.
dtschema-2023.2.dev3+gbb4b09d439b4
Python 3.10.6
dtbs_check on Loongson MIPS tree produces exception:
ARCH="mips" CROSS_COMPILE="mips64-linux-gnuabi64-" KBUILD_OUTPUT="out/" make loongson2k_defconfig
touch arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi
ARCH="mips" CROSS_COMPILE="mips64-linux-gnuabi64-" KBUILD_OUTPUT="out/" make dtbs_check
make[1]: Entering directory '/home/krzk/dev/linux/linux/out'
DTC_CHK arch/mips/boot/dts/loongson/loongson64_2core_2k1000.dtb
Traceback (most recent call last):
File "/home/krzk/.local/bin/dt-validate", line 164, in <module>
testtree = dtschema.load(filename)
File "/home/krzk/.local/lib/python3.10/site-packages/dtschema/lib.py", line 1023, in load
return [ dtschema.dtb.fdt_unflatten(f.read()) ]
File "/home/krzk/.local/lib/python3.10/site-packages/dtschema/dtb.py", line 485, in fdt_unflatten
fixup_interrupts(dt, 1)
File "/home/krzk/.local/lib/python3.10/site-packages/dtschema/dtb.py", line 414, in fixup_interrupts
fixup_interrupts(v, icells)
File "/home/krzk/.local/lib/python3.10/site-packages/dtschema/dtb.py", line 414, in fixup_interrupts
fixup_interrupts(v, icells)
File "/home/krzk/.local/lib/python3.10/site-packages/dtschema/dtb.py", line 414, in fixup_interrupts
fixup_interrupts(v, icells)
File "/home/krzk/.local/lib/python3.10/site-packages/dtschema/dtb.py", line 440, in fixup_interrupts
p_icells = _get_cells_size(phandles[phandle], '#interrupt-cells')
KeyError: 0
make[1]: Leaving directory '/home/krzk/dev/linux/linux/out'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.