Document API IEC60730 Library
Classes | Macros | Functions | Variables
Variable Memory Check

Verifies RAM is working correctly. More...

Classes

struct  sl_iec60730_vmc_test_region_t
 This structure is used as configuration for VMC testing. More...
 
struct  sl_iec60730_vmc_test_multiple_regions_t
 This structure is used as multiple test regions for VMC testing. More...
 

Macros

#define BLOCKSIZE   (4)
 
#define RT_BLOCK_OVERLAP   (1)
 
#define RT_BLOCKSIZE   (BLOCKSIZE + (RT_BLOCK_OVERLAP << 1))
 
#define BACKGROUND   ((uint32_t) 0x00000000uL)
 
#define SL_IEC60730_VMC_POST_ENTER_CRITICAL()
 Enter ATOMIC section of VMC Post. More...
 
#define SL_IEC60730_VMC_POST_EXIT_CRITICAL()   CORE_EXIT_CRITICAL()
 Exit ATOMIC section of VMC Post.
 
#define SL_IEC60730_VMC_BIST_ENTER_CRITICAL()
 Enter ATOMIC section of VMC Bist. More...
 
#define SL_IEC60730_VMC_BIST_EXIT_CRITICAL()   CORE_EXIT_CRITICAL()
 Exit ATOMIC section of VMC Bist.
 
#define STACK_CHECK   ((uint32_t *) (&stack_check))
 
#define RAM_START   ((uint32_t *) (&ram_start))
 RAM starting address.
 
#define RAM_END   ((uint32_t *) ((uint32_t) RAM_BACKUP - 1))
 RAM ending address.
 
#define RAM_BACKUP   ((uint32_t *) (&__StackTop))
 RAM backup address.
 
#define CLASSB_START   ((uint32_t *) (&classb_start))
 ClassbRAM starting address.
 
#define CLASSB_END   ((uint32_t *) ((uint32_t) (&class_b_limit) - 1))
 ClassbRAM ending address.
 
#define RAMTEST_START   CLASSB_START
 Example RAM starting address test.
 
#define RAMTEST_END   CLASSB_END
 Example RAM ending address test.
 
#define SL_IEC60730_USE_MARCHX_ENABLE   1
 Enable used the algorithm used in BIST is March-X.
 
#define SL_IEC60730_VAR_BLOCKS_PER_BIST   256
 Number of ram blocks tested per BIST.
 
#define SL_STACK_OVERFLOW_CONST_GUARD_VALUE_0   (0xEEEEEEEEuL)
 Pattern 0 is used for stack overflow.
 
#define SL_STACK_OVERFLOW_CONST_GUARD_VALUE_1   (0xCCCCCCCCuL)
 Pattern 1 is used for stack overflow.
 
#define SL_STACK_OVERFLOW_CONST_GUARD_VALUE_2   (0xBBBBBBBBuL)
 Pattern 2 is used for stack overflow.
 
#define SL_STACK_OVERFLOW_CONST_GUARD_VALUE_3   (0xDDDDDDDDuL)
 Pattern 3 is used for stack overflow.
 

Functions

void sl_iec60730_vmc_init (sl_iec60730_vmc_test_multiple_regions_t *test_config)
 
sl_iec60730_test_result_t sl_iec60730_vmc_post (void)
 
sl_iec60730_test_result_t sl_iec60730_vmc_bist (void)
 
bool sl_iec60730_vmc_pre_run_marchxc_step (uint32_t *addr, uint32_t size)
 This function is called before performing the RAM check. Depending on the RAM region will be checked to give reasonable actions. More...
 
void sl_iec60730_vmc_post_run_marchxc_step (uint32_t *addr, uint32_t size)
 After testing the RAM, you can restore the previous work. More...
 

Variables

uint32_t classb_start
 
uint32_t classb_end
 
uint32_t __StackTop
 
uint32_t ram_start
 
uint32_t class_b_limit
 
uint32_t stack_check
 

Detailed Description

Verifies RAM is working correctly.

Hardware Architecture

Depending on using the definitation, the testing process takes place through different steps and different region RAM memory.

Failure Risks

There are several potential sources of failure in the variable memory hardware

The variable memory check can detect the first three types of errors using the March-X algorithm. The VMC is based on a word-oriented March-X algorithm from http://www.ece.uc.edu/~wjone/Memory.pdf.

SEU failures are not detected in a class B control, and would require class C level of validation to detect - data duplication, error- detecting-and-correcting memory, etc. A failure of this type will be detected once it causes a secondary failure such as missing a watchdog restart or incorrect clock frequency.

Software Architecture

As show in Software Architecture, there are 3 test processes happen. In the case POST testing, the algorithm used is March-C. In the BIST testing, the algorithm used is March-X by default. If user DOES NOT use the SL_IEC60730_USE_MARCHX_ENABLE definition, the algorithm used is March-C. March-X algorithm is faster than March-C because March-X algorithm is only March-C algorithm that omits some steps (Step 3, 4). The March-C algorithm (van de Goor,1991) is described as below steps

Some detail about implementing of Variable Memory Check (VMC) and used variables. These variables are also used in the test cases (TC) of the VMC module.

To make sure the VMC module as well as the IMC module work properly, it is necessary to ensure the location of the ram area for these modules. The sections SHOULD be placed in the correct order: (*.rt_buf*) -> (*.overlap*). DO NOT change this order. Please refer to our example linker for more details.

User need declare a variable of struct sl_iec60730_vmc_test_region_t. In the initialization step, we need to assign the start address and end address to this variable for executing the VMC. For example, we will call the starting address RAMTEST_START and the ending address RAMTEST_END to make it easier to describe later.

Before performing the RAM test, we provide a callback function named sl_iec60730_vmc_pre_run_marchxc_step. After performing the RAM test, we also provide a callback function named sl_iec60730_vmc_post_run_marchxc_step, and the user decides what to do after the RAM test is over.

As mentioned about SL_IEC60730_BOARD_HEADER in Invariable Memory Check module, the definition SL_IEC60730_BOARD_HEADER also has the necessary information for VMC module to run. The RAMTEST_START and RAMTEST_END definitions are used to assigned to start, and end member of a variable of type sl_iec60730_vmc_test_region_t. Two definitions are optional because the user can directly assign values to the start and end member of a variable as long as these values satisfy the conditions describled of the RAMTEST_START, and RAMTEST_END definitions. The BACKGROUND, BLOCKSIZE, RT_BLOCK_OVERLAP, and RT_BLOCKSIZE SHOULD use our default definitions.

Currently we also support stack test to check for stack overflow using pattern (here is an array with 4 elements) placed at the bottom of the stack. You can refer to the (*.stack_bottom*) section in our linker example. The initialization values of this array are initialized when calling the function sl_iec60730_vmc_init. Every time when executing sl_iec60730_vmc_bist will check the value of this array and based on the check results will return SL_IEC60730_TEST_FAILED nor not.

sl_iec60730_vmc_post()

Figure 1 Flow chart of Variable Memory Check POST

sl_iec60730_vmc_bist()

Figure 2 Flow chart of Variable Memory Check BIST

Figure 3 shows two examples of RAM configurations. The figure on the left can be found in our examples. The figure on the right is a possible scenario. We will analyze these cases as below.

Figure 3 Example of RAM memory configuration

With the figure on the left, as mentioned above (*.rt_buf*) and (*.overlap*) are placed in fixed order, namely Ram Backup and Overlap as shown in the Figure. The RAMTEST_START can start the next Overlap. This figure also describes the algorithm of testing. The RAM area under test is defined starting from RAMTEST_START to RAMTEST_END, and split into multiple BLOCKs. Each block has a size determined by BLOCKSIZE. In the first test step, the BLOCK (1) and Overlap are tested. The Ram Backup is used to back up the data in the BLOCK being tested, and will restore it after the test in BLOCKs competletey. In the second test step, BLOCK (2) is tested and a part of BLOCK (1) is also tested. There is an area in BLOCK (1), also called overlap, which will be tested twice. This makes the test even more secure. Continue like this until the test reaches BLOCK (N), the last block, then return to test the Ram Backup.

The image on the right is slightly different when, the tested area (from RAMTEST_START to RAMTEST_END) contains Ram Backup and Overlap. In order to ensure the algorithm works properly, in the case like the figure on the right at the starting position (RAMTEST_START) it is necessary to create an overlap area. As mentioned above this overlap is also tested so user DOES NOT need to worry. Next, the test process is the same as said, will test the BLOCKs (from BLOCK (1) to BLOCK (N)). Here is a point to note when testing to Ram Backup, it will be ignored because this Ram Backup WILL be tested after the test of the last block (BLOCK (N)).

In case the tested area has the address of RAMTEST_START smaller than the address of Ram Backup, the test process is similar to the figure on the right.

Macro Definition Documentation

◆ BACKGROUND

#define BACKGROUND   ((uint32_t) 0x00000000uL)

The BACKGROUND definition is background used to testing. In our sample, value 0x00000000uL is used value for background. Of course, we can define another value. We recommend using definition like ours (0x00000000uL) because it accurately describes the steps of the March-X/March-C algorithm described above.

◆ BLOCKSIZE

#define BLOCKSIZE   (4)

The BLOCKSIZE definition MUST be 4 as our example for the algorithm to work properly.

◆ RT_BLOCK_OVERLAP

#define RT_BLOCK_OVERLAP   (1)

The RT_BLOCK_OVERLAP definition is used to present the size of #iec60730_ram_test_overlap buffer. The variable #iec60730_ram_test_overlap has a size of (2 * RT_BLOCK_OVERLAP). For the algorithm (March-X/March-C) to work properly this definition MUST take the value 1 as in our example.

◆ RT_BLOCKSIZE

#define RT_BLOCKSIZE   (BLOCKSIZE + (RT_BLOCK_OVERLAP << 1))

The definition of RT_BLOCKSIZE is taken from the definition of BLOCKSIZE and RT_BLOCK_OVERLAP.

◆ SL_IEC60730_VMC_BIST_ENTER_CRITICAL

#define SL_IEC60730_VMC_BIST_ENTER_CRITICAL ( )
Value:
CORE_DECLARE_IRQ_STATE; \
CORE_ENTER_CRITICAL()

Enter ATOMIC section of VMC Bist.

◆ SL_IEC60730_VMC_POST_ENTER_CRITICAL

#define SL_IEC60730_VMC_POST_ENTER_CRITICAL ( )
Value:
CORE_DECLARE_IRQ_STATE; \
CORE_ENTER_CRITICAL()

Enter ATOMIC section of VMC Post.

Function Documentation

◆ sl_iec60730_vmc_bist()

sl_iec60730_test_result_t sl_iec60730_vmc_bist ( void  )

public IEC60730 Variable Memory Check (VMC) BIST

Parameters
paramsinput parameter of struct sl_iec60730_vmc_test_region_t form
Returns
sl_iec60730_test_result_t.

Performs a variable memory check in defined area. For details how sl_iec60730_vmc_bist work, please refer to Software Architecture

Requires sl_iec60730_vmc_init to be called first to setup global variables.

◆ sl_iec60730_vmc_init()

void sl_iec60730_vmc_init ( sl_iec60730_vmc_test_multiple_regions_t test_config)

public IEC60730 Variable Memory Check (VMC) Initialize

Parameters
paramsinput parameter of struct sl_iec60730_vmc_test_multiple_regions_t form
Returns
void

Performs a initialization of global variables. This function SHOULD call before calling sl_iec60730_vmc_post()

◆ sl_iec60730_vmc_post()

sl_iec60730_test_result_t sl_iec60730_vmc_post ( void  )

public IEC60730 Variable Memory Check (VMC) POST

Parameters
paramsinput parameter of struct sl_iec60730_vmc_test_region_t form
Returns
sl_iec60730_test_result_t.

Performs a variable memory check in defined area. For details how sl_iec60730_vmc_post work, please refer to Software Architecture

◆ sl_iec60730_vmc_post_run_marchxc_step()

void sl_iec60730_vmc_post_run_marchxc_step ( uint32_t *  addr,
uint32_t  size 
)

After testing the RAM, you can restore the previous work.

Parameters
addrThe starting address of the ram under test
sizeThe size of the ram area to be tested. This parameter
Returns
void

◆ sl_iec60730_vmc_pre_run_marchxc_step()

bool sl_iec60730_vmc_pre_run_marchxc_step ( uint32_t *  addr,
uint32_t  size 
)

This function is called before performing the RAM check. Depending on the RAM region will be checked to give reasonable actions.

Parameters
addrThe starting address of the ram under test
sizeThe size of the ram area to be tested. This parameter is BLOCKSIZE
Returns
bool
  • true - allow running RAM test
  • false - not allow