Skip to content

mtd: Add MTD VFS wrapper for use with DevFS#3

Closed
jnohlgard wants to merge 1 commit intoOTAkeys:pr/mtdi_flashfrom
jnohlgard:spr/mtd-devfs
Closed

mtd: Add MTD VFS wrapper for use with DevFS#3
jnohlgard wants to merge 1 commit intoOTAkeys:pr/mtdi_flashfrom
jnohlgard:spr/mtd-devfs

Conversation

@jnohlgard
Copy link
Copy Markdown

A small wrapper to be able to register MTD devices as DevFS nodes

Usage example (taken from mulle with my generic SPI NOR driver):

mtd_spi_nor_t mulle_nor_dev = {
    .base = {
        .driver = &mtd_spi_nor_driver,
        .page_size = 256,
        .pages_per_sector = 256,
        .sector_count = 32,
    },
    .opcode = &mtd_spi_nor_opcode_default,
    .spi = MULLE_NVRAM_SPI_DEV,
    .cs = GPIO_PIN(PORT_D, 5),
    .addr_width = 3,
};

mtd_dev_t *mulle_nor = (mtd_dev_t *)&mulle_nor_dev;

static devfs_t mulle_nor_devfs = {
    .path = "/mtd0",
    .f_op = &mtd_vfs_ops,
    .private_data = &mulle_nor_dev,
};

and during start up:

int mulle_nor_init(void)
{
    int res = mtd_init(mulle_nor);

    if (res >= 0) {
        /* Register DevFS node */
        devfs_register(&mulle_nor_devfs);
    }

    return res;
}

@vincent-d
Copy link
Copy Markdown
Member

@gebart Looks nice, I'll take a deeper look on monday

* details.
*/

#if MODULE_MTD
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should be
#if MODULE_VFS

@vincent-d
Copy link
Copy Markdown
Member

cherry-picked

@vincent-d vincent-d closed this Jul 26, 2016
@jnohlgard jnohlgard deleted the spr/mtd-devfs branch July 26, 2016 16:41
toonst pushed a commit that referenced this pull request Jul 19, 2019
The evtimer_msg test is expanded to also delete entries.

Furthermore the messages that are printed should now show
numbers that are very close (if not equal). Something like
this:
At    740 ms received msg 0: "#2 supposed to be 740"
At   1081 ms received msg 1: "#0 supposed to be 1081"
At   1581 ms received msg 2: "#1 supposed to be 1581"
At   4035 ms received msg 3: "#3 supposed to be 4035"

The function evtimer_print is also called to show the
intermediate status of evtimer entries.
vincent-d pushed a commit that referenced this pull request Sep 6, 2019
The test randomly fails on `native` due to timers being not accurate but
it cannot be otherwise. So better disable it than raising fake errors.

    main(): This is RIOT! (Version: buildtest)
    Testing generic evtimer
    This should list 2 items
    ev #1 offset=1000
    ev #2 offset=500
    This should list 4 items
    ev #1 offset=659
    ev #2 offset=341
    ev #3 offset=500
    ev #4 offset=2454
    Are the reception times of all 4 msgs close to the supposed values?
    At    662 ms received msg 0: "#2 supposed to be 659"
    At   1009 ms received msg 1: "#0 supposed to be 1000"
    At   1511 ms received msg 2: "#1 supposed to be 1500"

    Traceback (most recent call last):
      File "/tmp/dwq.0.3125418833043728/ef3af88c4b3615788b164464a437df5c/tests/evtimer_msg/tests/01-run.py", line 33, in <module>
        sys.exit(run(testfunc))
      File "/tmp/dwq.0.3125418833043728/ef3af88c4b3615788b164464a437df5c/dist/pythonlibs/testrunner/__init__.py", line 29, in run
        testfunc(child)
      File "/tmp/dwq.0.3125418833043728/ef3af88c4b3615788b164464a437df5c/tests/evtimer_msg/tests/01-run.py", line 26, in testfunc
        assert(actual in range(expected - ACCEPTED_ERROR, expected + ACCEPTED_ERROR))
    AssertionError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants