-
Notifications
You must be signed in to change notification settings - Fork 22
dts.pest: Add support for comments in devicetree source files #96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v4.1-branch
Are you sure you want to change the base?
dts.pest: Add support for comments in devicetree source files #96
Conversation
This commit adds support for comments in devicetree source files by extending the existing parser grammar. The COMMENTS syntax is taken verbatim from a Pest example at https://pest.rs/book/grammars/syntax.html . Signed-off-by: Luca Burelli <[email protected]>
f365bd7
to
58b3897
Compare
Above manifest update PR passed Zephyr CI on the Rust targets. Compare with the errors with current
|
@d3zd3z PTAL when you have the chance, thanks! I based this on the stable branch for CI to pass on the Zephyr PR, but it's trivial to apply to |
Any idea what changed in Zephyr to have it start including comments in the output DTS? It'd be nice to reference to what has caused this to be needed. Otherwise, this looks pretty straightforward. |
The comments are being introduced by zephyrproject-rtos/zephyr#89410, that's actually the goal 🙂 /dts-v1/;
/* node '/' defined in zephyr/dts/common/skeleton.dtsi:9 */
/ {
#address-cells = < 0x1 >; /* in zephyr/dts/common/skeleton.dtsi:10 */
#size-cells = < 0x1 >; /* in zephyr/dts/common/skeleton.dtsi:11 */
model = "reel board"; /* in zephyr/boards/phytec/reel_board/reel_board.dts:14 */
compatible = "phytec,reel_board"; /* in zephyr/boards/phytec/reel_board/reel_board.dts:15 */
/* node '/chosen' defined in zephyr/dts/common/skeleton.dtsi:12 */
chosen {
zephyr,bt-hci = &bt_hci_controller; /* in zephyr/dts/arm/nordic/nrf52840.dtsi:10 */
zephyr,entropy = &rng; /* in zephyr/dts/arm/nordic/nrf52840.dtsi:11 */
zephyr,flash-controller = &flash_controller; /* in zephyr/dts/arm/nordic/nrf52840.dtsi:12 */
zephyr,sram = &sram0; /* in zephyr/boards/phytec/reel_board/reel_board.dts:23 */
zephyr,flash = &flash0; /* in zephyr/boards/phytec/reel_board/reel_board.dts:24 */
zephyr,code-partition = &slot0_partition; /* in zephyr/boards/phytec/reel_board/reel_board.dts:25 */
zephyr,ieee802154 = &ieee802154; /* in zephyr/boards/phytec/reel_board/dts/reel_board.dtsi:14 */
zephyr,console = &uart0; /* in zephyr/boards/phytec/reel_board/reel_board.dts:18 */
zephyr,shell-uart = &uart0; /* in zephyr/boards/phytec/reel_board/reel_board.dts:19 */
zephyr,uart-mcumgr = &uart0; /* in zephyr/boards/phytec/reel_board/reel_board.dts:20 */
zephyr,bt-mon-uart = &uart0; /* in zephyr/boards/phytec/reel_board/reel_board.dts:21 */
zephyr,bt-c2h-uart = &uart0; /* in zephyr/boards/phytec/reel_board/reel_board.dts:22 */
zephyr,display = &ssd16xx; /* in zephyr/boards/phytec/reel_board/reel_board.dts:26 */
};
[...]
/* node '/soc' defined in zephyr/dts/arm/armv7-m.dtsi:6 */
soc {
#address-cells = < 0x1 >; /* in zephyr/dts/arm/armv7-m.dtsi:7 */
#size-cells = < 0x1 >; /* in zephyr/dts/arm/armv7-m.dtsi:8 */
compatible = "nordic,nrf52840-qiaa",
"nordic,nrf52840",
"nordic,nrf52",
"simple-bus"; /* in zephyr/dts/arm/nordic/nrf52840_qiaa.dtsi:29 */
interrupt-parent = < &nvic >; /* in zephyr/dts/arm/armv7-m.dtsi:10 */
ranges; /* in zephyr/dts/arm/armv7-m.dtsi:11 */
/* node '/soc/interrupt-controller@e000e100' defined in zephyr/dts/arm/armv7-m.dtsi:13 */
nvic: interrupt-controller@e000e100 {
#address-cells = < 0x1 >; /* in zephyr/dts/arm/armv7-m.dtsi:14 */
compatible = "arm,v7m-nvic"; /* in zephyr/dts/arm/armv7-m.dtsi:15 */
reg = < 0xe000e100 0xc00 >; /* in zephyr/dts/arm/armv7-m.dtsi:16 */
interrupt-controller; /* in zephyr/dts/arm/armv7-m.dtsi:17 */
#interrupt-cells = < 0x2 >; /* in zephyr/dts/arm/armv7-m.dtsi:18 */
arm,num-irq-priority-bits = < 0x3 >; /* in zephyr/dts/arm/nordic/nrf52840.dtsi:572 */
phandle = < 0x1 >; /* in zephyr/dts/arm/armv7-m.dtsi:10 */
};
[...]
/* node '/soc/spi@4002f000' defined in zephyr/dts/arm/nordic/nrf52840.dtsi:525 */
spi3: arduino_spi: spi@4002f000 {
compatible = "nordic,nrf-spim"; /* in zephyr/dts/arm/nordic/nrf52840.dtsi:526 */
#address-cells = < 0x1 >; /* in zephyr/dts/arm/nordic/nrf52840.dtsi:527 */
#size-cells = < 0x0 >; /* in zephyr/dts/arm/nordic/nrf52840.dtsi:528 */
reg = < 0x4002f000 0x1000 >; /* in zephyr/dts/arm/nordic/nrf52840.dtsi:529 */
interrupts = < 0x2f 0x1 >; /* in zephyr/dts/arm/nordic/nrf52840.dtsi:530 */
max-frequency = < 0x1e84800 >; /* in zephyr/dts/arm/nordic/nrf52840.dtsi:531 */
easydma-maxcnt-bits = < 0x10 >; /* in zephyr/dts/arm/nordic/nrf52840.dtsi:532 */
rx-delay-supported; /* in zephyr/dts/arm/nordic/nrf52840.dtsi:533 */
rx-delay = < 0x2 >; /* in zephyr/dts/arm/nordic/nrf52840.dtsi:534 */
status = "ok"; /* in zephyr/samples/net/wifi/shell/boards/reel_board.overlay:27 */
cs-gpios = < &gpio1 0x3 0x1 >; /* in zephyr/samples/net/wifi/shell/boards/reel_board.overlay:28 */
pinctrl-0 = < &spi3_default_alt >; /* in zephyr/samples/net/wifi/shell/boards/reel_board.overlay:29 */
pinctrl-1 = < &spi3_sleep_alt >; /* in zephyr/samples/net/wifi/shell/boards/reel_board.overlay:30 */
pinctrl-names = "default",
"sleep"; /* in zephyr/samples/net/wifi/shell/boards/reel_board.overlay:31 */
/* node '/soc/spi@4002f000/winc1500@0' defined in zephyr/samples/net/wifi/shell/boards/reel_board.overlay:33 */
winc1500@0 {
status = "ok"; /* in zephyr/samples/net/wifi/shell/boards/reel_board.overlay:34 */
compatible = "atmel,winc1500"; /* in zephyr/samples/net/wifi/shell/boards/reel_board.overlay:35 */
reg = < 0x0 >; /* in zephyr/samples/net/wifi/shell/boards/reel_board.overlay:36 */
spi-max-frequency = < 0x3d0900 >; /* in zephyr/samples/net/wifi/shell/boards/reel_board.overlay:37 */
irq-gpios = < &gpio1 0x7 0x1 >; /* in zephyr/samples/net/wifi/shell/boards/reel_board.overlay:38 */
reset-gpios = < &gpio1 0x8 0x1 >; /* in zephyr/samples/net/wifi/shell/boards/reel_board.overlay:39 */
enable-gpios = < &gpio1 0xc 0x0 >; /* in zephyr/samples/net/wifi/shell/boards/reel_board.overlay:40 */
};
};
[...]
};
/* node '/connector' defined in zephyr/boards/phytec/reel_board/dts/reel_board.dtsi:55 */
arduino_header: connector {
compatible = "arduino-header-r3"; /* in zephyr/boards/phytec/reel_board/dts/reel_board.dtsi:56 */
#gpio-cells = < 0x2 >; /* in zephyr/boards/phytec/reel_board/dts/reel_board.dtsi:57 */
gpio-map-mask = < 0xffffffff 0xffffffc0 >; /* in zephyr/boards/phytec/reel_board/dts/reel_board.dtsi:58 */
gpio-map-pass-thru = < 0x0 0x3f >; /* in zephyr/boards/phytec/reel_board/dts/reel_board.dtsi:59 */
gpio-map = < 0x0 0x0 &gpio0 0x3 0x0 >,
< 0x1 0x0 &gpio0 0x4 0x0 >,
< 0x2 0x0 &gpio0 0x1c 0x0 >,
< 0x3 0x0 &gpio0 0x1d 0x0 >,
< 0x4 0x0 &gpio0 0x1e 0x0 >,
< 0x5 0x0 &gpio0 0x1f 0x0 >,
< 0x6 0x0 &gpio1 0x1 0x0 >,
< 0x7 0x0 &gpio1 0x2 0x0 >,
< 0x8 0x0 &gpio1 0x3 0x0 >,
< 0x9 0x0 &gpio1 0x4 0x0 >,
< 0xa 0x0 &gpio1 0x5 0x0 >,
< 0xb 0x0 &gpio1 0x6 0x0 >,
< 0xc 0x0 &gpio1 0x7 0x0 >,
< 0xd 0x0 &gpio1 0x8 0x0 >,
< 0xe 0x0 &gpio1 0xa 0x0 >,
< 0xf 0x0 &gpio1 0xb 0x0 >,
< 0x10 0x0 &gpio1 0xc 0x0 >,
< 0x11 0x0 &gpio1 0xd 0x0 >,
< 0x12 0x0 &gpio1 0xe 0x0 >,
< 0x13 0x0 &gpio1 0xf 0x0 >,
< 0x14 0x0 &gpio0 0x1a 0x0 >,
< 0x15 0x0 &gpio0 0x1b 0x0 >; /* in zephyr/boards/phytec/reel_board/dts/reel_board.dtsi:60 */
};
[...]
}; |
Add support for comments in devicetree source files by extending the existing parser grammar. This is currently required to allow CI to pass on zephyrproject-rtos/zephyr#89410.
I have zero experience on Rust, but the
COMMENT =
syntax is taken verbatim from an example on the Pest website, and I also tried the change on the live editor there, so... I'm pretty hopeful 🙂EDIT: CI passed on the manifest update PR (see message below)