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

Flash Storage example with SoftDevice not working in SDK15?

Hello,

I am facing an issue when trying to use the example flash_fstorage_example in SDK15 with the softdevice. According to the documentation, using the reading and write command should give me some predifned strings. However, that is not the case, as you can see what I get in the serial is the following

<info> app: fstorage example started.
<info> app: SoftDevice is present.
<info> app: Initializing nrf_fstorage_sd implementation...
<info> app: ========| flash info |========
<info> app: erase unit:         4096 bytes
<info> app: program unit:       4 bytes
<info> app: ==============================
<info> app: Writing "BADC0FFE" to flash.
<info> app: --> Event received: wrote 4 bytes at address 0x3E000.
<info> app: Done.
<info> app: Enabling the SoftDevice.
<info> app: Writing "DEADBEEF" to flash.
<info> app: --> Event received: wrote 4 bytes at address 0x3E100.
<info> app: Done.
<info> app: Writing "hello world" to flash.
<info> app: --> Event received: wrote 12 bytes at address 0x3F000.
<info> app: Done.
<info> app: Use 'read' to read bytes from the flash.
<info> app: Use 'write' to write bytes to the flash.
<info> app: Use 'erase' to erase flash pages.
<info> app: Use 'flasharea' to print and configure the flash read boundaries.
fstorage example:~$
fstorage example:~$
fstorage example:~$ read -h
read - read bytes from flash
       usage: read hex|str addr len
Options:
  -h, --help  :Show command help.
Subcommands:
  hex  :read bytes from flash in HEX format
        usage: read hex addr len
        - addr: the address to read from, in HEX
        - len: number of bytes to read
  str  :read bytes from flash in ASCII format
        usage: read str addr len
        - addr: the address to read from, in HEX
        - len: number of bytes to read
fstorage example:~$ read str 0x3e000 4
j
fstorage example:~$ read str 0x3e100 4
 ▒▒
fstorage example:~$ read str 0x3f000 12
@ad a ge`dd

Thus, I don't get the expected strings BADC0FFE, DEADBEEF or hello world , I have checked the memory for those values after writting and that entries are not there either...

What is happening? Is the softDevice blocking the writting?

Kind regards

Parents
  • Hi,

    BADC0FFE and DEADBEEF are not strings, they are HEX values. Please try reading using 'read hex' command instead:

    fstorage example:~$ read str 0x3e000 4
    ▒ܺ
    fstorage example:~$ read str 0x3e100 4
    ᆳ▒
    
    fstorage example:~$ read hex 0x3e100 4
    0xEF 0xBE 0xAD 0xDE
    fstorage example:~$ read hex 0x3e000 4
    0xFE 0xF 0xDC 0xBA
    
    fstorage example:~$ read hex 0x3F000 12
    0x68 0x65 0x6C 0x6C 0x6F 0x20 0x77 0x6F 0x72 0x6C 0x64 0x0
    fstorage example:~$ read str 0x3F000 12
    hello world

    I'm not sure what happened to your reading of the string "hello world". Please try to erase the board ('nrfjprog -e' command will rease all flash) and flash the example once more. You can check the content of the memory using nrfjprog:

    > nrfjprog --memrd 0x3e000 --w 32 
    0x0003E000: BADC0FFE |....| 
    
    > nrfjprog --memrd 0x3e100 --w 32 
    0x0003E100: DEADBEEF |....| 
    
    > nrfjprog --memrd 0x3f000 --w 8 --n 12 
    0x0003F000: 68 65 6C 6C 6F 20 77 6F 72 6C 64 00 |hello world.|

    Best regards,
    Jørgen

  • I think I have found the issue, it lies on the fact that the start address and the end address where I can write data into where wrong in the example. In that there was application data already present there, chaning those addresses along with those defined in the writting to adjust to the newer memory addresses solved the problem

    My solution

    NRF_FSTORAGE_DEF(nrf_fstorage_t fstorage) =
    {
        /* Set a handler for fstorage events. */
        .evt_handler = fstorage_evt_handler,
    
        /* These below are the boundaries of the flash space assigned to this instance of fstorage.
         * You must set these manually, even at runtime, before nrf_fstorage_init() is called.
         * The function nrf5_flash_end_addr_get() can be used to retrieve the last address on the
         * last page of flash available to write data. */
        .start_addr = 0x4e000,
        .end_addr   = 0x4ffff,
    };

    Example

    NRF_FSTORAGE_DEF(nrf_fstorage_t fstorage) =
    {
        /* Set a handler for fstorage events. */
        .evt_handler = fstorage_evt_handler,
    
        /* These below are the boundaries of the flash space assigned to this instance of fstorage.
         * You must set these manually, even at runtime, before nrf_fstorage_init() is called.
         * The function nrf5_flash_end_addr_get() can be used to retrieve the last address on the
         * last page of flash available to write data. */
        .start_addr = 0x3e000,
        .end_addr   = 0x3ffff,
    };
    

Reply
  • I think I have found the issue, it lies on the fact that the start address and the end address where I can write data into where wrong in the example. In that there was application data already present there, chaning those addresses along with those defined in the writting to adjust to the newer memory addresses solved the problem

    My solution

    NRF_FSTORAGE_DEF(nrf_fstorage_t fstorage) =
    {
        /* Set a handler for fstorage events. */
        .evt_handler = fstorage_evt_handler,
    
        /* These below are the boundaries of the flash space assigned to this instance of fstorage.
         * You must set these manually, even at runtime, before nrf_fstorage_init() is called.
         * The function nrf5_flash_end_addr_get() can be used to retrieve the last address on the
         * last page of flash available to write data. */
        .start_addr = 0x4e000,
        .end_addr   = 0x4ffff,
    };

    Example

    NRF_FSTORAGE_DEF(nrf_fstorage_t fstorage) =
    {
        /* Set a handler for fstorage events. */
        .evt_handler = fstorage_evt_handler,
    
        /* These below are the boundaries of the flash space assigned to this instance of fstorage.
         * You must set these manually, even at runtime, before nrf_fstorage_init() is called.
         * The function nrf5_flash_end_addr_get() can be used to retrieve the last address on the
         * last page of flash available to write data. */
        .start_addr = 0x3e000,
        .end_addr   = 0x3ffff,
    };
    

Children
No Data
Related