MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / fal_partition_write

Function fal_partition_write

components/fal/src/fal_partition.c:450–478  ·  view source on GitHub ↗

* write data to partition * * @param part partition * @param addr relative address for partition * @param buf write buffer * @param size write size * * @return >= 0: successful write data size * -1: error */

Source from the content-addressed store, hash-verified

448 * -1: error
449 */
450int fal_partition_write(const struct fal_partition *part, rt_uint32_t addr, const rt_uint8_t *buf, rt_size_t size)
451{
452 int ret = 0;
453 const struct fal_flash_dev *flash_dev = NULL;
454
455 RT_ASSERT(part);
456 RT_ASSERT(buf);
457
458 if (addr + size > part->len)
459 {
460 LOG_E("Partition write error! Partition address out of bound.");
461 return -1;
462 }
463
464 flash_dev = flash_device_find_by_part(part);
465 if (flash_dev == NULL)
466 {
467 LOG_E("Partition write error! Don't found flash device(%s) of the partition(%s).", part->flash_name, part->name);
468 return -1;
469 }
470
471 ret = flash_dev->ops.write(part->offset + addr, buf, size);
472 if (ret < 0)
473 {
474 LOG_E("Partition write error! Flash device(%s) write error!", part->flash_name);
475 }
476
477 return ret;
478}
479
480/**
481 * erase partition data

Callers 15

blk_dev_writeFunction · 0.85
mtd_nor_dev_writeFunction · 0.85
char_dev_writeFunction · 0.85
char_dev_fwriteFunction · 0.85
falFunction · 0.85
fal_ops_testFunction · 0.85
fal_testFunction · 0.85
ef_port_writeFunction · 0.85
fal_sampleFunction · 0.85
flash64k_testFunction · 0.85
flash32k_testFunction · 0.85
ef_port_writeFunction · 0.85

Calls 2

writeMethod · 0.45

Tested by 1

fal_sampleFunction · 0.68