<?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>How to place the custom linker section in the .data section?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/119783/how-to-place-the-custom-linker-section-in-the-data-section</link><description>Hi, 
 I am working with nrf5340 with the Zephyr OS. I created a custom data section in a custom linker file. 
 .my_data_section : { PROVIDE(__my_data_section_start = .); KEEP(*(.my_data_section)) PROVIDE(__my_data_section_end = .); } &amp;gt; RAM AT &amp;gt; FLASH</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 17 Mar 2025 16:09:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/119783/how-to-place-the-custom-linker-section-in-the-data-section" /><item><title>RE: How to place the custom linker section in the .data section?</title><link>https://devzone.nordicsemi.com/thread/527711?ContentTypeID=1</link><pubDate>Mon, 17 Mar 2025 16:09:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d1c3992-544a-433d-a216-11b8820a9770</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;My apology. I misread the other ticket.&lt;/p&gt;
&lt;p&gt;There are a couple of way to do this.&lt;/p&gt;
&lt;p&gt;The first one is to use Zephyr linker tool APIs, described here:&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/zephyr-apis-2.9.1/page/linker-tool-gcc_8h.html"&gt;https://docs.nordicsemi.com/bundle/zephyr-apis-2.9.1/page/linker-tool-gcc_8h.html&lt;/a&gt;&lt;br /&gt;A custom linker file needs to be used with it, and you can provide the linker file with the command&amp;nbsp;zephyr_linker_sources() in your CMakeLists.txt.&lt;/p&gt;
&lt;p&gt;Here are a few examples uses you can refer to:&lt;br /&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/tree/v3.7.99-ncs2/tests/application_development/code_relocation"&gt;sdk-zephyr/tests/application_development/code_relocation at v3.7.99-ncs2 · nrfconnect/sdk-zephyr&lt;/a&gt;&lt;br /&gt;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/commit/711ed082a2c361311a06b2c76c604f7e03fa8ddf"&gt;debug: tracing: Add Segger RTT linker section options · zephyrproject-rtos/zephyr@711ed08&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Another method is discussed in this DevZone case:&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/117706/define-a-section-to-consistently-place-rtt"&gt;Define a section to consistently place rtt&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to place the custom linker section in the .data section?</title><link>https://devzone.nordicsemi.com/thread/527383?ContentTypeID=1</link><pubDate>Fri, 14 Mar 2025 13:19:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d2d4c1d-1768-4b07-b9f0-c4252cb92099</guid><dc:creator>AlphaBeta</dc:creator><description>&lt;p&gt;Both questions have different context.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In this question, I am able to create my own data section in RAM. However, the global variables I place in this section do not have the correct initial values that I expect. This is because they should be placed under &amp;quot;.data&amp;quot; section for the compiler to recognize about correct initialization.&lt;/p&gt;
&lt;p&gt;In the final linker.cmd, I am expecting it to appear like the following (I just manually added this line for explanation purpose).&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1741958288791v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;I do not know how to automatically do this since linker.cmd is automatically generated.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to place the custom linker section in the .data section?</title><link>https://devzone.nordicsemi.com/thread/527380?ContentTypeID=1</link><pubDate>Fri, 14 Mar 2025 13:12:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74f1c941-1990-427f-8106-5d605cef74e3</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi AlphaBeta,&lt;/p&gt;
&lt;p&gt;I see you created this case&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/119796/how-can-i-add-postbuild-options-to-compute-a-checksum-and-add-it-at-an-address-in-flash"&gt;How can I add postbuild options to compute a checksum and add it at an address in Flash?&lt;/a&gt;&amp;nbsp;.&lt;/p&gt;
&lt;p&gt;From that case&amp;#39;s text, it seems you already figured out how to create your own custom section in&amp;nbsp;Flash.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If you already have the answer, it would be great if you could share it here for future readers.&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>