MCRC
MCRC module is used to perform CRC (Cyclic Redundancy check) to verify integrity of a memory system. The MCRC controller is used to calculate the signature for a set of data and then compare the calculated signature value against a predetermined good signature value. MCRC controller provides four channels to perform CRC calculation on multiple memories.
Features Supported
Each MCRC instance supports 4 channels. Each channel can be configured to operate in one of 3 modes
Auto Mode: In this mode, the MCRC controller, in conjunction with DMA controller, can perform CRC totally without CPU intervention.
Full Mode: In this mode, the CPU does the data patterns transfer and signature verification all by itself. CPU performs data patterns transfer by reading data from the memory system to the PSA signature register.
Semi Mode: In this mode, DMA controller is used to perform data patterns transfer and signature verification.
Timeout is configured to generate timeout interrupt to ensure that the memory system is examined with predefined time frame and no loss of incoming data. A 24-bit counter per CRC channel is configured.
The module supports below API’s for the application
API to support and configure Full, Semi, and Auto MCRC mode
API to support readback of static registers
API to support readback of written configuration
API to support interrupt configuration
SysConfig Features
None
Features NOT Supported
No DMA mode examples for M4
Important Usage Guidelines
None
Profiling Data
| MCRC Mode | Data Size | Profiling Time |
|---|---|---|
| AUTO | 256 KB | 2118 us |
| 128 KB | 1069 us | |
| 1 KB | 29 us | |
| Semi-CPU | 256 KB | 2117 us |
| 128 KB | 1068 us | |
| 1 KB | 28 us | |
| Full-CPU | 256 KB | 1733 us |
| 128 KB | 876 us | |
| 1 KB | 8 us |
Note
The above numbers were obtained in the mcu-r5fss0-0_nortos setting
Example Usage
The following shows an example of SDL MCRC API usage by the application for Full CPU mode.
Include the below file to access the APIs
#include <sdl/sdl_mcrc.h>
Initialize an MCRC instance and channel
SDL_MCRC_InstType instance = MCU_MCRC64_0;
result = SDL_MCRC_init(instance, SDL_MCRC_CHANNEL_1, MCRC_DEF_WATCHDOG_PRELOAD, MCRC_DEF_BLOCK_PRELOAD);
Reset and configure the MCRC channel
result = SDL_MCRC_channelReset(instance, SDL_MCRC_CHANNEL_1);
SDL_MCRC_config(instance, SDL_MCRC_CHANNEL_1, MCRC_DEF_PATTERN_COUNT, MCRC_DEF_SECTOR_COUNT, SDL_MCRC_OPERATION_MODE_FULLCPU);
Verify the configuration
result = SDL_MCRC_verifyConfig(instance, SDL_MCRC_CHANNEL_1, MCRC_DEF_PATTERN_COUNT, MCRC_DEF_SECTOR_COUNT, SDL_MCRC_OPERATION_MODE_FULLCPU);
if (result == SDL_PASS)
{
DebugP_log("\n Configurationn verified");
}
Compute the signature
SDL_MCRC_dataConfig_t mcrcData;
SDL_MCRC_Signature_t sectSignVal;
mcrcData.pMCRCData = (uint32_t *)testParams[testCase].sourceMemory;
mcrcData.size = testParams[testCase].dataSize;
mcrcData.dataBitSize = SDL_MCRC_DATA_32_BIT;
/* Pass the data to MCRC and get the signature */
result = SDL_MCRC_computeSignCPUmode(instance, SDL_MCRC_CHANNEL_1, &mcrcData, §SignVal);
Check the calculated signature
/*
* Check if the generated MCRC signature value
* matches with the reference signaure vaule
*/
if ((sectSignVal.regH == testParams[testCase].mcrcSignHigh) &&
(sectSignVal.regL == testParams[testCase].mcrcSignLow))
{
result = SDL_PASS;
}
else {
result = SDL_EFAIL;
}
API Reference
This file contains the prototypes of the APIs present in the device abstraction layer file of MCRC. This also contains some related macros.
MCRC Operation Mode
-
SDL_MCRC_OPERATION_MODE_DATA
Configure MCRC operation mode to Data Captures
-
SDL_MCRC_OPERATION_MODE_AUTO
Configure MCRC operation mode to Auto
-
SDL_MCRC_OPERATION_MODE_SEMICPU
Configure MCRC operation mode to Semi-CPU
-
SDL_MCRC_OPERATION_MODE_FULLCPU
Configure MCRC operation mode to Full-CPU
-
typedef uint32_t SDL_MCRC_ModeType
MCRC operation mode supported. MCRC can either operate in Semi-CPU, Full-CPU or Auto mode.
MCRC channel
-
SDL_MCRC_CHANNEL_1
Select channel 1 for operation
-
SDL_MCRC_CHANNEL_2
Select channel 2 for operation
-
SDL_MCRC_CHANNEL_3
Select channel 3 for operation
-
SDL_MCRC_CHANNEL_4
Select channel 4 for operation
-
typedef uint32_t SDL_MCRC_Channel_t
MCRC channel supported.
Defines
-
SDL_MCRC_CHANNEL_IRQSTATUS_RAW_MAIN_ALL
Macro defines mask for all the interrupts for a channel.
-
SDL_MCRC_PATTERN_COUNT_MAX
Macro defines maximum value of MCRC Pattern Count.
-
SDL_MCRC_SECTOR_COUNT_MAX
Macro defines maximum value of MCRC Sector Count.
-
SDL_MCRC_BCTOPLD_MAX
Macro defines maximum value of MCRC Block Complete Timeout Counter Preload.
-
SDL_MCRC_WDTOPLD_MAX
Macro defines maximum value of MCRC Watchdog Timeout Counter Preload.
-
SDL_MCRC_MAX_NUM_OF_CHANNELS
Max number of channels supported in MCRC.
Enums
Functions
-
int32_t SDL_MCRC_init(SDL_MCRC_InstType instance, SDL_MCRC_Channel_t channel, uint32_t watchdogPreload, uint32_t blockPreload)
Initialize MCRC channel and will configure watchdog and block preload value for given channel.
- Parameters:
instance – MCRC instance either MCU or Main.
channel – Channel number to be initializaed. Values given by SDL_MCRC_Channel_t.
watchdogPreload – It is used to check if DMA does supply a block of data responding to a request in a given time frame.
blockPreload – It is used to check if MCRC for an entire block is completed in a given time frame.
- Returns:
status MCRC channel initialization status. SDL_PASS: success SDL_EBADARGS: failure, indicate the bad input arguments
-
int32_t SDL_MCRC_verifyInit(SDL_MCRC_InstType instance, SDL_MCRC_Channel_t channel, uint32_t watchdogPreload, uint32_t blockPreload)
Verify the MCRC watchdog and block preload value initialized for given channel.
- Parameters:
instance – MCRC instance either MCU or Main.
channel – Channel number to be verified initialization. Values given by SDL_MCRC_Channel_t.
watchdogPreload – It is used to check if DMA does supply a block of data responding to a request in a given time frame.
blockPreload – It is used to check if MCRC for an entire block is completed in a given time frame.
- Returns:
status MCRC channel verfiy initialization status. SDL_PASS: success SDL_EBADARGS: failure, indicate the bad input arguments SDL_EFAIL: failure, indicate verify initialization failed
-
int32_t SDL_MCRC_config(SDL_MCRC_InstType instance, SDL_MCRC_Channel_t channel, uint32_t patternCount, uint32_t sectorCount, SDL_MCRC_ModeType mode)
This API will configure MCRC mode, pattern and sector count for given channel.
- Parameters:
instance – MCRC instance either MCU or Main.
channel – Channel number to be configured. Values given by SDL_MCRC_Channel_t.
patternCount – Number of data patterns in one sector to be compressed.
sectorCount – Number of sectors in a block of memory.
mode – MCRC operational mode. Refer SDL_MCRC_ModeType.
- Returns:
status MCRC channel configuration status SDL_PASS: success SDL_EBADARGS: failure, indicate the bad input arguments
-
int32_t SDL_MCRC_verifyConfig(SDL_MCRC_InstType instance, SDL_MCRC_Channel_t channel, uint32_t patternCount, uint32_t sectorCount, SDL_MCRC_ModeType mode)
This API will verify the configure of MCRC mode, pattern and sector count for given channel.
- Parameters:
instance – MCRC instance either MCU or Main.
channel – Channel number to be verified configuration. Values given by SDL_MCRC_Channel_t.
patternCount – Number of data patterns in one sector to be compressed.
sectorCount – Number of sectors in a block of memory.
mode – MCRC operational mode. Refer SDL_MCRC_ModeType.
- Returns:
status MCRC channel configuration status SDL_PASS: success SDL_EBADARGS: failure, indicate the bad input arguments SDL_EFAIL: failure, indicate verify configure failed
-
int32_t SDL_MCRC_channelReset(SDL_MCRC_InstType instance, SDL_MCRC_Channel_t channel)
This API is used to reset the MCRC channel.
- Parameters:
instance – MCRC instance either MCU or Main.
channel – Channel number for which reset is to be done. Values given by SDL_MCRC_Channel_t.
- Returns:
status MCRC channel reset status SDL_PASS: success SDL_EBADARGS: failure, indicate the bad input arguments
-
int32_t SDL_MCRC_setPSASeedSig(SDL_MCRC_InstType instance, SDL_MCRC_Channel_t channel, const SDL_MCRC_Signature_t *pSeedSign)
This API is used to set the PSA seed value without compression for given Channel.
- Parameters:
instance – MCRC instance either MCU or Main.
channel – Channel number for which PSA seed value to be set. Values given by SDL_MCRC_Channel_t.
pSeedSign – Pointer to MCRC PSA seed signature values. Refer struct SDL_MCRC_Signature_t for details.
- Returns:
status MCRC channel set PSA seed value status SDL_PASS: success SDL_EBADARGS: failure, indicate the bad input arguments
-
int32_t SDL_MCRC_getPSASectorSig(SDL_MCRC_InstType instance, SDL_MCRC_Channel_t channel, SDL_MCRC_Signature_t *pSecSign)
This API is used to get sector signature Value/ MCRC value for given channel.
- Parameters:
instance – MCRC instance either MCU or Main.
channel – Channel number which was configured for MCRC calculation. Values given by SDL_MCRC_Channel_t.
pSecSign – Pointer to MCRC PSA sector signature values Refer struct SDL_MCRC_Signature_t.
- Returns:
status MCRC channel get PSA sector signaure value status SDL_PASS: success SDL_EBADARGS: failure, indicate the bad input arguments
-
int32_t SDL_MCRC_getIntrStatus(SDL_MCRC_InstType instance, SDL_MCRC_Channel_t channel, uint32_t *pIntrStatus)
This API is used to get the pending interrupts for given Channel.
- Parameters:
instance – MCRC instance either MCU or Main.
channel – Channel number for which pending interrupt is to get. Values given by SDL_MCRC_Channel_t.
pIntrStatus – Pointer to pending interrupt status/occurred.
- Returns:
status MCRC get pending interrupts status SDL_PASS: success SDL_EBADARGS: failure, indicate the bad input arguments
-
int32_t SDL_MCRC_enableIntr(SDL_MCRC_InstType instance, SDL_MCRC_Channel_t channel, uint32_t intrMask)
This API is used to enable interrupts for given Channel.
- Parameters:
instance – MCRC instance either MCU or Main.
channel – Channel number for which interrupt is to enable. Values given by SDL_MCRC_Channel_t.
intrMask – Interrupts to enable.
- Returns:
status MCRC enable interrupts status SDL_PASS: success SDL_EBADARGS: failure, indicate the bad input arguments
-
int32_t SDL_MCRC_disableIntr(SDL_MCRC_InstType instance, SDL_MCRC_Channel_t channel, uint32_t intrMask)
This API is used to disable interrupts for given Channel.
- Parameters:
instance – MCRC instance either MCU or Main.
channel – Channel number for which interrupt is to disable. Values given by SDL_MCRC_Channel_t.
intrMask – Interrupts to disable.
- Returns:
status MCRC disable interrupts status SDL_PASS: success SDL_EBADARGS: failure, indicate the bad input arguments
-
int32_t SDL_MCRC_clearIntr(SDL_MCRC_InstType instance, SDL_MCRC_Channel_t channel, uint32_t intrMask)
This API is used to clear interrupts for given Channel.
- Parameters:
instance – MCRC instance either MCU or Main.
channel – Channel number for which interrupt is to clear. Values given by SDL_MCRC_Channel_t.
intrMask – Interrupts to clear status.
- Returns:
status MCRC clear interrupts status SDL_PASS: success SDL_EBADARGS: failure, indicate the bad input arguments
-
int32_t SDL_MCRC_isBusy(SDL_MCRC_InstType instance, SDL_MCRC_Channel_t channel, uint32_t *pBusyFlag)
This API is used to check if MCRC is busy for given Channel.
During Auto or Semi-CPU mode, the busy flag is set when the first data pattern of the block is compressed and remains set until the the last data pattern of the block is compressed. The flag is cleared when the last data pattern of the block is compressed.
- Parameters:
instance – MCRC instance either MCU or Main.
channel – Channel number for which busy status is to get. Values given by SDL_MCRC_Channel_t.
pBusyFlag – Pointer to busy flag. 1U: MCRC channel is busy. 0U: MCRC channel is free.
- Returns:
status MCRC channel check busy status SDL_PASS: success SDL_EBADARGS: failure, indicate the bad input arguments
-
int32_t SDL_MCRC_getCurSecNum(SDL_MCRC_InstType instance, SDL_MCRC_Channel_t channel, uint32_t *pCurSecNum)
This API is used to get the current sector number of which the signature verification fails in AUTO mode for given channel.
When a sector fails, the erroneous sector number is logged and the MCRC fail interrupt is generated.
- Parameters:
instance – MCRC instance either MCU or Main.
channel – Channel number for which the curent sector number is to get. Values given by SDL_MCRC_Channel_t.
pCurSecNum – Pointer to current sector number.
- Returns:
status MCRC channel get current sector number status SDL_PASS: success SDL_EBADARGS: failure, indicate the bad input arguments
-
int32_t SDL_MCRC_getPSASig(SDL_MCRC_InstType instance, SDL_MCRC_Channel_t channel, SDL_MCRC_Signature_t *pPSAsig)
This API is used to get current known good signature value/ MCRC value for given channel.
- Parameters:
instance – MCRC instance either MCU or Main.
channel – Channel number for which current MCRC value is to get. Values given by SDL_MCRC_Channel_t.
pPSAsig – Pointer to current MCRC PSA signature values Refer struct SDL_MCRC_Signature_t.
- Returns:
status MCRC channel get current PSA signaure value status SDL_PASS: success SDL_EBADARGS: failure, indicate the bad input arguments
-
int32_t SDL_MCRC_readStaticReg(SDL_MCRC_InstType instance, SDL_MCRC_StaticRegs_t *pStaticRegs)
This API is used to read static registers of MCRC module. This API needs to be called after the initial configuration is done and hence mutliple read between static registers do not change the values.
- Parameters:
instance – MCRC instance either MCU or Main.
pStaticRegs – pointer to static registers to be read
- Returns:
SDL_PASS - success
SDL_EBADARGS - API fails due to bad input arguments
-
int32_t SDL_MCRC_getCurPSASig(SDL_MCRC_InstType instance, SDL_MCRC_Channel_t channel, SDL_MCRC_Signature_t *pCurPSASig)
This API is used to get current known good signature value/ MCRC value for given channel.
- Parameters:
instance – MCRC instance either MCU or Main.
channel – Channel number for which current MCRC value is to get. Values given by SDL_MCRC_Channel_t.
pCurPSASig – Pointer to current MCRC PSA signature values Refer struct SDL_MCRC_Signature_t.
- Returns:
status MCRC channel get current PSA signaure value status SDL_PASS: success SDL_EBADARGS: failure, indicate the bad input arguments
-
int32_t SDL_MCRC_getPSASigRegAddr(SDL_MCRC_InstType instance, SDL_MCRC_Channel_t channel, SDL_MCRC_SignatureRegAddr_t *pMCRCregAddr)
This API is used to get the PSA register address for given Channel.
- Parameters:
instance – MCRC instance either MCU or Main.
channel – Channel number for which PSA register address is to get. Values given by SDL_MCRC_Channel_t.
pMCRCregAddr – Pointer to MCRC PSA register address structure. Refer structure SDL_MCRC_SignatureRegAddr_t.
- Returns:
status MCRC channel get PSA signature register address status SDL_PASS: success SDL_EBADARGS: failure, indicate the bad input arguments
-
int32_t SDL_MCRC_computeSignCPUmode(SDL_MCRC_InstType instance, SDL_MCRC_Channel_t channel, const SDL_MCRC_DataConfig_t *pDataConfig, SDL_MCRC_Signature_t *sectSignVal)
This API is used to compute the signature for CPU-only mode and it check if the generated MCRC signature value matches with the reference signature value.
- Parameters:
instance – MCRC instance either MCU or Main.
channel – MCRC channel number to be used
pDataConfig – Pointer to data configuration
sectSignVal – Generated sector signature value.
- Returns:
SDL_PASS: Success; SDL_FAIL: Failure; SDL_EBADARGS: Bad arguments error
-
struct SDL_MCRC_Signature_t
- #include <sdl_mcrc.h>
Structure for accessing MCRC register data which are 64 bit wide.
-
struct SDL_MCRC_SignatureRegAddr_t
- #include <sdl_mcrc.h>
Structure for accessing MCRC registers address which are 64 bit wide.
-
struct SDL_MCRC_ChannelStaticRegs
- #include <sdl_mcrc.h>
MCRC channel static registers list.
-
struct SDL_MCRC_StaticRegs_t
- #include <sdl_mcrc.h>
MCRC static registers list.
Public Members
-
SDL_MCRC_ChannelStaticRegs channelRegs[SDL_MCRC_MAX_NUM_OF_CHANNELS]
Channel Specific Static Registers
-
uint32_t CTRL0
CTRL0 Register
-
uint32_t CTRL1
CTRL1 Register
-
uint32_t BUS_SEL
Data Bus Tracing Select Register
-
SDL_MCRC_ChannelStaticRegs channelRegs[SDL_MCRC_MAX_NUM_OF_CHANNELS]
-
struct SDL_MCRC_DataConfig_t
- #include <sdl_mcrc.h>
Structure for MCRC CPU inputs data.
Public Members
-
uint32_t *pMCRCData
Pointer to Data used for MCRC
-
uint32_t size
Size of Data in Bytes
-
SDL_MCRC_DataBitSize dataBitSize
Data Bit size
-
uint32_t *pMCRCData