Skip to content

NFTL Disk Driver#100858

Merged
MaureenHelm merged 5 commits intozephyrproject-rtos:mainfrom
endresshauser-lp:ftl_dhara
Mar 18, 2026
Merged

NFTL Disk Driver#100858
MaureenHelm merged 5 commits intozephyrproject-rtos:mainfrom
endresshauser-lp:ftl_dhara

Conversation

@LinderPi
Copy link
Copy Markdown
Contributor

Zephyr has currently no flash translation layer implemented. This pull request adds the basic possibility to use Dhara as FTL in Zephyr. It is implemented as disk driver that can be placed between a filesystem and a flash driver. The FTL uses API extensions for bad block management, which are also faked on the flash simulator to facilitate tests.

The Dhara repository shall be moved to the Zephyr organisation as soon as the module is ready for that (#99908, #100834).

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 11, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
dhara 🆕 N/A (Added) zephyrproject-rtos/dhara@6f163ca (zephyr) N/A

DNM label due to: 1 added project

Note: This message is automatically posted and updated by the Manifest GitHub Action.

Comment thread drivers/flash/flash_simulator.c Outdated
Comment thread include/zephyr/drivers/flash/nand_flash_api_ex.h Outdated
Comment thread modules/dhara/Kconfig Outdated
Comment thread drivers/flash/flash_simulator.c Outdated
Comment thread drivers/disk/ftl_dhara.c Outdated
Comment thread drivers/disk/ftl_dhara.c Outdated
Comment thread drivers/disk/ftl_dhara.c Outdated
Comment thread drivers/disk/ftl_dhara.c Outdated
Comment thread drivers/disk/ftl_dhara.c Outdated
Comment thread drivers/disk/ftl_dhara.c Outdated
@tpambor tpambor requested a review from de-nordic March 12, 2026 09:18
tpambor and others added 2 commits March 13, 2026 19:02
Add extended operations to the flash API to support marking blocks
as bad and checking if a block is bad. This is necessary for
NAND flash devices, which can have bad blocks that need to be managed.

Signed-off-by: Pascal Linder <pascal.linder@zuehlke.com>
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
NAND flash translation layers require the flash extended operations API
for bad block management. Add it here without implementation to test an
FTL on the flash simulator.

Signed-off-by: Pascal Linder <pascal.linder@zuehlke.com>
de-nordic
de-nordic previously approved these changes Mar 13, 2026
@tpambor
Copy link
Copy Markdown
Contributor

tpambor commented Mar 13, 2026

@de-nordic can the DNM (manifest) be removed?

@kartben kartben removed the DNM (manifest) This PR should not be merged (controlled by action-manifest) label Mar 15, 2026
Comment on lines -112 to +118
#define FF_VOLUME_STRS \
DT_FOREACH_STATUS_OKAY(zephyr_flash_disk, _FF_DISK_NAME) \
DT_FOREACH_STATUS_OKAY(zephyr_ram_disk, _FF_DISK_NAME) \
DT_FOREACH_STATUS_OKAY(zephyr_sdmmc_disk, _FF_DISK_NAME) \
DT_FOREACH_STATUS_OKAY(zephyr_mmc_disk, _FF_DISK_NAME) \
DT_FOREACH_STATUS_OKAY(st_stm32_sdmmc, _FF_DISK_NAME)
#define FF_VOLUME_STRS \
DT_FOREACH_STATUS_OKAY(zephyr_flash_disk, _FF_DISK_NAME) \
DT_FOREACH_STATUS_OKAY(zephyr_ram_disk, _FF_DISK_NAME) \
DT_FOREACH_STATUS_OKAY(zephyr_sdmmc_disk, _FF_DISK_NAME) \
DT_FOREACH_STATUS_OKAY(zephyr_mmc_disk, _FF_DISK_NAME) \
DT_FOREACH_STATUS_OKAY(st_stm32_sdmmc, _FF_DISK_NAME) \
DT_FOREACH_STATUS_OKAY(zephyr_ftl_dhara, _FF_DISK_NAME)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stray changes, have nothing to do with "modules: dhara: Implement Dhara disk driver as Zephyr module"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have split them off into separate commit.

Comment thread dts/bindings/disk/zephyr,ftl-dhara.yaml Outdated
Comment on lines +22 to +35
buffer-size:
type: int
required: true
description: |
Buffer size in bytes for the FTL driver. Must be equal or greater than the page size of the
backing flash.

gc-ratio:
type: int
default: 15
description: |
Garbage collection ratio for the FTL driver. This is the ratio of garbage collection
operations to real writes when automatic collection is active. Smaller values lead to faster
and more predictable input/output at the expense of capacity.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both properties sound like they are software configurations. Do they need to be configurable per instance, or can they be Kconfig options?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buffer-size is somewhat hardware related as it has to be at least the size of a page of the flash. So, if one has multiple flashes with different page sizes and this is a KConfig one has to set it to the largest and would ovetallocate for the smaller flash. This was the motivation to have it in DT. zephyr,flash-disk has similar properties with cache-size and sector-size. I have no strong opinion here, if a KConfig is preferable, I can change it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about gc-ratio does it make sense to be configurable per driver instance?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have switched gc-ratio to a KConfig. The GC ratio trades off write amplification for available capacity. The capacity for rewritable blocks is the number of pages times 1/(ratio+1), and the write amplification factor is (ratio+1). I don't think this needs to be configured per instance.

@github-actions github-actions Bot added the DNM (manifest) This PR should not be merged (controlled by action-manifest) label Mar 16, 2026
@tpambor tpambor removed the DNM (manifest) This PR should not be merged (controlled by action-manifest) label Mar 16, 2026
tpambor added 3 commits March 16, 2026 23:15
Zephyr has currently no flash translation layer implemented. This commit
adds the basic possibility to use Dhara as FTL in Zephyr. It is
implemented as disk driver that can be placed between a filesystem and a
flash driver.

Signed-off-by: Pascal Linder <pascal.linder@zuehlke.com>
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Add disk names for zephyr,ftl-dhara disks to FF_VOLUME_STRS, so that
they are available for mounting.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Add testcase and corresponding overlay for native_sim to test
the FTL (Flash Translation Layer) disk driver.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
@github-actions github-actions Bot added the DNM (manifest) This PR should not be merged (controlled by action-manifest) label Mar 16, 2026
@tpambor tpambor removed the DNM (manifest) This PR should not be merged (controlled by action-manifest) label Mar 16, 2026
@sonarqubecloud
Copy link
Copy Markdown

@tpambor
Copy link
Copy Markdown
Contributor

tpambor commented Mar 18, 2026

@jfischer-no Please take another look, all comments have been addressed

Copy link
Copy Markdown
Contributor

@de-nordic de-nordic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks.

@carlescufi
Copy link
Copy Markdown
Member

@tpambor I now added the "Override required" label since this must be merged with override due to a new module being added.

@MaureenHelm MaureenHelm merged commit 02672c5 into zephyrproject-rtos:main Mar 18, 2026
33 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants