int libmem_register_cfi_driver(libmem_driver_handle_t *h,
                               uint8_t *start,
                               libmem_geometry_t *geometry,
                               int max_geometry_regions,
                               libmem_flash_info_t *flash_info);

libmem_register_cfi_driver registers a FLASH driver based on detected CFI information.

h — A pointer to the LIBMEM handle structure to use for this LIBMEM driver.

start — The start address of the FLASH memory.

geometry — A pointer to the memory location to store the geometry description.

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.

libmem_register_cfi_driver returns — The LIBMEM status result.

This function calls libmem_cfi_get_info to detect the type and geometry of the the FLASH pointed to by start and then, if the FLASH memory is supported, registers an appropriate LIBMEM driver for the FLASH.

Use of this function requires all supported CFI LIBMEM drivers to be linked in, therefore if memory is at a premium you should register only the LIBMEM FLASH driver you require instead of using this function.


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];
libmem_driver_handle_t flash1_handle;
int res;

res = libmem_register_cfi_driver(&flash1_handle,

  printf("libmem_register_cfi_driver : success\n");
  printf("libmem_register_cfi_driver : failed (%d)\n", res);