Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flash device emulation w/ MCI driver for native #4345

Closed
wants to merge 1 commit into from

Conversation

x3ro
Copy link
Contributor

@x3ro x3ro commented Nov 26, 2015

Supersedes #4033
Depends on #4220

I propose the following "flash simulation layer" for developing/testing RIOT applications, intended to access flash-based storage, on native. It emulates the following characteristics of flash storage:

  • Structured as blocks containing pages
  • Pages are the smallest unit that can be written to
  • Blocks are the smallest unit that can be erased
  • Pages cannot be re-written without erasing the parent block first

Also included is an implementation, based on the flash simulation layer, for the existing MCI storage interface (implemented e.g. for the MSBA2 board).

@x3ro x3ro added the Type: new feature The issue requests / The PR implemements a new feature for RIOT label Nov 26, 2015
E_FS_OUT_OF_RANGE = 3, //!< The operation was out of range
E_FS_FILE_ERROR = 4, //!< Error operating on the file simulating the flash device
E_FS_NOT_INITIALIZED = 5 //!< Flash simulation layer was not initialized prior to operation
} flash_sim_error_t;
Copy link
Member

Choose a reason for hiding this comment

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

Why does flash_sim needs it's own error class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to have meaningful errors tailored to the module. What would you suggest I use?

Copy link
Member

Choose a reason for hiding this comment

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

As far as I see everyone of these can be expressed through an errno.

E_FS_SUCCESS         = 0
E_FS_INVALID_WRITE   = -EIO    /* Input/output error */
E_FS_INVALID_PARAMS  = -EINVAL /* Invalid argument */
E_FS_OUT_OF_RANGE    = -EFAULT /* Bad address */
E_FS_FILE_ERROR      = /* multiple errnos related to files, depending on what you want, see errno(3) */
E_FS_NOT_INITIALIZED = -ENODEV /* No such device */

Making up new error classes for modules is not very meaningful or helpful IMHO, since:

  1. most users don't check them anyways (only IF there was an error)
  2. it makes passing errors up more complicated, since modules passing up the error have to first check what it was and then use their respective error code
  3. it decouples documentation of the error case from the actual place where it happens. Your code already just states E_SUCCESS or another ::flash_sim_error_t. That makes it really hard for testers to say if a function can error on E_FS_INVALID_WRITE, E_FS_OUT_OF_RANGE, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. Thanks for the input :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you think this is also the case for more complex errors? When interacting with a flash device, for example, I might encounter ECC errors or a page I'm trying to read from may not have been written too and thus cannot be read. While I could represent both of those errors with EIO, being able to distinguish such error cases is necessary since they need to be handled differently. What would be a good solution in such a case?

Copy link
Member

Choose a reason for hiding this comment

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

In most cases there is some kind of error code that can loosely describe the behavior. For the ECC error EIO seems like a good idea, or EBADF. For the other thing EBADFD might be a good code. You are the only one using the error codes in that scope and they can be generalized more, when you hand them upstream. Get creative ;-)

@x3ro x3ro force-pushed the ma/flash-emulation branch from 69b1472 to fde29f1 Compare November 30, 2015 19:21
@OlegHahm OlegHahm modified the milestone: Release 2016.03 Dec 7, 2015
@OlegHahm OlegHahm assigned OlegHahm and PeterKietzmann and unassigned OlegHahm Dec 8, 2015
@x3ro x3ro force-pushed the ma/flash-emulation branch 2 times, most recently from 4c28d4c to 4ed4677 Compare December 15, 2015 19:24
@PeterKietzmann
Copy link
Member

Does anyone volunteer to take over this PR?

[flashsim] Fix broken unit tests

[flashsim] Add documentation

[flashsim] Properly namespace error enum

[flashsim] Fix header not renamed

[fs] replace custom error codes with errnos
@x3ro x3ro force-pushed the ma/flash-emulation branch from 4ed4677 to 3b5d7c2 Compare February 15, 2016 13:28
@PeterKietzmann
Copy link
Member

Won't be able to review until the next release, sorry Lucas!

@PeterKietzmann PeterKietzmann modified the milestones: Release 2016.07, Release 2016.04 Mar 23, 2016
@PeterKietzmann PeterKietzmann modified the milestones: Release 2016.10, Release 2016.07 Jul 11, 2016
@PeterKietzmann PeterKietzmann removed this from the Release 2016.10 milestone Oct 19, 2016
@PeterKietzmann
Copy link
Member

Who has time and knowledge to review this PR? I will remove the Milestone label for now.

@OlegHahm
Copy link
Member

So, what do we do with this PR?

@aabadie aabadie modified the milestone: Release 2017.07 Jun 23, 2017
@aabadie aabadie removed this from the Release 2017.07 milestone Jun 30, 2017
@smlng
Copy link
Member

smlng commented Jan 12, 2018

needs rebase and adoption, until then I'll remove milestone

@smlng smlng removed this from the Release 2018.01 milestone Jan 12, 2018
@miri64
Copy link
Member

miri64 commented Feb 15, 2018

No progress for over a year. Closing as memo for now.

@miri64 miri64 closed this Feb 15, 2018
@miri64 miri64 added the State: archived State: The PR has been archived for possible future re-adaptation label Feb 15, 2018
@jnohlgard jnohlgard added the Area: fs Area: File systems label Feb 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: fs Area: File systems State: archived State: The PR has been archived for possible future re-adaptation Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants