Closed danlsk closed 7 years ago
@danlsk that function erases a flash sector (usually the last page).
I believe the flash sector might be a little different due to the OTA bootloader. It must have erased sketch/program vector address. The module is stucked at OTA blinking loop. The current bondstore.clearData() does not work correctly for the BLE Nano! If you have a BLE Nano there, you can definitely reproduce the error.
Withour cleardata(), the bonding handler doesn't work correctly. It is said pair unsuccessfully, yet shown as "connected" on the IOS but without the "i" symbol which allows to "forget the device".
I got a workaround by using offset =1. This will eliminate the forever OTA loop after a power/reset cycle.
BLEBondStore bleBondStore(1);
I don't think this may be correct fix because now the default OTA blink doesn't work anymore.
I am not sure how the clearData() or other things have deleted the OTA blink. I have to download the OTA bootloader again. So, now the clearData() and OTA work after power/reset cycle, using this change below.
BLEBondStore bleBondStore(1);
Ok, so this means the last page of flash is used by the boot loader some how, passing 1 makes it use the second last page.
Feel free to open a pull request for the related examples to add a comment for RedBearLab nRF51 based boards should pass in one etc. Thanks.
I believe the BLEBondStore needs to define correctly. What i got may just be a quick workaround that may not subject to rigorous testing. I don't believe using your last page or my second last page is correct. nrf51 and nrf52 flash memory map is different also. nrf5x flash memory map Also, RFduino doesn't have a reset button, hence, I didn't test the reset cycle. I may need a wire to test the reset pin. The power cycle on RFduino seems ok.
I'm open to suggestions, please open a PR once you figure things out.
Not all boards are running the Nordic Bootloader - so the flash map does not necessarily apply. The RBL boards do use it though, RFduino from what I remember has a custom closed source boot loader.
What is the version of S110 that RFduino is using? I just want to double check the flash memory map. Anyhow, Your example works fine for RFduino without any changes. I tested the reset cycle. It behaves just like the power cycle. As for BLE Nano, I believe this code might be safer.
NRF51
BLEBondStore bleBondStore(21);
NRF52
BLEBondStore bleBondStore(32);
What is the version of S110 that RFduino is using?
v5 with a custom (closed sourced) bootloader.
Using Redbearlab BLE NANO with the default OTA bootloader enabled, I am not able to resume the device name/ANCS program after the power cycle. The device became DFU_S130_V1.0 forever and never got out from OTA boot request. The LED keeps blinking. I was told by Redbearlab support, the LED blinks supposed to timeout and get into program. In the case of no application, it gets to reset and never comes out.
I realized the BLEBondstore is creating problem.
bleBondStore.clearData();
I commented them out and found the program able to boot but ANCS program is not working correctly.