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

Function fal_partition_read

components/fal/src/fal_partition.c:409–437  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

407 * -1: error
408 */
409int fal_partition_read(const struct fal_partition *part, rt_uint32_t addr, rt_uint8_t *buf, rt_size_t size)
410{
411 int ret = 0;
412 const struct fal_flash_dev *flash_dev = NULL;
413
414 RT_ASSERT(part);
415 RT_ASSERT(buf);
416
417 if (addr + size > part->len)
418 {
419 LOG_E("Partition read error! Partition(%s) address(0x%08x) out of bound(0x%08x).", part->name, addr + size, part->len);
420 return -1;
421 }
422
423 flash_dev = flash_device_find_by_part(part);
424 if (flash_dev == NULL)
425 {
426 LOG_E("Partition read error! Don't found flash device(%s) of the partition(%s).", part->flash_name, part->name);
427 return -1;
428 }
429
430 ret = flash_dev->ops.read(part->offset + addr, buf, size);
431 if (ret < 0)
432 {
433 LOG_E("Partition read error! Flash device(%s) read error!", part->flash_name);
434 }
435
436 return ret;
437}
438
439/**
440 * write data to partition

Callers 15

blk_dev_readFunction · 0.85
mtd_nor_dev_readFunction · 0.85
char_dev_readFunction · 0.85
char_dev_freadFunction · 0.85
falFunction · 0.85
fal_ops_testFunction · 0.85
fal_testFunction · 0.85
ef_port_readFunction · 0.85
fal_sampleFunction · 0.85
flash64k_testFunction · 0.85
flash32k_testFunction · 0.85
ef_port_readFunction · 0.85

Calls 2

readMethod · 0.45

Tested by 1

fal_sampleFunction · 0.68