<?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>nRF5 SDK 14.2.0 - Secure Bootloader DFU always fail after adding new variable to a characteristic</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/96574/nrf5-sdk-14-2-0---secure-bootloader-dfu-always-fail-after-adding-new-variable-to-a-characteristic</link><description>Hello! I am currently working in an temperature sensor which has bluetooth features based in the nRF52832 and I am currently using the nRF5 SDK 14.2.0. While I was working in a new feature, I was looking to add a new variable to a known characteristic</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 16 Feb 2023 21:26:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/96574/nrf5-sdk-14-2-0---secure-bootloader-dfu-always-fail-after-adding-new-variable-to-a-characteristic" /><item><title>RE: nRF5 SDK 14.2.0 - Secure Bootloader DFU always fail after adding new variable to a characteristic</title><link>https://devzone.nordicsemi.com/thread/410475?ContentTypeID=1</link><pubDate>Thu, 16 Feb 2023 21:26:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:70f60162-7eeb-420a-9839-4a0b14fececb</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi fabocode,&lt;/p&gt;
&lt;p&gt;The code you share is your company&amp;#39;s custom implementation to add BLE characteristic.&amp;nbsp;ble_char_config_t is not a nRF5 SDK v14.2.0 type. My guess is&amp;nbsp;there would be a helper function/library that read that array and add the characteristic.&lt;/p&gt;
&lt;p&gt;My next guess is that the size of&amp;nbsp;ble_char_config_t changed and somehow mess up the DFU service. Did you check if&amp;nbsp;ble_ge_cookware_data_t increases&amp;nbsp;after your change?&lt;/p&gt;
&lt;p&gt;One possible cause of DFU issues after a change to the service table is exactly what is written in the &amp;quot;VERY IMPORTANT NOTE&amp;quot; comment&amp;nbsp;in your code. However, your change should not cause this...&lt;br /&gt;To rule out this possibility, please repeat the test with&amp;nbsp;a phone having forgotten the device, and a device that has been fully erased, then programmed with the new application&lt;/p&gt;
&lt;p&gt;I have another idea, but for now&amp;nbsp;please&amp;nbsp;help me with my above question and suggestion first.&lt;/p&gt;
[quote user="fabocode"]as an update, I see now that if I forget the device from the iphone I have running nrf connect, and restarting the bluetooth in the phone, the error I keep seeing in the logs from nrf connect is what I attached to this post &amp;quot;Error 14: Peer removed pairing information&amp;quot;[/quote]
&lt;p&gt;If you forget the device on the phone, you also need to clear the bond information on the device. The&amp;nbsp;central (phone) will not be able to pair to the&amp;nbsp;peripheral if the peripheral still remembers the old bond.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;On a tangential note, a way to address the problem in &amp;quot;VERY IMPORTANT NOTE&amp;quot; is to use the Service Changed characteristic. Does your application configure &lt;span&gt;NRF_SDH_BLE_SERVICE_CHANGED=1&lt;/span&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5 SDK 14.2.0 - Secure Bootloader DFU always fail after adding new variable to a characteristic</title><link>https://devzone.nordicsemi.com/thread/410190?ContentTypeID=1</link><pubDate>Wed, 15 Feb 2023 22:11:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d694997-2db1-4769-a461-729fba9c99dd</guid><dc:creator>fabocode</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/vthieu"&gt;Hieu&lt;/a&gt;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I would like to add more details about the problem I have.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I have a struct which is part of one of the characteristics is currently running in the microcontroller.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;typedef struct __attribute__ ((__packed__)) {
    software_revision_t  version;   // Device firmware version
    uint16_t  product_id;           // Device Product ID
    uint8_t   battery_v;            // Battery voltage in 0.01 V increments
    uint16_t  temp_degF;            // Sensor reading in 0.1 F increments
    int8_t    cjt_degC;             // Cold-Junction Temperature (thermocouple ADC temp offset)
    uint8_t   status;               // Indicates error state with thermocouple or connection
    accel_event_data_t motion;      // Indicates motion &amp;amp; gesture detection
    uint8_t   wakeup_status;        // Indicates if device has woke up from deep sleep &amp;lt;------ This is the variable I added to the struct
} ge_cookware_data_t;


typedef struct __attribute__ ((__packed__)) {
    uint32_t    timestamp;      // time in nrf ticks (generally called milliseconds, but actually 1/1024 second)
    uint8_t     counter;        // increments by 1 every time data contents change (rolls over when reaches 0xff)
    uint8_t     packet_id;      // Advertising packet version (adv_packet_id_t)
    ge_cookware_data_t ge_cookware;
} ge_adv_packet_t;

typedef ge_adv_packet_t   ble_ge_cookware_data_t;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;And here&amp;#39;s the struct created for the service/characteristic definition&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/**** Service ****/
static const ble_char_config_t k_ble_cw_char_config[] = {
    /*                  characteristic UUID, READ,    WRITE,      NOTIFY,        INDICATE, REQUEST_ID, SEND_AS_EVENT,                               SIZE,                   MAX_SIZE, WRITE_TYPE,              HANDLE_STATE VARIABLE */
  /* 1st */  {        COOKWARE_UUID_CHAR_HANDLE_DATA, READ, NO_WRITE, AUTO_NOTIFY,     NO_INDICATE,         NO,            NO,     sizeof(ble_cw_cookware_data_t),                          0,      SHORT,    COOKWARE_VARIABLE_COOKWARE_DATA },
  /* 2nd */  {        COOKWARE_UUID_CHAR_HANDLE_HWID, READ, NO_WRITE,   NO_NOTIFY,     NO_INDICATE,         NO,            NO,     sizeof(ble_cw_cookware_hwid_t),                          0,      SHORT,          COOKWARE_VARIABLE_INVALID },
  /* 3rd */  {             COOKWARE_UUID_CHAR_EVENTS, READ, NO_WRITE,   NO_NOTIFY, DEMAND_INDICATE,        YES,            NO,             sizeof(ble_cw_event_t), BLE_GATT_MAX_PACKET_LENGTH,      SHORT,          COOKWARE_VARIABLE_INVALID },
  /* 4th */  {     COOKWARE_UUID_CHAR_GE_HANDLE_DATA, READ, NO_WRITE, AUTO_NOTIFY,     NO_INDICATE,         NO,            NO,     sizeof(ble_ge_cookware_data_t) /* here&amp;#39;s the struct used by the characteristic */,                          0,      SHORT, COOKWARE_VARIABLE_GE_COOKWARE_DATA }, 
  /* 5th */  {           COOKWARE_UUID_CHAR_COMMANDS, READ,    WRITE,   NO_NOTIFY,     NO_INDICATE,        YES,            NO, sizeof(ble_cookware_instruction_t), BLE_GATT_MAX_PACKET_LENGTH,      SHORT,          COOKWARE_VARIABLE_INVALID },
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;That&amp;#39;s what I mean when I say &amp;quot;I added a variable&amp;quot;. And I am currently testing to replicate as much scenarios as possible to recover the FW from DFU to a downgraded version. I can see that the problem resides in the firmware running in the device itself, not the build being downloaded, but I am not understanding what&amp;#39;s the real issue that&amp;#39;s making fail all the attempts to do DFU, even to versions which share the same property (the new variable in the struct).&amp;nbsp;&lt;br /&gt;&lt;br /&gt;as an update, I see now that if I forget the device from the iphone I have running nrf connect, and restarting the bluetooth in the phone, the error I keep seeing in the logs from nrf connect is what I attached to this post &amp;quot;Error 14: Peer removed pairing information&amp;quot;.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/photo_5F00_2023_2D00_02_2D00_15_5F00_17_2D00_09_2D00_37.jpg" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5 SDK 14.2.0 - Secure Bootloader DFU always fail after adding new variable to a characteristic</title><link>https://devzone.nordicsemi.com/thread/409617?ContentTypeID=1</link><pubDate>Mon, 13 Feb 2023 13:49:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84ace9aa-3d42-47e9-a2bf-665176681ef1</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi fabocode,&lt;/p&gt;
&lt;p&gt;Could you please clarify in detailed what you did by &amp;quot;adding a variable?&amp;quot;&lt;/p&gt;
&lt;p&gt;Are you changing the maximum size of a Characteristic Value? Or are you&amp;nbsp;adding a new Characteristic?&lt;/p&gt;
&lt;p&gt;I also feel there are some conflicts in the information you are providing.&lt;/p&gt;
[quote userid="84523" url="~/f/nordic-q-a/96574/nrf5-sdk-14-2-0---secure-bootloader-dfu-always-fail-after-adding-new-variable-to-a-characteristic"]- Remove the variable previously added to recover the state of where the device was, even removing the variable from the code, I still I am unable to do DFU&amp;#39;s&lt;br /&gt;- Trying to flash the microcontroller directly, deleting all memory in the microcontroller before flashing it again with new code (which does not have the variable I was looking to add at first) and try DFU again, DFU is still failing.&amp;nbsp;[/quote]
&lt;p&gt;Do you mean you remove it from the image you are downloading?&lt;br /&gt;In this case, is the image on the device still having your modification?&lt;/p&gt;
&lt;p&gt;The issue is most likely due to the firmware running the download, so the thing on the device, not the image being downloaded at all. Changing the image being download doesn&amp;#39;t help.&lt;/p&gt;
[quote userid="84523" url="~/f/nordic-q-a/96574/nrf5-sdk-14-2-0---secure-bootloader-dfu-always-fail-after-adding-new-variable-to-a-characteristic"]- By flashing manually to a version without the variable I wanted to add in the 1st place, I was able to get the DFU working. So far this is the only way to make it go back to an stable version that is able to work with DFU.&amp;nbsp;[/quote]
&lt;p&gt;And thus this observation makes sense.&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>