Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

[nrf52832] How to update retention memory configuration through DFU?

When the system is working normally, we will transmit logs and other data from the local to the peer through rf communication. 

However, when the system suddenly goes to sleep or restarts due to an abnormal error, the logs will not be transmitted to the peer end in time, and this part of the logs will be lost.

Therefore, we want to save the logs by reserving memory, and transmit this part of the logs to the peer after the system restarts again.

In fact, this part of the function has been implemented and can work normally (use nrfgo through jlink connection). Refer to the following configuration:

devzone.nordicsemi.com/.../152338

But the problem is that if the new reserved memory configuration is upgraded through dfu, it will not take effect, and this part of the memory is still not reserved.

So my question is, how to update retention memory configuration through DFU.

Parents
  • Hi,

    I'll have to consult with a colleague on this Ram retention issue. Meanwhile, have you considered backing up your logs to some flash partition (non-volatile storage) before performing a DFU, and retrieving it afterwards?

    Best regards,

    Raoul

  • Hi,

    Thank you for your reply. I don't know much about it, I just think that flash has a limit on the number of erasing and writing, so I didn't choose this way. In addition, if the power is turned off abnormally during the process of saving logs, will there be problems?

    If there is a solution to save the log in flash, I can try it.

    Thanks.

  • Hi, regarding the RAM retention:

    My colleague tells me that the startup script of the bootloader (which places data to designated places in RAM) is probably overwriting the .noinit section of your application. So according to him, the only thing you have to do is to define the same address range as .noinit in the bootloader, as you did in your application. Then the data won't be initialized to 0 during startup of either the application or the bootloader.

    You can take a look at the generated .map files to verify that the same ranges are defined as .noinit.

    I assume you are using Keil, since you linked to that previous case on RAM retention.

    Best regards,

    Raoul

  • Hi,

    Ok, thank you, yes, I use keil, so back to this question, can I update the memory configuration by using dfu (such as adding a noinit area)?

    In fact, I added a noinit area through the example of the above url link. After compiling the upgrade package, and then using dfu to upgrade, I found that the relevant memory area has not been reserved.

    (I don't know if I am missing the necessary configuration, or if the modification of the memory configuration cannot take effect through the dfu upgrade.)

    In addition, you mentioned saving logs to flash, is there any relevant information? I want to find out if it can meet my needs.

    Thanks.

  • If by "updating the memory configuration" you mean change the .noinit RAM address ranges, then no, I don't think you'll be able to change this over a DFU.

    You have to ensure that the bootloader and the application both agree on what is .noinit RAM, if you want your logs to be preserved. If you only change the .noinit RAM range for the application, the bootloader will still overwrite it. And the bootloader can't be upgraded

    So you will have to first update your bootloader configuration, making sure that the defined noinit range is correct there. Then you must flash this to the device directly, with a debugger.


    Regarding flash data storage, take a look at the Flash Data Storage example if you haven't used it before. I intended to suggest that you could back up your logs from RAM to Flash right before you perform a DFU (but I prefer the noinit RAM method you are looking at currently!). Since DFU's don't happen frequently, I don't think you will have to worry about the "limit on the number of erasing and writing", as you asked earlier.

    In addition, if the power is turned off abnormally during the process of saving logs, will there be problems?

    Yes, you might lose data.

    If it is critical for you to keep your logs, you could also try to log to flash continuously. I found a case on that here, but it's quite old:  Is it possible to continuously log data to flash memory?

    I don't usually work with the nRF5 SDK so my experience is limited. But let me know if you have further questions.

    Best regards,

    Raoul

  • Hi,

    OK, your answer has been detailed and exactly what I needed.

    Thanks a lot.

  • You're welcome, but I have to make a correction! The nRF5 SDK has a Master Boot Record, and it is actually possible to update the bootloader itself through a DFU.

    So,

    can I update the memory configuration by using dfu (such as adding a noinit area)?

    Yes, it should actually be possible. As mentioned before, you would have to update the noinit area of both the bootloader and application, to have matching address ranges.

    Bootloader DFU samples can be found in your installation: nRF5_SDK_17.1.0_ddde560\examples\dfu\secure_dfu_test_images\ble\

    I hope that's useful!

    Best regards,

    Raoul

Reply
  • You're welcome, but I have to make a correction! The nRF5 SDK has a Master Boot Record, and it is actually possible to update the bootloader itself through a DFU.

    So,

    can I update the memory configuration by using dfu (such as adding a noinit area)?

    Yes, it should actually be possible. As mentioned before, you would have to update the noinit area of both the bootloader and application, to have matching address ranges.

    Bootloader DFU samples can be found in your installation: nRF5_SDK_17.1.0_ddde560\examples\dfu\secure_dfu_test_images\ble\

    I hope that's useful!

    Best regards,

    Raoul

Children
Related