<?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>Modify zephyr&amp;#39;s Driver with out of tree procedure</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/118225/modify-zephyr-s-driver-with-out-of-tree-procedure</link><description>Hi 
 I have been using my out of tree driver for my BG95 module, which I have copy pasted from the zephyr&amp;#39;s quectel_bg9x driver (drivers/modem/quectel-bg9x) and its required files into respective folders and renamed as quectel-bg95cd and made a few additions</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 07 Jun 2025 23:34:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/118225/modify-zephyr-s-driver-with-out-of-tree-procedure" /><item><title>RE: Modify zephyr's Driver with out of tree procedure</title><link>https://devzone.nordicsemi.com/thread/538525?ContentTypeID=1</link><pubDate>Sat, 07 Jun 2025 23:34:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0fad7e35-70af-4748-b409-8049340cafa3</guid><dc:creator>helpfulchicken</dc:creator><description>&lt;p&gt;I had a similar issue (difficulties making a custom modem driver work), and I finally got it working so I thought I would share my key findings here to&amp;nbsp;help the next poor soul to stumble here while working on a similar problem.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;As mentioned above, when building your code with your custom driver amendment, you need to have &lt;code&gt;list(APPEND ZEPHYR_EXTRA_MODULES path_to/my_module&lt;/code&gt; but a key detail that is easy to miss is that&amp;nbsp;it needs to be BEFORE the step where you call &lt;code&gt;find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}).&lt;/code&gt; This is probably the main thing that tripped me up for a long time.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;# - this &amp;#39;append extra modules&amp;#39; step must be prior to the &amp;#39;find package zephyr&amp;#39; step!
list(APPEND ZEPHYR_EXTRA_MODULES ${MAIN_REPO_DIRECTORY}/custom_driver_module)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})

project(app)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Use &lt;code&gt;zephyr_library_amend()&lt;/code&gt; as mentioned above, to specify how the driver is to be built as an addition to an existing driver library. Don&amp;#39;t include duplicates of the existing source files from the driver library you&amp;#39;re trying to add to or you&amp;#39;ll you&amp;#39;ll get &amp;#39;multiple definitions&amp;#39; conflicts, keep it to just your new functions etc. Duplicate + modified Kconfig files don&amp;#39;t seem to be an issue. Based on this, having files like&amp;nbsp;modem_context.c in your custom driver will cause conflicts, unless your copy only adds new function names.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;The general folder structure shown in the original post should work. You need the dts/bindings/my_module/company,thing.yml file so that you can specify your thing in the devicetree files in the &amp;#39;compatible&amp;#39; property. I didn&amp;#39;t find that I needed the include/app/drivers/ portion, I just put&amp;nbsp;my&amp;nbsp;quectel-bg95cd.h equivalent into the drivers/modem&amp;nbsp;folder.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;This was my folder structure which worked for me:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;boards
└── ...

custom_driver_module
├── drivers
|   ├── modem
|   |   ├── CMakeLists
|   |   ├── Kconfig
|   |   ├── Kconfig.quectel-bg95cd
|   |   ├── quectel_bg95cd.c
|   |   └── quectel_bg95cd.h
|   ├── CMakeLists.txt
|   └── Kconfig
├── dts
|   └── bindings
|       └── modem
|           └── quectel,bg95cd.yaml
├── zephyr
|   └── module.yml
├── CMakeLists.txt
└── Kconfig

app
├── boards
|   └── ...
├── src
|   └── ...
└── CMakeLists.txt&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I hope this helps someone.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Modify zephyr's Driver with out of tree procedure</title><link>https://devzone.nordicsemi.com/thread/520189?ContentTypeID=1</link><pubDate>Mon, 27 Jan 2025 13:55:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d34a9c4c-e8f9-4e14-b034-4e867b3c8033</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Vignesh,&lt;/p&gt;
&lt;p&gt;It appears that we have been using the wrong path to find modem_socket.h. It is not located in zephyr/subsys/net/lib/sockets, but in zephyr/drivers/modem.&lt;/p&gt;
&lt;p&gt;Please change the path accordingly.&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Modify zephyr's Driver with out of tree procedure</title><link>https://devzone.nordicsemi.com/thread/519886?ContentTypeID=1</link><pubDate>Thu, 23 Jan 2025 22:56:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:99ceecb7-17e8-40a1-b895-7ae1c787bbb4</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Vignesh,&lt;/p&gt;
&lt;p&gt;Let me try to reproduce your issue and I will follow up with you in 1 or 2 workdays.&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Modify zephyr's Driver with out of tree procedure</title><link>https://devzone.nordicsemi.com/thread/519618?ContentTypeID=1</link><pubDate>Wed, 22 Jan 2025 15:58:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9214f3f-52cb-45fb-832c-4800a4312604</guid><dc:creator>Vignesh R</dc:creator><description>&lt;p&gt;Hello Hieu,&lt;/p&gt;
&lt;p&gt;I tried putting this line in my drivers/modem/CMakeLists.txt file (available in line no.16 of the cmakelists I gave above)&lt;/p&gt;
&lt;p&gt;Now as u suggested I tried putting it in my drivers/CMakeLists.txt too, but ended up with same error&lt;/p&gt;
&lt;p&gt;attaching my drivers/CMakeLists.txt&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/1731.CMakeLists.txt"&gt;devzone.nordicsemi.com/.../1731.CMakeLists.txt&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Modify zephyr's Driver with out of tree procedure</title><link>https://devzone.nordicsemi.com/thread/519595?ContentTypeID=1</link><pubDate>Wed, 22 Jan 2025 14:37:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa988a44-01c7-4fb4-aa1e-b51067e6ce2a</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Vignesh,&lt;/p&gt;
&lt;p&gt;It seems that from NCS v2.6.0, Zephyr was changed in a way that&amp;nbsp;internal headers are not readily available to external modules, which I think is a good thing.&lt;/p&gt;
&lt;p&gt;Can you try adding this to the driver&amp;#39;s CMakeLists.txt?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;zephyr_library_include_directories_ifdef(CONFIG_NET_SOCKETS ${ZEPHYR_BASE}/subsys/net/lib/sockets)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>