<?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>Some questions about NCS DFU target library</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/112130/some-questions-about-ncs-dfu-target-library</link><description>Hello, 
 I&amp;#39;ve got some questions regarding the use of DFU target library. I get my update data from the UART and like to use a setup with two partitions on my device. Is this generally possible with the library? 
 The dfu_target_init() function has the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 03 Jun 2025 15:14:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/112130/some-questions-about-ncs-dfu-target-library" /><item><title>RE: Some questions about NCS DFU target library</title><link>https://devzone.nordicsemi.com/thread/537908?ContentTypeID=1</link><pubDate>Tue, 03 Jun 2025 15:14:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae4f80c0-abe8-42d7-80a8-b613af17a437</guid><dc:creator>jay</dc:creator><description>&lt;p data-start="150" data-end="160"&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/runsiv"&gt;runsiv,&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p data-start="162" data-end="315"&gt;I&amp;#39;m also planning to use the &lt;code data-start="191" data-end="203"&gt;dfu_target&lt;/code&gt; library for performing OTA updates over cellular, where the firmware chunks are received via UART from a modem.&lt;/p&gt;
&lt;p data-start="317" data-end="539"&gt;While reviewing the &lt;code data-start="337" data-end="358"&gt;dfu_target_test.zip&lt;/code&gt; example you shared (particularly the &lt;code data-start="396" data-end="404"&gt;main.c&lt;/code&gt; file), I noticed that the &lt;code data-start="431" data-end="439"&gt;offset&lt;/code&gt; variable is incremented by the chunk size after each write. However, I&amp;rsquo;d like to better understand:&lt;/p&gt;
&lt;blockquote data-start="541" data-end="803"&gt;
&lt;p data-start="543" data-end="803"&gt;How does &lt;code data-start="552" data-end="572"&gt;dfu_target_write()&lt;/code&gt; internally handle the firmware image address updates?&lt;br data-start="626" data-end="629" /&gt; Does it automatically manage the correct memory offset for the write operation based on previous writes, or is there any explicit address management required from our side?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p data-start="805" data-end="922"&gt;Appreciate your clarification, as this will help ensure we integrate it correctly with our modem-based delivery flow.&lt;/p&gt;
&lt;p data-start="924" data-end="941"&gt;Thanks,&lt;br data-start="931" data-end="934" /&gt; &lt;strong data-start="934" data-end="941"&gt;Jay&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;

#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;dfu/dfu_target_mcuboot.h&amp;gt;

#include &amp;lt;zephyr/logging/log.h&amp;gt;
#define LOG_MODULE_NAME main
LOG_MODULE_REGISTER(LOG_MODULE_NAME);

#define CHUNK_SIZE    156
#define FW_SIZE CHUNK_SIZE * 0x400

__ALIGN(4) static uint8_t fw_image[CHUNK_SIZE];


int main(void)
{
	int err;
	size_t offset = 0;
	__ALIGN(4) uint8_t dfu_buf[(CHUNK_SIZE + 3) &amp;amp; ~3];

	memset(fw_image, 0xAA, sizeof(fw_image));
	
	err = dfu_target_mcuboot_set_buf(dfu_buf, sizeof(dfu_buf));
	LOG_INF(&amp;quot;dfu_target_mcuboot_set_buf: %d. Size: %d &amp;quot;, err, sizeof(dfu_buf));
	
	err = dfu_target_init(DFU_TARGET_IMAGE_TYPE_MCUBOOT, 0, FW_SIZE, NULL);
	LOG_INF(&amp;quot;dfu_target_init:%d&amp;quot;, err);

	do {
		err = dfu_target_write(fw_image, CHUNK_SIZE);
		if (err) {
			LOG_ERR(&amp;quot;dfu_target_write() failed. (err %d)&amp;quot;, err);
			return 0;
		}
		offset += CHUNK_SIZE;

	} while (offset &amp;lt;= FW_SIZE);

	LOG_INF(&amp;quot;Hello World! %s&amp;quot;, CONFIG_BOARD);
	return 0;
}
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;
&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: Some questions about NCS DFU target library</title><link>https://devzone.nordicsemi.com/thread/489451?ContentTypeID=1</link><pubDate>Wed, 19 Jun 2024 09:13:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cddecf19-176a-4aaf-a2b2-dd31e1a03b9e</guid><dc:creator>db_lw</dc:creator><description>&lt;p&gt;Thanks for your reply it was helpful.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Some questions about NCS DFU target library</title><link>https://devzone.nordicsemi.com/thread/489115?ContentTypeID=1</link><pubDate>Mon, 17 Jun 2024 13:14:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f17ab940-d23e-4bb1-8446-1f0e7b22a27a</guid><dc:creator>runsiv</dc:creator><description>[quote user="bugl_lt"]&lt;p&gt;Is the selection of the right partition to flash the new firmware, done automatically under the hood in the DFU target library or do I have to write this my self?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;I&amp;#39;ts the bootloader task to copy it the to correct spot. You can have a look at this sample a coworker of mine made. The image number is set to 0 so the image will be sent to the secondary slot as it should be&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Runar&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/dfu_5F00_target_5F00_test.zip"&gt;devzone.nordicsemi.com/.../dfu_5F00_target_5F00_test.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Some questions about NCS DFU target library</title><link>https://devzone.nordicsemi.com/thread/488999?ContentTypeID=1</link><pubDate>Mon, 17 Jun 2024 07:23:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:839a1746-3b56-4480-8274-2aeefde8a199</guid><dc:creator>db_lw</dc:creator><description>&lt;p&gt;Hi Runar,&lt;/p&gt;
&lt;p&gt;thanks for your response.&lt;/p&gt;
[quote userid="122502" url="~/f/nordic-q-a/112130/some-questions-about-ncs-dfu-target-library/488856"]Which version of the SDK are you using?[/quote]
&lt;p&gt;nRF Connect SDK v2.0.2&lt;/p&gt;
[quote userid="122502" url="~/f/nordic-q-a/112130/some-questions-about-ncs-dfu-target-library/488856"]Which device are you using?[/quote]
&lt;p&gt;nRF52840&lt;/p&gt;
[quote userid="122502" url="~/f/nordic-q-a/112130/some-questions-about-ncs-dfu-target-library/488856"]With two partitions, are you referring to two partitions for the your application where one is the current application and one is for the new one like described &lt;a href="https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-8-bootloaders-and-dfu-fota/topic/device-firmware-update-dfu-essentials/"&gt;here&lt;/a&gt;?[/quote]
&lt;p&gt;Yes, this is what I mean. Two partitions for the application. I already looked into this lesson and found it very helpful but the configuration in the exercise is a bit different than mine. The exercise uses mcumgr protocol and not the DFU target library.&lt;/p&gt;
[quote userid="122502" url="~/f/nordic-q-a/112130/some-questions-about-ncs-dfu-target-library/488856"]The img_num reefers to if the image is for the application core or the network core if you have a multi image build.&amp;nbsp;[/quote]
&lt;p&gt;Ok, that&amp;#39;s good to know.&lt;/p&gt;
&lt;p&gt;Is the selection of the right partition to flash the new firmware, done automatically under the hood in the DFU target library or do I have to write this my self?&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;David&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Some questions about NCS DFU target library</title><link>https://devzone.nordicsemi.com/thread/488856?ContentTypeID=1</link><pubDate>Fri, 14 Jun 2024 12:22:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95a1856d-47f6-49d2-b400-f284721f5c6d</guid><dc:creator>runsiv</dc:creator><description>&lt;p&gt;Hi David&lt;/p&gt;
&lt;p&gt;Could you tell me a bit regarding your application&lt;/p&gt;
&lt;p&gt;Which version of the SDK are you using?&lt;/p&gt;
&lt;p&gt;Which device are you using? There are some differences between for example the 52 series and the 53 series hench my question.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user=""]&lt;p&gt;I&amp;#39;ve got some questions regarding the use of DFU target library. I get my update data from the UART and like to use a setup with two partitions on my device. Is this generally possible with the library?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;With two partitions, are you referring to two partitions for the your application where one is the current application and one is for the new one like described &lt;a href="https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-8-bootloaders-and-dfu-fota/topic/device-firmware-update-dfu-essentials/"&gt;here&lt;/a&gt;?&amp;nbsp; If so yes it is possible, you will find an exercise &lt;a href="https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-8-bootloaders-and-dfu-fota/topic/exercise-1-dfu-over-uart/"&gt;here &lt;/a&gt;that walk you through setting it up&lt;/p&gt;
[quote user=""]&lt;p&gt;The dfu_target_init() function has the img_num argument. does this relate to the partition number?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;The img_num reefers to if the image is for the application core or the network core if you have a multi image build.&amp;nbsp;&lt;/p&gt;
[quote user=""]&lt;p&gt;If a firmware update was succesful and dfu_target_done(true) and dfu_target_schedule_update(0) are called does the reboot to actually run the new firmware need to be done manually?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;If they are successful you should be running the new image after a reboot&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Runar&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>