The Flash driver provides API to read and write to xSPI based flash devices present in the board.
The driver takes care of all sequencing necessary to perform writes across pages and the application need not take care of the programming intricacies.
Features Supported
- APIs to read and write to a flash offset
- Provides API to return flash attributes like block size, page size etc
- API for block erases
- Supports Nand Flash
SysConfig Features
- Note
- It is strongly recommend to use SysConfig where it is available instead of using direct SW API calls. This will help simplify the SW application and also catch common mistakes early in the development cycle.
- Option to select flash type based on board
- Supported flash devices
Features NOT Supported
Important Usage Guidelines
- Typically before writing to an offset, erase the block which corresponds to the offset
- Flashes support multiple erase sizes, conditionally. We provide 2 APIs for this cause in case the flash supports 2 different erase sizes:
- Flash_eraseBlk()
- Flash_eraseSector() The larger size can be thought of as a 'block' and the smaller size as a 'sector'. In a flash where both are supported, one can make use of both. In some flashes, the sector configuration has to be fixed before-hand. In such cases the way erase sizes supported will be subject to this configuration. Take care in the flash configuration and the application to make sure the erase APIs are called only with the right configuration.
- Flash writes can only be done to a page size aligned offset, otherwise the write API returns an error
- The
sbl_ospi
will be typically flashed at location 0x00000000 in the flash memory. So applications using flash should refrain from using this offset. Similarly, the starting of the last block of the flash is used for storing attackVector patterns later used for PHY tuning. So avoid using this offset as well.
Example Usage
Include the below file to access the APIs
Flash Read API
uint32_t offset;
offset = 0;
Flash Write API
uint32_t offset;
offset = 0;
Flash Erase API
uint32_t offset, blk, page;
offset = 0;
API
APIs for FLASH