<?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>Setting REGOUT0 in merged.hex</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/116490/setting-regout0-in-merged-hex</link><description>Hi there, 
 Our firmware is built on NCS 2.6.1 (soon to be ported to 2.7.0) and uses MCUboot. 
 I want to set REGOUT0 to 5 (which corresponds to 3.3V) and the `nrfjprog --memwr 0x10001304 --val 5` command works for this purpose. 
 However, I want this</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 28 Nov 2024 22:07:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/116490/setting-regout0-in-merged-hex" /><item><title>RE: Setting REGOUT0 in merged.hex</title><link>https://devzone.nordicsemi.com/thread/512647?ContentTypeID=1</link><pubDate>Thu, 28 Nov 2024 22:07:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75f6a208-dd81-49e6-872f-3aac12bfed84</guid><dc:creator>mlac</dc:creator><description>&lt;p&gt;Thank you so much, it&amp;#39;s working!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting REGOUT0 in merged.hex</title><link>https://devzone.nordicsemi.com/thread/512360?ContentTypeID=1</link><pubDate>Wed, 27 Nov 2024 13:03:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9dae0d06-8e59-4293-bde5-0e821a0f910f</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I am sorry, missed to see this ticket. I think I created a wrong hex file, but my intention was to show you how it is done.&lt;/p&gt;
&lt;p&gt;There are so many ways to create an intel HEX one I could think of is using objcopy&lt;/p&gt;
&lt;p&gt;&lt;span&gt;printf&lt;/span&gt; &lt;span&gt;&amp;quot;\x05\x00\x00\x00&amp;quot;&lt;/span&gt; &amp;gt; regout0.bin&lt;br /&gt;arm-none-eabi-objcopy --adjust-vma=0x10001304 -I binary -O ihex regout0.bin regout0.hex&lt;br /&gt;mergehex -m app.hex regout0.hex -o merged.hex&lt;br /&gt;nrfjprog --program merged.hex --verify&lt;br /&gt;nrfjprog --memrd 0x10001304 --n 4&lt;br /&gt;&lt;br /&gt;I think that should work.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting REGOUT0 in merged.hex</title><link>https://devzone.nordicsemi.com/thread/511770?ContentTypeID=1</link><pubDate>Sat, 23 Nov 2024 20:46:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c88a23bf-3d96-4ba1-b14a-332b763036e6</guid><dc:creator>mlac</dc:creator><description>&lt;p&gt;Hi Susheel,&lt;/p&gt;
&lt;p&gt;`mergehex --merge dongle-merged-3ba9eec.hex regout0.hex --output dongle-merged-3ba9eec-regout0.hex` yields:&lt;/p&gt;
&lt;p&gt;Failed to parse line 1 : &amp;quot;:0403040050000005E3&amp;quot;ERROR: One of the files to merge is not a valid hex file.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/dongle_2D00_merged_2D00_3ba9eec.hex"&gt;devzone.nordicsemi.com/.../dongle_2D00_merged_2D00_3ba9eec.hex&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/regout0.hex"&gt;devzone.nordicsemi.com/.../regout0.hex&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Can you help with this error?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting REGOUT0 in merged.hex</title><link>https://devzone.nordicsemi.com/thread/511242?ContentTypeID=1</link><pubDate>Wed, 20 Nov 2024 09:07:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:11a4a86a-1556-4a1f-96a0-fbc1dac2365f</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Laszlo,&lt;/p&gt;
&lt;p&gt;I think it is getting complicated with the changes going the route of having it in linker file. I think simpler would be just add it to the merged.hex in a different way.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I had another thought&lt;/p&gt;
&lt;p&gt;create a regout0.hex with this content&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;:020000041000EA&lt;br /&gt; :0403040050000005E3&lt;br /&gt; :00000001FF&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;and add custom merge in CMakeLists.txt&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;# Path to the custom HEX file
set(REGOUT0_HEX ${CMAKE_CURRENT_SOURCE_DIR}/regout0.hex)

# Append REGOUT0_HEX to the final merged.hex
add_custom_command(
&amp;#160;&amp;#160;&amp;#160; TARGET ${APPLICATION}
&amp;#160;&amp;#160;&amp;#160; POST_BUILD
&amp;#160;&amp;#160;&amp;#160; COMMAND mergehex --merge ${CMAKE_BINARY_DIR}/zephyr/merged.hex ${REGOUT0_HEX} --output ${CMAKE_BINARY_DIR}/zephyr/merged_with_regout.hex
&amp;#160;&amp;#160;&amp;#160; COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/zephyr/merged_with_regout.hex ${CMAKE_BINARY_DIR}/zephyr/merged.hex
)&lt;/pre&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;verify through nrfjprog after you flash this new merged.hex&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;nrfjprog --readcode output.hex
grep &amp;quot;10001304&amp;quot; output.hex
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting REGOUT0 in merged.hex</title><link>https://devzone.nordicsemi.com/thread/511186?ContentTypeID=1</link><pubDate>Tue, 19 Nov 2024 21:41:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0167ebf3-2036-40e3-97ae-4b8e866727e0</guid><dc:creator>mlac</dc:creator><description>&lt;p&gt;Thanks for your help, Susheel!&lt;/p&gt;
&lt;p&gt;Unfortunately, the suggested solution didn&amp;#39;t make a difference. I used claude.ai to get closer to the solution.&lt;/p&gt;
&lt;p&gt;Instead of using set_property or set, I used:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;zephyr_linker_sources(SECTIONS my_regout0_settings.ld)&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;Which included the&amp;nbsp;my_regout0_settings.ld&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;But then the build failed because the UICR memory section wasn&amp;#39;t present, so I included it:&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;MEMORY&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; &amp;nbsp; UICR (rw) : ORIGIN = 0x10001000, LENGTH = 0x1000&lt;br /&gt;}&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;The build failed due to multiple memory sections, so I included the following in the device tree:&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;soc {&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; uicr: uicr@10001000 {&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; compatible = &amp;quot;zephyr,memory-region&amp;quot;;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; reg = &amp;lt;0x10001000 0x1000&amp;gt;;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; zephyr,memory-region = &amp;quot;UICR&amp;quot;;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; status = &amp;quot;okay&amp;quot;;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; };&lt;/div&gt;
&lt;div&gt;};&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;The above devicetree fragment created the memory section in linker.cmd.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Then I added the following to my_regout0_settings.ld:&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;SECTIONS&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; &amp;nbsp; .uicr_regout0 (0x10001304) :&lt;br /&gt;&amp;nbsp; &amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; KEEP(*(.uicr_regout0))&lt;br /&gt;&amp;nbsp; &amp;nbsp; } &amp;gt;UICR&lt;br /&gt;}&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;The build failed, presumably because of multiple sections. I added the following devicetree fragment which doesn&amp;#39;t make a difference:&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;regout0_partition: partition@10001304 {&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; compatible = &amp;quot;zephyr,code-partition&amp;quot;;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; reg = &amp;lt;0x10001304 0x4&amp;gt;;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; zephyr,memory-region = &amp;quot;UICR&amp;quot;;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; zephyr,section-name = &amp;quot;uicr_regout0&amp;quot;;&lt;/div&gt;
&lt;div&gt;};&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;I&amp;#39;m stuck at this point.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Do any of you at Nordic have further suggestions?&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Setting REGOUT0 in merged.hex</title><link>https://devzone.nordicsemi.com/thread/511149?ContentTypeID=1</link><pubDate>Tue, 19 Nov 2024 15:53:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5bdbde33-c2a6-4afb-905f-dddd8f9f5f87</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;There should be one way that I think you can try using linked script&amp;nbsp;&lt;/p&gt;
&lt;p&gt;add a linker script in your project folder for example my_regout0_settings.ld like this&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;SECTIONS
{
    .uicr_regout0 (0x10001304) :
    {
        KEEP(*(.uicr_regout0))
    } &amp;gt;UICR
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In your&amp;nbsp;CMakeLists.txt: Include the custom linker script in the build process:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;pre class="ui-code" data-mode="text"&gt;set_property(GLOBAL APPEND PROPERTY linker_script custom_uicr.ld)&lt;/pre&gt;
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div dir="ltr"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;If &lt;strong&gt;set_property&lt;/strong&gt; does not work, then just use &lt;strong&gt;set&lt;/strong&gt;&lt;/div&gt;
&lt;p&gt;In your application somewhere, set the REGOUT0 value like this&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;__attribute__((section(&amp;quot;.uicr_regout0&amp;quot;)))
const uint32_t regout0 = 0xFFFFFF05; // 3.3V&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>