Synopsis
int libmem_cfi_get_info(uint8_t *start,
                        size_t *size,
                        libmem_geometry_t *geometry,
                        int max_geometry_regions,
                        libmem_flash_info_t *flash_info);
Description

libmem_cfi_get_info returns a FLASH memory device's common flash interface (CFI) information.

start — The start address of the FLASH memory.

size — A pointer to the memory location to store the size (in bytes) of the FLASH memory.

geometry — A pointer to the memory location to store the geometry description or NULL if not required.

max_geometry_regions — The maximum number of geometry regions that can be stored at the memory pointed to by geometry. The geometry description is NULL terminated so max_geometry_regions must be at least two regions in size in order to store one geometry region and one terminator entry.

flash_info — A pointer to the memory location to store the remaining FLASH information, or NULL if not required.

libmem_cfi_get_info returns — The LIBMEM status result.

This function attempts to return the FLASH device's type, size, geometry and other FLASH information from only a pointer to the first address the FLASH memory is located at. It uses the common flash memory interface (CFI) to obtain this information and therefore only works on FLASH devices that fully support this interface.

Example:

uint8_t *flash1_start = (uint8_t *)0x10000000;
libmem_flash_info_t flash1_info;
const int flash1_max_geometry_regions = 4;
libmem_geometry_t flash1_geometry[flash1_max_geometry_regions];
size_t flash1_size;
int res;

res = libmem_cfi_get_info(flash1_start,
                          &flash1_size,
                          flash1_geometry,
                          flash1_max_geometry_regions,
                          &flash1_info);

if (res == LIBMEM_STATUS_SUCCESS)
  printf("libmem_cfi_get_info : success\n");
else
  printf("libmem_cfi_get_info : failed (%d)\n", res);