![]() |
RA Flexible Software Package Documentation
Release v6.0.0
|
|
Functions | |
fsp_err_t | R_MRAM_Open (flash_ctrl_t *const p_api_ctrl, flash_cfg_t const *const p_cfg) |
fsp_err_t | R_MRAM_Write (flash_ctrl_t *const p_api_ctrl, uint32_t const src_address, uint32_t mram_address, uint32_t const num_bytes) |
fsp_err_t | R_MRAM_Erase (flash_ctrl_t *const p_api_ctrl, uint32_t const address, uint32_t const num_blocks) |
fsp_err_t | R_MRAM_BlankCheck (flash_ctrl_t *const p_api_ctrl, uint32_t const address, uint32_t num_bytes, flash_result_t *p_blank_check_result) |
fsp_err_t | R_MRAM_StatusGet (flash_ctrl_t *const p_api_ctrl, flash_status_t *const p_status) |
fsp_err_t | R_MRAM_IdCodeSet (flash_ctrl_t *const p_api_ctrl, uint8_t const *const p_id_code, flash_id_code_mode_t mode) |
fsp_err_t | R_MRAM_AccessWindowSet (flash_ctrl_t *const p_api_ctrl, uint32_t const start_addr, uint32_t const end_addr) |
fsp_err_t | R_MRAM_AccessWindowClear (flash_ctrl_t *const p_api_ctrl) |
fsp_err_t | R_MRAM_Reset (flash_ctrl_t *const p_api_ctrl) |
fsp_err_t | R_MRAM_StartUpAreaSelect (flash_ctrl_t *const p_api_ctrl, flash_startup_area_swap_t swap_type, bool is_temporary) |
fsp_err_t | R_MRAM_BankSwap (flash_ctrl_t *const p_api_ctrl) |
fsp_err_t | R_MRAM_UpdateFlashClockFreq (flash_ctrl_t *const p_api_ctrl) |
fsp_err_t | R_MRAM_InfoGet (flash_ctrl_t *const p_api_ctrl, flash_info_t *const p_info) |
fsp_err_t | R_MRAM_Close (flash_ctrl_t *const p_api_ctrl) |
fsp_err_t | R_MRAM_CallbackSet (flash_ctrl_t *const p_api_ctrl, void(*p_callback)(flash_callback_args_t *), void *const p_context, flash_callback_args_t *const p_callback_memory) |
fsp_err_t | R_MRAM_AntiRollbackCounterIncrement (flash_ctrl_t *const p_api_ctrl, flash_arc_t counter) |
fsp_err_t | R_MRAM_AntiRollbackCounterRefresh (flash_ctrl_t *const p_api_ctrl, flash_arc_t counter) |
fsp_err_t | R_MRAM_AntiRollbackCounterRead (flash_ctrl_t *const p_api_ctrl, flash_arc_t counter, uint32_t *const p_count) |
fsp_err_t | R_MRAM_UserLockableAreaWrite (flash_ctrl_t *const p_api_ctrl, uint32_t const src_address, uint32_t mram_address, uint32_t const num_bytes) |
Driver for the MRAM memory on RA MCUs. This module implements the Flash Interface.
The MRAM HAL module APIs allow an application to write and erase MRAM areas that reside within the MCU. The amount of MRAM memory available varies across MCU parts.
The R_MRAM module has the following key features:
Configuration | Options | Default | Description |
---|---|---|---|
Parameter Checking |
| Default (BSP) | If selected code for parameter checking is included in the build. |
Configuration | Options | Default | Description |
---|---|---|---|
Name | Name must be a valid C symbol | g_mram0 | Module name. |
MRAM uses MRAM bus clock for Code MRAM and MRAM clock for Extra MRAM.
This module does not use I/O pins.
Code MRAM cannot be accessed while writing or erasing code MRAM. In order to support modifying code MRAM all supporting code must reside in RAM. Code MRAM operation will not return before the operation has completed. By default, the vector table resides in the code MRAM. If an interrupt occurs during the code MRAM operation, then code MRAM will be accessed to fetch the interrupt's starting address and an error will occur. The simplest work-around is to disable interrupts during code MRAM operations. Another option is to copy the vector table to RAM, update the VTOR (Vector Table Offset Register) accordingly and ensure that any interrupt service routines execute out of RAM. Similarly, you must ensure that if in a multi-threaded environment, threads running from code MRAM cannot become active while a code MRAM operation is in progress.
The erase API was designed with flash blocks in mind. The Erase API provides a mechanism for quickly overwriting blocks of data at a single time. The block size is determined by the MRAM Unit of Programming size.
Anti-rollback counters are available on select MCUs and can be used to prevent or limit firmware downgrade. The counters can only be incremented and never decremented or reset, even with an external programming tool.
When anti-rollback counters are used for one or more non-secure applications, the Anti-Rollback Counter Configuration Setting for ARC_NSEC (ARCCS) must be configured as either a single line (1xn bits) or multi-line counter (mxn bits). Single line is suitable when there is only one non-secure application using the anti-rollback counter. Multi-line is suitable when there are multiple non-secure applications. Before the counter is configured, it can't be used.
This configuration setting is permanent and must be performed with an external programming tool such as Renesas Flash Programmer (RFP). It cannot be configured in e2 studio.
The secure application and OEM bootloader anti-rollback counters do not require any initial configuration.
Select MCUs have the ability to permanently lock the anti-rollback counters using the Anti-Rollback Counter Lock Setting (ARCLS). It cannot be set with e2 studio, but if needed, it can be configured with an external programming tool such as Renesas Flash Programmer (RFP). Once the lock protection is applied to a counter, the counter value can never be incremented again. It is still possible to read the value of a locked counter.
By default, the contents of code MRAM are cached by e2 studio. This means that during a debug session, modifications to these memory regions will not be observed by e2 studio. When debugging applications using e2 studio, disable the "Allow caching of flash contents" option in the debug configuration in order to view modified MRAM contents (Debug Configuration > Debugger > Debug Tool Settings > Allow caching of flash contents).
This is a basic example of writing to MRAM.
This example demonstrates basic usage of the anti-rollback counter functions.
Data Structures | |
struct | mram_instance_ctrl_t |
struct mram_instance_ctrl_t |
MRAM instance control block. DO NOT INITIALIZE.
fsp_err_t R_MRAM_Open | ( | flash_ctrl_t *const | p_api_ctrl, |
flash_cfg_t const *const | p_cfg | ||
) |
Initializes the MRAM peripheral. Implements flash_api_t::open.
The Open function initializes the MRAM.
Example:
FSP_SUCCESS | Initialization was successful. |
FSP_ERR_ALREADY_OPEN | The MRAM control block is already open. |
FSP_ERR_ASSERTION | NULL provided for p_ctrl or p_cfg. |
FSP_ERR_IRQ_BSP_DISABLED | Caller is requesting BGO but the MRAM interrupts are not supported. |
fsp_err_t R_MRAM_Write | ( | flash_ctrl_t *const | p_api_ctrl, |
uint32_t const | src_address, | ||
uint32_t | mram_address, | ||
uint32_t const | num_bytes | ||
) |
Writes to the specified MRAM memory area. Implements flash_api_t::write.
Example:
FSP_SUCCESS | Operation successful. |
FSP_ERR_IN_USE | The MRAM peripheral is busy with a prior on-going transaction. |
FSP_ERR_NOT_OPEN | The MRAM API is not Open. |
FSP_ERR_CMD_LOCKED | MRAM Application Command Interface is in locked state |
FSP_ERR_WRITE_FAILED | Status is indicating a Programming error for the requested operation. This may be returned if the requested MRAM area is not blank. |
FSP_ERR_TIMEOUT | Timed out waiting for write operation to complete. |
FSP_ERR_INVALID_SIZE | Number of bytes provided was invalid |
FSP_ERR_INVALID_ADDRESS | Invalid address was input or address not on programming boundary. |
FSP_ERR_ASSERTION | NULL provided for p_ctrl. |
FSP_ERR_PE_FAILURE | Failed to enter or exit P/E mode. |
fsp_err_t R_MRAM_Erase | ( | flash_ctrl_t *const | p_api_ctrl, |
uint32_t const | address, | ||
uint32_t const | num_blocks | ||
) |
Erases the specified MRAM blocks. Implements flash_api_t::erase by the block_erase_address.
Example:
FSP_SUCCESS | Successful open. |
FSP_ERR_INVALID_BLOCKS | Invalid number of blocks specified |
FSP_ERR_INVALID_ADDRESS | Invalid address specified. |
FSP_ERR_IN_USE | Other MRAM operation in progress, or API not initialized |
FSP_ERR_CMD_LOCKED | MRAM Application Command Interface is in locked state |
FSP_ERR_ASSERTION | NULL provided for p_ctrl |
FSP_ERR_NOT_OPEN | The MRAM API is not Open. |
FSP_ERR_ERASE_FAILED | Status is indicating a Erase error. |
FSP_ERR_TIMEOUT | Timed out waiting for the MACI to become ready. |
FSP_ERR_PE_FAILURE | Failed to enter or exit P/E mode. |
fsp_err_t R_MRAM_BlankCheck | ( | flash_ctrl_t *const | p_api_ctrl, |
uint32_t const | address, | ||
uint32_t | num_bytes, | ||
flash_result_t * | p_blank_check_result | ||
) |
Stub function Implements flash_api_t::blankCheck.
FSP_ERR_UNSUPPORTED | Blank Check is not supported on this MCU. |
fsp_err_t R_MRAM_StatusGet | ( | flash_ctrl_t *const | p_api_ctrl, |
flash_status_t *const | p_status | ||
) |
Query the MRAM peripheral for its status. Implements flash_api_t::statusGet.
FSP_SUCCESS | MRAM peripheral is ready to use. |
FSP_ERR_ASSERTION | NULL provided for p_ctrl. |
FSP_ERR_NOT_OPEN | The MRAM API is not Open. |
fsp_err_t R_MRAM_IdCodeSet | ( | flash_ctrl_t *const | p_api_ctrl, |
uint8_t const *const | p_id_code, | ||
flash_id_code_mode_t | mode | ||
) |
Stub function Implements flash_api_t::idCodeSet.
FSP_ERR_UNSUPPORTED | ID Code is not supported on this MCU. |
fsp_err_t R_MRAM_AccessWindowSet | ( | flash_ctrl_t *const | p_api_ctrl, |
uint32_t const | start_addr, | ||
uint32_t const | end_addr | ||
) |
Stub function Implements flash_api_t::accessWindowSet.
FSP_ERR_UNSUPPORTED | Access window is not supported on this MCU. |
fsp_err_t R_MRAM_AccessWindowClear | ( | flash_ctrl_t *const | p_api_ctrl | ) |
Stub function Implements flash_api_t::accessWindowClear.
FSP_ERR_UNSUPPORTED | Access window is not supported on this MCU. |
fsp_err_t R_MRAM_Reset | ( | flash_ctrl_t *const | p_api_ctrl | ) |
Reset the MRAM peripheral. Implements flash_api_t::reset.
No attempt is made to check if the MRAM is busy before executing the reset since the assumption is that a reset will terminate any existing operation.
FSP_SUCCESS | MRAM circuit successfully reset. |
FSP_ERR_ASSERTION | NULL provided for p_ctrl. |
FSP_ERR_NOT_OPEN | The control block is not open. |
FSP_ERR_PE_FAILURE | Failed to enter or exit P/E mode. |
FSP_ERR_TIMEOUT | Timed out waiting for the MACI to become ready. |
FSP_ERR_CMD_LOCKED | MRAM Application Command Interface is in locked state |
fsp_err_t R_MRAM_StartUpAreaSelect | ( | flash_ctrl_t *const | p_api_ctrl, |
flash_startup_area_swap_t | swap_type, | ||
bool | is_temporary | ||
) |
Selects which block, Default (Block 0) or Alternate (Block 1), is used as the startup area block. The provided parameters determine which block will become the active startup block and whether that action will be immediate (but temporary), or permanent subsequent to the next reset. Implements flash_api_t::startupAreaSelect.
FSP_SUCCESS | Start-up area successfully toggled. |
FSP_ERR_IN_USE | MRAM peripheral is busy with a prior operation. |
FSP_ERR_ASSERTION | NULL provided for p_ctrl. |
FSP_ERR_NOT_OPEN | The control block is not open. |
FSP_ERR_PE_FAILURE | Failed to enter or exit MRAM P/E mode. |
FSP_ERR_TIMEOUT | Timed out waiting for the MACI to become ready. |
FSP_ERR_WRITE_FAILED | Status is indicating a Programming error for the requested operation. |
FSP_ERR_CMD_LOCKED | MRAM Application Command Interface is in locked state |
fsp_err_t R_MRAM_BankSwap | ( | flash_ctrl_t *const | p_api_ctrl | ) |
Stub function flash_api_t::bankSwap.
FSP_ERR_UNSUPPORTED | Bank Swap is not supported on this MCU. |
fsp_err_t R_MRAM_UpdateFlashClockFreq | ( | flash_ctrl_t *const | p_api_ctrl | ) |
Indicate to the MRAM module that the system clock has changed. Implements flash_api_t::updateFlashClockFreq.
This should be the case if the application has changed the system clock.
FSP_SUCCESS | Start-up area successfully toggled. |
FSP_ERR_IN_USE | MRAM is busy with an on-going operation. |
FSP_ERR_ASSERTION | NULL provided for p_ctrl |
FSP_ERR_NOT_OPEN | MRAM API has not yet been opened. |
fsp_err_t R_MRAM_InfoGet | ( | flash_ctrl_t *const | p_api_ctrl, |
flash_info_t *const | p_info | ||
) |
Returns the information about the MRAM regions. Implements flash_api_t::infoGet.
FSP_SUCCESS | Successful retrieved the request information. |
FSP_ERR_NOT_OPEN | The control block is not open. |
FSP_ERR_ASSERTION | NULL provided for p_ctrl or p_info. |
fsp_err_t R_MRAM_Close | ( | flash_ctrl_t *const | p_api_ctrl | ) |
Releases any resources that were allocated by the Open() or any subsequent MRAM operations. Implements flash_api_t::close.
FSP_SUCCESS | Successful close. |
FSP_ERR_NOT_OPEN | The control block is not open. |
FSP_ERR_ASSERTION | NULL provided for p_ctrl or p_cfg. |
fsp_err_t R_MRAM_CallbackSet | ( | flash_ctrl_t *const | p_api_ctrl, |
void(*)(flash_callback_args_t *) | p_callback, | ||
void *const | p_context, | ||
flash_callback_args_t *const | p_callback_memory | ||
) |
Stub function Implements flash_api_t::callbackSet.
FSP_ERR_UNSUPPORTED | Interrupt driven operation is not supported on this MCU. |
fsp_err_t R_MRAM_AntiRollbackCounterIncrement | ( | flash_ctrl_t *const | p_api_ctrl, |
flash_arc_t | counter | ||
) |
Increments the selected anti-rollback counter.
Implements flash_api_t::antiRollbackCounterIncrement
FSP_SUCCESS | Counter incremented successfully |
FSP_ERR_NOT_OPEN | The control block is not open. |
FSP_ERR_ASSERTION | NULL provided for p_api_ctrl |
FSP_ERR_NOT_ENABLED | The specified counter has not been configured (configuration is only required for ARC_NSEC) |
FSP_ERR_OVERFLOW | The counter cannot be incremented because it is already at its max value |
FSP_ERR_PE_FAILURE | Failed to enter or exit MRAM P/E mode. |
FSP_ERR_TIMEOUT | Timed out waiting for the MACI to become ready. |
FSP_ERR_CMD_LOCKED | MRAM Application Command Interface is in locked state |
FSP_ERR_UNSUPPORTED | Selected anti-rollback counter is not supported on this MCU |
fsp_err_t R_MRAM_AntiRollbackCounterRefresh | ( | flash_ctrl_t *const | p_api_ctrl, |
flash_arc_t | counter | ||
) |
Stub function Implements flash_api_t::antiRollbackCounterRefresh
FSP_ERR_UNSUPPORTED | Anti-Rollback counter refresh is not supported on this MCU |
fsp_err_t R_MRAM_AntiRollbackCounterRead | ( | flash_ctrl_t *const | p_api_ctrl, |
flash_arc_t | counter, | ||
uint32_t *const | p_count | ||
) |
Reads the selected anti-rollback counter and returns the number of counter bits set.
Implements flash_api_t::antiRollbackCounterRead
FSP_SUCCESS | Counter read successfully into p_count |
FSP_ERR_NOT_OPEN | The control block is not open. |
FSP_ERR_ASSERTION | NULL provided for p_api_ctrl or p_count |
FSP_ERR_NOT_ENABLED | The specified counter has not been configured (configuration is only required for ARC_NSEC) |
FSP_ERR_PE_FAILURE | Failed to enter or exit MRAM P/E mode. |
FSP_ERR_TIMEOUT | Timed out waiting for the MACI to become ready. |
FSP_ERR_CMD_LOCKED | MRAM Application Command Interface is in locked state |
fsp_err_t R_MRAM_UserLockableAreaWrite | ( | flash_ctrl_t *const | p_api_ctrl, |
uint32_t const | src_address, | ||
uint32_t | mram_address, | ||
uint32_t const | num_bytes | ||
) |
Stub function Implements flash_api_t::userLockableAreaWrite
FSP_ERR_UNSUPPORTED | User Lockable Area is not supported on this MCU |