(NCS 2.5.0) Unable to OTA if the device is previously bonded.

Hi,

We are running into a serious issue with OTA. Specifically, we have observed that nRF52832 will not be able to perform OTA to a newer firmware given that it is previously bonded with a device . The problem arises when the newer firmware modifies a previously static defined user service (via BT_GATT_SERVICE_DEFINE) where a couple of new characteristics are added. Attempting to perform an OTA update using the NRF device manager app results in a "Writing is not permitted" error after the image swap on IOS. We are only able to OTA given that the device bonding is forgotten prior to the OTA process. However, this is not acceptable for our use case, as we don't expect our customers to forget the bonding before each OTA update. 

According to this post ( RE: Force GATT client to sync database with Zephyr) , it looks like the code will need to enable the service changed characteristic to notify the connected client to force a new service discovery after OTA. However, after enabling CONFIG_BT_GATT_SERVICE_CHANGED=y on both the older and newer firmware version, we are still not able to successfully OTA without having to remove the bonding info. Nevertheless, it looks like this use case should be really common and I am wondering if there is anything we can do to fix this. Any help or guidance are greatly appreciated.

  • Hi Taspon, 


    I would suggest to try testing with the nRF Connect app to see if you can write to the SMP service. 

    Before you do the test please try to remove any bonding . Then bond with the original firmware and try DFU. There could be a chance that the attribute table is mixing up between new and old firmware. 


    Please try look for the log and see which exact characteristic is being written. You may need to use a sniffer trace to see which handle id used. 

  • We were finally able to fix this issue after digging through zephyr's GATT codebase.

    For the service changed indication to get sent, it looks like GATT data have to be cached in the device flash for it to compare the GATT attribute table hash after OTA. Zephyr checks for the DB hash after boot and sends a service change indication work item to the queue if it doesn't match.

    It looks like CONFIG_BLE_GATT_CACHING needs to be set for the app to properly clear the attribute cache, which fixed our connection issue after OTA given the device is previously bonded.

Related