PMSIS BSP
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Partition

Data Structures

struct  pi_partition_t
 partition information structure More...
 

Typedefs

typedef void * pi_partition_table_t
 partition table object More...
 

Enumerations

enum  pi_partition_type_t
 Partition type. More...
 
enum  pi_partition_subtype_t
 Partition subtype. More...
 

Functions

pi_err_t pi_partition_table_load (pi_device_t *flash, const pi_partition_table_t *table)
 Open a partition table from a flash device. More...
 
void pi_partition_table_free (pi_partition_table_t table)
 Close an opened partition table from pi_partition_table_load. More...
 
const pi_partition_tpi_partition_find_first (const pi_partition_table_t table, const pi_partition_type_t type, const pi_partition_subtype_t subtype, const char *label)
 Find first partition based on one or more parameters. More...
 
static pi_err_t pi_partition_close (const pi_partition_t *partition)
 Close an opened partition device. More...
 
static pi_err_t pi_partition_read_async (const pi_partition_t *partition, const uint32_t partition_addr, void *data, const size_t size, pi_task_t *task)
 Enqueue an asynchronous read copy to the flash partition (from flash partition to processor). More...
 
static pi_err_t pi_partition_read (const pi_partition_t *partition, const uint32_t partition_addr, void *data, const size_t size)
 Enqueue a read copy to the flash partition (from flash to processor). More...
 
static pi_err_t pi_partition_write_async (const pi_partition_t *partition, const uint32_t partition_addr, const void *data, const size_t size, pi_task_t *task)
 Enqueue an asynchronous read copy to the flash partition (from processor to flash partition). More...
 
static pi_err_t pi_partition_write (const pi_partition_t *partition, const uint32_t partition_addr, const void *data, const size_t size)
 Enqueue a write copy to the flash partition (from processor to flash). More...
 
static pi_err_t pi_partition_erase_async (const pi_partition_t *partition, uint32_t partition_addr, int size, pi_task_t *task)
 Erase an area in the flash partition asynchronously. More...
 
static pi_err_t pi_partition_erase (const pi_partition_t *partition, uint32_t partition_addr, int size)
 Erase an area in the flash partition. More...
 
size_t pi_partition_get_size (const pi_partition_t *partition)
 Erase the whole flash partition asynchronously. More...
 
uint32_t pi_partition_get_flash_offset (const pi_partition_t *partition)
 Get flash partition start offset. More...
 

Description

The partition driver provides support for handling partition contained into a device storage. Currently, PMSIS and GAP SDK provide both partitions, binary firmware and filesystem.

The beginning of the filesystem partition is aligned on a flash sector. Thus, an erase partition operation at address zero does not affect the data of the previous partition.

Typedef Documentation

typedef void* pi_partition_table_t

Enumeration Type Documentation

Note
Keep this enum in sync with PartitionDefinition class in gapy tool.
Enumerator
PI_PARTITION_SUBTYPE_APP_FACTORY 

Factory application partition.

PI_PARTITION_SUBTYPE_APP_OTA_0 

OTA partition 0.

PI_PARTITION_SUBTYPE_APP_OTA_1 

OTA partition 1.

PI_PARTITION_SUBTYPE_APP_TEST 

Test application partition.

PI_PARTITION_SUBTYPE_APP_UPDATER_0 

Updater partition 0.

PI_PARTITION_SUBTYPE_APP_UPDATER_1 

Updater partition 1.

PI_PARTITION_SUBTYPE_APP_0 

App partition 0 to run once.

PI_PARTITION_SUBTYPE_APP_1 

App partition 1 to run once.

PI_PARTITION_SUBTYPE_APP_2 

App partition 2 to run once.

PI_PARTITION_SUBTYPE_APP_3 

App partition 3 to run once.

PI_PARTITION_SUBTYPE_APP_4 

App partition 4 to run once.

PI_PARTITION_SUBTYPE_APP_5 

App partition 5 to run once.

PI_PARTITION_SUBTYPE_APP_6 

App partition 6 to run once.

PI_PARTITION_SUBTYPE_APP_7 

App partition 7 to run once.

PI_PARTITION_SUBTYPE_APP_8 

App partition 8 to run once.

PI_PARTITION_SUBTYPE_APP_9 

App partition 9 to run once.

PI_PARTITION_SUBTYPE_DATA_OTA 

OTA selection partition.

PI_PARTITION_SUBTYPE_DATA_PHY 

PHY init data partition.

PI_PARTITION_SUBTYPE_DATA_RAW 

RAW space partition.

PI_PARTITION_SUBTYPE_DATA_READFS 

Readonly filesystem partition.

PI_PARTITION_SUBTYPE_DATA_LFS 

LittleFS filesystem partition.

pi_PARTITION_SUBTYPE_ANY 

Used to search for partitions with any subtype.

PI_PARTITION_SUBTYPE_UNKNOWN 

LittleFS filesystem partition.

Note
Keep this enum in sync with PartitionDefinition class in gapy tool
Enumerator
PI_PARTITION_TYPE_APP 

Application partition type.

PI_PARTITION_TYPE_DATA 

Data partition type.

Function Documentation

static pi_err_t pi_partition_close ( const pi_partition_t partition)
inlinestatic

This function can be called to close an opened partition device once it is not needed anymore, in order to free all allocated resources. Once this function is called, the device is not accessible anymore and must be opened again before being used.

Parameters
partitionThe partition structure of the device to close.
Returns
PI_OK if the operation is successfull, PI_FAIL if there was an error.
static pi_err_t pi_partition_erase ( const pi_partition_t partition,
uint32_t  partition_addr,
int  size 
)
inlinestatic

This will erase the specified area. The duration of this operation may be long and may be retrieved from the datasheet. If the flash only supports sector erasing, all the sectors partially or entirely covered by this aread will be erased. The caller is blocked until the operation is finished.

Parameters
partitionThe partition descriptor on which to do the operation.
partition_addrThe address of the partition area to be erased.
sizeThe size of the area to be erased.
Returns
PI_OK if the operation is successfull, PI_ERR_INVALID_ARG if adress is out of range.
static pi_err_t pi_partition_erase_async ( const pi_partition_t partition,
uint32_t  partition_addr,
int  size,
pi_task_t *  task 
)
inlinestatic

This will erase the specified area. The duration of this operation may be long and may be retrieved from the datasheet. If the flash only supports sector erasing, all the sectors partially or entirely covered by this aread will be erased. A task must be specified in order to specify how the caller should be notified when the transfer is finished.

Parameters
partitionThe partition descriptor on which to do the operation.
partition_addrThe address of the partition area to be erased.
sizeThe size of the area to be erased.
taskThe task used to notify the end of transfer. See the documentation of pi_task_t for more details.
Returns
PI_OK if the operation is successfull, PI_ERR_INVALID_ARG if adress is out of range.
const pi_partition_t* pi_partition_find_first ( const pi_partition_table_t  table,
const pi_partition_type_t  type,
const pi_partition_subtype_t  subtype,
const char *  label 
)
Parameters
tablethe partition table descriptor on which to do the operation. This table must be loaded before with pi_partition_table_load(...)
typePartition type, one of pi_partition_type_t values
subtypePartition subtype, one of pi_partition_subtype_t values. To find all partitions of given type, use pi_PARTITION_SUBTYPE_ANY.
label(optional) Partition label. Set this value if looking for partition with a specific name. Pass NULL otherwise.
Returns
pointer to pi_partition_t structure, or NULL if no partition is found. This pointer is valid for the lifetime of the application.
uint32_t pi_partition_get_flash_offset ( const pi_partition_t partition)
Parameters
partitionThe partition where the offset will be fetched.
Returns
The flash offset in byte where the partition starts.
size_t pi_partition_get_size ( const pi_partition_t partition)

This will erase the entire partition. The duration of this operation may be long and may be retrieved from the datasheet. A task must be specified in order to specify how the caller should be notified when the transfer is finished.

Parameters
partitionThe partition descriptor on which to do the operation.
taskThe task used to notify the end of transfer. See the documentation of pi_task_t for more details.
Returns
PI_OK if the operation is successfull, PI_FAIL if there was an error.Erase the whole flash partition.

This will erase the entire partition. The duration of this operation may be long and may be retrieved from the datasheet. The caller is blocked until the operation is finished.

Parameters
partitionThe partition descriptor on which to do the operation.
Returns
PI_OK if the operation is successfull, PI_FAIL if there was an error.Get the size in byte of the partition
Parameters
partitionThe partition where the size will be fetched.
Returns
The size in byte of the partition
static pi_err_t pi_partition_read ( const pi_partition_t partition,
const uint32_t  partition_addr,
void *  data,
const size_t  size 
)
inlinestatic

The copy will make a transfer between the flash partition and one of the processor memory areas. The caller is blocked until the transfer is finished. Depending on the chip, there may be some restrictions on the memory which can be used. Check the chip-specific documentation for more details.

Parameters
partitionThe partition descriptor on which to do the copy.
partition_addrThe address of the copy in the partition.
dataThe address of the copy in the processor.
sizeThe size in bytes of the copy
Returns
PI_OK if the operation is successfull, PI_ERR_INVALID_ARG if adress is out of range.
static pi_err_t pi_partition_read_async ( const pi_partition_t partition,
const uint32_t  partition_addr,
void *  data,
const size_t  size,
pi_task_t *  task 
)
inlinestatic

The copy will make a transfer between the flash partition and one of the processor memory areas. A task must be specified in order to specify how the caller should be notified when the transfer is finished. Depending on the chip, there may be some restrictions on the memory which can be used. Check the chip-specific documentation for more details.

Parameters
partitionThe partition descriptor on which to do the copy.
partition_addrThe address of the copy in the partition.
dataThe buffer address of the copy.
sizeThe size in bytes of the copy.
taskThe task used to notify the end of transfer. See the documentation of pi_task_t for more details.
Returns
PI_OK if the operation is successfull, PI_ERR_INVALID_ARG if adress is out of range.
void pi_partition_table_free ( pi_partition_table_t  table)
Parameters
tableA reference of the partition table to free.
pi_err_t pi_partition_table_load ( pi_device_t *  flash,
const pi_partition_table_t table 
)
Parameters
flashThe flash device in which to fetch the partition table.
tableA reference to the user table variable. if the return code is PI_OK, this pointer contains a reference to the new partition table.
Returns
PI_OK on success; PI_ERR_INVALID_ARG if the table pointer is NULL or if the flash device is invalid; PI_ERR_L2_NO_MEM if the allocation of the table in L2 memory fails; PI_ERR_NOT_FOUND if the partition table is not present on the flash device; PI_ERR_INVALID_VERSION if the format version of the partition table missmatch between flash data and BSP program; PI_ERR_INVALID_STATE if partition table MD5 missmatch (Partition table data corrupted).
static pi_err_t pi_partition_write ( const pi_partition_t partition,
const uint32_t  partition_addr,
const void *  data,
const size_t  size 
)
inlinestatic

The copy will make a write transfer from one of the processor memory areas to the partition. The locations in the flash being written should have first been erased. The caller is blocked until the transfer is finished. Depending on the chip, there may be some restrictions on the memory which can be used. Check the chip-specific documentation for more details.

Parameters
partitionThe partition descriptor on which to do the copy.
partition_addrThe address of the copy in the partition.
dataThe address of the copy in the processor.
sizeThe size in bytes of the copy
Returns
PI_OK if the operation is successfull, PI_ERR_INVALID_ARG if adress is out of range.
static pi_err_t pi_partition_write_async ( const pi_partition_t partition,
const uint32_t  partition_addr,
const void *  data,
const size_t  size,
pi_task_t *  task 
)
inlinestatic

The copy will make a transfer between the flash partition and one of the processor memory areas.

A task must be specified in order to specify how the caller should be notified when the transfer is finished. Depending on the chip, there may be some restrictions on the memory which can be used. Check the chip-specific documentation for more details.

Parameters
partitionThe partition descriptor on which to do the copy.
partition_addrThe address of the copy in the partition.
dataThe buffer address of the copy.
sizeThe size in bytes of the copy.
taskThe task used to notify the end of transfer. See the documentation of pi_task_t for more details.
Returns
PI_OK if the operation is successfull, PI_ERR_INVALID_ARG if adress is out of range.