levelx

v6.4.5.202504_rel
LevelX is a specialized flash wear leveling library for embedded systems, providing management for both NAND and NOR flash memory. It presents a logical sector interface to applications while transparently managing physical flash constraints, ensuring even distribution of erase cycles and robust fault tolerance during power interruptions.

Features

  • Support for both NAND and NOR flash memory types with specialized management modules.

  • Wear leveling algorithms that distribute flash usage evenly to extend hardware longevity.

  • Logical-to-physical sector mapping for transparent application and file system access.

  • Fault-tolerant design using a multi-step update process to ensure recovery after power loss.

  • Seamless integration with the FileX FAT-compatible file system for flash-based storage.

  • Standalone mode support allowing operation without the ThreadX RTOS.

  • Configurable NOR flash direct read option to bypass driver routines for higher performance.

  • Extended cache support for NOR flash to improve sector access and mapping speeds.

  • Logical sector mapping cache with configurable sizes to balance memory use and performance.

  • Thread-safe operation through optional integration with ThreadX mutex objects.

  • NAND flash metadata block management with configurable allocation limits.

  • Free sector data verification logic to ensure NOR flash integrity during initialization.

  • Mapping bitmap support in extended cache for efficient physical sector tracking.

  • Obsolete count cache for NOR flash to optimize garbage collection and erase cycles.

  • Customizable logical sector sizes for NOR flash to match specific application requirements.

  • User-definable extensions for NAND and NOR flash control blocks for custom metadata.

LevelX acts as a middleware layer between an application (or file system like FileX) and the underlying flash hardware driver. Its primary responsibility is to manage the physical constraints of flash memory, specifically the finite number of erase cycles and the requirement to erase blocks before rewriting. It implements a logical-to-physical mapping system where the application sees a contiguous array of logical sectors, while LevelX manages their actual placement on the physical media.

The architecture is designed for robustness; flash updates are performed in discrete steps, allowing the system to recover to a consistent state if interrupted by power failure. It includes specific modules for NAND and NOR flash, reflecting their different operational characteristics, such as block-based versus word-based access and the handling of spare areas in NAND devices.

Core Components

  • NOR Management: Handles word-aligned access, sector mapping, and optional extended caching mechanisms.
  • NAND Management: Manages block-based access, spare area/metadata, and bad block management.
  • Mapping Layer: Translates logical sector addresses to physical flash offsets using internal tables.
  • Cache Engine: Provides optional sector mapping and data caching to reduce physical I/O overhead.
  • Driver Interface: Standardized API for hardware-specific flash drivers to perform read, write, and erase operations.

Use Cases

This library is ideal for:

  • Data Logging: Systems requiring frequent writes to flash memory where wear leveling is critical to prevent premature hardware failure.
  • Embedded File Systems: Providing a reliable backend for FileX or other FAT-based systems on raw NAND/NOR flash chips.
  • Fault-Tolerant Storage: Applications operating in unstable power environments where data integrity during write operations is paramount.
  • Resource-Constrained Devices: Deeply embedded systems needing a small-footprint wear leveling solution without the overhead of a full OS.

Getting Started

To integrate LevelX, developers should first clone the repository recursively and include the common directory in their build system. Configuration is handled via the lx_user.h file (based on the provided lx_user_sample.h), where features like LX_THREAD_SAFE_ENABLE or LX_STANDALONE_ENABLE can be defined. For CMake-based projects, LevelX can be added using add_subdirectory() and linked against the application target. Detailed API documentation for NAND and NOR operations, including driver implementation requirements, can be found in the official LevelX documentation.

Related Projects (11)

View All 11 Projects →
Eclipse ThreadX IoT DevKit Starter Application

Eclipse ThreadX IoT DevKit Starter Application

A foundational starter application for the MXChip AZ3166 IoT DevKit based on the Eclipse ThreadX RTOS and NetX Duo network stack. It provides a preconfigured environment for the STM32F412RG MCU, enabling WiFi connectivity and peripheral access for embedded IoT development.

threadx filexguixeclipse-threadx-levelx
14

STM32CubeN6 MCU Firmware Package

A comprehensive embedded software platform for the STM32N6 series microcontrollers. It provides HAL and LL drivers, CMSIS modules, and a full middleware stack featuring Azure RTOS (ThreadX), USBX, and FileX. The package includes numerous examples and applications for STM32N6 evaluation and Nucleo boards.

threadx filexmcubooteclipse-threadx-levelx
51

X-CUBE-AZRTOS-F4 Azure RTOS Software Expansion for STM32Cube

A comprehensive software expansion package for the STM32F4 series that integrates the Microsoft Azure RTOS suite into the STM32Cube ecosystem. It provides a full middleware stack including ThreadX, NetXDuo, FileX, LevelX, and USBX, optimized for STM32 microcontrollers.

threadx filexeclipse-threadx-levelx
49

X-CUBE-AZRTOS-F7 Azure RTOS Software Expansion for STM32Cube

A comprehensive software expansion package that integrates the Microsoft Azure RTOS suite with the STM32F7 series of microcontrollers. It provides a full middleware stack including ThreadX, NetXDuo, FileX, LevelX, and USBX, along with ready-to-run examples for STM32F7 evaluation boards.

threadx filexeclipse-threadx-levelx

X-CUBE-AZRTOS-G0: Azure RTOS Software Expansion for STM32Cube

A comprehensive software expansion package for the STM32G0 series, integrating Microsoft Azure RTOS into the STM32Cube ecosystem. It provides a full suite of middleware including ThreadX, NetXDuo, FileX, LevelX, and USBX, along with hardware-specific drivers and ready-to-run examples for evaluation boards.

threadx filexeclipse-threadx-levelx

X-CUBE-AZRTOS-G4 Azure RTOS Software Expansion for STM32Cube

A comprehensive software expansion package that integrates the Microsoft Azure RTOS suite into the STM32Cube ecosystem for STM32G4 microcontrollers. It provides a full middleware stack including ThreadX, NetXDuo, FileX, LevelX, and USBX, along with hardware-specific porting and ready-to-run examples.

threadx filexeclipse-threadx-levelx
13

X-CUBE-AZRTOS-H7 Azure RTOS Software Expansion

A comprehensive software expansion package for the STM32Cube ecosystem that integrates the Microsoft Azure RTOS suite with STM32H7 microcontrollers. It provides a full middleware stack including ThreadX, NetXDuo, FileX, LevelX, and USBX, along with hardware-specific drivers and ready-to-run examples for evaluation boards.

threadx filexeclipse-threadx-levelx
179

X-CUBE-AZRTOS-L4 Azure RTOS Software Expansion for STM32Cube

A comprehensive software expansion package for STM32Cube that integrates Microsoft Azure RTOS with the STM32L4 series of microcontrollers. It includes middleware components like ThreadX, NetXDuo, FileX, LevelX, and USBX, along with ready-to-run examples for evaluation boards.

threadx eclipse-threadx-levelxfilex