<?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>Out-of-tree driver - Zephyr (freestanding app)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/100815/out-of-tree-driver---zephyr-freestanding-app</link><description>Hi, 
 We have a custom board that includes an ST LIS2DE12 sensor. I followed what looks like the normal procedure to create an out-of-tree driver for it by refactoring the Zephyr driver for a similar ST part. I&amp;#39;ve included the driver in my source tree</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 01 Aug 2024 15:47:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/100815/out-of-tree-driver---zephyr-freestanding-app" /><item><title>RE: Out-of-tree driver - Zephyr (freestanding app)</title><link>https://devzone.nordicsemi.com/thread/496677?ContentTypeID=1</link><pubDate>Thu, 01 Aug 2024 15:47:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4da2d5cc-c2cc-4317-8eb9-53d524102f54</guid><dc:creator>Fisherdude</dc:creator><description>&lt;p&gt;Thanks for this! Another nugget I found along the way:&lt;/p&gt;
&lt;p&gt;The driver&amp;#39;s CMakeLists.txt must include&amp;nbsp;zephyr_library_add_dependencies(offsets_h), or the Zephyr&amp;nbsp;file linker-defs.h may not compile on a clean build because its #include &amp;lt;offsets.h&amp;gt; doesn&amp;#39;t find the file.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Out-of-tree driver - Zephyr (freestanding app)</title><link>https://devzone.nordicsemi.com/thread/488049?ContentTypeID=1</link><pubDate>Mon, 10 Jun 2024 08:23:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a75c706c-bbeb-4f16-a991-ed8701d9cdea</guid><dc:creator>Mirco</dc:creator><description>&lt;p&gt;You are my&amp;nbsp;&lt;span&gt;savior!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Out-of-tree driver - Zephyr (freestanding app)</title><link>https://devzone.nordicsemi.com/thread/480963?ContentTypeID=1</link><pubDate>Sun, 28 Apr 2024 05:22:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e5b24c3-101a-4512-b6fa-6bfc499073f7</guid><dc:creator>Vignesh R</dc:creator><description>&lt;p&gt;Hey Hi!&lt;/p&gt;
&lt;p&gt;I tried the above and with some references , i could able to build out of tree driver for my application.&lt;/p&gt;
&lt;p&gt;But, i cannot able to access the rtc.h (in&amp;nbsp;your case) from pcf85063a.c ,if rtc.h is placed in include/app/drivers/rtc.h.&lt;/p&gt;
&lt;p&gt;i moved it to the pcf85063a.c folder and accessed it by &amp;quot;#include &amp;quot;rtc.h&amp;quot;&amp;quot; directly,&lt;/p&gt;
&lt;p&gt;but i cant access if it is in the include directory, how to include the rtc.h if placed there?&lt;/p&gt;
&lt;p&gt;should i need to add some line in cmakelists to include them??&lt;/p&gt;
&lt;p&gt;or anyother way to include them??&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Out-of-tree driver - Zephyr (freestanding app)</title><link>https://devzone.nordicsemi.com/thread/475247?ContentTypeID=1</link><pubDate>Thu, 21 Mar 2024 21:55:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02516c06-4381-4cf7-90c9-2f63de42c6d4</guid><dc:creator>Cammie</dc:creator><description>&lt;p&gt;OK - I&amp;#39;m going to give this a whirl - thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Out-of-tree driver - Zephyr (freestanding app)</title><link>https://devzone.nordicsemi.com/thread/475236?ContentTypeID=1</link><pubDate>Thu, 21 Mar 2024 19:53:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6af63f92-8ece-4f97-bbe0-551bc8453529</guid><dc:creator>pixbroker</dc:creator><description>&lt;p&gt;Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Out-of-tree driver - Zephyr (freestanding app)</title><link>https://devzone.nordicsemi.com/thread/475227?ContentTypeID=1</link><pubDate>Thu, 21 Mar 2024 17:51:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dea330c3-092f-4190-a42c-624e1775b8cc</guid><dc:creator>ElectRocnic</dc:creator><description>&lt;p&gt;The name of the server is &amp;quot;zephyrproject&amp;quot;&amp;nbsp;&lt;br /&gt;This link is only valid for 7 days :(&amp;nbsp;&lt;br /&gt;&lt;a id="" href="https://discord.gg/sTDQeVDD"&gt;https://discord.gg/sTDQeVDD&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The post I found was from 13. dezember 2022 and was answered by the user Archie.&lt;br /&gt;As soon as you are on this server, my original link should work tho.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Out-of-tree driver - Zephyr (freestanding app)</title><link>https://devzone.nordicsemi.com/thread/475167?ContentTypeID=1</link><pubDate>Thu, 21 Mar 2024 14:33:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6c35807-27f5-4af6-93c5-516473415e36</guid><dc:creator>pixbroker</dc:creator><description>&lt;p&gt;Thank you. Could you share the Discord server/channel you found the answer at? The link is not working for me.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Out-of-tree driver - Zephyr (freestanding app)</title><link>https://devzone.nordicsemi.com/thread/432333?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2023 13:12:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39b2bb92-ee1c-402b-b9cb-bf00ae46b179</guid><dc:creator>ElectRocnic</dc:creator><description>&lt;p&gt;I have found a working solution to this now, thanks to&amp;nbsp;&lt;a title="this dicord answer" href="https://discord.com/channels/720317445772017664/1052185203088568371/1052186938200817664"&gt;this dicord answer&lt;/a&gt;:&lt;br /&gt;&lt;br /&gt;The problem is indeed, that Zephyr does not seem to clearly document freestanding+out-of-tree applications:&lt;br /&gt;You have to include your out-of-tree driver inside your freestanding app root folder like this:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;├── drivers
│   ├── CMakeLists.txt
│   ├── Kconfig
│   ├── rtc
│   │   ├── CMakeLists.txt
│   │   ├── Kconfig
│   │   ├── pcf85063a_util.h
│   │   └── pcf85063a.c
│   └── zephyr
│       └── module.yml
├── dts
│   └── bindings
│       └── rtc
│           └── nxp,pcf85063a.yaml
├── include
│     └── app
│       └── drivers
│           └── rtc.h
├── src
└── proj.conf&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and your driver is actually a so-called &amp;quot;module&amp;quot; which needs the &lt;code&gt;drivers/zephyr/module.yml&lt;/code&gt;&amp;nbsp;file with the following content:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;build:
  cmake: .
  kconfig: Kconfig&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Next, you need to include this in your app&amp;#39;s root CMakeLists.txt&amp;nbsp;&lt;strong&gt;before&amp;nbsp;&lt;/strong&gt;you find the zephyr package (I don&amp;#39;t know why, but I got it running this way):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;list(APPEND ZEPHYR_EXTRA_MODULES
  ${CMAKE_CURRENT_SOURCE_DIR}/drivers
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This is needed&amp;nbsp;&lt;strong&gt;instead&lt;/strong&gt; of the previously (likely, as in my case) used&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;add_subdirectory(drivers)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;so I removed the latter line in my repo and replaced it with the list command above.&lt;/p&gt;
&lt;p&gt;Hope, you will find that this solution also works in your case!&lt;br /&gt;&lt;br /&gt;Kind regards.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Out-of-tree driver - Zephyr (freestanding app)</title><link>https://devzone.nordicsemi.com/thread/432045?ContentTypeID=1</link><pubDate>Tue, 20 Jun 2023 13:47:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e9d23c4b-6cc7-4b81-a963-c216be0b8dec</guid><dc:creator>ElectRocnic</dc:creator><description>&lt;p&gt;First little check I made, was to verify that it is indeed a problem with the application type (out-of-tree vs. in-tree), and I did this by duplication an existing driver in the zephyr ncs:&lt;/p&gt;
&lt;p&gt;1. Duplicate the folder &lt;code&gt;.../ncs/v2.4.0/zephyr/drivers/sensor/bmi270&lt;/code&gt; to &lt;code&gt;.../bmi271&lt;/code&gt;. For simplicity, the new folder can be added to the workspace in VS Code and then use &amp;quot;find in directory&amp;quot; to replace all case-sensitive instances of &lt;code&gt;bmi270&lt;/code&gt; with &lt;code&gt;bmi271&lt;/code&gt;, and all &lt;code&gt;BMI270&lt;/code&gt; with &lt;code&gt;BMI271&lt;/code&gt;. In the &lt;code&gt;.../ncs/v2.4.0/zephyr/drivers/sensor/CMakeLists.txt&lt;/code&gt; file, I also had to duplicate the line for BMI270:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;add_subdirectory_ifdef(CONFIG_BMI270		bmi270)
add_subdirectory_ifdef(CONFIG_BMI271		bmi271)&lt;/pre&gt;&lt;/p&gt;
&lt;div class="bg-black rounded-md mb-4"&gt;
&lt;div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md"&gt;&lt;span&gt;In the &lt;/span&gt;&lt;code&gt;.../ncs/v2.4.0/zephyr/drivers/sensor/Kconfig&lt;/code&gt;&lt;span&gt; file too:&lt;/span&gt;&lt;/div&gt;
&lt;div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md"&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;source &amp;quot;drivers/sensor/bmi270/Kconfig&amp;quot;
source &amp;quot;drivers/sensor/bmi271/Kconfig&amp;quot;&lt;/pre&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md"&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md"&gt;&lt;span&gt;In &lt;/span&gt;&lt;code&gt;ncs/v2.4.0/zephyr/dts/bindings/sensor&lt;/code&gt;&lt;span&gt;, duplicate the 3 Bosch bindings and rename them (both filename and all strings within the files).&lt;/span&gt;&lt;/div&gt;
&lt;div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md"&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;bosch,bmi270-i2c.yaml
bosch,bmi270-spi.yaml
bosch,bmi270.yaml
bosch,bmi271-i2c.yaml
bosch,bmi271-spi.yaml
bosch,bmi271.yaml
&lt;/pre&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md"&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md"&gt;&lt;span&gt;In the main.c of the sample project, the app.overlay now needs to be adjusted. For this, I created a second spi node, which looks as follows:&lt;/span&gt;&lt;/div&gt;
&lt;div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md"&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;imu: &amp;amp;spi1 {
    compatible = &amp;quot;nordic,nrf-spim&amp;quot;;
    status = &amp;quot;okay&amp;quot;;
    cs-gpios = &amp;lt;&amp;amp;gpio0 18 0&amp;gt;;
    
    fake_sensor: bmi271@0 {
        compatible = &amp;quot;bosch,bmi271&amp;quot;;
        reg = &amp;lt;0&amp;gt;;
        spi-max-frequency = &amp;lt;10000000&amp;gt;;
    };
};&lt;/pre&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md"&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;What&amp;#39;s relevant is the compatible string and then the location in main.c:&lt;/p&gt;
&lt;div class="bg-black rounded-md mb-4"&gt;
&lt;div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md"&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;const struct device *const accel_sensor = DEVICE_DT_GET_ONE(bosch_bmi271);
if (!device_is_ready(accel_sensor)) {
		printf(&amp;quot;Device %s is not ready\n&amp;quot;, accel_sensor-&amp;gt;name);
		return 0;
}

char msg_accel[100];  // size might need to be adjusted based on your needs
snprintf(msg_accel, sizeof(msg_accel), &amp;quot;Device %p name is %s&amp;quot;, accel_sensor, accel_sensor-&amp;gt;name);&lt;/pre&gt;&lt;/div&gt;
&lt;div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md"&gt;&lt;/div&gt;
&lt;div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md"&gt;Note that I already had a Bosch BMI270 in my app.overlay at spi0 and it worked with the above code already. But I wanted to add an Kionix which is not in the Zephyr device tree and it did not work so far.&lt;br /&gt;My next steps are for now to use this workaround in-tree to get my own PoC for the Kionix, after that I can look into this problem again because I need my Kionix Driver to work out-of-tree anyways.&lt;br /&gt;&lt;br /&gt;Until then, kind regards.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Out-of-tree driver - Zephyr (freestanding app)</title><link>https://devzone.nordicsemi.com/thread/431836?ContentTypeID=1</link><pubDate>Mon, 19 Jun 2023 16:33:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4312b732-128d-4772-8aa4-492b9a5eb428</guid><dc:creator>ElectRocnic</dc:creator><description>&lt;p&gt;I tried to get this example driver code running in a freestanding fresh hello-world sample in VS Code.&lt;br /&gt;&lt;a id="" href="https://github.com/nobodyguy/HX711_zephyr_driver"&gt;https://github.com/nobodyguy/HX711_zephyr_driver&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Getting the error &lt;code&gt;main.c:61: undefined reference to `__device_dts_ord_8&amp;#39;&lt;br /&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Even had to add one line in my main Kconfig to get it so far:&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;code&gt;&lt;span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;pre class="ui-code" data-mode="text"&gt;source &amp;quot;Kconfig.zephyr&amp;quot; # this one
rsource &amp;quot;drivers/Kconfig&amp;quot;&lt;/pre&gt;
&lt;div&gt;&lt;code&gt;&lt;span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;apparently freestanding apps have major problems easily compared to in-tree apps?&lt;br /&gt;Or I am just too stupid to acknowledge the very basics of Zephyr.&lt;br /&gt;&lt;br /&gt;My &lt;code&gt;CMakeLists.txt&lt;/code&gt; for the app looks like this:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(hello_world)

# Point to this project&amp;#39;s root directory.
set(HX711_DIR ${CMAKE_CURRENT_LIST_DIR} CACHE PATH &amp;quot;HX711 module root directory&amp;quot;)

# Subdirectories
add_subdirectory(drivers)

# Include headers
zephyr_include_directories(drivers)

target_sources(app PRIVATE src/main.c)&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;code&gt;I now also tried&amp;nbsp;&lt;a id="" href="https://github.com/jeremyherbert/zephyr_testrepo"&gt;https://github.com/jeremyherbert/zephyr_testrepo&lt;/a&gt;&amp;nbsp;with no luck after I read&amp;nbsp;&lt;a id="" href="https://github.com/zephyrproject-rtos/zephyr/issues/41677"&gt;https://github.com/zephyrproject-rtos/zephyr/issues/41677&lt;/a&gt;&amp;nbsp;where Jeremy seemingly got it working. (Had to adapt a few things like adding &amp;quot;zephyr&amp;quot; to each #include statement before the header names). Also, this repo does not even define an overlay.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Out-of-tree driver - Zephyr (freestanding app)</title><link>https://devzone.nordicsemi.com/thread/431819?ContentTypeID=1</link><pubDate>Mon, 19 Jun 2023 14:54:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c01716f-21e6-4a6a-bb80-0868dbd9294b</guid><dc:creator>ElectRocnic</dc:creator><description>&lt;p&gt;I have the exact same problem right now and am trying to find a solution. My approach is to go deep into the Zephyr theory, looked into a lot of docs from docs.zephyrproject.org and watched youtube talks about writing custom drivers.&lt;br /&gt;I think the problem might be to the difference between freestanding projects vs. in-tree or in-workspace projects in combination with the Kconfig and west yaml.&lt;br /&gt;&lt;br /&gt;I will come back if I find a solution.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Out-of-tree driver - Zephyr (freestanding app)</title><link>https://devzone.nordicsemi.com/thread/431309?ContentTypeID=1</link><pubDate>Thu, 15 Jun 2023 14:11:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5c1810b-a643-4e03-b584-fb5f2dca5a70</guid><dc:creator>Cammie</dc:creator><description>&lt;p&gt;2.3.0&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Out-of-tree driver - Zephyr (freestanding app)</title><link>https://devzone.nordicsemi.com/thread/431308?ContentTypeID=1</link><pubDate>Thu, 15 Jun 2023 14:10:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6c97506-4a0c-44f5-9a9b-576af165e523</guid><dc:creator>Hakon</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;what version of NCS are you trying to build this with?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>