Skip to content

Is there any way I can use SDIO with filesystem? #6384

Closed
@savent404

Description

@savent404

Description

  • Type: Question
  • Priority: Major

Question

As title

Activity

0xc0170

0xc0170 commented on Mar 19, 2018

@0xc0170
Contributor

@deepikabhavnani Please review

deepikabhavnani

deepikabhavnani commented on Mar 19, 2018

@deepikabhavnani

We have SDBlockDevice driver for SD cards which uses SPI interface, and SDIO support is not available yet. In case you are planning to implement SDIO driver, you can add it as BlockDevice. BlockDevice class provides the underlying API for representing block-based storage that you can use to back a file system. Mbed OS provides standard interfaces for the more common storage media, and you can extend the BlockDevice class to provide support for unsupported storage.

For more information please refer: https://os.mbed.com/docs/v5.7/reference/storage.html

savent404

savent404 commented on Mar 20, 2018

@savent404
Author

There is only one question: mbed-os not support a API for SDIO interface, and i only plain to use it in stm32. How can I implement SDIO driver or only implement SDFilesystem for STM32 SDIO driver?

deepikabhavnani

deepikabhavnani commented on Mar 20, 2018

@deepikabhavnani

API's for SDIO interface will be same as API's for SPI interface. https://github.com/ARMmbed/sd-driver/blob/master/SDBlockDevice.h

pauluap

pauluap commented on Mar 23, 2018

@pauluap

I'm sorry I don't have a public repository to share, but I found it pretty straightforward to implement the BlockDevice API using ST's Cube BSP functions - BSP_SD_xxx() Depending on your STM device, you should be able to download the appropriate ST Cube package to get the BSP drivers to use. If you're not using any of their evaluation boards, then you can use the BSP implementation as a starting point.

savent404

savent404 commented on Mar 27, 2018

@savent404
Author

That is exactly what i'm doing!

0xc0170

0xc0170 commented on Jun 22, 2018

@0xc0170
Contributor

Thanks @pauluap for sharing.

@savent404 The question answered? I'll close it. Please reopen with an update if any

JojoS62

JojoS62 commented on Sep 11, 2018

@JojoS62
Contributor

I have implemented a SDIOBlockDevice for the STM32F4. It needs some further testing but it is working already on a DISCO_F469NI and on a chinese STM32F407VE board. I would like to make a PR and appreciate any help for testing and design decisions.
Should this issue be reopened or shall I open a new issue?

savent404

savent404 commented on Sep 11, 2018

@savent404
Author

Hi, I got a solution about implement BlockDevice

JojoS62

JojoS62 commented on Sep 11, 2018

@JojoS62
Contributor

I've also used the STM32 HAL implementation and created a /components/SDIO_BLOCKDEVICE. That makes it compatible with the FileSystem class and also LittleFS can be used.
I need to clean up my code before pushing, it contains too much stuff for testing.

23 remaining items

JojoS62

JojoS62 commented on Oct 29, 2018

@JojoS62
Contributor

@MarceloSalazar I have tried the first time to use the mbed tests. I copied the tests from SDBlockdevice and changed the setttings for SDIOBlockdevice.
I have some problems with the bd.init() / bd.deinit() sequence, on an execution of another bd.init() after a deinit() the HAL code is hanging in a SD_FindSCR() function when checking if 4 bit mode is supported. When I uncomment this check and switch to 4 bit mode anyway the tests are all passing positive.
In the case of the failing tests I can not see the reason why the seek test is passing ok but other tests are failing, the seek test performs also an init/deinit. Only the fopen test is programmed differently, the bd is assigned in the fs constructor statically and no init/deint is performed, so no problem.
SDIOBlockdevice-Testresult-ok.txt
SDIOBlockdevice-Testresult-notOk.txt

JojoS62

JojoS62 commented on Oct 30, 2018

@JojoS62
Contributor

At the moment, I found two problems:

  • SD_FindSCR() is trying to read the SCR with polling when the SD is in fast transfer mode already. This polling seams to be very time critical, although data is read from a fifo. Within the read loop, there is a timeout check that reads the mbed timer. But due to a lot of lockings and checks for locking this has become very slow. Removing the timeout check makes the code work. Anyway, removing the FindSCR from the initialisation works more reliable and the SD standard requires 1 and 4 bit mode.
  • the FATFS format makes calls to blockdevice init/deinit, it looks like the reference counting for init/deinit is mandatory in the BD implementation, is that true?
MarceloSalazar

MarceloSalazar commented on Oct 31, 2018

@MarceloSalazar

@dannybenor @offirko is this something you could review and advise? Thanks!

JojoS62

JojoS62 commented on Oct 31, 2018

@JojoS62
Contributor

thanks for your support.
For the second point I will implement the reference counting.
I had also some problems with rebasing my feature brand with master, after solving I will update my github repo.

masoudr

masoudr commented on Nov 9, 2018

@masoudr
Contributor

@JojoS62 About a month ago I tested the SDIO and worked fine for me. Now I tried your new version that works too but I have some problem with mounting sd I need to reset my board twice or more to get sd mounted. I mean Filesystem.mount(sdio block).

JojoS62

JojoS62 commented on Nov 9, 2018

@JojoS62
Contributor

@masoudr I have continued my work in a newer branch, add-sdioblockdevice. In 'add-component-sdio-blockdevice' I mixed sources from two origins and I could not rebase it without always merging.
My PR was not accepted, but I will create a lib as suggested here: #8634 I'm currently working on this.
The tests that I used showed also a problem with multiple init/deinit of the blockdevice, this was fixed in the 'add-sdioblockdevice' branch, so you should try these files.

masoudr

masoudr commented on Nov 9, 2018

@masoudr
Contributor

@JojoS62 Thanks. Now I'm testing it and it is a lot faster. I'm testing it with zlib and it worked fine for me.

savent404

savent404 commented on Nov 10, 2018

@savent404
Author
JojoS62

JojoS62 commented on Nov 10, 2018

@JojoS62
Contributor

@savent404 You are right, the constructor should get the IO pins for the SDIO interface. This version was tested with F469NI and F407VE, there the was same configuration. I will check this.
For the DMA, there are only two choices. There could be also a configuration via constructor or mBed configuration system.
And please answer through the github web interface, not by replying to the mail notification.

deepikabhavnani

deepikabhavnani commented on Dec 28, 2018

@deepikabhavnani

We have separate repository for SDIO driver https://github.com/ARMmbed/sdio-driver. Please add issues, queries and PR to respective repository, closing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @pauluap@MarceloSalazar@0xc0170@JojoS62@masoudr

        Issue actions

          Is there any way I can use SDIO with filesystem? · Issue #6384 · ARMmbed/mbed-os