<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Adding to the device tree with overlays - Zephyr</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/87784/adding-to-the-device-tree-with-overlays---zephyr</link><description>I&amp;#39;m still new to Zephyr, so this could be an easy question that I&amp;#39;m googling poorly - if so, sorry in advance. I just wanted to add an extra LED, led4 , to the existing nrf9160dk device tree. I tried adding it directly to the device tree like so 
 
 but</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 13 May 2022 14:04:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/87784/adding-to-the-device-tree-with-overlays---zephyr" /><item><title>RE: Adding to the device tree with overlays - Zephyr</title><link>https://devzone.nordicsemi.com/thread/367870?ContentTypeID=1</link><pubDate>Fri, 13 May 2022 14:04:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4578d024-fa0f-4ce3-8cf4-4fa9d0568920</guid><dc:creator>tedhavelka</dc:creator><description>&lt;p&gt;Hello &lt;a href="https://devzone.nordicsemi.com/members/smallerpond"&gt;SmallerPond&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;While not a deal breaker to keep dashes and underscores out of device tree alias names, I believe I made a mistake when I said they may not be allowed.&amp;nbsp; Last night I was reviewing the main DTS board file for the Thingy91.&amp;nbsp; In the &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/main/boards/arm/thingy91_nrf9160/thingy91_nrf9160_common.dts#L74" rel="noopener noreferrer" target="_blank"&gt;aliases section of Thingy91 DTS board file&lt;/a&gt; I see several alias names with dashes in them!&amp;nbsp; This naming convention must be ok.&amp;nbsp; The error I was running into while adding aliases to my own custom board file must be due to something else.&lt;/p&gt;
&lt;p&gt;The only difference I can think might matter here is that I am building against ncs v1.6.1, and I believe the latest release as of 2022-05-13 is v1.9.1.&amp;nbsp; I have not found a ready way to reach older ncs release tags on github&amp;#39;s web interface, for the nrfconnect collection of code repositories.&amp;nbsp; Nordic Semi seems to have configured things so older releases when selected just appear as zip archives.&amp;nbsp; Not quite as manually searchable on line that way . . . :/&lt;/p&gt;
&lt;p&gt;I think it is unlikely a DTS naming convention such as allowed characters in alias names has changed in the past few months.&lt;/p&gt;
&lt;p&gt;- Ted&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding to the device tree with overlays - Zephyr</title><link>https://devzone.nordicsemi.com/thread/367427?ContentTypeID=1</link><pubDate>Wed, 11 May 2022 13:08:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5fc072d1-f7b4-4401-a204-5841be21af62</guid><dc:creator>Einarh</dc:creator><description>&lt;p&gt;Hello&lt;/p&gt;
&lt;p&gt;Using devicetree overlays in Zephyr is documented here:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/build/dts/howtos.html#set-devicetree-overlays"&gt;http://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/build/dts/howtos.html#set-devicetree-overlays&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You might find the information you need there, if you&amp;#39;re still having problems please let me know.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding to the device tree with overlays - Zephyr</title><link>https://devzone.nordicsemi.com/thread/367259?ContentTypeID=1</link><pubDate>Tue, 10 May 2022 20:42:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff344fc1-97e0-40ff-90f2-c10508585785</guid><dc:creator>tedhavelka</dc:creator><description>&lt;p&gt;Hi SmallerPond,&lt;/p&gt;
&lt;p&gt;Good to see you here on another useful tech forum!&amp;nbsp; Also good steps you have tried this past hour, switching to alternate board and related.&amp;nbsp; I don&amp;#39;t know whether I&amp;#39;ll help you get further on this issue, but a couple of points to explore and or consider:&lt;/p&gt;
&lt;p&gt;(1)&amp;nbsp; Your build environment permitting, try to locate the build artifact &lt;span style="font-family:courier new, courier;"&gt;[project_top_dir]/build/zephyr/zephyr.dts&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;(2)&amp;nbsp; Be cautious and use only alphas and numerics in DTS alias names, no dashes or underscores.&lt;/p&gt;
&lt;p&gt;As I develop on Linux hosts, I get to run `west` at the command line and I have a now easy time locating and reviewing all custom project sources, as well as familiarity with the neighboring dirs along side my project&amp;#39;s top dir, namely `nrf`, `zephyr`, `modules`, the major parts of Nordics ncs Software Development Kit.&amp;nbsp; This file locating ability has given me quick access to an intermediate dtc artifact, a combined project device tree file which I can review for errors.&lt;/p&gt;
&lt;p&gt;The file `&lt;span style="font-family:courier new, courier;"&gt;zephyr.dts&lt;/span&gt;` is a culmination of all board dts files and dot overlays, with latest ones read &amp;quot;winning&amp;quot; in any places they&amp;#39;ve amended preexisting device nodes.&amp;nbsp; By reviewing zephyr.dts and searching for the newer nodes you added, you might be able to make sense of what&amp;#39;s causing the later error.&amp;nbsp; One thing to look for might be repeatedly defined names (symbols) or repeatedly referenced peripheral resources.&amp;nbsp; Without seeing more of your project&amp;#39;s dts code I may not be able to say more.&lt;/p&gt;
&lt;p&gt;The second point relates to your alias name `&lt;span style="font-family:courier new, courier;"&gt;bootloader-led&lt;/span&gt;`.&amp;nbsp; This feels like an obscure, undocumented one to me.&amp;nbsp; Through trial and error I found that I could only employ DTS alias names which contains just alphas and numerics.&amp;nbsp; All my attempts to put underscores in alias names resulted in compile time errors, either at the `dtc` stage or later when &lt;span style="font-family:courier new, courier;"&gt;cross-ng&lt;/span&gt; pre-processor hits certain Zephyr macros which expand my device aliases.&lt;/p&gt;
&lt;p&gt;I can understand the import to keep dashes out of device tree aliases, and other symbols which get meta-compiled into C code.&amp;nbsp; The dash is a basic C operator, and so without some kind of dts name &amp;quot;sanitizing&amp;quot; a dash or other character-that-is-C-operator is likely to break the, in this case, intermediate C code compiled from Device Tree Source.&amp;nbsp; Be cautious with alias names in your DTS files, .dts and .overlay.&lt;/p&gt;
&lt;p&gt;Unwinding Zephyr macros can be mentally challenging, and it is possible that a malformed DTS alias that appears before the alias that throws an error is responsible for that error.&amp;nbsp; Again that goes to the complexity of DTS getting converted to C source, which is on some level parsed sequentially.&amp;nbsp; These nested macros constructs of Zephyr combined with an unintended C operator can make compile-time debugging hard!&lt;/p&gt;
&lt;p&gt;- Ted&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding to the device tree with overlays - Zephyr</title><link>https://devzone.nordicsemi.com/thread/367257?ContentTypeID=1</link><pubDate>Tue, 10 May 2022 20:17:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:862fceb7-28a1-42e5-a29a-225502f78427</guid><dc:creator>SmallerPond</dc:creator><description>&lt;p&gt;Hey Ted, very helpful comment!&amp;nbsp; Actually, I think you have helped me before (or your posts have) at Jared Wolff&amp;#39;s forum :-)&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;led1&lt;/code&gt; was a typo, it&amp;#39;s &lt;code&gt;led4&lt;/code&gt; in the file - fixed that.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m doing this on the nRF9160DK, but just for kicks I tried on on the CircuitDojo nRF Feather/Sparkfun Thing Plus board as well and get the same results.&amp;nbsp;In all cases I triple checked that I am using a free GPIO pin.&lt;/p&gt;
&lt;p&gt;Now that I type that, it would likely be easier to focus on the CircuitDojo board since that overlay works well aside from the addition of my LED.&amp;nbsp; In that overlay (../nfed/shared/conf/mcuboot/circuitdojo_feather_nrf9160ns.overlay) I add an entry for my new LED (a little different from above because that board has only one LED otherwise)&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/ {
	leds {
		white_led: led_1 {
			gpios = &amp;lt;&amp;amp;gpio0 29 GPIO_ACTIVE_HIGH&amp;gt;;
			label = &amp;quot;White external LED (external D1)&amp;quot;;
		};
	};

	aliases {
		bootloader-led0 = &amp;amp;blue_led;
		led1 = &amp;amp;white_led;
    };
};

// Full speed ahead
&amp;amp;uart0 {
	status = &amp;quot;okay&amp;quot;;
	current-speed = &amp;lt;1000000&amp;gt;;
	tx-pin = &amp;lt;6&amp;gt;;
	rx-pin = &amp;lt;5&amp;gt;;
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Doing this gives me the exact same message as in my OP, but now with a 1 instead of a 4:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;error: &amp;#39;DT_N_ALIAS_led1_P_gpios_IDX_0_VAL_pin&amp;#39; undeclared&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;I also get this error when adding &lt;span style="font-family:courier new, courier;"&gt;compatible = &amp;quot;gpio-leds&amp;quot;.&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;&amp;nbsp; Also in this case multiple builds doesn&amp;#39;t have an effect.&amp;nbsp;&lt;/span&gt;&lt;/span&gt; Could I be getting the error it because I&amp;#39;m trying to add a device to an existing list of devices (leds)?&lt;/p&gt;
&lt;p&gt;It seems difficult to track down the process in the documentation, they don&amp;#39;t have any information (that I can see) about adding to existing lists - everything seems to be about completely new components/functionality.&lt;code&gt;&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding to the device tree with overlays - Zephyr</title><link>https://devzone.nordicsemi.com/thread/367251?ContentTypeID=1</link><pubDate>Tue, 10 May 2022 18:48:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f28fff3-43bc-4b0c-a422-1a02aa154e7b</guid><dc:creator>tedhavelka</dc:creator><description>&lt;p&gt;Hello SmallerPond,&lt;/p&gt;
&lt;p&gt;Regarding your situation with a build time, device tree source (DTS) error when adding an LED to your targeted board and project, your DTS syntax looks correct in the first and longer code excerpt.&amp;nbsp; You do not mention which board you are programming, whether it is an off shelf dev kit like Thingy91 or a custom board.&lt;/p&gt;
&lt;p&gt;As an upfront comment, changes to a project&amp;#39;s device tree files are pick up automatically by `west` based builds.&amp;nbsp; Not sure of most of the mechanisms for this, but when you name and locate your overlays per Zephyr (or DTS?) convention, changes there will compel a rebuild of most if not all your project sources.&lt;/p&gt;
&lt;p&gt;If you are using a Zephyr supported board, changing the board&amp;#39;s primary DTS file will potentially impact various sample apps which ship with Nordic&amp;#39;s nRF SDK.&amp;nbsp; Perhaps you have chosen a GPIO that&amp;#39;s available for developer&amp;#39;s use choice, so such an impact is benign.&amp;nbsp; You mention also the term &amp;quot;overlay&amp;quot;, which is a really handy feature of device tree source.&amp;nbsp; Your second code excerpt looks like a reasonable &amp;quot;dot overlay&amp;quot; file to add an LED to your project.&lt;/p&gt;
&lt;p&gt;Where is your overlay file located?&amp;nbsp; How is it named?&lt;/p&gt;
&lt;p&gt;Also, do you mean to assign the &amp;amp;led4 node to a DTS alias named led1?&lt;/p&gt;
&lt;p&gt;You may also want to add to your smaller overlay block of code the line `&lt;span style="font-family:courier new, courier;"&gt;compatible = &amp;quot;gpio-leds&amp;quot;;&lt;/span&gt;`.&amp;nbsp; Not sure if that is required, but I don&amp;#39;t think that will hurt anything, and may add some readability.&lt;/p&gt;
&lt;p&gt;When I first got .overlay files working, while programming a Sparkfun Thing Plus nRF9160 development board, I learned that I needed to locate and name my first .overlay file in a particular way.&amp;nbsp; My project was one I &amp;quot;spun off&amp;quot; from a Nordic Semi ncs 1.6.1 sample app, so it stood in its own directory, which contains a `&lt;span style="font-family:courier new, courier;"&gt;src&lt;/span&gt;` subdir and a `&lt;span style="font-family:courier new, courier;"&gt;boards&lt;/span&gt;` subdir.&amp;nbsp; My targeted board has a corresponding DTS board file named `&lt;span style="font-family:courier new, courier;"&gt;sparkfun_thing_plus_nrf9160ns.dts&lt;/span&gt;`, &lt;a href="https://github.com/nrfconnect/sdk-zephyr/tree/main/boards/arm/sparkfun_thing_plus_nrf9160" rel="noopener noreferrer" target="_blank"&gt;in a deep branch of the ncs 1.6.1 Zephyr Project 2.6.0 fork&lt;/a&gt;.&amp;nbsp; In my project&amp;#39;s `boards` directory, I created a file named:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &lt;span style="font-family:courier new, courier;"&gt;sparkfun_thing_plus_nrf9160ns.overlay&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The basename of my first overlay file must match the basename of my targeted board file.&lt;/p&gt;
&lt;p&gt;Device tree source files are meta-compiled into C by the compiling tool `dtc`.&amp;nbsp; This compiler is installed somewhere on your work station.&amp;nbsp; Further, somewhere in the Zephyr based build configuration I am guessing there is a rule which informs `dtc` to check for overlay files in a project&amp;#39;s `boards` directory.&amp;nbsp; You can have multiple .overlay files.&amp;nbsp; There is an `include` keyword in device tree source, which functions much like C language #include statements.&amp;nbsp; That is how you can add .overlay files to your project and give them arbitrary names.&lt;/p&gt;
&lt;p&gt;I ask about your filename choice of the overlay file and its location, because for the Zephyr based builds there is a naming convention in place.&amp;nbsp; I could be wrong, but from what I can tell it is necessary for at least the first &amp;quot;dot overlay&amp;quot; file basename to match your targeted board&amp;#39;s board file basename, in order to be found and processed by `dtc`.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;One last caveat:&amp;nbsp; I have noticed something now that I am developing firmware which targets a custom board.&amp;nbsp; To build for a custom board I needed to create a full set of board files for that board.&amp;nbsp; Following the .dts and .yml board filename conventions I could see in Zephyr supported boards, I created several files.&amp;nbsp; One in particular seems to be the &amp;quot;primary&amp;quot; DTS file, the file which contains a complete device tree for my custom board.&amp;nbsp; It is to this file that any overlays make or apply changes.&amp;nbsp; The filename form of this file -- and this goes for all the boards I see in &lt;a href="https://github.com/nrfconnect/sdk-nrf/tree/main/boards/arm/" rel="noopener noreferrer" target="_blank"&gt;ncs 1.6.1 supported ARM based boards directories&lt;/a&gt; -- is of the form &amp;quot;board_name_common.dts&amp;quot;.&amp;nbsp; No other board files among Zephyr&amp;#39;s many supported boards contains the pattern &amp;quot;common&amp;quot;.&amp;nbsp; From time to time when I edit this file, upon first re-compilation I see errors relating to my latest DTS change in that file.&amp;nbsp; This so even when I have built with the &amp;quot;dash pristine&amp;quot; -p option.&amp;nbsp; I must build a second time for the DTS amendment to be properly compiled.&lt;/p&gt;
&lt;p&gt;This has happened only when I edit my custom board&amp;#39;s primary, main .dts file.&amp;nbsp; Not when I edit overlay files.&lt;/p&gt;
&lt;p&gt;My toolchain is up to date, and I don&amp;#39;t see this behavior all the time, but thought I would mention it.&amp;nbsp; Building twice doesn&amp;#39;t cost too much, and perhaps someone else has seen and solved this intermittent issue with `west` based command line builds.&lt;/p&gt;
&lt;p&gt;- Ted&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>