History: media_drv_ftl_base

This page describes all changes made to the media_drv_ftl_base package, SafeFTL, since its release.


5.29 (2021-06-10, 11:55):

  • FTL initialization reports error if management data is invalid: FTL could return sectors containing invalid data in case of an invalid LOG block (pages followed by an invalid first page in a data block were considered valid).

5.28 (2021-03-08, 10:24):

  • MDRIVER_ERR_IOCTL_MSG_NOT_SUPPORTED is returned for non supported IOCTL options.

5.27 (2020-11-03, 14:49):

  • The value of MDRIVER_FTL_COPY_LAST_PAGE is only feasible if it is less than the number of pages within a flash block. FTL initialization might have failed with MDRIVER_FTL_COPY_LAST_PAGE set to a value bigger than that. This version introduces a fix for this, maximizing the effective setting in (Nr. of pages per block) - 1. Consider a flash with, say, 64 pages per block: 64 or any value bigger than that will be considered 63.

5.26 (2020-07-16, 10:11):

  • MDRIVER_FTL_COPY_LAST_PAGE feature improvement: the flash page to be re-written at FTL initialization (the page written last during the previous power cycle) might have been read more than once from the flash, with possibly different outcomes (reading a weakly programmed page might fail or succeed, and it is not possible that the behaviour changes during FTL's initialization process). This phenomenon has been eliminated, resulting in a more robust initialization if there is no proper brown-out detection in the system but MDRIVER_FTL_COPY_LAST_PAGE is enabled.

5.25 (2020-04-27, 19:00):

  • Added ftl_idle_erase() API to manually schedule background erase in idle time. API is available if MDRIVER_FTL_IDLE_ERASE configuration option is set and MDRIVER_FTL_IDLE_ERASE_USE_TASK is cleared.

5.24 (2020-04-03, 11:05):

  • Compiler warnings were eliminated.

5.23 (2020-02-21, 13:51):

  • Added MDRIVER_FTL_HLAYER_NONSTD_PAGE_SIZE option: allows handling non-power of two size pages.

5.22 (2019-12-11, 11:42):

  • Errors from the low-level driver were not handled properly and as a result the error could not be detected at the media driver layer. If an error occurs during the merge of log block, the media becomes read-only.
  • Eliminated  compiler error that occurred when MDRIVER_FTL_IDLE_ERASE was enabled.

5.21 (2019-11-26, 16:22):

  • Low-level driver was not released when the media driver was released. This left the low-level driver uninitialized after the media driver was released then re-initialized.

5.20 (2019-10-18, 17:04):

  • Static analysis issue eliminated.

5.19 (2019-04-10, 17:18):

  • Superfluous low level driver initialization calls are eliminated.

5.18 (2018-02-26, 16:22):

  • Storage class of get_mapblock() fixed.
  • Prototypes for static functions added.

5.17 (2018-02-23, 12:28):

  • calc_alloc_mem() was refactored to avoid NULL-pointer de-reference when high optimization is used in IAR 7.80.4.

5.16 (2017-10-20, 13:16):

  • ml_format() function updated to support pre-programmed images.


  • MDRIVER_FTL_COPY_LAST_PAGE configuration option added; when this is enabled FTL will search for the last written page during initialization and make a copy of it.


  • Include path of psp_types.h fixed.
  • Supports 64 bit environments.


  • Static analyzer (CodeSonar) warnings were eliminated.
  • psp_types.h is included instead of stdint.h.


  • Compiler warnings eliminated.


  • FTL_SSD: MDRIVER_FTL_FAST_INIT (psp_ftl_nvram interface) supports multiple volumes.


  • FTL_SSD: background merge feature and MDRIVER_FTL_BACKGROUND_MERGE config option added.


  • Internal data structure reorganized to eliminate compiler warnings.


  • FTL_SSD: FTL_ALLOW_NVRAM_FORMAT init option added.  When MDRIVER_FTL_FAST_INIT is set and ftl_initfunc() is called with this init option it will start without valid NVRAM content and format NVRAM at the end of the initialization.


  • ftl_initfunc() works when read-only flag is used.
  • MDRIVER_FTL_FAST_INIT config option added to allow FTL to store map block locations into dedicated non-volatile memory which may be used later by ftl_initfunc() to speed up FTL volume initialization.
  • Maximum map block count limited to 8, previously higher number was accepted from the low level driver causing incorrect operation.


  • Inline code eliminated.


  • FTL failed to work correctly if a driver returned LL_REWRITE from ll_read (triggers rewrite of a block if required by the driver) when MDRIVER_FTL_REWRITE wasn't enabled.
  • MDRIVER_FTL_DATABLOCK_LOGGING option added - extra LOG pages will be allocated at the end of data blocks to speed up random write.
  • MDRIVER_FTL_CACHE_WRITE option added - contiguous write will be speeded up if the NAND and the driver support the "PROGRAM PAGE CACHE" command.
  • MDRIVER_FTL_MULTILUN option added - if MDRIVER_FTL_CACHE_WRITE is set FTL will use "PROGRAM PAGE CACHE" during merge if the destination block is on a different LUN/chip.


  • issue fixed in ftldrv.c when compiling without HLAYER.


  • block rewrite feature introduced. If the physical layer driver reports LL_REWRITE after a read the affected block will be scheduled for rewrite. The frequency of rewrite operations may be limited by the newly introduced t_ftl_phy.rewrite_interval parameter on a per-volume basis.


  • ml_lowinit() sets t_ftl_phy.wear_static_limit and .wear_static_count fields to default values before calling low-level driver's getphy() function - this helps make old NAND drivers compatible with

FTL v5.x.


  • ftl_erase() added: it erases all blocks on a given media which aren't marked as bad.
  • ftl_stats() function added for retrieving statistics about mounted FTL volumes.
  • ftl_get_blockinfo() function added for retrieving wear and address info   of selected blocks.
  • wear_static_limit and wear_static_count fields added to t_ftl_phy; these values are now independently configurable for different low-level drivers.


  • FTL handles all FLASH read and write errors: it reports all errors to the application, in some critical cases it also makes the volume read-only to prevent more errors to cause data corruption.


  • Format failed for NAND flashes with factory bad blocks, as it incorrectly became read-only.


  • drive becomes and remains read-only when flash media reaches end-of-life.
  • ftldrive_getmem() and ftldrive_setmem() functions reorganized.


  • ftldrive_setmem() returns error code if the physical layer driver initialization failed.
  • "variable might be used uninitialized" warning removed from ftldrive_setmem().


  • MDRIVER_FTL_IDLE_ERASE config option added.
  • When MDRIVER_FTL_IDLE_ERASE is set, FTL will create a low-priority background task which will do the erase operations. The underlying physical layer driver must handle the situation when an erase operation is still in progress and a read/write request arrives.


  • Compiler warnings were eliminated (warnings occurred in 16-bit environment).

3.1 r2:

  • documentation updated to v1.03.


  • ftl_format() automatically erases the media and retries the format if the first attempt failed.  
  • ftl_initfunc() can be instructed to automatically format an unformatted media by setting the FTL_ALLOW_FORMAT bit in the driver_param argument.

3.0 r3:

  • documentation updated to v1.02.


  • api_mdriver_ftl.h: t_ftl_phy simplified, drivers don't need to report n_fragpermap and n_max_frag anymore.
  • ml_types.h: redundantly used fields removed from t_ml_volume and t_ll_data structures.




  • ftldrive_getmem() fixed, other cosmetic changes.


  • Memory allocation for FTL drives now goes through ftldrive_getmem() and ftldrive_setmem() calls. config_mdriver_ftl_init.c and config_mdriver_ftlnor_init.c contain drive number and driver assignment.


  •  FTL now supports more than 254 free blocks.
  •  MDRIVER_FTL_MAX_FREE_BLOCKS config value introduced.


  • ftl_release warnings fixed.


  • Initial release in new source tree with support for multiple FTL volumes and big blocks.