This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Not able to Write to flash memory during ble Uart data receive

Hi,

I am using nordic 52840 development kit along with sdk17.1

I am tried to use ble-uart example code to receive data from the app and based on the data i need to write it in the flash memory.

But when i m trying to write some data in memory at that time it hit the breakpoint condition and went to system reset.

Just want to know that why i am not able to write data in memory. 

And even if i just put breakpoint inside the the nus_data_handler() then also it reaches to the breakpoint condition and then system reset.

Can someone helps me to understand this issue. how can i resolve this.

Regards

Rohit Saini

  • Hi,

    How do you write the data to flash? It would be helpful if you include the code you used.

    Flash writes will halt the CPU during the write, when application is running from flash. The BLE protocol have hard real-time requirements, which means that the CPU must be available at specific time to handle critical tasks. To prevent issues with the BLE functionality during flash writes, the softdevice owns the NVMC peripheral when it is enabled. You then need to use the softdevice flash API to write data to flash, or erase flash pages. The softdevice can then schedule the operations between BLE events. If you access the NVMC peripheral directly, the softdevice will generate an invalid memory access error and assert, which will put you in the error handler like you are seeing.

    If you need to write/update data in flash often, you may want to look into the fstorage and FDS libraries, which supports a softdevice backend, along with additional features like minimizing flash operations, basic wear-leveling, etc.

    The same thing will happen if you put a breakpoint in the code. Hitting breakpoints will halt the CPU, preventing the softdevice from handling timing-critical events. If you need to debug the application through breakpoints when the softdevice is enabled, you can look into J-Link Monitor Mode Debugging.

    Best regards,
    Jørgen

  • Thanks for your support Jorgen.

    I am able to write in memory in the memory during ble functionality.

    But is there any API to read the flash data also, because i can see flash write and erase API only.

    Regards

    R_S

  • There is no API to read flash. Read operations are very fast and does not require to halt the CPU. You can access flash data in flash directly as shown in flashwrite example, etc.

Related