<?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>nrf52832  buttonless DFU with fstorage</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/65228/nrf52832-buttonless-dfu-with-fstorage</link><description>I am using nrf52832 with buttonless DFU ,SDK 15.0,using fstorage.I want to store some device information in flash,such as serial number,hardware version,these data will not be erased duing DFU,and I want to save firmware version too,I tested that if I</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 27 Aug 2020 09:41:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/65228/nrf52832-buttonless-dfu-with-fstorage" /><item><title>RE: nrf52832  buttonless DFU with fstorage</title><link>https://devzone.nordicsemi.com/thread/266681?ContentTypeID=1</link><pubDate>Thu, 27 Aug 2020 09:41:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d314d26c-56f8-44bf-91a7-de10b4410220</guid><dc:creator>Coder_hope</dc:creator><description>&lt;p&gt;This problem is solved. here is my solution:&lt;/p&gt;
&lt;p&gt;#define SN_HW_EXIST_MASK&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(uint32_t)0x12345678u&lt;br /&gt;#define FIRMWARE_EXIST_MASK&amp;nbsp; &amp;nbsp; &amp;nbsp; (uint32_t)0x87654321u&lt;/p&gt;
&lt;p&gt;#define FSTORAGE_START_ADDR&amp;nbsp; &amp;nbsp; (uint32_t)0x3EE00&lt;br /&gt;#define FSTORAGE_END_ADDR&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(uint32_t)0x78000&lt;br /&gt;uint32_t Hardware_VerAddr&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; __attribute__ ((at(0x74400)));&lt;br /&gt;uint32_t Serial_NumAddr&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; __attribute__ ((at(0x74300)));&lt;br /&gt;uint32_t SN_HW_EXIST_Addr&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;__attribute__ ((at(0x74100)));&lt;/p&gt;
&lt;p&gt;uint32_t Firmware_VerAddr&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;__attribute__ ((at(0x3EE10)));&lt;br /&gt;uint32_t Firmware_EXIST_Addr&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;__attribute__ ((at(0x3EE00)));&lt;/p&gt;
&lt;p&gt;I changed FW version addr and exist addr, fstorage start addr changed too,In my app,when dfu command comes, device prepare to enter bootloader,I reset the&amp;nbsp;&lt;span&gt;FW version exist addr`s value in &lt;em&gt;&lt;strong&gt;ble_dfu_evt_handler, add&amp;nbsp;&amp;nbsp;Reset_FIRMWARE_EXIST_MASK();&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;em&gt;&lt;strong&gt;void Reset_FIRMWARE_EXIST_MASK(void)&lt;br /&gt;{&lt;br /&gt; uint32_t data=0xFFFFFFFF;&lt;br /&gt; ret_code_t rc;&lt;br /&gt; rc = nrf_fstorage_write(&amp;amp;fstorage, (uint32_t )(&amp;amp;Firmware_EXIST_Addr),&amp;amp;data,sizeof(uint32_t), NULL);//写入标志&lt;br /&gt; APP_ERROR_CHECK(rc); &lt;br /&gt;}&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;em&gt;&lt;strong&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void ble_dfu_evt_handler(ble_dfu_buttonless_evt_type_t event)
{
    switch (event)
    {
        case BLE_DFU_EVT_BOOTLOADER_ENTER_PREPARE:
            NRF_LOG_INFO(&amp;quot;Device is preparing to enter bootloader mode.&amp;quot;);
            // YOUR_JOB: Disconnect all bonded devices that currently are connected.
            //           This is required to receive a service changed indication
            //           on bootup after a successful (or aborted) Device Firmware Update.
			Reset_FIRMWARE_EXIST_MASK();
		    nrf_gpio_pin_set(LED_RED);
            break;

        case BLE_DFU_EVT_BOOTLOADER_ENTER:
            // YOUR_JOB: Write app-specific unwritten data to FLASH, control finalization of this
            //           by delaying reset by reporting false in app_shutdown_handler
			Reset_FIRMWARE_EXIST_MASK();
		    nrf_gpio_pin_set(LED_RED);
            NRF_LOG_INFO(&amp;quot;Device will enter bootloader mode.&amp;quot;);
            break;

        case BLE_DFU_EVT_BOOTLOADER_ENTER_FAILED:
            NRF_LOG_ERROR(&amp;quot;Request to enter bootloader mode failed asynchroneously.&amp;quot;);
            // YOUR_JOB: Take corrective measures to resolve the issue
            //           like calling APP_ERROR_CHECK to reset the device.
            break;

        case BLE_DFU_EVT_RESPONSE_SEND_ERROR:
            NRF_LOG_ERROR(&amp;quot;Request to send a response to client failed.&amp;quot;);
            // YOUR_JOB: Take corrective measures to resolve the issue
            //           like calling APP_ERROR_CHECK to reset the device.
            APP_ERROR_CHECK(false);
            break;

        default:
            NRF_LOG_ERROR(&amp;quot;Unknown event from ble_dfu_buttonless.&amp;quot;);
            break;
    }
}&lt;/pre&gt;&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;em&gt;&lt;strong&gt;tell app that firmware&amp;nbsp; information does not exist,when dfu is finished,app reboot and rewrite firmware data and exist value&amp;nbsp;.&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;may this be helpful for others!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52832  buttonless DFU with fstorage</title><link>https://devzone.nordicsemi.com/thread/266639?ContentTypeID=1</link><pubDate>Thu, 27 Aug 2020 08:24:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:63ffd026-4529-4345-ab67-ba308088c8f1</guid><dc:creator>Coder_hope</dc:creator><description>&lt;p&gt;Thanks for response,&lt;/p&gt;
&lt;p&gt;with device information,the app.bin file`s size is 100KB,without device information ,the app.bin file`s size is 99kb, almost the same.&lt;/p&gt;
&lt;p&gt;My app.hex size is 279kb,is it too big for dual bank dfu,and it automaticly choose single bank and erase flash?&lt;/p&gt;
&lt;p&gt;the FW version is selfdifined,so we can read it and show..&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52832  buttonless DFU with fstorage</title><link>https://devzone.nordicsemi.com/thread/266635?ContentTypeID=1</link><pubDate>Thu, 27 Aug 2020 07:59:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e751887-6a36-4084-89b4-fa9461a65c03</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The DFU image will become too big if variables are placed inside the preserved app data region at link time. You may check the size difference by comparing the size of the *.bin file inside the generated DFU package with and without these device information variables included.&lt;/p&gt;
&lt;p&gt;Also, you may want to consider using the UICR registers for one-time configurations such as the serial number and device type. And the app FW version is already stored in the bootloader settings page (&lt;span&gt;&lt;a title="s_dfu_settings" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/group__nrf__dfu__settings.html?cp=7_1_6_10_7_0_6_8#gaea8ed0d20006b2509636a6ff6e8a349d"&gt;s_dfu_settings&lt;/a&gt;&lt;/span&gt; @0x7F000).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52832  buttonless DFU with fstorage</title><link>https://devzone.nordicsemi.com/thread/266606?ContentTypeID=1</link><pubDate>Thu, 27 Aug 2020 03:05:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:984da5b8-0b66-4eb0-b137-c947bb6f6ca8</guid><dc:creator>Coder_hope</dc:creator><description>&lt;p&gt;new progress：&lt;/p&gt;
&lt;p&gt;I regenerate public key and privete key，DFU and device information work well ,but when i change the&amp;nbsp;&lt;span&gt;Firmware_Version,and run dfu, the reported frimware is still old one ,not new one.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I guess this is because the DFU uses dual bank ,the&amp;nbsp;Firmware_VerAddr is not erased during OTA,so it remain the same,So how to set the edge address of bank0 and bank1,to make the code of&amp;nbsp;Firmware_Version work as I wash?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>