DeviceTree - schema介绍

GitHub - devicetree-org/dt-schema: Devicetree schema tools

Devicetree Schema Tools / 设备树模式工具

dtschema 模块包含使用 json-schema ( JSON Schema  )词汇表验证 Devicetree 模式的工具和模式数据。这些工具使用 DT 绑定模式文件验证 Devicetree 文件。工具还能验证 DT 绑定模式文件。模式文件采用与 JSON 兼容的 YAML 子集编写,具有人机可读性。

The dtschema module contains tools and schema data for Devicetree schema validation using the json-schema vocabulary. The tools validate Devicetree files using DT binding schema files. The tools also validate the DT binding schema files. Schema files are written in a JSON compatible subset of YAML to be both human and machine readable.

1,Data Model / 数据模型

要了解验证是如何工作的,就必须了解模式数据是如何组织和使用的。如果您正在阅读这篇文章,我想您已经熟悉 Devicetree 和 .dts 文件格式了。

在这个资源库中,你会发现两种数据文件:模式和元模式。

To understand how validation works, it is important to understand how schema data is organized and used. If you're reading this, I assume you're already familiar with Devicetree and the .dts file format.

In this repository you will find 2 kinds of data files; Schemas and Meta-Schemas.

Devicetree Schemas / 设备树模式

Found under ./dtschema/schemas

Devicetree 模式描述了 Devicetree 数据的格式。原始 Devicetree 文件格式非常开放,不限制数据的编码方式。所以,编写devietree时很容易犯错误。模式文件对可以放入 Devicetree 的数据施加了限制。

该资源库包含 "核心 "模式,其中包括 DT 规范中定义的 DT 属性以及 GPIO、时钟和 PHY 绑定等常见绑定。

该资源库不包含特定设备绑定。这些绑定目前与 Devicetree 文件(.dts)一起保存在 Linux 内核树中。

验证时,该工具将加载所有能找到的模式文件,然后遍历 Devicetree 的所有节点。对于每个节点,工具将确定哪些模式适用,并确保节点数据与模式约束相匹配。未通过模式测试的节点将显示错误。不匹配任何模式的节点会发出警告。

Devicetree Schemas describe the format of devicetree data. The raw Devicetree file format is very open ended and doesn't restrict how data is encoded.Hence, it is easy to make mistakes when writing a Devicetree. Schema files impose the constraints on what data can be put into a Devicetree.

This repository contains the 'core' schemas which consists of DT properties defined within the DT Specification and common bindings such as the GPIO, clock, and PHY bindings.

This repository does not contain device specific bindings. Those are currently maintained within the Linux kernel tree alongside Devicetree files (.dts).

When validating, the tool will load all the schema files it can find and then iterate over all the nodes of the Devicetree. For each node, the tool will determine which schema(s) are applicable and make sure the node data matches the schema constraints. Nodes failing a schema test will emit an error. Nodes that don't match any schema can emit a warning.

作为开发人员,您需要为创建的每个新设备绑定编写 Devicetree 模式文件,并将其添加到 ./schemas 目录中。

模式文件还具有文档描述绑定的双重目的。定义新绑定时,只需创建一个文件,其中包含机器可验证的数据格式和文档。

Devicetree 模式文件是使用 jsonschema 词汇表的普通 YAML 文件。

Devicetree 模式文件经过简化,更加紧凑。

json-schema 中数组的默认大小是可变的。可以通过定义 "minItems"、"maxItems "和 "additionalItems "来加以限制。在大多数情况下,DeviceTree 模式需要一个固定大小的数组,因此这些属性是根据 "items "列表的大小添加的。

As a developer, you would write a Devicetree schema file for each new device binding that you create and add it to the ./schemas directory.

Schema files also have the dual purpose of documenting a binding. When you define a new binding, you only have to create one file that contains both the machine-verifiable data format and the documentation.

Devicetree Schema files are normal YAML files using the jsonschema vocabulary.

The Devicetree Schema files are simplified to make them more compact.

The default for arrays in json-schema is they are variable sized. This can be restricted by defining 'minItems', 'maxItems', and 'additionalItems'. For DeviceTree Schemas, a fixed size is desired in most cases, so these properties are added based on the size of 'items' list.

Devicetree Meta-Schemas / 设备树元模式

Found in ./dtschema/meta-schemas

Devicetree 元模式描述 Devicetree 模式文件的数据格式。元模式确保所有绑定模式都采用正确的格式,如果格式不正确,工具就会出错。默认情况下,json-schema 对模式中允许使用的内容非常宽松。例如,未知关键字会被静默忽略。DT 元模式旨在编写模式时时限制允许的内容,并捕捉编写模式时的常见错误。

作为开发人员,通常不需要编写元模式文件。

Devicetree 元模式文件是使用 jsonschema 词汇表的普通 YAML 文件。

Devicetree Meta-Schemas describe the data format of Devicetree Schema files. The Meta-schemas make sure all the binding schemas are in the correct format and the tool will emit an error if the format is incorrect. json-schema by default is very relaxed in terms of what is allowed in schemas. Unknown keywords are silently ignored as an example. The DT Meta-schemas are designed to limit what is allowed and catch common errors in writing schemas.

As a developer you normally will not need to write metaschema files.

Devicetree Meta-Schema files are normal YAML files using the jsonschema vocabulary.

2,Usage / 使用

tools/ 目录中有几种可用工具。

tools/dt-doc-validate: 该工具获取模式文件或模式文件目录,并根据 DT 元模式对其进行验证。

There are several tools available in the tools/ directory.

tools/dt-doc-validate: 

This tool takes a schema file(s) or directory of schema files and validates them against the DT meta-schema.

Example:

dt-doc-validate -u test/schemas test/schemas/good-example.yaml

tools/dt-mk-schema:

该工具获取用户提供的模式文件和本软件仓库中的核心模式文件,删除验证中不需要的所有内容,对模式进行修正,并输出一个包含处理后模式的文件。这一步是可选的,可单独完成,以加快 Devicetrees 的后续验证。

tools/dt-mk-schema: 

This tool takes user-provided schema file(s) plus the core schema files in this repo, removes everything not needed for validation, applies fix-ups to the schemas, and outputs a single file with the processed schema. This step is optional and can be done separately to speed up subsequent validation of Devicetrees.

Example:

dt-mk-schema -j test/schemas/ > processed-schema.json

tools/dt-validate:

该工具接收用户提供的 Devicetree 和模式目录或来自 dt-mk-schema 的预处理模式文件,然后根据模式验证 Devicetree。

tools/dt-validate:

This tool takes user-provided Devicetree(s) and either a schema directory or a pre-processed schema file from dt-mk-schema, and then validates the Devicetree against the schema.

Example:

dtc -O dtb -o device.dtb test/device.dts

dt-validate -s processed-schema.json device.dtb

tools/dt-check-compatible:

该工具测试模式中是否存在兼容字符串列表。默认情况下,当兼容字符串与模式中的字符串(或模式)匹配时,就会打印出来。

tools/dt-check-compatible: 

This tool tests whether a list of compatible strings are found or not in the schemas. By default, a compatible string is printed when it matches one (or a pattern) in the schemas.

Example:

dt-check-compatible -s processed-schema.json vendor,a-compatible

3,Installing / 安装

The project and its dependencies can be installed with pip:

pip3 install dtschema

or directly from git:

pip3 install git+https://github.com/devicetree-org/dt-schema.git@main

All executables will be installed. Ensure ~/.local/bin is in the PATH.

For development, clone the git repository manually and run pip on local tree:

git clone https://github.com/devicetree-org/dt-schema.git

cd dt-schema

pip3 install -e .

4,Dependencies / 依赖

注:上述安装说明会自动处理所有依赖关系。

此代码依赖于 Python 3 以及 pylibfdt、ruamel.yaml、rfc3987 和 jsonschema 库。安装 pylibfdt 依赖于 "swig" 程序。

在 Debian/Ubuntu 上,可以使用 apt 或 pip 安装依赖项。rfc3987 模块未打包,因此必须使用 pip:

Note: The above installation instructions handle all of the dependencies automatically.

This code depends on Python 3 with the pylibfdt, ruamel.yaml, rfc3987, and jsonschema libraries. Installing pylibfdt depends on the 'swig' program.

On Debian/Ubuntu, the dependencies can be installed with apt and/or pip. The rfc3987 module is not packaged, so pip must be used:

sudo apt install swig

sudo apt install python3 python3-ruamel.yaml

pip3 install rfc3987

jsonschema

该代码至少依赖于 Python jsonschema 库(GitHub - python-jsonschema/jsonschema: An implementation of the JSON Schema specification for Python)的 4.1.2 版本,以支持 Draft 2019-09。

可使用 pip 直接从 github 安装该模块:

This code depends on at least version 4.1.2 of the Python jsonschema library for Draft 2019-09 support.

The module can be installed directly from github with pip:

pip3 install git+https://github.com/Julian/jsonschema.git

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/4008.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【JavaEE】HTML 基础

文章目录 一、HTML 结构二、HTML 文件基本结构 一、HTML 结构 认识 HTML 标签 HTML 代码是由 “标签” 构成的. 形如: <body>hello</body>标签名 (body) 放到 < > 中 大部分标签成对出现. 为开始标签, 为结束标签. 少数标签只有开始标签, 称为 “单标签”.…

小项目-词法分析器

小项目-词法分析器 1.理论 一个完整的编译器&#xff0c;大致会经历如下几个阶段 各个阶段的职责&#xff0c;简单描述如下&#xff1a; 词法分析&#xff1a;对源文件进行扫描&#xff0c;将源文件的字符划分为一个一个的记号(token) (注&#xff1a;类似中文中的分词)。 语…

Eagle for Mac:强大的图片管理工具

Eagle for Mac是一款专为Mac用户设计的图片管理工具&#xff0c;旨在帮助用户更高效、有序地管理和查找图片资源。 Eagle for Mac v1.9.2中文版下载 Eagle支持多种图片格式&#xff0c;包括JPG、PNG、GIF、SVG、PSD、AI等&#xff0c;无论是矢量图还是位图&#xff0c;都能以清…

EasyRecovery数据恢复软件2025激活码及下载使用步骤教程

EasyRecovery数据恢复软件是一款功能强大且用户友好的数据恢复工具&#xff0c;专为帮助用户找回因各种原因丢失的数据而设计。该软件由全球知名的数据恢复技术公司开发&#xff0c;经过多年的技术积累和更新迭代&#xff0c;已经成为行业内备受推崇的数据恢复解决方案。 EasyR…

【定制化体验:使用Spring Boot自动配置,打造个性化Starter】

项目结构 Pom <?xml version"1.0" encoding"UTF-8"?> <project xmlns"http://maven.apache.org/POM/4.0.0"xmlns:xsi"http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation"http://maven.apache.org/POM/4…

SpringBoot---------整合Redis

目录 第一步&#xff1a;引入依赖 第二步&#xff1a;配置Redis信息 第三步&#xff1a;选择Spring Data Redis进行操作Redis数据库 ①操作String类型数据&#xff08;用的少&#xff09; ②操作Object类型数据&#xff08;重要&#xff01;&#xff01;&#xff01;&#x…

【Python】深入理解Pandas中的连续变量与分类变量以提升模型训练效果

你啊你&#xff0c;是自在如风的少年 飞在天地间&#xff0c;比梦还遥远 你啊你&#xff0c;飞过了流转的时间 归来的时候&#xff0c;是否还有青春的容颜 &#x1f3b5; 好妹妹《你飞到城市另一边》 引言&#xff1a; 在使用Python进行数据科学和机器学…

[iOS]使用CocoaPods发布私有库

1.创建私有 Spec 仓库 首先&#xff0c;需要一个私有的 Git 仓库来存放你的 Podspec 文件&#xff0c;这个仓库用于索引你所有的私有 Pods。 在 GitHub 或其他 Git 服务上创建一个新的私有仓库&#xff0c;例如&#xff0c;名为 PrivatePodSpecs。克隆这个仓库到本地&#xf…

AI大模型探索之路-训练篇2:大语言模型预训练基础认知

文章目录 前言一、预训练流程分析二、预训练两大挑战三、预训练网络通信四、预训练数据并行五、预训练模型并行六、预训练3D并行七、预训练代码示例总结 前言 在人工智能的宏伟蓝图中&#xff0c;大语言模型&#xff08;LLM&#xff09;的预训练是构筑智慧之塔的基石。预训练过…

Docker基本操作 容器相关命令

docker run:运行镜像; docker pause:暂停容器&#xff0c;会让该容器暂时挂起&#xff1b; docker unpauser:从暂停到运行; docker stop:停止容器&#xff0c;杀死进程; docker start:重新创建进程。 docker ps&#xff1a;查看所有运行的容器及其状态&#xff0c;默认只展…

Angular Subject和BehaviorSubject之间的区别

Subject和BehaviorSubject是RxJS中两种常用的Subject类型。 概念&#xff1a; Subject&#xff1a; Subject是一种特殊的Observable&#xff0c;同时也是Observer。它可以被用来订阅Observable&#xff0c;也可以手动向它推送新的值。Subject是一种热Observable&#xff0c;它…

JavaScript创建和填充数组的更多方法

空数组fill()方法创建并填充数组 ● 我们之前创建数组的方式都是手动去创建去一个数据&#xff0c;例如 console.log([1, 2, 3, 4, 5, 6, 7]);● 当然我们也可以使用Array对象来构造数组 console.log([1, 2, 3, 4, 5, 6, 7]); console.log(new Array(1, 2, 3, 4, 5, 6, 7));…

python生成二维码及进度条源代码

一、进度条 1、利用time模块实现 import time for i in range(0, 101, 2):time.sleep(0.3)num i // 2if i 100:process "\r[%3s%% ]: |%-50s|\n" % (i, # * num)else:process "\r[%3s%% ]: |%-50s|" % (i, # * num)print(process, end, flushTrue)2、使…

tcp服务器端与多个客户端连接

如果希望Tcp服务器端可以与多个客户端连接&#xff0c;可以这样写&#xff1a; tcpServernew QTcpServer(this);connect(tcpServer,SIGNAL(newConnection()),this,SLOT(onNewConnection())); void MainWindow::onNewConnection() {QTcpSocket *tcpSocket;//TCP通讯的Sockettcp…

陪丨玩丨系丨统前后端开发流程,APP小程序H5前后端源码交付支持二开!多人语音,开黑,线上线下两套操作可在一个系统完成!

100%全部源码出售 官网源码APP源码 管理系统源码 终身免费售后 产品免费更新 产品更新频率高 让您时刻立足于行业前沿 软件开发流程步骤及其作用&#xff1a; 软件开发是一个复杂而系统的过程&#xff0c;涉及多个环节&#xff0c;以下是软件开发的主要流程步骤及其作用…

MySQL 服务器权限与对象权限

MySQL服务器权限&#xff08;全局权限&#xff09;和对象权限&#xff08;数据库权限和表权限&#xff09;是MySQL权限体系中的两个重要组成部分&#xff0c;它们共同构成了MySQL的安全管理机制。 服务器权限&#xff08;全局权限&#xff09; 服务器权限&#xff0c;也称为全…

leetCode60. 排列序列

leetCode60. 排列序列 方法一:语法版&#xff0c;面试官不认可的方法&#xff1a;next_permutation函数 // 方法一&#xff1a;使用next_permutation函数&#xff0c;将某容器设置为当前按照字典序 // 的下一个全排列的内容 class Solution { public:string getPermutation(in…

SystemUI KeyButtonView setDarkIntensity 解析

继承自 ImageView KeyButtonDrawable intensity为0时按键颜色为白色。 intensity为1时黑色为的调用堆栈&#xff1a; java.lang.NullPointerException: Attempt to invoke virtual method int java.lang.String.length() on a null object referenceat com.android.systemui.…

PostgreSQL的扩展(extensions)-常用的扩展之pgBackRest

PostgreSQL的扩展&#xff08;extensions&#xff09;-常用的扩展之pgBackRest pgBackRest 是一个高度灵活和功能丰富的备份和恢复解决方案&#xff0c;专为 PostgreSQL 数据库设计。pgBackRest 致力于简化备份和恢复流程&#xff0c;同时提供高级功能&#xff0c;如点对点恢复…

LLaMA-Factory参数的解答(命令,单卡,预训练)

前面这个写过&#xff0c;但觉得写的不是很好&#xff0c;这次是参考命令运行脚本&#xff0c;讲解各个参数含义。后续尽可能会更新&#xff0c;可以关注一下专栏&#xff01;&#xff01; *这是个人写的参数解读&#xff0c;我并非该领域的人如果那个大佬看到有参数解读不对或…