Skip to content

Add default block device support (SD, SPIF and FLASHIAP) #7774

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

Merged
merged 257 commits into from
Sep 1, 2018

Conversation

yossi2le
Copy link
Contributor

@yossi2le yossi2le commented Aug 13, 2018

Description

In this PR the SD, SPIF and FLASHIAP block device are moved into mbedos, enabling the addon of default block device and default filesystem functionality in favor of firmware update requirement.
SD, SPIF and FLASHIAP block devices are added under the new component label configured in target.json. Any board with SD or SPIF component enabled will have a default block device and filesystem. Using the new feature is as easy as:

#include "SystemStorage.h"
BlockDevice *bd = mbed::SystemStorage::get_default_blockdevice();
FileSystem  *fs = mbed::SystemStorage::get_default_filesystem();

The default implementation is implemented using MBED_WEAK enabling an easy way to override it if needed.

namespace mbed {
namespace SystemStorage{
BlockDevice* get_default_blockdevice()
{
    static HeapBlockDevice( 32*1024);
    return &default_bd;
}
}
}

Using any desired block device and filesystem are not affected by this PR.

Directory structure

New block devices and their tests can be found under the following paths:
./components/storage/blockdevices/COMPONENT_SD
/components/storage/blockdevices/COMPONENT_SPIF
/components/storage/blockdevices/COMPONENT_FLASHIAP

The default block device and default filesystem implementation is found under SystemStorage namespace at:
./features/storage/system_storage

New filesystem test for default block device and filesystem are found at:
./features/storage/TESTS/filesystem/general_filesystem

The PR also includes reordering of the storage directory in order to maintain much cleaner and more structured environment in mbedos.

Common filesystem files were moved from ./feature/filesystem to ./feature/storage/filesystem.
Common block devices files were moved from ./features/filesystem/bd to ./features/storage/blockdevices
those changes has been done in order to follow the components design spirit.

configuration

Configuration of SPI pins has been moved into PinsNames.h under targets, however the option to override the default configuration or add one, if PinsName.h is missing the SPI pins, can be done from application config.

Example for SD:

"target_overrides": {
        "DISCO_L476VG": {
              "sd.SPI_MOSI": "PE_15",
              "sd.SPI_MISO": "PE_14",
              "sd.SPI_CLK":  "PE_13",
              "sd.SPI_CS":   "PE_12"
        },

Example for SPIF:

"target_overrides": {
       "MTB_UBLOX_ODIN_W2": {
             "spif-driver.SPI_MOSI": "PE_14",
             "spif-driver.SPI_MISO": "PE_13",
             "spif-driver.SPI_CLK":  "PE_12",
             "spif-driver.SPI_CS":   "PE_11"
        },

Dependencies

This PR is dependent on PR #7644

Pull request type

[ ] Fix
[ ] Refactor
[ ] Target update
[ ] Feature
[x] Breaking change

simonqhughes and others added 30 commits March 7, 2017 17:19
Fix default spi speed to 40mhz
…s due to incompatible versions of mbed-os and sd-driver.
Fix default spi speed to 40Mhz
Fix const attribute mismatch on size function
…ation with 1ms wait between response queries.
Fix for armmbed/sd-driver issue 4: SDCard Initialisation fails for ES…
Modify example also similarly to match the PIN definitions. This encapsulates
all the SD-card related stuff to this library. By including this library you
also get the pin definitions on the same go.
Enable the internal SD-card reader in UBLOX_EVK_ODIN_W2. This will
disable the CI-shield SD-card reader if you have, if you prefer using it
you have to remove this target override section.

Please note that there seem to be some reliability problems with the
internal SD-card slot, in my case the mbed OS CI-shield works better.
Add UBLOX_EVK_ODIN_W2 override for int. SD-card
This is needed as the regular configuration does not work with this board due pin conflict with Ethernet and SD-card.
1. Added function to select/deselect the device
2. Init function for SPI
3. Removed redundant function _cmdx
1. Added enum for all commands supported.
2. Added error codes
3. Command Response defines
4. SPI Data Read/Write defines
5. Separated SPI functionality in different function call.
6. Used enums for existing commands using _cmd function.
@mbed-ci
Copy link

mbed-ci commented Sep 1, 2018

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 1, 2018

/morph test

@mbed-ci
Copy link

mbed-ci commented Sep 1, 2018

@cmonr cmonr merged commit 993c897 into ARMmbed:master Sep 1, 2018
@0xc0170 0xc0170 removed the needs: CI label Sep 1, 2018
@yossi2le
Copy link
Contributor Author

yossi2le commented Sep 1, 2018

@0xc0170, @cmonr and all maintainers.
Thanks a lot for all the help with this PR:)

@cmonr
Copy link
Contributor

cmonr commented Sep 1, 2018

@yossi2le Of course! Thank you for all of the hard work on the PR!

@jeromecoutant
Copy link
Collaborator

Hi

It seems that added "SPI_PERSISTENT_MEM_CS" is not used anywhere ?

Maybe you should remove it from all PinNames.h files ?

Thx

@yossi2le
Copy link
Contributor Author

yossi2le commented Sep 4, 2018

Hi

It seems that added "SPI_PERSISTENT_MEM_CS" is not used anywhere ?

Maybe you should remove it from all PinNames.h files ?

Thx

@jeromecoutant Thanks for pointing this. those are important and should be used in config files. it appears that we missed it in last releases.
I will fix it in a sperate PR.

@jeromecoutant
Copy link
Collaborator

Hi

Do you also plan to update https://github.com/ARMmbed/ci-test-shield ?
(replace SDDriver.lib by the component)

@yossi2le
Copy link
Contributor Author

yossi2le commented Sep 4, 2018

We haven't added this in our plans. however, I believe someone does need to do so.

@jeromecoutant
Copy link
Collaborator

And in https://github.com/ARMmbed/sd-driver

Maybe we should indicate that this repo is “deprecated”,
all new patch will be posted only in mbed-os now ?

@yossi2le
Copy link
Contributor Author

yossi2le commented Sep 4, 2018

And in https://github.com/ARMmbed/sd-driver

Maybe we should indicate that this repo is “deprecated”,
all new patch will be posted only in mbed-os now?

The Sd-driver, spif-driver, dataflash-driver and flashiap-driver repos have already has a pending PR just for that.

yossi2le pushed a commit to yossi2le/mbed-os that referenced this pull request Sep 5, 2018
…mit reverts those files excpet for K82F and K64F which are left as an example
cmonr pushed a commit that referenced this pull request Sep 6, 2018
Reverting PinNames.h after PR #7774 changes
adbridge pushed a commit that referenced this pull request Sep 11, 2018
…erts those files excpet for K82F and K64F which are left as an example
yossi2le pushed a commit to yossi2le/mbed-os that referenced this pull request Oct 4, 2018
adbridge pushed a commit that referenced this pull request Oct 19, 2018
yossi2le pushed a commit to yossi2le/mbed-os that referenced this pull request Oct 25, 2018
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.