Function esp_idf_svc::hal::sys::esp_partition_write

source ·
pub unsafe extern "C" fn esp_partition_write(
    partition: *const esp_partition_t,
    dst_offset: usize,
    src: *const c_void,
    size: usize,
) -> i32
Expand description

@brief Write data to the partition

Before writing data to flash, corresponding region of flash needs to be erased. This can be done using esp_partition_erase_range function.

Partitions marked with an encryption flag will automatically be written via the esp_flash_write_encrypted() function. If writing to an encrypted partition, all write offsets and lengths must be multiples of 16 bytes. See the esp_flash_write_encrypted() function for more details. Unencrypted partitions do not have this restriction.

@param partition Pointer to partition structure obtained using esp_partition_find_first or esp_partition_get. Must be non-NULL. @param dst_offset Address where the data should be written, relative to the beginning of the partition. @param src Pointer to the source buffer. Pointer must be non-NULL and buffer must be at least ‘size’ bytes long. @param size Size of data to be written, in bytes.

@note Prior to writing to flash memory, make sure it has been erased with esp_partition_erase_range call.

@return ESP_OK, if data was written successfully; ESP_ERR_INVALID_ARG, if dst_offset exceeds partition size; ESP_ERR_INVALID_SIZE, if write would go out of bounds of the partition; ESP_ERR_NOT_ALLOWED, if partition is read-only; or one of error codes from lower-level flash driver.