FLASH

FLASH API Reference

Functions

OSStatus BkFlashInit(void)

Initialises flash driver.

Return

kNoErr : On success.

kGeneralErr : If an error occurred with any step

Parameters
  • inPartition::

OSStatus BkFlashUninit(void)

De-initialise flash driver.

Return

kNoErr : On success.

kGeneralErr : If an error occurred with any step

Parameters
  • inPartition::

bk_logic_partition_t *bk_flash_get_info(bk_partition_t inPartition)

Get the infomation of the specified flash area.

Return

bk_logi_partition struct

Parameters
  • inPartition:: The target flash logical partition which should be erased

OSStatus bk_flash_erase(bk_partition_t inPartition, uint32_t off_set, uint32_t size)

Erase an area on a Flash logical partition.

Note

Erase on an address will erase all data on a sector that the address is belonged to, this function does not save data that beyond the address area but in the affected sector, the data will be lost.

Return

kNoErr : On success.

kGeneralErr : If an error occurred with any step

Parameters
  • inPartition: : The target flash logical partition which should be erased

  • off_set: : Start address of the erased flash area

  • size: : Size of the erased flash area

OSStatus bk_flash_write(bk_partition_t inPartition, volatile uint32_t off_set, uint8_t *inBuffer, uint32_t inBufferLength)

Write data to an area on a Flash logical partition.

Return

kNoErr : On success.

kGeneralErr : If an error occurred with any step

Parameters
  • inPartition: : The target flash logical partition which should be read which should be written

  • off_set: :

  • inBuffer: : point to the data buffer that will be written to flash

  • inBufferLength: : The length of the buffer

OSStatus bk_flash_read(bk_partition_t inPartition, volatile uint32_t off_set, uint8_t *outBuffer, uint32_t inBufferLength)

Read data from an area on a Flash to data buffer in RAM.

Return

kNoErr : On success.

kGeneralErr : If an error occurred with any step

Parameters
  • inPartition: : The target flash logical partition which should be read

  • off_set: :

  • outBuffer: : Point to the data buffer that stores the data read from flash

  • inBufferLength: : The length of the buffer

OSStatus bk_flash_enable_security(PROTECT_TYPE type)

Set security options on a logical partition.

Return

kNoErr : On success.

kGeneralErr : If an error occurred with any step

Parameters
  • type: : the type of protect, seen PROTECT_TYPE

OSStatus bk_flash_get_security(PROTECT_TYPE *protect_flag)

Get security options on a logical partition.

Return

kNoErr : On success.

kGeneralErr : If an error occurred with any step

Parameters
  • protect_flag: : the type of protect, seen PROTECT_TYPE

int bk_flash_abs_addr_write(unsigned int off_set, const unsigned char *inBuffer, unsigned int size, unsigned char eraseflag)

Write data to target Flash address.

Return

kNoErr : On success.

kGeneralErr : If an error occurred with any step

Parameters
  • off_set: : The target flash addrerss

  • inBuffer: : point to the data buffer that will be written to flash

  • size: : The length of the buffer

  • eraseflag: : whether erase flash before Write

int bk_flash_abs_addr_erase(unsigned int flashOffset, unsigned int size)

Erase an area on a Flash address.

Note

Erase on an address will erase all data on a sector that the address is belonged to, this function does not save data that beyond the address area but in the affected sector, the data will be lost.

Return

kNoErr : On success.

kGeneralErr : If an error occurred with any step

Parameters
  • flashOffset: : Start address of the erased flash address

  • size: : Size of the erased flash

int bk_flash_abs_addr_read(unsigned int off_set, unsigned char *outBuffer, unsigned int size)

Read data from an area on a Flash to data buffer in RAM.

Return

kNoErr : On success.

kGeneralErr : If an error occurred with any step

Parameters
  • off_set: : Start address of the erased flash address

  • outBuffer: : Point to the data buffer that stores the data read from flash

  • size: : The length of the buffer

uint32_t bk_flash_read_otp(uint32_t off_set, uint8_t *out_buf, uint32_t buf_len)

Read data from otp.

Return

kNoErr : On success.

kGeneralErr : If an error occurred with any step

Parameters
  • off_set: : Start address of the otp

  • out_buf: : Point to the data buffer that stores the data read from otp

  • buf_len: : The length of the buffer

Structures

struct platform_logic_partition_t

Macros

BK_PARTITION_USER_MAX
PAR_OPT_READ_POS
PAR_OPT_WRITE_POS
PAR_OPT_READ_MASK
PAR_OPT_WRITE_MASK
PAR_OPT_READ_DIS
PAR_OPT_READ_EN
PAR_OPT_WRITE_DIS
PAR_OPT_WRITE_EN

Type Definitions

typedef platform_logic_partition_t bk_logic_partition_t

Enumerations

enum bk_partition_t

Values:

enumerator BK_PARTITION_BOOTLOADER
enumerator BK_PARTITION_APPLICATION
enumerator BK_PARTITION_OTA
enumerator BK_PARTITION_RF_FIRMWARE
enumerator BK_PARTITION_NET_PARAM
enumerator BK_PARTITION_USR_CONFIG
enumerator BK_PARTITION_MAX
enum bk_flash_t

Values:

enumerator BK_FLASH_EMBEDDED
enumerator BK_FLASH_SPI
enumerator BK_FLASH_MAX
enumerator BK_FLASH_NONE