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, however, since I added a new byte (uint8_t new_var) to the characteristic / service, I have been unable to do secure bootloader DFU's anymore... Is this something related with some memory management issue?
Something interesting in the code is the following, when older developers detailed which characteristics/services where going to be placed in the microcontroller, they added some documentation to advice future developers (like me) about any changes made in that section:
/**** Service ****/ static const ble_char_config_t k_ble_cw_char_config[] = { //////////////////////////////////////////////////////////////////// // // VERY IMPORTANT NOTE // // Before you make any changes here, make sure you read and // understand this. // // The order in which add characteristics affects the order in // which the soft device allocates handles. Controllers (definitely // iOS) may cache these handles. So if you add a characteristic to // a service, all characteristics added after it, whether in this // service or another, will see their handles go up. This means // they will be out of sync with the controller's cache. In development // it's a pain, but not fatal because we know how to clear the // iOS cache by turning BT off and then on again in settings. But for // regular users it will be confusing and might make them think // firmware updates broke or bricked their burners. // // It's not entirely clear how we get around this, but we might // have to change the id of the service as a whole when we upgrade, // and make sure that the upgrde can only be done from a device with // a new enough iOS app to know to use the new service. But that // wil break other phones that use the same burner if they are not // upgraded. // // Within the service, let's at least try to keep these in // monotonically increasing order of UUID, as they are now. // // Need to think long and hard about this and have a bulletproof // solution before we put burners out in the wild. //////////////////////////////////////////////////////////////////// /* characteristic UUID, READ, WRITE, NOTIFY, INDICATE, REQUEST_ID, SEND_AS_EVENT, SIZE, MAX_SIZE, WRITE_TYPE, HANDLE_STATE VARIABLE */ { 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 }, { 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 }, { 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 }, { COOKWARE_UUID_CHAR_GE_HANDLE_DATA, READ, NO_WRITE, AUTO_NOTIFY, NO_INDICATE, NO, NO, sizeof(ble_ge_cookware_data_t), 0, SHORT, COOKWARE_VARIABLE_GE_COOKWARE_DATA }, { 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 }, };
However, since I added that new variable, every attempt to do DFU is failing, even by deleting bond information + restarting the Bluetooth module in the phone, it's always showing me these logs in the nrf connect app (android and iOS).


Things I've tried so far without any luck:
- 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's
- 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.
UPDATE:
- 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.
So, my question really is:
- How does this SDK version works in terms of how is it possible to add safely new characteristic data without harming any code in the process for DFU? Is it possible to do a safe DFU back without needing to do a manual flash over USB? This samples will be sealed and will not be able to have physical access to the HW.