Practical Zephyr - Devicetree basics (Part 3) | Interrupt

In the previous article, we configured software using the kernel configuration tool Kconfig, and we’ve silently assumed that there’s a UART interface on our board that is configurable and used for logging.


This is a companion discussion topic for the original entry at https://interrupt.memfault.com/blog/practical_zephyr_dt

@martin do you know if there any convention or preference for node names regarding the use of underscores (pwm_led_0) vs. dashes (pwm-led-0) as word separators?

The Linux kernel Devicetree Sources (DTS) Coding Style restricts node names to use dashes only. There also appears to be an effort to require dashes in property names, but I haven’t seen a similar proposal for node names in Zephyr. I’m wondering if you know any history as to why Zephyr allows underscores in node names, and whether it is actually preferred in Zephyr to use underscores instead of dashes (I feel like I see underscores used more often than dashes in Zephyr). Is this just a style preference thing, or is there any benefit of using dashes vs. underscores in node names?

I’m not aware of a particular naming convention for DTS in Zephyr. In fact, dashes are used a lot in Zephyr’s devicetree files. You could stick to an underscore-only convention if you wanted to, and it might even make sense since for the devicetree API you need to use the lowercase-and-underscore form anyhow and thus all dashes are transformed into underscores.