STM32CubeWBA: Flash management

Revision as of 17:08, 28 February 2023 by Registered User (→‎Flash Manager)
Under construction.png Coming soon



1. Introduction

Flash management proposes a simple interface to the upper layers to execute operations in FLASH. It manages synchronization between flash operations and the RF activity. Thus, users do not have to bother with RF timing and flash operations.

2. Features

2.1. Concepts

The flash management is a multi-layer organization and rely on different concepts. Among these concepts, here are the most important ones:

  • Organization:
Flash management is based upon a 5 layers distribution composed by:
Flash Management overview.png
Simple NVM Arbiter
Specific flash interface that emulates the behavior of multiple NVMs.
Flash manager
Main user interface for flash operation (Flash write, flash erase, etc.).
RF Timing synchro
Module that realizes synchronization between BLE LL and Flash operations by activating or deactivating the dedicated flash control status.
Flash Driver
Low level driver abstraction layer. Controlled by the flash control statuses.
HAL Flash
Low level driver that interacts directly with the Flash HW.
  • Asynchronous Operations:
The whole flash operations are either executed via the Flash Manager interface or via the Simple NVM Arbiter interface. Both work on an asynchronous behavior, which means that the user is requesting operations to be performed and is notified later on, once the operation is over.
However, since the operation is asynchronous, during write operation, the user shall hold his buffer allocation as long as the write operation is not done. In case of a content change in this buffer, the user shall restart a brand-new flash operation.
  • Synchronous flash access with RF:
Flash operations achieved with Flash manager or Simple NVM Arbiter are synchronized with RF activity. Meaning that flash operations are achieved only during free RF activity time slot.
This feature is transparent to the user and is fully handled by the Flash manager or the Simple NVM Arbiter. Therefore, the user does not have to bother with RF and Flash synchro. This is all, already, managed.
  • Flash Access:
In this Flash management implementation, the Flash access is protected at two distinct levels:
Flash semaphore
A semaphore is required to share the flash interface between several SW modules. The owner of the semaphore is the only one that can request flash operations. The semaphore is attributed to the first requester and released once its operation is over.
Flash control statuses
Independently from the flash semaphore, the flash driver provides flags – Flash Control Status – to prevent flash operation depending on the system activity. These flags/statuses are checked before any flash operation by the flash driver.

2.2. Flash Driver

2.3. RF Timing Synchro

2.4. Flash Manager

2.5. Simple NVM Arbiter

3. Interfaces

Here comes a list of the available functions for the different Flash management modules:

3.1. Flash Driver

3.1.1. Flash driver error codes

FD_FlashOp_Status_t
Error code Description
FD_FLASHOP_SUCCESS Flash operation success
FD_FLASHOP_FAILURE Flash operation failure

3.1.2. Flash driver functions

FD_SetStatus

Description

Update Flash Control status.
Syntax
void FD_SetStatus(FD_Flash_ctrl_bm_t Flags_bm, FD_FLASH_Status_t Status);
Parameters
[in] Flags_bm
Type: FD_Flash_ctrl_bm_t
Description: Bit mask identifying the caller
[in] Status
Type: FD_FLASH_Status_t
Description: Action requested (enable or disable flash access)
Return Value
None
FD_WriteData

Description

Write a block of 128 bits (4 32-bit words) in Flash
Syntax
FD_FlashOp_Status_t FD_WriteData(uint32_t Dest, uint32_t Payload);
Parameters
[in] Dest
Type: uint32_t
Description: Address where to write in Flash (128-bit aligned)
[in] Payload
Type: uint32_t
Description: Address of data to be written in Flash (32-bit aligned)
Return Value
FD_FlashOp_Status_t
FD_EraseSectors

Description

Erase one sector of Flash
Syntax
FD_FlashOp_Status_t FD_EraseSectors(uint32_t Sect);
Parameters
[in] Sect
Type: uint32_t
Description: Identifier of the sector to erase
Return Value
FD_FlashOp_Status_t

3.2. RF Timing Synchro

3.2.1. RF Timing synchro error codes

RFTS_Cmd_Status_t
Error code Description
RFTS_CMD_OK The RF Timing synchronization command was successfully executed
RFTS_WINDOW_REQ_FAILED The RF Timing synchronization module failed to register the window request
RFTS_WINDOW_REL_ERROR An error occurred during the window release procedure

3.2.2. RF Timing synchro functions

RFTS_ReqWindow

Description

Request a time window to the SNPS FW LL
Syntax
RFTS_Cmd_Status_t RFTS_ReqWindow(uint32_t Duration, void (*Callback)(void));
Parameters
[in] Duration
Type: uint32_t
Description: Duration in us of the time window requested
[in] Callback
Type: void (*Callback)(void)
Description: Callback to be called when time window is allocated
Return Value
RFTS_Cmd_Status_t
RFTS_RelWindow

Description

Execute necessary tasks to allow the time window to be released
Syntax
RFTS_Cmd_Status_t RFTS_RelWindow(void);
Parameters
None
Return Value
RFTS_Cmd_Status_t

3.3. Flash Manager

3.3.1. Flash manager error codes

FM_Cmd_Status_t
Error code Description
FM_OK The Flash Manager is available and a window request is scheduled
FM_BUSY The Flash Manager is busy and the caller will be called back when it is available
FM_ERROR An error occurred while processing the command

3.3.2. Flash manager functions

FM_Write

Description

Request the Flash Manager module to initiate a Flash Write operation
Syntax
FM_Cmd_Status_t FM_Write(uint32_t *Src, uint32_t *Dest, int32_t Size, FM_CallbackNode_t *CallbackNode);
Parameters
[in] Src
Type: uint32_t *
Description: Address of the data to be stored in FLASH. It shall be 32bits aligned
[in] Dest
Type: uint32_t *
Description: Address where the data shall be written. It shall be 128bits aligned
[in] Size
Type: int32_t
Description: This is the size of data to be written in Flash. The size is a multiple of 32bits (size = 1 means 32bits)
[in] CallbackNode
Type: FM_CallbackNode_t *
Description: Pointer to the callback node for storage in list
Return Value
FM_Cmd_Status_t
FM_Erase

Description

Request the Flash Manager module to initiate a Flash Erase operation
Syntax
FM_Cmd_Status_t FM_Erase(uint32_t FirstSect, uint32_t NbrSect, FM_CallbackNode_t *CallbackNode);
Parameters
[in] FirstSect
Type: uint32_t
Description: Index of the first sector to erase
[in] NbrSect
Type: uint32_t
Description: Number of sector to erase
[in] CallbackNode
Type: FM_CallbackNode_t *
Description: Pointer to the callback node for storage in list
Return Value
FM_Cmd_Status_t
FM_BackgroundProcess

Description

Execute Flash Manager background tasks
Syntax
void FM_BackgroundProcess (void);
Parameters
None
Return Value
None
FM_ProcessRequest

Description

Request to the user scheduler to be scheduled
Syntax
void FM_ProcessRequest (void);
Parameters
None
Return Value
None

3.4. Simple NVM Arbiter

AMM_Init

Description

Initialize the Advanced Memory Manager Pool.
Syntax
AMM_Function_Error_t AMM_Init (const AMM_InitParameters_t * const p_InitParams);
Parameters
[in] p_InitParams
Type: const AMM_InitParameters_t * const
Description: Struct of init parameters
Return Value
AMM_Function_Error_t

4. How to

TBD.

5. Revisions

Rev. number Description
0.1 First wiki version.