Applied the standard MIT license header to all project-owned C, header,
assembly, shell, and Python files that were missing a copyright notice.
Third-party, toolchain startup, and auto-generated files were excluded.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
WARNING: This feature is brand new and has not been tested beyond the
existing regression suite. It should be thoroughly tested — including
stress, power-loss, and wear-levelling scenarios — before being used in
any production system.
When LX_NAND_FLASH_ENABLE_LAZY_SECTOR_RELEASE is defined and free blocks
exceed LX_NAND_FLASH_SECTOR_RELEASE_LAZY_THRESHOLD (default 10), releasing
a sector from a full block defers the copy+erase. A tombstone page is
written to a freshly-allocated block; the old full block is flagged
COMPACTION_PENDING in its block status and recorded in a new per-LG
compaction table. Compaction (merge + erase) is triggered lazily:
* sector_write: before writing to a full block with a pending source
* block_data_move: intercepts wear-levelling moves for pending LGs
* defragment: iterates all pending LGs (now actually implemented)
* block_allocate: emergency compaction when the free list is empty
Reads transparently fall back to the compaction-pending block when the
primary block does not contain the requested sector.
Crash recovery is handled in open_extended:
- Phase 1: detects COMPACTION_PENDING blocks and either clears the flag
(crash before mapping update — abort) or rebuilds compaction_table
(crash after mapping update — resume deferred compaction).
- Phase 2: erases orphaned ALLOCATED blocks not present in any mapping.
Without the flag, all paths remain unchanged and defragment returns
LX_NOT_SUPPORTED as before.
Fixes: https://github.com/eclipse-threadx/levelx/issues/70
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
align the nand flash simulator against the PR #65
Tests:
Total Test time (real) = 6.33 sec
~/work/git_repos/github/eclipse/levelx_rahmanih/test/cmake
3/3 Test #1: default_build_coverage::levelx_nand_flash_test ........ Passed 44.06 sec
100% tests passed, 0 tests failed out of 3
for each erased block write the word (1 | LX_NOR_ERASED) at the
first word. this is actually equivalent to 0x80000001.
When the lx_nor_flash_open_extended() is called, only the erase count will remain
valid.
Remove the LX_DISABLE/LX_RESTORE sequence.
New APIs:
- lx_nor_flash_format(): setup the NOR Flash for a new and fresh filesystem.
- lx_nor_flash_open_extended(): adds a user data pointer that could be passed to the underlying low-level NOR driver.
- lx_nand_flash_open_extended(): adds a user data pointer that could be passed to the underlying low-level NAND driver.
Updated APIs:
- lx_nor_flash_open(): call the lx_nor_flash_open_extended() with a NULL as user data pointer.
- lx_nand_flash_open(): call the lx_nand_flash_open_extended() with a NULL as user data pointer.
New APIs
--------
- lx_nor_flash_format(): erases nor flash blocks and setup block metadata
- lx_nor_flash_open_extended(): same as lx_nor_flash_open() with
user data pointer a last argument.
- lx_nand_flash_open_extended(): same as lx_nand_flash_open() with
user data pointer a last argument.
Updates
-------
- lx_nor_flash_open(): calls lx_nor_flash_open_extended() with a NULL as
last argument
- lx_nand_flash_open(): calls lx_nand_flash_open_extended() with a NULL as
last argument
- regression tests: to call the lx_nor_flash_format()
Test results
-------------
100% tests passed, 0 tests failed out of 3
Total Test time (real) = 6.27 sec
3/3 Test #1: standalone_free_sector_verify_build::levelx_nand_flash_test ........ Passed 6.29 sec
100% tests passed, 0 tests failed out of 3
Total Test time (real) = 6.29 sec
3/3 Test #1: nor_obsolete_mapping_cache_build::levelx_nand_flash_test ........ Passed 6.58 sec
100% tests passed, 0 tests failed out of 3
Total Test time (real) = 6.58 sec
3/3 Test #1: nor_obsolete_cache_build::levelx_nand_flash_test ........ Passed 6.67 sec
100% tests passed, 0 tests failed out of 3
Total Test time (real) = 6.67 sec
3/3 Test #1: nor_mapping_cache_build::levelx_nand_flash_test ........ Passed 6.77 sec
100% tests passed, 0 tests failed out of 3
Total Test time (real) = 6.78 sec
3/3 Test #1: full_build::levelx_nand_flash_test ........ Passed 6.91 sec
100% tests passed, 0 tests failed out of 3
Total Test time (real) = 6.91 sec
3/3 Test #1: free_sector_verify_build::levelx_nand_flash_test ........ Passed 7.14 sec
100% tests passed, 0 tests failed out of 3
Total Test time (real) = 7.14 sec
3/3 Test #1: standalone_full_build::levelx_nand_flash_test ........ Passed 7.21 sec
100% tests passed, 0 tests failed out of 3
Total Test time (real) = 7.21 sec
3/3 Test #1: standalone_build::levelx_nand_flash_test ........ Passed 12.05 sec
100% tests passed, 0 tests failed out of 3
Total Test time (real) = 12.06 sec
3/3 Test #1: default_build_coverage::levelx_nand_flash_test ........ Passed 48.78 sec
100% tests passed, 0 tests failed out of 3
Total Test time (real) = 48.81 sec
Add new levelx APIs
New APIs
--------
- lx_nor_flash_format(): erases nor flash blocks and setup block metadata
- lx_nor_flash_open_extended(): same as lx_nor_flash_open() with
user data pointer a last argument.
- lx_nand_flash_open_extended(): same as lx_nand_flash_open() with
user data pointer a last argument.
Updates
-------
- lx_nor_flash_open(): calls lx_nor_flash_open_extended() with a NULL as
last argument
- lx_nand_flash_open(): calls lx_nand_flash_open_extended() with a NULL as
last argument
- regression tests: to call the lx_nor_flash_format()
Test results
-------------
100% tests passed, 0 tests failed out of 3
Total Test time (real) = 6.27 sec
3/3 Test #1: standalone_free_sector_verify_build::levelx_nand_flash_test ........ Passed 6.29 sec
100% tests passed, 0 tests failed out of 3
Total Test time (real) = 6.29 sec
3/3 Test #1: nor_obsolete_mapping_cache_build::levelx_nand_flash_test ........ Passed 6.58 sec
100% tests passed, 0 tests failed out of 3
Total Test time (real) = 6.58 sec
3/3 Test #1: nor_obsolete_cache_build::levelx_nand_flash_test ........ Passed 6.67 sec
100% tests passed, 0 tests failed out of 3
Total Test time (real) = 6.67 sec
3/3 Test #1: nor_mapping_cache_build::levelx_nand_flash_test ........ Passed 6.77 sec
100% tests passed, 0 tests failed out of 3
Total Test time (real) = 6.78 sec
3/3 Test #1: full_build::levelx_nand_flash_test ........ Passed 6.91 sec
100% tests passed, 0 tests failed out of 3
Total Test time (real) = 6.91 sec
3/3 Test #1: free_sector_verify_build::levelx_nand_flash_test ........ Passed 7.14 sec
100% tests passed, 0 tests failed out of 3
Total Test time (real) = 7.14 sec
3/3 Test #1: standalone_full_build::levelx_nand_flash_test ........ Passed 7.21 sec
100% tests passed, 0 tests failed out of 3
Total Test time (real) = 7.21 sec
3/3 Test #1: standalone_build::levelx_nand_flash_test ........ Passed 12.05 sec
100% tests passed, 0 tests failed out of 3
Total Test time (real) = 12.06 sec
3/3 Test #1: default_build_coverage::levelx_nand_flash_test ........ Passed 48.78 sec
100% tests passed, 0 tests failed out of 3
Total Test time (real) = 48.81 sec
fix: Write the correct meta data on the block after erase
add missing nand_flash_format_extended API
Fix description
----------------
add missing checks on the index of nor_flash -> lx_nor_flash_extended_cache[i]
Fixes Issue#58
Signed-off-by: Haithem Rahmani <haithem.rahmani@st.com>
Fix description
----------------
add missing checks on the index of nor_flash -> lx_nor_flash_extended_cache[i]
Fixes Issue#58
Signed-off-by: Haithem Rahmani <haithem.rahmani@st.com>