AM263x MCU+ SDK  08.02.01
Flash

The Flash driver provides API to read and write to QSPI 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

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
    • S25FL128SA

Features NOT Supported

NA

Important Usage Guidelines

  • Typically before writing to an offset, erase the block which corresponds to the offset
  • Flash writes can only be done to a page size aligned offset, otherwise the write API returns an error
  • The sbl_qspi will be typically flashed at location 0x00000000 in the flash memory. So applications using flash should refrain from using this offset.

Example Usage

Include the below file to access the APIs

#include <board/flash.h>

Flash Read API

uint32_t offset;
/* Set offset to read from */
offset = 0;
/* Do the read */
status = Flash_read(handle, offset, buffer, 100);

Flash Write API

uint32_t offset;
/* Set offset to write to */
offset = 0;
/* Do the write */
status = Flash_write(handle, offset, buffer, 100);

Flash Erase API

uint32_t offset, blk, page;
/* Set offset to erase */
offset = 0;
/* Find the block number corresponding to the offset */
status = Flash_offsetToBlkPage(handle, offset, &blk, &page);
/* Erase the block */
status = Flash_eraseBlk(handle,blk);

API

APIs for FLASH

Flash_offsetToBlkPage
int32_t Flash_offsetToBlkPage(Flash_Handle handle, uint32_t offset, uint32_t *block, uint32_t *page)
Utility API to convert offset in bytes to (Block Num, Page Num)
SystemP_SUCCESS
#define SystemP_SUCCESS
Return status when the API execution was successful.
Definition: SystemP.h:56
DebugP_assert
#define DebugP_assert(expression)
Function to call for assert check.
Definition: DebugP.h:159
Flash_eraseBlk
int32_t Flash_eraseBlk(Flash_Handle handle, uint32_t blockNum)
Erase a block from flash.
Flash_write
int32_t Flash_write(Flash_Handle handle, uint32_t offset, uint8_t *buf, uint32_t len)
Write to flash.
flash.h
Flash_read
int32_t Flash_read(Flash_Handle handle, uint32_t offset, uint8_t *buf, uint32_t len)
Read data from flash.