pub unsafe extern "C" fn flash_flatten(
dev: *const device,
offset: i32,
size: usize,
) -> i32
Expand description
@brief Erase part or all of a flash memory or level it
If device is explicit erase type device or device driver provides erase callback, the callback of the device is called, in which it behaves the same way as flash_erase. If a device does not require explicit erase, either because it has no erase at all or has auto-erase/erase-on-write, and does not provide erase callback then erase is emulated by leveling selected device memory area with erase_value assigned to device.
Erase page offset and size are constrains of paged, explicit erase devices, but can be relaxed with devices without such requirement, which means that it is up to user code to make sure they are correct as the function will return on, if these constrains are not met, -EINVAL for paged device, but may succeed on non-explicit erase devices. For RAM non-volatile devices the erase pages are emulated, at this point, to allow smooth transition for code relying on device being paged to function properly; but this is completely software constrain.
Generally: if your code previously required device to be erase prior to some actions to work, replace flash_erase calls with this function; but if your code can work with non-volatile RAM type devices, without emulating erase, you should rather have different path of execution for page-erase, i.e. Flash, devices and call flash_erase for them.
@param dev : flash device @param offset : erase area starting offset @param size : size of area to be erased
@return 0 on success, negative errno code on fail.
@see flash_erase()