- Flash *fd = FLASH_CAST(_fd);
- ASSERT(fd->fd.seek_pos + (kfile_off_t)size <= (kfile_off_t)fd->fd.size);
- size = MIN((kfile_off_t)size, fd->fd.size - fd->fd.seek_pos);
-
- LOG_INFO("Reading at pos[%u]\n", fd->fd.seek_pos);
- // Flush current buffered page (if modified).
- flash_avr_flush(fd);
-
- /*
- * AVR pointers are 16 bits wide, this hack is needed to avoid
- * compiler warning, cause fd->seek_pos is a 32bit offset.
- */
- const uint8_t *pgm_addr = (const uint8_t *)0;
- pgm_addr += fd->fd.seek_pos;
-
- memcpy_P(buf, pgm_addr, size);
- fd->fd.seek_pos += size;
- LOG_INFO("Read %u bytes\n", size);
- return size;
+ common_init(fls);
+ fls->blk.priv.vt = &flash_avr_buffered_vt;
+ fls->blk.priv.flags |= KB_BUFFERED | KB_PARTIAL_WRITE;
+ fls->blk.priv.buf = flash_buf;