This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

flash download fail after pstorage_clear

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

my_app_last.rar

image description

image description

Parents
  • Strange. Could you upload your complete project? Or a project which reproduces this? What SDK version and SoftDevice version are you using?

    Edit 13.08.2015.

    I just has a look at my_app_last.rar

    Firstly I recommend you to use the error codes in the SDK and SoftDevice, for example instead of

    pstorage_clear(&flash_block_0_handle,60);
    

    do

    uint32_t err_code;
    err_code = pstorage_clear(&flash_block_0_handle,60);
    APP_ERROR_CHECK(err_code);
    

    Then you can check the error code using the debugger (if you have turned of optimizations, Target for Options->C/C++->Optimization->Level 0) 0x00000000 is NRF_SUCCESS, if you get something else you can use the error code to give you a pointer to what is wrong. Set a breakpoint on APP_ERROR_CHECK().

    With the above code you will get NRF_ERROR_INVALID_PARAM, and no clear will be performed. This is because the size input must be a multiple of block size. Your block size is 64, so you can use 64 (or 0). Anything else will return an error. This is stated in pstorage.h above pstorage_clear().

    If I set the size to 64 your application seems to be working fine.

  • Great! Then I would appreciate if you could accept my answer. How to do it is explained in the tour.

Reply Children
No Data
Related