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 erasedoff_set
: : Start address of the erased flash areasize
: : 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 writtenoff_set
: :inBuffer
: : point to the data buffer that will be written to flashinBufferLength
: : 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 readoff_set
: :outBuffer
: : Point to the data buffer that stores the data read from flashinBufferLength
: : 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 addrerssinBuffer
: : point to the data buffer that will be written to flashsize
: : The length of the buffereraseflag
: : 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 addresssize
: : 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 addressoutBuffer
: : Point to the data buffer that stores the data read from flashsize
: : 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 otpout_buf
: : Point to the data buffer that stores the data read from otpbuf_len
: : The length of the buffer
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
¶