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

SDIO support - WIP #10235

Closed
wants to merge 22 commits into from
Closed

SDIO support - WIP #10235

wants to merge 22 commits into from

Conversation

orenc17
Copy link
Contributor

@orenc17 orenc17 commented Mar 26, 2019

Description

@JojoS62 thanks for the hard work
@ARMmbed/mbed-os-maintainers please set this to a new feature branch

Pull request type

[ ] Fix
[ ] Refactor
[ ] Target update
[X] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Reviewers

@ARMmbed/mbed-os-maintainers @ARMmbed/mbed-os-storage @JojoS62 @ARMmbed/team-st-mcd

Release Notes

@orenc17
Copy link
Contributor Author

orenc17 commented Mar 26, 2019

@mmahadevan108 FYI

@cmonr cmonr changed the base branch from master to feature-sdio March 26, 2019 18:34
@cmonr
Copy link
Contributor

cmonr commented Mar 26, 2019

@orenc17 Please take a look at the astyle issues (yesterday's issues have been fixed and merged. Results in job appear to be correctly failing).

@cmonr cmonr requested review from a team March 26, 2019 18:39
@jeromecoutant
Copy link
Collaborator

jeromecoutant commented Mar 27, 2019

Hi
Are there any tests ?

@orenc17
Copy link
Contributor Author

orenc17 commented Mar 27, 2019

Hi
Are there any tests ?

@jeromecoutant i'm working on integrating the new Blockdevice to the current Blockdevice tests

JojoS62 and others added 12 commits March 27, 2019 11:02
add SDIOBlockdevice
implementation for STM32F4
almost the same as for STM32F4, but in F7 SDIO device is renamed to SDMMC
SDMMC1 is used for DISCO_F746NG
updated readme.md for new target

# Conflicts:
#	README.md
- removed comments
- renamed short variable names
tickstart was inside checking loop
removed wait_ms() calls
added timeout checks for all while loops
return SD_BLOCK_DEVICE_ERROR_NO_DEVICE;
}

if (!is_valid_read(addr, size)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

when not initialized 'this->size()" is 0 and is_valid_read/program/trim will fail..
You will receive SD_BLOCK_DEVICE_ERROR_PARAMETER instead of SD_BLOCK_DEVICE_ERROR_NO_INIT, which is more appropriate.

@orenc17 orenc17 changed the base branch from feature-sdio to master March 27, 2019 13:18
@orenc17 orenc17 changed the base branch from master to feature-sdio March 27, 2019 13:18
@orenc17
Copy link
Contributor Author

orenc17 commented Mar 27, 2019

@ARMmbed/mbed-os-hal can you please review

mmahadevan108 and others added 3 commits March 27, 2019 17:55
Tested this with the block device test inside features-storage-tests-blockdevice-general_block_device
Below was the change made to add SDIO test

--- a/features/storage/TESTS/blockdevice/general_block_device/main.cpp
+++ b/features/storage/TESTS/blockdevice/general_block_device/main.cpp
@@ -47,6 +47,8 @@
 #include "FlashIAPBlockDevice.h"
 #endif

+#include "SDIOBlockDevice.h"
+
 using namespace utest::v1;

 #define TEST_BLOCK_COUNT 10
@@ -69,6 +71,7 @@ enum bd_type {
     dataflash,
     sd,
     flashiap,
+    sdio,
     default_bd
 };

@@ -90,6 +93,11 @@ static inline uint32_t align_up(uint32_t val, uint32_t size)
 static BlockDevice *get_bd_instance(uint8_t bd_type)
 {
     switch (bd_arr[bd_type]) {
+        case sdio: {
+            static SDIOBlockDevice default_bd(P0_17);
+            return &default_bd;
+            break;
+        }
         case spif: {
 #if COMPONENT_SPIF
             static SPIFBlockDevice default_bd(
@@ -632,6 +640,8 @@ void test_get_type_functionality()
     const char *bd_type = block_device->get_type();
     TEST_ASSERT_NOT_EQUAL(0, bd_type);

+    TEST_ASSERT_EQUAL(0, strcmp(bd_type, "SDIO"));
+
 #if COMPONENT_QSPIF
     TEST_ASSERT_EQUAL(0, strcmp(bd_type, "QSPIF"));
 #elif COMPONENT_SPIF
@@ -708,10 +718,12 @@ int get_bd_count()
     bd_arr[count++] = flashiap;       //4
 #endif

+    bd_arr[count++] = sdio;       //5
+
     return count;
 }

-static const char *prefix[] = {"SPIF ", "QSPIF ", "DATAFLASH ", "SD ", "FLASHIAP ", "DEFAULT "};
+static const char *prefix[] = {"SPIF ", "QSPIF ", "DATAFLASH ", "SD ", "FLASHIAP ", "SDIO ", "DEFAULT "};

 int main()
 {

Signed-off-by: Mahesh Mahadevan <[email protected]>
@orenc17
Copy link
Contributor Author

orenc17 commented Mar 27, 2019

@mmahadevan108
I've added your implementation from ARMmbed/sdio-driver#2
modified a bit, could you please review?

it seems to pass the general-block-device test

@mmahadevan108
Copy link
Contributor

mmahadevan108 commented Mar 27, 2019

Should we pass in PinNames to sdio_init() for DAT0-3, CLK, CMD?

@orenc17 orenc17 closed this Mar 27, 2019
@orenc17 orenc17 reopened this Mar 27, 2019
@orenc17
Copy link
Contributor Author

orenc17 commented Mar 27, 2019

Should we pass in PinNames to sdio_init() for DAT0-3, CLK, CMD?

@mmahadevan108 i think so, this is an initial step, it will evolve in time
that is also why this PR is targeted to a feature branch

* @param ReadAddr: Address from where data is to be read
* @param NumOfBlocks: Number of SD blocks to read
* @retval SD status
*/

Choose a reason for hiding this comment

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

Please specify the ReadAddress units: Bytes or blocks?

uint32_t RelCardAdd; /* Specifies the Relative Card Address */
uint32_t BlockNbr; /* Specifies the Card Capacity in blocks */
uint32_t BlockSize; /* Specifies one block size in bytes */
uint32_t LogBlockNbr; /* Specifies the Card logical Capacity in blocks */

Choose a reason for hiding this comment

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

Will be good to add some comments about the difference between BlockNbr and LogBlockNbr

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this part is a direct copy from sdio-driver.
@JojoS62 is there a difference?

@screamerbg
Copy link
Contributor

screamerbg commented Mar 28, 2019

@orenc17 @0xc0170 @bulislaw Is this a feature or a new component? I'm confused as this looks more like a new component implementation, rather than fundametal Mbed OS feature. I.e. it's an addition to the storage feature.

@orenc17
Copy link
Contributor Author

orenc17 commented Mar 28, 2019

@screamerbg this is a new HAL layer for mbed-os plus a new BlockDevice using that hal
Blockdevices in mbed-os are components

you wont find any FEATURE_ folders in this PR

@orenc17 orenc17 changed the title New feature - SDIO SDIO support - WIP Mar 28, 2019
@@ -48,6 +48,10 @@
#include "FlashIAPBlockDevice.h"
#endif

#if COMPONENT_SDIO
#include "SDIOBlockDevice.h"
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happened if a targets adds component SDIO and SD and QSPIF ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All three blockdevices will be tested

@jeromecoutant
Copy link
Collaborator

i'm working on integrating the new Blockdevice to the current Blockdevice tests

Could you attach your test results ?

Thx

},
"target_overrides": {
"DISCO_F469NI": {
"CMD_TIMEOUT": 30000
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why same value is overridden ?

PC9 ------> SDIO_D1
PC8 ------> SDIO_D0
*/
GPIO_InitStruct.Pin = GPIO_PIN_12 | GPIO_PIN_11 | GPIO_PIN_10 | GPIO_PIN_9 | GPIO_PIN_8;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This pin configuration can't be defined for all STM32 like this.
We should use some MACRO which can be define at each MCU level?
Or we should create a new structure in PeripheralPins.c ?

But OK to keep it like this in a first step, it can be optimized later while adding more SDIO targets.

"USBDEVICE"
"USBDEVICE",
"SDIO",
"SDIO_ASYNC"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to add COMPONENT_SDIO AND DEVICE_SDIO AND DEVICE_SDIO_ASYNC ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

@jeromecoutant
Copy link
Collaborator

Hi
Any review update and test result ?

@adbridge
Copy link
Contributor

adbridge commented May 1, 2019

@orenc17 Could you address the review comments please ?

@0xc0170
Copy link
Contributor

0xc0170 commented May 3, 2019

@orenc17 What is missing here to land this on the feature branch? Besides tests.

@jeromecoutant
Copy link
Collaborator

Hi
Initial PR from @JojoS62 was in November 2018...
Can you assign someone to review, update and merge this one ?
Thx

@MarceloSalazar

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 4, 2019

@ARMmbed/mbed-os-storage ^^

@orenc17 orenc17 closed this Jun 4, 2019
@0Grit
Copy link

0Grit commented Jun 4, 2019

@davisga @trowbridgec @farrenv @AGlass0fMilk any feedback?
I know next to nothing about SDIO.

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.