sys/eepreg: use MTD#22158
Conversation
crasbe
left a comment
There was a problem hiding this comment.
The static test has some comments too and why is mtd_eeprom.h sometimes conditionally and sometimes unconditionally included? 🤔
Murdock results❌ FAILED 82dcd5b fixup! fixup! boards: expose default EEPROM MTD Build failures (21)
Artifacts |
|
The build for |
|
The |
|
The I'm unfamiliar with |
|
The |
| @@ -1 +1 @@ | |||
| FEATURES_REQUIRED += periph_eeprom | |||
| USEMODULE += mtd | |||
There was a problem hiding this comment.
| USEMODULE += mtd | |
| # eepreg works with other `mtd_%` subsystems than `mtd_eeprom` too as not all | |
| # microcontrollers have built-in EEPROMs. However at least one `mtd_%` | |
| # subsystem has to be configured, otherwise fall back to requiring the internal | |
| # EEPROM. This makes sure the automatic feature resultion of the CI only | |
| # tries to compile the test for boards that it would work on. | |
| # Checking the USEMODULE before adding to it makes sure we don't test in the | |
| # first round of dependency resolution to avoid false-negatives. | |
| ifneq (,$(filter mtd,$(USEMODULE))) | |
| ifeq (,$(filter mtd_%,$(USEMODULE))) | |
| FEATURES_REQUIRED += periph_eeprom | |
| endif | |
| endif | |
| USEMODULE += mtd |
This should make sure that eepreg builds for all boards that expose an MTD_0 if they have an mtd_% configured or have periph_eeprom present.
buechse@skyleaf:~/RIOTstuff/riot-vanilla/RIOT/tests/sys/eepreg$ BUILD_IN_DOCKER=1 BOARD=nrf52dk make
There are unsatisfied feature requirements: periph_eeprom
/home/buechse/RIOTstuff/riot-vanilla/RIOT/tests/sys/eepreg/../../../Makefile.include:1033: *** You can let the build continue on expected errors by setting CONTINUE_ON_EXPECTED_ERRORS=1 to the command line. Stop.
buechse@skyleaf:~/RIOTstuff/riot-vanilla/RIOT/tests/sys/eepreg$ BUILD_IN_DOCKER=1 BOARD=nrf52840dk make
Launching build container using image "docker.io/riot/riotbuild@sha256:08fa7da2c702ac4db7cf57c23fc46c1971f3bffc4a6eff129793f853ec808736".
docker run --rm --tty --user $(id -u) --platform linux/amd64 -v '/home/buechse/RIOTstuff/riot-vanilla/RIOT:/data/riotbuild/riotbase:delegated' -v '/home/buechse/.cargo/registry:/data/riotbuild/.cargo/registry:delegated' -v '/home/buechse/.cargo/git:/data/riotbuild/.cargo/git:delegated' -e 'TZ=Europe/Berlin' -e 'RIOTBASE=/data/riotbuild/riotbase' -e 'CCACHE_BASEDIR=/data/riotbuild/riotbase' -e 'BUILD_DIR=/data/riotbuild/riotbase/build' -e 'BUILD_IN_DOCKER=0' -e 'RIOTPROJECT=/data/riotbuild/riotbase' -e 'RIOTCPU=/data/riotbuild/riotbase/cpu' -e 'RIOTBOARD=/data/riotbuild/riotbase/boards' -e 'RIOTMAKE=/data/riotbuild/riotbase/makefiles' -e 'BOARD=nrf52840dk' -e 'DISABLE_MODULE=' -e 'DEFAULT_MODULE=test_utils_interactive_sync test_utils_print_stack_usage' -e 'FEATURES_REQUIRED=' -e 'FEATURES_BLACKLIST=' -e 'FEATURES_OPTIONAL=' -e 'USEMODULE=eepreg' -e 'USEPKG=' -w '/data/riotbuild/riotbase/tests/sys/eepreg/' 'docker.io/riot/riotbuild@sha256:08fa7da2c702ac4db7cf57c23fc46c1971f3bffc4a6eff129793f853ec808736' make
Building application "tests_eepreg" for "nrf52840dk" with CPU "nrf52".
"make" -C /data/riotbuild/riotbase/pkg/cmsis/
...
"make" -C /data/riotbuild/riotbase/sys/tsrb
text data bss dec hex filename
16728 168 2548 19444 4bf4 /data/riotbuild/riotbase/tests/sys/eepreg/bin/nrf52840dk/tests_eepreg.elf
There was a problem hiding this comment.
Given this patch I would see USEMODULE += mtd_eeprom there instead of FEATURES_REQUIRED += periph_eeprom. This in the end requires periph_eepom too but it is not explicitly mentioned.
So this will pull mtd_eeprom as a fallback if no particular MTD is used.
There was a problem hiding this comment.
Sure. Then it depends on whether you want to open eepreg for other MTDs too.
There was a problem hiding this comment.
You could also filter for mtd_24cxxxx only for EEPROM-like MTD devices instead of filtering for all mtd_%.
| #ifndef TEST_EEPREG_MTD | ||
| # define TEST_EEPREG_MTD MTD_0 | ||
| #endif | ||
|
|
There was a problem hiding this comment.
| #ifndef MTD_0 | |
| # define MTD_0 mtd_dev_get(0) | |
| #endif | |
This would be a workaround since not all boards provide MTD_0 (for example if mtd_sdmmc is used).
Or do you want to do a full treewide migration and add the appropriate MTD_0 defines? This would be relevant for devices that have more than one MTD 🤔
There was a problem hiding this comment.
I think I added an MTD_<0|1> for all boards that support periph_eeprom.
Giving them an MTD is a benefit for boards that previously did not have any.
Why is mtd_sdmmc relevant? Because the CI will attempt to compile the eepreg test for a board that has only mtd_sdmmc but no MTD_0 defined? That's a a bit of a flaw. Maybe the workaround can be integrated in to mtd in general. I dont know yet
There was a problem hiding this comment.
You removed the periph_eeprom feature requirement, so now CI will try to compile for all boards.
I assumed this was intentional.
There was a problem hiding this comment.
Yes but I expected that every board supporting an MTD defines at least MTD_0.
There was a problem hiding this comment.
I have not applied this yet. For native it is currently an issue that the eeprom would be MTD_1. The eepreg test for native MTD fails.
I would by now not use any MTD_ but rather introduce the naming convention that the internal EEPROM MTD must be calles "mtd_eeprom" for example.
|
|
||
| #define DAT_START (EEPROM_SIZE - EEPROM_RESERV_CPU_HI \ | ||
| #ifndef TEST_EEPREG_MTD |
There was a problem hiding this comment.
This configuration parameter should be documented in the tests/sys/eepreg/README.md, especially considering boards that might have multiple MTD devices.
| WARNING: This will write to your EEPROM and probably corrupt any data that is | ||
| there! | ||
|
|
||
| Add `CFLAGS += -DTEST_EEPREG_MTD=MTD_<X>` if a different MTD should be used than MTD_0. |
There was a problem hiding this comment.
This has to be changed to MTD_EEPROM now I guess?
|
|
||
| #ifndef TEST_EEPREG_MTD | ||
| # define TEST_EEPREG_MTD MTD_0 | ||
| # define TEST_EEPREG_MTD (&mtd_eeprom.base) |
There was a problem hiding this comment.
Why not use MTD_EEPROM here?
| #endif | ||
|
|
||
| #if defined(MODULE_MTD_EEPROM) | ||
| #include "mtd_eeprom.h" |
There was a problem hiding this comment.
| #include "mtd_eeprom.h" | |
| # include "mtd_eeprom.h" |
| #if MODULE_MTD_EEPROM | ||
| static mtd_eeprom_t eeprom_mtd = MTD_EEPROM_INIT_VAL; | ||
| MTD_XFA_ADD(eeprom_mtd, 0); | ||
| mtd_eeprom_t mtd_eeprom = MTD_EEPROM_INIT_VAL; |
There was a problem hiding this comment.
Even though this is not a define, I'd propose to call it MTD_EEPROM to reduce the confusion with the module.
But still, there is confusion potential between the module and the MTD device when both have the same name 😅
There was a problem hiding this comment.
But I don't have a better name for the MTD device unfortunately :(

Contribution description
Add an MTD to the EEPROM registry API, so that other MTD (EEPROMS) can also be used.
mtd_eepromto boards that supportperiph/eepromTesting procedure
USEMODULE+=at24mac CFLAGS+=-DTEST_EEPREG_MTD="mtd_dev_get\(1\)" DEVELHELP=1 VERBOSE_ASSERT=1 make -C tests/sys/eepreg/ BOARD=same54-xpro flash termIssues/PRs references