FLASH PARTITION

FLASH PARTITION API Status

API

BK7239

BK7239_cp1

bk_flash_partition_get_info()

Y

Y

bk_flash_partition_erase()

Y

Y

bk_flash_partition_write()

Y

Y

bk_flash_partition_read()

Y

Y

FLASH PARTITION API Reference

Header File

Functions

bk_logic_partition_t *bk_flash_partition_get_info(bk_partition_t partition)

Get the infomation of the specified flash area.

Parameters

partition – The target flash logical partition

Returns

bk flash logic partition struct

bk_err_t bk_flash_partition_erase(bk_partition_t partition, uint32_t offset, 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.

Parameters
  • partition – The target flash logical partition which should be erased

  • offset – Start address of the erased flash area

  • size – Size of the erased flash area

Returns

  • BK_OK: succeed

  • others: other errors

bk_err_t bk_flash_partition_erase_by_name(const char *label, uint32_t offset, 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.

Parameters
  • label – The target flash logical partition which should be erased

  • offset – Start address of the erased flash area

  • size – Size of the erased flash area

Returns

  • BK_OK: succeed

  • others: other errors

bk_err_t bk_flash_partition_erase_all(const char *label)

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.

Parameters

label – The target flash logical partition which should be erased all

Returns

  • BK_OK: succeed

  • others: other errors

bk_err_t bk_flash_partition_write(bk_partition_t partition, const uint8_t *buffer, uint32_t offset, uint32_t buffer_len)

Write data to an area on a Flash logical partition.

Parameters
  • partition – The target flash logical partition which should be written

  • buffer – Pointer to the data buffer that will be written to flash

  • off_set – The offset of write address

  • buffer_len – The length of the buffer

Returns

  • BK_OK: succeed

  • others: other errors

bk_err_t bk_flash_partition_write_by_name(const char *label, const uint8_t *buffer, uint32_t offset, uint32_t buffer_len)

Write data to an area on a Flash logical partition.

Parameters
  • label – The target flash logical partition which should be written

  • buffer – Pointer to the data buffer that will be written to flash

  • off_set – The offset of write address

  • buffer_len – The length of the buffer

Returns

  • BK_OK: succeed

  • others: other errors

bk_err_t bk_flash_partition_read(bk_partition_t partition, uint8_t *out_buffer, uint32_t offset, uint32_t buffer_len)

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

Parameters
  • partition – The target flash logical partition which should be read

  • out_buffer – Pointer to the data buffer that stores the data read from flash

  • offsets – The offset of read address

  • buffer_len – The length of the buffer

Returns

  • BK_OK: succeed

  • others: other errors

bk_err_t bk_flash_partition_read_by_name(const char *label, uint8_t *out_buffer, uint32_t offset, uint32_t buffer_len)

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

Parameters
  • label – The target flash logical partition which should be read

  • out_buffer – Pointer to the data buffer that stores the data read from flash

  • offsets – The offset of read address

  • buffer_len – The length of the buffer

Returns

  • BK_OK: succeed

  • others: other errors

bk_err_t bk_flash_partition_read_enhanced(bk_partition_t partition, uint8_t *out_buffer, uint32_t offset, uint32_t buffer_len)
bk_err_t bk_flash_partition_write_enhanced(bk_partition_t partition, const uint8_t *buffer, uint32_t offset, uint32_t buffer_len)
const bk_logic_partition_t *get_partition_info_by_name(const char *label)
const bk_logic_partition_t *get_partition_info(bk_partition_t partition)
const bk_logic_partition_t *bk_flash_partition_get_info_by_name(const char *label)
uint32_t get_partition_index(const bk_logic_partition_t *partition)
bk_err_t bk_spec_flash_write_bytes(bk_partition_t partition, const uint8_t *user_buf, uint32_t size, uint32_t offset)

Write data to flash (only operating 4k flash space)

Parameters
  • partition – partition to write (eg:partition BK_PARTITION_RF_FIRMWARE)

  • user_buf – the pointer to data which is to write

  • size – size to write

  • offset – offset to write

Returns

  • BK_OK: succeed

  • BK_ERR_FLASH_ADDR_OUT_OF_RANGE: flash address is out of range

  • others: other errors.

static inline uint32_t bk_flash_partition_get_type(const bk_logic_partition_t *partition)
static inline uint32_t bk_flash_partition_get_options(const bk_logic_partition_t *partition)

Structures

struct bk_logic_partition_t

Public Members

bk_flash_t partition_owner

flash partition owners

const char *partition_description

flash partition description

uint32_t partition_start_addr

flash partition start address

uint32_t partition_length

flash partition length

uint32_t partition_options

flash partition options

Macros

PAR_OPT_READ_POS
PAR_OPT_READ_DIS
PAR_OPT_READ_EN
PAR_OPT_WRITE_POS
PAR_OPT_WRITE_DIS
PAR_OPT_WRITE_EN
PAR_OPT_EXECUTE_POS
PAR_OPT_EXECUTE_DIS
PAR_OPT_EXECUTE_EN
PARTITION_FLAGS_DBUS_READ
PARTITION_FLAGS_DBUS_WRITE
PARTITION_FLAGS_EXECUTE
PARTITION_FLAGS_CBUS_READ
PARTITION_FLAGS_CBUS_WRITE
PARTITION_FLAGS_OTA_WRITE_CBUS
PARTITION_FLAGS_DOWNLOAD_WRITE_CBUS
PARTITION_FLAGS_OTA_READ_CBUS
PARTITION_FLAGS_CBUS_NS
PARTITION_FLAGS_DBUS_NS

Type Definitions

typedef uint16_t bk_partition_type_t
typedef uint16_t bk_partition_subtype_t

Enumerations

enum bk_flash_t

Values:

enumerator BK_FLASH_EMBEDDED
enumerator BK_FLASH_SPI
enumerator BK_FLASH_MAX
enumerator BK_FLASH_NONE
enum bk_partition_t

Values:

enumerator BK_PARTITION_BOOTLOADER
enumerator BK_PARTITION_APPLICATION
enumerator BK_PARTITION_OTA
enumerator BK_PARTITION_APPLICATION1
enumerator BK_PARTITION_MATTER_FLASH
enumerator BK_PARTITION_RF_FIRMWARE
enumerator BK_PARTITION_NET_PARAM
enumerator BK_PARTITION_USR_CONFIG
enumerator BK_PARTITION_OTA_FINA_EXECUTIVE
enumerator BK_PARTITION_APPLICATION2
enumerator BK_PARTITION_EASYFLASH
enumerator BK_PARTITION_MAX
enum [anonymous]

Values:

enumerator PARTITION_TYPE_DATA
enumerator PARTITION_TYPE_APP
enum [anonymous]

Values:

enumerator PARTITION_SUBTYPE_DEFAULT
enumerator PARTITION_SUBTYPE_OW_ACTIVE
enumerator PARTITION_SUBTYPE_OW_OTA
enumerator PARTITION_SUBTYPE_XIP_A
enumerator PARTITION_SUBTYPE_XIP_B
enumerator PARTITION_SUBTYPE_MERGE_OVERWRITE
enumerator PARTITION_SUBTYPE_MERGE_XIP_A
enumerator PARTITION_SUBTYPE_MERGE_XIP_B
enumerator PARTITION_SUBTYPE_BL1_CTRL
enumerator PARTITION_SUBTYPE_BL1_MANIFEST
enumerator PARTITION_SUBTYPE_NVS
enumerator PARTITION_SUBTYPE_PARTITION
enumerator PARTITION_SUBTYPE_OW_OTA_CONTROL
enumerator PARTITION_SUBTYPE_XIP_OTA_CONTROL