<?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>nRF51822 &amp;amp; Zephyr - OTA DFU</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/93855/nrf51822-zephyr---ota-dfu</link><description>Hello, everyone! 
 We have nRF51822 SoC running Zephyr OS. We would like to have the ability to perform OTA DFU. Given the fact that nRF51822 has only 256KB of flash memory, we have separated the Zephyr part from the application code so that we can update</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 04 Apr 2024 03:49:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/93855/nrf51822-zephyr---ota-dfu" /><item><title>RE: nRF51822 &amp; Zephyr - OTA DFU</title><link>https://devzone.nordicsemi.com/thread/476996?ContentTypeID=1</link><pubDate>Thu, 04 Apr 2024 03:49:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:867d9941-a6c7-4430-b6ab-5af883a487dd</guid><dc:creator>liteyear</dc:creator><description>&lt;p&gt;FWIW I tried to get the same outcome with a different approach. After some study of &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;CONFIG_CODE_DATA_RELOCATION&lt;/span&gt; (only works for different &lt;em&gt;regions&lt;/em&gt; it seems, not within a region) and &lt;a href="https://docs.zephyrproject.org/latest/services/storage/flash_map/flash_map.html"&gt;flash_map&lt;/a&gt; (only suited for storage, not XIP code) I went down the &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;custom-sections.ld&lt;/span&gt; linker script route. Things were looking good, separating out the app segments from the Zephyr segments, thanks to &lt;a href="https://stackoverflow.com/a/48061740/3697870"&gt;this&lt;/a&gt; trick that allows segments to be specified by library.&amp;nbsp;&lt;span&gt;Alas I hit a brick wall because there&amp;#39;s some symbols in the app library (eg. &lt;/span&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;code class="code cc-1o5d2cw" data-renderer-mark="true"&gt;_static_thread_data*&lt;/code&gt;&lt;/span&gt;&lt;span&gt; that by default get grouped with some Zephyr symbols. If I try to move them, the app silently hangs, so I assume there&amp;#39;s some address arithmetic going on that&amp;nbsp;relies on them being&amp;nbsp;grouped together.&lt;br /&gt;&lt;br /&gt;I gather this might be the class of challenge that have led others to conclude that OS and app cannot be separated, and I have, very reluctantly, come to the same conclusion. I&amp;#39;d love to hear otherwise! Prior to hitting the brick wall, I had 5kB of application code isolated from &amp;gt;600kB of Zephyr library, and the Zephyr library was not changing as I made meaningful changes to the application. You can imagine the benefits this could bring for OTA, including opening the door to a two-stage upgrade strategy - OTA for incremental updates and cabled for OS or major updates.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF51822 &amp; Zephyr - OTA DFU</title><link>https://devzone.nordicsemi.com/thread/395959?ContentTypeID=1</link><pubDate>Wed, 16 Nov 2022 11:41:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6706d07-920f-40ed-ab1a-e207fe531f78</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Bojan,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not aware of a way to seperate zephyr OS from application. I don&amp;#39;t think by defining a &amp;quot;zephyr_partition&amp;quot; you would be able to put the OS into a separate partition that you can split it using&amp;nbsp;&lt;strong&gt;&lt;span&gt;arm-none-eabi-objcopy.&amp;nbsp;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;My understanding is that when you build a Zephyr application, the OS and the application is mixed and there is no&amp;nbsp;easy way to separate them.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What you see as zephyr.hex is the mixture of the Zephyr OS and the application.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;This may also explain why when you change anything in the application, the zephyrOS.hex also change.&lt;/p&gt;
&lt;p&gt;My suggestion, if the internal flash is too small, you may want to think of either using external flash to receive new image, or use our nRF5 SDK solution (Bootloader + Softdevice) and then have the zephyr application running as a NRF5 SDK application.&lt;/p&gt;
&lt;p&gt;But i&amp;#39;m not so sure if you have enough space.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF51822 &amp; Zephyr - OTA DFU</title><link>https://devzone.nordicsemi.com/thread/395920?ContentTypeID=1</link><pubDate>Wed, 16 Nov 2022 09:21:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:57887282-c587-4194-a0c5-5a8863e1bae4</guid><dc:creator>bojan</dc:creator><description>&lt;p&gt;Hello, &lt;a href="https://devzone.nordicsemi.com/members/hungbui"&gt;Hung Bui&lt;/a&gt; !&lt;/p&gt;
&lt;p&gt;Sorry for the delayed reply.&lt;/p&gt;
[quote userid="2121" url="~/f/nordic-q-a/93855/nrf51822-zephyr---ota-dfu/395537"]Could you give us more information on how you separate Zephyr from the app and how you locate Zephyr in a different partition&amp;nbsp; ?[/quote]
&lt;p&gt;In our custom .dts file, we have defined our memory layout in the following way:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;&amp;amp;flash0 {
	partitions {
		compatible = &amp;quot;fixed-partitions&amp;quot;;
		#address-cells = &amp;lt;1&amp;gt;;
		#size-cells = &amp;lt;1&amp;gt;;

		boot_partition: partition@0 {
			label = &amp;quot;mcuboot&amp;quot;;
			reg = &amp;lt;0x00000000 0x6000&amp;gt;;
		};
		slot0_partition: partition@6000 {
			label = &amp;quot;image-0&amp;quot;;
			reg = &amp;lt;0x00006000 0x6000&amp;gt;;
		};
		slot1_partition: partition@c000 {
			label = &amp;quot;image-1&amp;quot;;
			reg = &amp;lt;0x0000c000 0x6000&amp;gt;;
		};
		scratch_partition: partition@12000 {
			label = &amp;quot;image-scratch&amp;quot;;
			reg = &amp;lt;0x00012000 0x1000&amp;gt;;
		};
		zephyr_partition: partition@13000 {
			label = &amp;quot;zephyr&amp;quot;;
			reg = &amp;lt;0x000013000 0x2C000&amp;gt;;
		};

		storage_partition: partition@3f000 {
			label = &amp;quot;storage&amp;quot;;
			reg = &amp;lt;0x0003f000 0x00001000&amp;gt;;
		};
	};
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;We separate Zephyr from the app by using the &lt;strong&gt;&lt;span style="background-color:#ccffcc;"&gt;arm-none-eabi-objcopy&lt;/span&gt;&lt;/strong&gt; executable from the compiler:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;                // Extract app section to bin
                &amp;quot;${config:TOOLCHAIN_PATH}/bin/arm-none-eabi-objcopy -O binary --only-section=rom_start --only-section=app_flash ${workspaceFolder}/build/zephyr/zephyr.elf ${workspaceFolder}/images/${config:BOARD_NAME}.bin;&amp;quot;,
                // Extract app section to hex
                &amp;quot;${config:TOOLCHAIN_PATH}/bin/arm-none-eabi-objcopy -O ihex --only-section=rom_start --only-section=app_flash ${workspaceFolder}/build/zephyr/zephyr.elf ${workspaceFolder}/images/${config:BOARD_NAME}.hex;&amp;quot;,
                // Extract Zephyr section to bin
                &amp;quot;${config:TOOLCHAIN_PATH}/bin/arm-none-eabi-objcopy -O binary --remove-section=rom_start --remove-section=app_flash ${workspaceFolder}/build/zephyr/zephyr.elf ${workspaceFolder}/images/ZephyrOS.bin;&amp;quot;,
                // Extract Zephyr section to hex
                &amp;quot;${config:TOOLCHAIN_PATH}/bin/arm-none-eabi-objcopy -O ihex --remove-section=rom_start --remove-section=app_flash ${workspaceFolder}/build/zephyr/zephyr.elf ${workspaceFolder}/images/ZephyrOS.hex;&amp;quot;,&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Here is what we have noticed recently:&lt;/p&gt;
&lt;p&gt;Once we change the application code, compile it, and separate Zephyr from the app, &lt;strong&gt;&lt;span style="background-color:#ff99cc;"&gt;ZephyrOS.hex&lt;/span&gt;&lt;/strong&gt; file is different compared to the &lt;strong&gt;&lt;span style="background-color:#ff99cc;"&gt;ZephyrOS.hex&lt;/span&gt;&lt;/strong&gt; file we get after compilation of the initial version of the code. We found ~26 lines of difference between the two &lt;strong&gt;&lt;span style="background-color:#ff99cc;"&gt;ZephyrOS.hex&lt;/span&gt;&lt;/strong&gt; files. This might be the reason for HardFault after DFU.&lt;/p&gt;
&lt;p&gt;How can we get consistent/deterministic content of the &lt;strong&gt;&lt;span style="background-color:#ff99cc;"&gt;ZephyrOS.hex&lt;/span&gt;&lt;/strong&gt; file? We don&amp;#39;t change anything related to the Zephyr when we update our application code. Consequently, we expect &lt;strong&gt;&lt;span style="background-color:#ff99cc;"&gt;ZephyrOS.hex&lt;/span&gt;&lt;/strong&gt; part to always be the same.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="2121" url="~/f/nordic-q-a/93855/nrf51822-zephyr---ota-dfu/395537"]Which bootloader did you use ? I assume it&amp;#39;s MCUBoot ?&amp;nbsp;[/quote]
&lt;p&gt;Yes, we are using the MCUBoot bootloader. &lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best,&lt;br /&gt;Bojan.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF51822 &amp; Zephyr - OTA DFU</title><link>https://devzone.nordicsemi.com/thread/395537?ContentTypeID=1</link><pubDate>Mon, 14 Nov 2022 11:59:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5280e5c3-a009-45ac-8b95-b7bc7d08bc67</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Bojan,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Could you give us more information on how you separate Zephyr from the app and how you locate Zephyr in a different partition&amp;nbsp; ?&lt;/p&gt;
&lt;p&gt;Which bootloader did you use ? I assume it&amp;#39;s MCUBoot ?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;If you try to&amp;nbsp;DFU update with very simple application , for example blinking LED, do you see the same issue ?&lt;br /&gt;&lt;br /&gt;Please be aware that we don&amp;#39;t support nRF51 in our nRF Connect SDK. You can use it with Zephyr but it&amp;#39;s pretty much on your own. For new development we suggest to go with nRF52 or nRF53.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>