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

sd_flash_write halts

Hi,

On SDK12.3 when using sd_flash_write at any memory location causes the device to halt and restart.
On SDK11 I've been using flash_word_write and flash_page_erase using the NRF_NVMC registers, and it worked flawlessly.
But I can't seem to figure out what is the issue with SDK12.3.
I've read that using NRF_NVMC with the softdevice is not allowed.
I've been writing to NRF_FICR->CODEPAGESIZE * (NRF_FICR->CODESIZE - 1) previously and that always worked.
But is there a way to reserve a page of flash to which I can store my custom data structure and modify it in the firmware without using fds?
I've tried making a const char array of a size and then writing to its pointer, but that didn't work. If I know my application code is less than 32k, can't I just write anything after the 32k mark?
I also have a softdevice and bootloader.

Edit:
I'm currently using SDK12.3 and I can't migrate it to a newer version, but the question applies for newer SDK too.

Parents
  • Hello,

    It is correct as says, the NRF_NVMC is only available when the softdevice isn't enabled.

    However, it should be possible to use sd_flash_write() (and all other functions starting with sd_...().

    The description halt and restart sounds like the error handler. You probably get an return from one of your calls (possible sd_flash_write()) which returns an err_code != 0, which is passed into an APP_ERROR_CHECK(err_code);

    Try to define DEBUG in your preprocessor defines, and set a breakpoint on line 76 in app_error.c. Add error_info to watch, and see where the error comes from. What is the .err_code, and what is the function call that returned the err_code which was passed into APP_ERROR_CHECK(err_code) on line .line_num in file .p_file_name ?

    Best regards,

    Edvin

  • I'm trying out fstorage and it seems to work, but I'm having a problem I had a long time ago, and I don't remember what was the fix.
    When using fstorage I can read the data properly, but when it comes to erasing and writing it it gets weird.
    I either can have it erase, or have it write data. Both functions don't work at the same time. Sometimes it will only erase, sometimes only write. I trigger the functions by hand.
    I am also using the address 0x00040000 for testing which I found to be unused.

  • What function calls return the return values that you list? FS_ERR_INVALID_ADDR and FS_ERR_QUEUE_FULL?

    Is it possible for me to reproduce your issue? Do you have a project that you can zip and send?

    Best regards,

    Edvin

  • Ah, the queue problem was due to not calling void fs_sys_event_handler(uint32_t sys_evt), now it works, but only in the area the DFU is supposed to go. How to I make it write in the application address range?

  • What function do you use to write to the area that isn't working?

    What functions returns FS_ERR_ONVALID_ADDR and FS_ERR_QUEUE_FULL?

  • I have:
    fsdata[0]=123;
    retco(fs_store(&fs_config, (uint32_t*)MEM_ADDR, fsdata, 1,NULL));
    where retco just prints me out the result.
    I fixed the FS_ERR_QUEUE_FULL problem, but now it only works when MEM_ADDR is 0x007F000 which is exactly where the DFU bootloader is supposed to go. So how do I make it working in the 0x0001F000 - 0x0007D000 range where the application+application data storage is located by the nrf memory map without getting a FS_ERR_INVALID_ADDR  error?

  • Thank you.

    If you look in the fs_store() function, you see that it returns FS_ERR_INVALID_ADDR on line 418 if the above check returns true (line 415-416).

    What does your fs_init() look like. I don't know what project you use. I suspect it is not one of the examples from the SDK.

    Do you use FDS, or only fstorage?

     

    The p_end_addr and p_start_addr are defined in the first input of fs_store(). Try to set a breakpoint on line 515 in fstorage.c to see which one that is outside the limits.

    Best regards,

    Edvin

Reply
  • Thank you.

    If you look in the fs_store() function, you see that it returns FS_ERR_INVALID_ADDR on line 418 if the above check returns true (line 415-416).

    What does your fs_init() look like. I don't know what project you use. I suspect it is not one of the examples from the SDK.

    Do you use FDS, or only fstorage?

     

    The p_end_addr and p_start_addr are defined in the first input of fs_store(). Try to set a breakpoint on line 515 in fstorage.c to see which one that is outside the limits.

    Best regards,

    Edvin

Children
Related