Skip to content

Conversation

@zhaoxingyu12
Copy link
Contributor

@zhaoxingyu12 zhaoxingyu12 commented Jan 23, 2026

Note: Please adhere to Contributing Guidelines.

Summary

Modify the Kconfig name of the mtdconfig module

  1. MTD_CONFIG_FAIL_SAFE has been renamed to MTD_CONFIG_NVS, and the Kconfig configuration for MTD_CONFIG submodules has been optimized.
    If MTD_CONFIG is enabled, mtd_config.c will be used;
    if MTD_CONFIG_NVS is enabled, mtd_config_nvs.c will be used;
    if neither is enabled, setting MTD_CONFIG_NONE=y.
    These changes are made to facilitate the integration of other mtd_config submodules.

  2. All mtd_config submodules should add the mtdconfig_register_by_path and mtdconfig_unregister_by_path APIs. The new mtdconfig_register_by_path and mtdconfig_unregister_by_path APIs allow dynamic registration and unregistration of mtdconfig devices by device path, improving the flexibility of device management.

  3. The device dependencies have been adjusted: if MTD_CONFIG is required, it now needs to be set with ifndef CONFIG_MTD_CONFIG_NONE, etc.

Impact

These changes significantly improve the usability and maintainability of the mtdconfig subsystem. By supporting device registration and unregistration by path, developers can manage devices more dynamically and flexibly, adapting to a wider range of application scenarios.
The improvements to the Kconfig options make the configuration interface more user-friendly and the dependencies more intuitive, which is helpful for future feature expansion and maintenance. Overall, these patches enhance the flexibility, reliability, and user experience of mtdconfig.

Testing

test it by CICT together with apache/nuttx-apps#3371

I have conducted tests with CFGDATA on QEMU, and the test results are in line with expectations.

enabled these configurations.
CONFIG_MTD_CONFIG_NVS=y
CONFIG_SYSTEM_CFGDATA=y
CONFIG_MTD_CONFIG_NAMED=y

register lomtdconfig
dd if=/dev/zero of=/data/nvs.img bs=8192 count=10
lomtd -c 2 /dev/config /data/nvs.img

test pass
goldfish-armv7a-ap> cfgdata print mykey
Error reading config entry 'mykey'
goldfish-armv7a-ap> cfgdata set mykey "myvalue"
goldfish-armv7a-ap>
goldfish-armv7a-ap> cfgdata print mykey
myvalue
goldfish-armv7a-ap> cfgdata all
Name Len Data
mykey 8 myvalue

@zhaoxingyu12
Copy link
Contributor Author

====================================================================================
Configuration/Tool: esp32c3-legacy-devkit/nvcfgdata
2026-01-23 03:19:45

Cleaning...
Configuring...
Building NuttX...
[1/1] Normalize esp32c3-legacy-devkit/nvcfgdata
46d45
< CONFIG_SYSTEM_CFGDATA=y
48d46
< CONFIG_TESTING_MTD_CONFIG_FAIL_SAFE=y
Saving the new configuration file
HEAD detached at pull/18120/merge
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git restore ..." to discard changes in working directory)
modified: boards/risc-v/esp32c3-legacy/esp32c3-legacy-devkit/configs/nvcfgdata/defconfig

no changes added to commit (use "git add" and/or "git commit -a")

report this error, because it needs CICT together with apache/nuttx-apps#3371
in nuttx-apps, it's config has changed to the following depends on, and MTD_CONFIG_NVS enabled @xiaoxiang781216
config SYSTEM_CFGDATA
tristate "Cfgdata Command"
default n
depends on !MTD_CONFIG_NONE

config TESTING_MTD_CONFIG_FAIL_SAFE
tristate "MTD Config fail-safe storage test"
default n
depends on MTD_CONFIG_NVS

@zhaoxingyu12 zhaoxingyu12 force-pushed the mtdconfig_name branch 2 times, most recently from 7f1abc1 to 8463e9a Compare January 25, 2026 02:01
change filename  mtd/mtd_config_fs.c to mtd/mtd_config_nvs.c
and optimize the configuration related to mtdconfig

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
The structure of mtd_config in Kconfig has changed.

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
…y_path api

mtd_config/mtd_config_nvs should all support
mtdconfig_register_by_path/mtdconfig_unregister_by_path api

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
For the MTD_CONFIG configuration item in
drivers/mtd/Kconfig has changed.

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
change nvs module testcase name TESTING_MTD_CONFIG_FAIL_SAFE
to CONFIG_TESTING_MTD_CONFIG_NVS

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Drivers Drivers issues Area: File System File System issues Board: arm Board: risc-v Size: M The size of the change in this PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants