Hi all,
I've a problem using pstorage: after I execute a pstorage_clear, my ic (i have the pca10028 board) go crazy, the application I've write stop execute and I can't flash download again from Keil. So I tried to reflash it by nRFgo but when I select the Segger it give me the attached screen. After much attempts it restart to work, but I have to flash an hex without pstorage command.
I've started my application by ble_peripheral template without using the scheduler, I'm using the S110 with the attached screen configuration. I attach the code also.
I've checked the memory by debugger, and I've saw that the code start from 0 (softdevices) to 18000 and after there's my application code, all correct, the pstorage block handle give me a value of 0x3F400 that is 3 k under the flash end address (0x40000) cause I allocate 2 pstorage pages of 1024 plus the pstorage swap page.
I don't understand the bootloader question, if it is comprised in the S110 or not, but I think the software can check its presence by NRF_UICR->BOOTLOADERADDR.
How you can see in the code,I set a flash block size of 64 bytes and 1 block. In thi block I would save information baout the struct "ebutton_conf", I pass a casted pointer to the pstorage functions. First I initialize the pstorage module and after I run a flash_read(), in the content of the readed buffer (written by pointer in the ebutton_conf variable) I check if the ebutton_conf.config_flag contains the string "stored": if not (first access in the flash memory) I execute a flash_erase() and after a flash_write() with default value, the flash_write() will write the string "stored" also.
The issue is in the flash_erase(): in this function I set the flash_completed flag to 0, I execute the pstorage_clear() and wait the callback set the flass_completed flag to 1 so the flash_erase() function can exit from the while loop.
About the issue of the bad flash state after this operation (the Keil can't re download the firmware and nRFstudio can't get the device connected), I try to erase 63 bytes instead 64: with 63 the application always doesn't work but the Keil and nRFstudio problem doesn't happen (I don't undestand why.....).
I forgot to add the pstorage_sys_event_handler(sys_evt) in the sys_evt_dispatch() but after I do it, nothing changed....
If you want to semplify the code, you can call flash_erase() after flash_init() removing flash_read(), so you can check directly the problem.
Below screens and code in rar file (the project run under Nordic/examples/ble_peripheral)
Thanks!
Riccardo