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

Testing Flash and RAM

Hello,

I want to run a memory test whenever my device nrf52832 starts up to check for various faults like stuck at, transition and other faults in both flash and RAM. Does the CRC in flash check all the flash blocks including the .txt one or does it only use CRC for reading and writing to the flash? Or is there any other way to check the credibility of the flash and RAM

I read that you can create a checksum of the entire flash. My question is how can I create a checksum for the entire flash region or at least the region where the code and the peer manager is stored? As far as RAM is considered, it looks like I have to do any of the March tests. How do I access the RAM region via software?

Also, last question, suppose I am doing march test. Will doing this in main before initializing the modules affect the global variables assigned?

  • Hello,

    It is not really a typical thing to do this on the nRFs (at least that is my impression). That being said, there is nothing preventing you from doing so.

    If you are going to do this, I would split it into two parts:

    1. CRC check of the application. We do have a bootloader that can do this. Actually, if you plan to use a bootloader at all, I would recommend that you just use the option to check the CRC on every reboot, instead of only when a new image is received, which is the default behavior. What you would to is to set these settings from the bootloader's sdk_config.h to 0:

    #ifndef NRF_BL_APP_CRC_CHECK_SKIPPED_ON_GPREGRET2
    #define NRF_BL_APP_CRC_CHECK_SKIPPED_ON_GPREGRET2 1
    #endif
    
    // <q> NRF_BL_APP_CRC_CHECK_SKIPPED_ON_SYSTEMOFF_RESET  - Skip integrity check of the application when waking up from the System Off state.
     
    
    // <i> Only CRC checks can be skipped. For other boot validation types, the reset state is ignored.
    
    #ifndef NRF_BL_APP_CRC_CHECK_SKIPPED_ON_SYSTEMOFF_RESET
    #define NRF_BL_APP_CRC_CHECK_SKIPPED_ON_SYSTEMOFF_RESET 1
    #endif

    However, if you have not used the bootloader before, I suggest you get that up and running with the default settings before you start to adjust it. 

    If you don't want to do this using the bootloader, I think you should look at how the bootloader checks the CRC of the application, and somehow try to replicate this from your application.

    2: You said that you want to check the CRC of your peer manager. The peer manager uses FDS (Flash Data Storage) to store it's data. The FDS actually has an option to check CRC of the records that are stored, so you would just need to make sure that this is enabled in your application's FDS settings in sdk_config.h. Set:

    FDS_CRC_CHECK_ON_READ to 1

    and alternatively: 

    FDS_CRC_CHECK_ON_WRITE to 1 as well.

    Best regards,

    Edvin

  • Hmm, thanks a lot

    I will look into the bootloader description and check if it's possible. Right now, I dont have a bootloader and we are so close to delivering our project. How long will it take to add a bootloader to the application without any errors and is there any measures I might have to follow in doing the same?

    Second question is how do I access RAM address via software and read and write data to it.

  • So did you plan to have a bootloader before delivering the project? Either way, I think you should read through and follow this guide:

    Getting started with Nordic's Secure Bootloader.

    A couple of hints:

    1: Make sure that you are able to build Makefile projects from the command line (the guide briefly explains how to set it up)

    2: In order to run an application while you have a bootloader programmed, you either have to have transferred the application via DFU, or you need to generate bootloader settings and program it.

    Your initial request is a bit unusual. What will you do in case there is a CRC error in the application flash? What makes you think it will happen? Are you sending it into space (cosmic radiation)? Or is it to prevent someone from injecting faulty software to your chip?

  • Or is it to prevent someone from injecting faulty software to your chip?

    No I am using read back protection for the same.

    As per standards in the compliance, I need to check for codes in flash and RAM.

  • Ok. Either you need to either apply a bootloader, or you need to look at how the bootloader does the CRC calculations. 

    I guess the function crc32_compute() from crc32.c in the SDK could be a way to go in your case. You would of course need to calculate it from outside the application, to know what the crc32_compute() will return, in order to check that it is still the same.

    Best regards,

    Edvin

Related