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 2
This pull request makes two main adjustments to align with recent changes in the NuttX mtd_config module Kconfig.

  1. it renames MTD_CONFIG_FAIL_SAFE to MTD_CONFIG_NVS.
  2. it updates dependencies that previously relied on MTD_CONFIG to now depend on MTD_CONFIG_NONE=n.

Impact

These changes ensure compatibility with the updated mtd_config Kconfig structure in NuttX. By standardizing the naming and clarifying dependency logic, the configuration becomes more robust and easier to maintain, reducing the risk of conflicts and making it simpler to integrate or extend mtd_config submodules in the future

Testing

test it by CICT together with apache/nuttx#18120

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

Because the MTD_CONFIG configuration item in
drivers/mtd/Kconfig has changed

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

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
@zhaoxingyu12
Copy link
Contributor Author

Configuration/Tool: esp32c3-legacy-devkit/nvcfgdata
2026-01-23 03:26:54

Cleaning...
Configuring...
Building NuttX...
[1/1] Normalize esp32c3-legacy-devkit/nvcfgdata
49d48
< CONFIG_TESTING_MTD_CONFIG_FAIL_SAFE=y
Saving the new configuration file
On branch master
Your branch is up to date with 'origin/master'.

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#18120
it changes CONFIG_MTD_CONFIG_FAIL_SAFE to CONFIG_MTD_NVS
@xiaoxiang781216

@acassis
Copy link
Contributor

acassis commented Jan 23, 2026

@zhaoxingyu12 please include some testing results. Did you test CFGDATA too? Maybe we need to add CFGDATA to "SIM" or "QEMU" to make the test easy to do. Currently only two boards are using it

@acassis
Copy link
Contributor

acassis commented Jan 23, 2026

@zhaoxingyu12 I'm not sure that changing MTD_CONFIG to MTD_CONFIG_NONE is a good name change. I noticed your idea was to rename MTD_CONFIG_FAIL_SAFE to MTD_CONFIG_NVS, but it will be strange see CFGDATA depending on MTD_CONFIG_NONE.

Could you please add more details in the git commit message about this change? It seems very strange

@zhaoxingyu12
Copy link
Contributor Author

@zhaoxingyu12 I'm not sure that changing MTD_CONFIG to MTD_CONFIG_NONE is a good name change. I noticed your idea was to rename MTD_CONFIG_FAIL_SAFE to MTD_CONFIG_NVS, but it will be strange see CFGDATA depending on MTD_CONFIG_NONE.

Could you please add more details in the git commit message about this change? It seems very strange

now, CFGDATA depending on !MTD_CONFIG_NONE. (If either MTD_CONFIG or MTD_CONFIG_NVS is enabled, CFGDATA will be enabled.)

Currently, the mtd_config implementations use a choice structure, where all implementations (such as MTD_CONFIG, MTD_CONFIG_NVS (Original name: MTD_CONFIG_FAIL_SAFE), and any future submodules) are defined as mutually exclusive options—only one can be selected at a time.
MTD_CONFIG: mtd_config.c
MTD_CONFIG_NVS: mtd_config_nvs.c
MTD_CONFIG_NONE: Disables all MTD config solutions.

By introducing MTD_CONFIG_NONE as a "no implementation" option, other submodules only need to depend on MTD_CONFIG_NONE=n, ensuring that their features are enabled only when a specific implementation is chosen. This approach not only avoids multiple dependencies and configuration conflicts, but also provides a clearer and more unified way to integrate additional mtd_config submodules in the future.

it relates to this pr apache/nuttx#18120

choice
prompt "Select MTD config solution"
default MTD_CONFIG_NONE

config MTD_CONFIG
bool "Enable Dev Config (MTD based) device"
---help---
Provides a /dev/config device for saving / restoring application
configuration data to a standard MTD device or partition.

config MTD_CONFIG_NVS
bool "NVS"
---help---
NVS is a lightweight KV storage mechanism which supports classical
on-chip NorFlash, it implements basic KV write, read, and delete
functions, and supports power down protection.

config MTD_CONFIG_NONE
bool "None MTD config"

endchoice

@zhaoxingyu12
Copy link
Contributor Author

@zhaoxingyu12 please include some testing results. Did you test CFGDATA too? Maybe we need to add CFGDATA to "SIM" or "QEMU" to make the test easy to do. Currently only two boards are using it

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

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

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

  3. 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

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.

2 participants