Choosing read() callout

In most cases, setting the callout pointer to NULL is sufficient. This causes the MTD to use memcpy() to read directly from flash. You need to write a custom read callout if your board has special read restrictions.

Here is an example:

#include <sys/f3s_mtd.h>

int32_t f3s_mtd_read(f3s_dbase_t *dbase,
                     f3s_access_t *access,
                     uint32_t flags,
                     uint32_t offset,
                     int32_t size,
                     uint8_t *buffer)
{
   uint8_t *memory;
   /* Set proper page on socket */
   memory = (uint8_t *)access->service->page(&access->socket,
                                             F3S_POWER_ALL, 
                                             offset, 
                                             NULL);
   if (memory == NULL)
   {
       fprintf(stderr, 
               "%s: %d page() returns NULL\n",
               __func__, 
               __LINE__);
       return (-1);
   }
   /* Replace this memcpy with your special handling code */
   memcpy(buffer, memory, size);
   return (size);
}