Skip to content

Commit 10d597e

Browse files
authored
Merge branch 'main' into node-gats
2 parents 80604bd + 7479eaf commit 10d597e

12 files changed

Lines changed: 529 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## [0.2.1] - 2026-06-16
2+
3+
### Bug Fixes
4+
5+
- Validate `off_mem_rsvmap` and `off_dt_struct` in the FDT parser ([#38](https://github.com/google/dtoolkit/pull/38))
6+
- Return error when accessing data at invalid offsets in the FDT parser instead of panicking ([#40](https://github.com/google/dtoolkit/pull/40))
7+
8+
## [0.2.0] - 2026-06-01
9+
10+
### Features
11+
12+
- [**breaking**] Validate node and property names ([#35](https://github.com/google/dtoolkit/pull/35))
13+
14+
### Refactor
15+
16+
- [**breaking**] Implement generic `From<T>` for `DeviceTreeNode` ([#28](https://github.com/google/dtoolkit/pull/28))
17+
18+
## [0.1.1] - 2026-01-12
19+
20+
### Miscellaneous
21+
22+
- Add docs.rs metadata to Cargo.toml and use `doc_cfg` ([#26](https://github.com/google/dtoolkit/pull/26))
23+
24+
## [0.1.0] - 2026-01-09
25+
26+
### Features
27+
28+
- First version published on crates.io

CONTRIBUTING.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,20 @@ information on using pull requests.
4141
(beyond performance optimization) it must be accompanied by
4242
an `#[expect(unsafe_code)]` attribute, stating the rationale.
4343
* All `unsafe` code must be tested. The CI suite includes Miri to detect any
44-
undefined behavior.
44+
undefined behavior.
45+
46+
## Releasing a new version
47+
48+
This project uses [git-cliff](https://git-cliff.org/) to generate changelogs.
49+
When releasing a new version, run:
50+
51+
```
52+
git-cliff --unreleased --tag <version>
53+
```
54+
55+
(where `<version>` is the version number to be released)
56+
57+
Append the output to the `CHANGELOG.md` file and make changes if necessary.
58+
59+
Note that in order for this to work properly, the commit messages must follow
60+
[Conventional Commits](https://git-cliff.org/docs/#how-should-i-write-my-commits).

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "dtoolkit"
3-
version = "0.1.1"
3+
version = "0.2.1"
44
edition = "2024"
55
license = "Apache-2.0 OR MIT"
66
rust-version = "1.88"

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,31 @@ See LICENSE for details.
2929
If you want to contribute to the project, see details of
3030
[how we accept contributions](CONTRIBUTING.md).
3131

32+
## Fuzzing
33+
34+
Fuzzing helps prevent unexpected panics and ensures correct behavior on
35+
unexpected inputs. The project uses `cargo-fuzz`, which is not part of the
36+
default Rust installation. It is recommended to run the relevant fuzzer for a
37+
while before pushing a change.
38+
39+
Install `cargo-fuzz` with:
40+
41+
```sh
42+
cargo +nightly install cargo-fuzz
43+
```
44+
45+
Run a fuzz target by name from the repository root:
46+
47+
```sh
48+
cargo +nightly fuzz run <fuzzer name>
49+
```
50+
51+
For example, to run the `parse` fuzzer:
52+
53+
```sh
54+
cargo +nightly fuzz run parse
55+
```
56+
3257
## Disclaimer
3358

3459
This is not an officially supported Google product. This project is not

cliff.toml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# git-cliff ~ configuration file
2+
# https://git-cliff.org/docs/configuration
3+
4+
5+
[changelog]
6+
# See https://keats.github.io/tera/docs/#introduction
7+
body = """
8+
{% if version %}\
9+
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
10+
{% else %}\
11+
## [unreleased]
12+
{% endif %}\
13+
{% for group, commits in commits | group_by(attribute="group") %}
14+
### {{ group | striptags | trim | upper_first }}
15+
{% for commit in commits %}
16+
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
17+
{% if commit.breaking %}[**breaking**] {% endif %}\
18+
{{ commit.message | upper_first }}\
19+
{% endfor %}
20+
{% endfor %}
21+
"""
22+
# Remove leading and trailing whitespaces from the changelog's body.
23+
trim = true
24+
# Render body even when there are no releases to process.
25+
render_always = true
26+
# An array of regex based postprocessors to modify the changelog.
27+
postprocessors = [
28+
# Replace the placeholder <REPO> with a URL.
29+
#{ pattern = '<REPO>', replace = "https://github.com/orhun/git-cliff" },
30+
]
31+
# render body even when there are no releases to process
32+
# render_always = true
33+
# output file path
34+
# output = "test.md"
35+
36+
[git]
37+
# Parse commits according to the conventional commits specification.
38+
# See https://www.conventionalcommits.org
39+
conventional_commits = true
40+
# Exclude commits that do not match the conventional commits specification.
41+
filter_unconventional = true
42+
# Require all commits to be conventional.
43+
# Takes precedence over filter_unconventional.
44+
require_conventional = false
45+
# Split commits on newlines, treating each line as an individual commit.
46+
split_commits = false
47+
# An array of regex based parsers to modify commit messages prior to further processing.
48+
commit_preprocessors = [
49+
# Replace the issue/PR number with the link. It will work for issues as well as GitHub has a redirect.
50+
{ pattern = "\\(#([0-9]+)\\)", replace = "([#${1}](https://github.com/google/dtoolkit/pull/${1}))" },
51+
]
52+
# Prevent commits that are breaking from being excluded by commit parsers.
53+
protect_breaking_commits = false
54+
# An array of regex based parsers for extracting data from the commit message.
55+
# Assigns commits to groups.
56+
# Optionally sets the commit's scope and can decide to exclude commits from further processing.
57+
commit_parsers = [
58+
{ message = "^feat", group = "<!-- 0 -->Features" },
59+
{ message = "^fix", group = "<!-- 1 -->Bug Fixes" },
60+
{ message = "^doc", group = "<!-- 3 -->Documentation" },
61+
{ message = "^perf", group = "<!-- 4 -->Performance" },
62+
{ message = "^refactor", group = "<!-- 2 -->Refactor" },
63+
{ message = "^style", group = "<!-- 5 -->Styling" },
64+
{ message = "^test", group = "<!-- 6 -->Testing" },
65+
{ message = "^chore\\(release\\): prepare for", skip = true },
66+
{ message = "^chore\\(deps.*\\)", skip = true },
67+
{ message = "^chore\\(pr\\)", skip = true },
68+
{ message = "^chore\\(pull\\)", skip = true },
69+
{ message = "^chore|^ci", group = "<!-- 7 -->Miscellaneous" },
70+
{ body = ".*security", group = "<!-- 8 -->Security" },
71+
{ message = "^revert", group = "<!-- 9 -->Revert" },
72+
{ message = ".*", group = "<!-- 10 -->Other" },
73+
]
74+
# Exclude commits that are not matched by any commit parser.
75+
filter_commits = false
76+
# Fail on a commit that is not matched by any commit parser.
77+
fail_on_unmatched_commit = false
78+
# An array of link parsers for extracting external references, and turning them into URLs, using regex.
79+
link_parsers = []
80+
# Include only the tags that belong to the current branch.
81+
use_branch_tags = false
82+
# Order releases topologically instead of chronologically.
83+
topo_order = false
84+
# Order commits topologically instead of chronologically.
85+
topo_order_commits = true
86+
# Order of commits in each group/release within the changelog.
87+
# Allowed values: newest, oldest
88+
sort_commits = "oldest"
89+
# Process submodules commits
90+
recurse_submodules = false

fuzz/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
target
2+
corpus
3+
artifacts
4+
coverage

fuzz/Cargo.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "dtoolkit-fuzz"
3+
version = "0.0.0"
4+
publish = false
5+
edition = "2024"
6+
7+
[package.metadata]
8+
cargo-fuzz = true
9+
10+
[dependencies]
11+
libfuzzer-sys = "0.4"
12+
13+
[dependencies.dtoolkit]
14+
path = ".."
15+
16+
[[bin]]
17+
name = "parse"
18+
path = "fuzz_targets/parse.rs"
19+
test = false
20+
doc = false
21+
bench = false

fuzz/corpus-src/all.dts

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/*
2+
* Copyright 2026 Arm Limited and/or its affiliates <open-source-office@arm.com>
3+
*
4+
* Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5+
* https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6+
* <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
7+
* option. This file may not be copied, modified, or distributed
8+
* except according to those terms.
9+
*/
10+
11+
/dts-v1/;
12+
13+
/memreserve/ 0x0000000080000000 0x0000000000010000;
14+
/memreserve/ 0x00000000c0000000 0x0000000000010000;
15+
16+
/ {
17+
#address-cells = <2>;
18+
#size-cells = <2>;
19+
model = "dtoolkit fuzzer corpus";
20+
compatible = "dtoolkit,test";
21+
serial-nnumber = "1234";
22+
chassis-type = "desktop";
23+
phandle = <1>;
24+
status = "okay";
25+
26+
virtual-reg = <0x80000000>;
27+
dma-coherent;
28+
29+
aliases {
30+
serial1 = "/soc@1/serial@1000";
31+
ethernet0 = "/soc@1/dma@2000";
32+
33+
serial0 = &uart0;
34+
cpu0 = &cpu0;
35+
};
36+
37+
memory@100000002 {
38+
device_type = "memory";
39+
reg = <0x00000001 0x00000002 0x00000003 0x00000004>,
40+
<0x00000005 0x00000006 0x00000007 0x00000008>;
41+
initial-mapped-area = <0x00000001 0x00000002 0x00000003 0x00000004>,
42+
<0x00000005 0x00000006 0x00000007 0x00000008>;
43+
hotpluggable;
44+
status = "okay";
45+
};
46+
47+
reserved-memory {
48+
#address-cells = <2>;
49+
#size-cells = <2>;
50+
ranges;
51+
52+
mem1@80000000 {
53+
reg = <0x00000001 0x00000002 0x00000003 0x00000004>;
54+
size = <0x00000005 0x00000006>;
55+
alignment = <0x00000007 0x00000008>;
56+
alloc-ranges = <0x00000009 0x0000000a 0x0000000b 0x0000000c>;
57+
compatible = "shared-dma-pool";
58+
no-map;
59+
status = "fail";
60+
};
61+
62+
mem2@a0000000 {
63+
reg = <0x00000001 0x00000002 0x00000003 0x00000004>;
64+
size = <0x00000005 0x00000006>;
65+
alignment = <0x00000007 0x00000008>;
66+
reusable;
67+
status = "okay";
68+
};
69+
};
70+
71+
chosen {
72+
bootargs = "console=ttyS0 root=/dev/ram0";
73+
stdout-path = "/soc@1/serial@1000:115200n8";
74+
stdin-path = "/soc@1/serial@1000";
75+
};
76+
77+
cpus {
78+
#address-cells = <2>;
79+
#size-cells = <0>;
80+
81+
cpu0: cpu@0 {
82+
device_type = "cpu";
83+
compatible = "arm,armv8";
84+
reg = <0x00000000 0x00000000>;
85+
clock-frequency = <1000000000>;
86+
timebase-frequency = <1000000>;
87+
status = "okay";
88+
enable-method = "spin-table";
89+
cpu-release-addr = <0x00000000 0x80000000>;
90+
phandle = <2>;
91+
92+
};
93+
94+
cpu@1 {
95+
device_type = "cpu";
96+
compatible = "arm,armv8";
97+
reg = <0x00000000 0x00000001>;
98+
status = "disabled";
99+
enable-method = "spin-table";
100+
cpu-release-addr = <0xffffffff 0xffffffff>;
101+
102+
tlb-split;
103+
tlb-size = <2>;
104+
tlb-sets = <3>;
105+
d-tlb-size = <4>;
106+
d-tlb-sets = <5>;
107+
i-tlb-size = <6>;
108+
i-tlb-sets = <7>;
109+
cache-unified;
110+
cache-size = <8>;
111+
cache-sets = <9>;
112+
cache-block-size = <10>;
113+
cache-line-size = <11>;
114+
i-cache-size = <12>;
115+
i-cache-sets = <13>;
116+
i-cache-block-size = <14>;
117+
i-cache-line-size = <15>;
118+
d-cache-size = <16>;
119+
d-cache-sets = <17>;
120+
d-cache-block-size = <18>;
121+
d-cache-line-size = <19>;
122+
};
123+
};
124+
125+
soc@1 {
126+
compatible = "dummy-soc";
127+
#address-cells = <1>;
128+
#size-cells = <1>;
129+
ranges = <0x00000001 0x00000002 0x00000003 0x00000004>;
130+
dma-ranges = <0x00000005 0x00000006 0x00000007 0x00000008>;
131+
dma-coherent;
132+
status = "okay";
133+
134+
uart0: serial@1000 {
135+
compatible = "pl011";
136+
reg = <0x00000001 0x00000002>;
137+
virtual-reg = <0x00000003>;
138+
phandle = <3>;
139+
status = "okay";
140+
};
141+
142+
dma@2000 {
143+
compatible = "dma";
144+
reg = <0x00000001 0x00000002>;
145+
dma-coherent;
146+
status = "reserved";
147+
};
148+
};
149+
};

fuzz/corpus-src/generate.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
3+
# Copyright 2026 Arm Limited and/or its affiliates <open-source-office@arm.com>
4+
#
5+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
# https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
# <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
8+
# option. This file may not be copied, modified, or distributed
9+
# except according to those terms.
10+
11+
# Generate DTB corpus files from DTS files.
12+
13+
if [ $# -ne 2 ]; then
14+
echo "error: input and output directories are required" >&2
15+
echo "usage: $0 <input dir> <output dir>" >&2
16+
exit 1
17+
fi
18+
19+
input_dir=$1
20+
output_dir=$2
21+
22+
for dts in "$input_dir"/*.dts; do
23+
dtb="${dts%.dts}.dtb"
24+
dtc -Idts -Odtb -o "$output_dir/$dtb" "$dts"
25+
done

fuzz/corpus/parse/all.dtb

2.71 KB
Binary file not shown.

0 commit comments

Comments
 (0)