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.mfbz.cn/a/576728.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

运行游戏提示dll文件丢失,分享多种有效的解决方法

在我们日常频繁地利用电脑进行娱乐活动,特别是畅玩各类精彩纷呈的电子游戏时,常常会遭遇一个令人困扰的问题。当我们满怀期待地双击图标启动心仪的游戏程序,准备全身心投入虚拟世界时,屏幕上却赫然弹出一条醒目的错误提示信息&…

【书生浦语第二期实战营学习作业笔记(二)】

书生浦语第二期实战营学习作业&笔记(二) 操作文档:https://github.com/InternLM/Tutorial/blob/camp2/helloworld/hello_world.md 基础作业 : 使用 InternLM2-Chat-1.8B 模型生成 300 字的小故事: 八戒部署(笔记&#xff0…

基于灰狼算法的综合能源系统多时间尺度优化调度(附matlab程序)

0.代码链接 基于灰狼算法的综合能源系统多时间尺度优化调度(MATLAB程序)资源-CSDN文库 1.简述 对于冷、热、电联供综合能源系统优化问题,为了提高可再生能源利用率,故以弃风、弃光量最小和综合能源系统运行经济性为优化目标&…

mac配置maven

在 macOS 上配置 Maven 也相对简单。以下是一种常用的方法: 1. 安装maven **下载 Maven:**首先,你需要从 Maven 官网(https://maven.apache.org/download.cgi)下载最新版本的 Maven。你可以选择二进制压缩包&#xf…

redis常用数据结构

redis常用数据结构 Redis 底层在实现下面数据结构的时候,会进行特定的优化,来达到节省时间/空间的效果。 内部结构 String raw(最基本的字符串),int(实现计数功能,当value为整数的时候会用整…

JPEG图像常用加密算法简介

JPEG图像加密算法 目前,JPEG图像加密算法可以分成异或加密、置乱加密和置乱与异或组合加密。下面对这三种加密方式进行阐述。 (1) 异或加密 文献[1]提出了一种基于异或加密的JPEG图像的RDH-EI方案。该算法通过对AC系数的ACA和图像的量化表进行流密码异或&#xf…

Feign功能详解、使用步骤、代码案例

简介:Feign是Netflix开发的声明式,模板化的HTTP客户端,简化了HTTP的远程服务的开发。Feign是在RestTemplate和Ribbon的基础上进一步封装,使用RestTemplate实现Http调用,使用Ribbon实现负载均衡。我们可以看成 Feign R…

经典的免费wordpress模板

这款经典的免费WordPress模板以鲜艳的红色为主调,充满了活力与热情。设计简洁而现代,适合各种类型的项目网站。模板采用响应式设计,确保在不同设备和屏幕尺寸上都能呈现出完美的视觉效果。 红色象征着激情、活力和自信,这款模板…

ubuntu子系统密码忘记了,怎么办?

🏆本文收录于「Bug调优」专栏,主要记录项目实战过程中的Bug之前因后果及提供真实有效的解决方案,希望能够助你一臂之力,帮你早日登顶实现财富自由🚀;同时,欢迎大家关注&&收藏&&…

18种WEB常见漏洞:揭秘网络安全的薄弱点

输入验证漏洞: 认证和会话管理漏洞: 安全配置错误: 其他漏洞: 防范措施: Web 应用程序是现代互联网的核心,但它们也容易受到各种安全漏洞的影响。了解常见的 Web 漏洞类型,对于开发人员、安全测试人员和普通用户都至关重要。以下将介绍 18 种常见的 …

HttpClient工具类编写

HttpClient 介绍 HttpClient是Apache Jakarta Common下的一个子项目,它提供了一个高效的、最新的、功能丰富的支持HTTP协议的客户端编程工具包。它支持HTTP协议最新的版本和建议,并实现了Http1.0和Http1.1协议。 HttpClient具有可扩展的面向对象的结构…

电脑壁纸怎么设置?简单3步,让你的电脑桌面变得更合心意

电脑壁纸是我们每天在电脑上工作和娱乐时不可或缺的一部分。一张精美的电脑壁纸,既能提升我们的工作效率,也能为我们带来愉悦的心情。无论是静谧的自然风光、抽象的艺术设计,还是心动的明星照片,都可以在电脑壁纸的世界里找到自己…

HF区块链链码基础

链码生命周期 一 . 链码准备 准备文件 . 在测试目录下创建chaincode,拷贝测试链码进 chaincode目录,拷贝 set-env.sh 脚本进 scripts 目录 二. 打包链码 打包测试链码 export FABRIC_CFG_PATH${PWD}/config peer lifecycle chaincode package ./chaincode/chaincode_basic.…

Springboot 中RedisTemplate使用scan来获取所有的key底层做了哪些事情

直接上代码&#xff0c;围绕着代码来讨论 redisTemplate.execute((RedisCallback<Object>) (connection) -> {Cursor<byte[]> scan connection.scan(ScanOptions.scanOptions().count(2).match("*").build());scan.forEachRemaining((bytes) -> {…

TypeScript 中 interface 和 type 的使用#记录

一、interface&#xff1a;接口 interface A{label: string; }const aa ((aObj: A) > {console.log(aObj.label);//123return aObj.label; })aa({label: 123}) 1、可选属性 interface A{label: string;age?: number; } 2、只读属性 interface A{label: string;age?:…

【网络安全】安全事件管理处置 — windows应急响应

专栏文章索引&#xff1a;网络安全 有问题可私聊&#xff1a;QQ&#xff1a;3375119339 目录 一、账户排查 二、windows网络排查 三、进程排查 四、windows注册表排查 五、内存分析 总结 一、账户排查 账户排查主要包含以下几个维度 登录服务器的途径弱口令可疑账号 新增…

019基于JavaWeb的在线音乐系统(含论文)

019基于JavaWeb的在线音乐系统&#xff08;含论文&#xff09; 开发环境&#xff1a; Jdk7(8)Tomcat7(8)MysqlIntelliJ IDEA(Eclipse) 数据库&#xff1a; MySQL 技术&#xff1a; JavaServletJqueryJavaScriptAjaxJSPBootstrap 适用于&#xff1a; 课程设计&#xff0c;毕…

Web-SpringBootWen

创建项目 后面因为报错&#xff0c;所以我把jdk修改成22&#xff0c;仅供参考。 定义类&#xff0c;创建方法 package com.start.springbootstart.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotati…

易基因:Nat Commun:RRBS测序揭示小鼠衰老过程中的DNA甲基化变化轨迹|研究速递

大家好&#xff0c;这里是专注表观组学十余年&#xff0c;领跑多组学科研服务的易基因。 DNA甲基化数据可以生成非常精确的年龄预测器&#xff0c;但关于这一关键表观遗传生物标志物在生命周期中的动态变化知之甚少。关于衰老不连续方面的研究仍处于起步阶段&#xff0c;关键的…

冯唐成事心法笔记 —— 知人

系列文章目录 冯唐成事心法笔记 —— 知己 冯唐成事心法笔记 —— 知人 冯唐成事心法笔记 —— 知世 冯唐成事心法笔记 —— 知智慧 文章目录 系列文章目录PART 2 知人 人人都该懂战略人人都该懂战略第一&#xff0c;什么是战略第二&#xff0c;为什么要做战略第三&#xff0…
最新文章