Skip to content

Usb host msd block device #4230

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 3 commits into from
May 26, 2017
Merged

Usb host msd block device #4230

merged 3 commits into from
May 26, 2017

Conversation

jamike
Copy link
Contributor

@jamike jamike commented Apr 26, 2017

Description

Since BlockDevice has been introduced USBHostMSD is no more supported.
With this patch USBhostMSD inherits from BlockDevice , and can be used with FATFileSystem class.

Migration

As USBHostMSD does not inherit from FATFilesystem any more, the code using the class has to be modified.

Status

READY

@geky
Copy link
Contributor

geky commented Apr 26, 2017

With regard to the adoption of the block device api, this looks great!

printf("file system mounted\n");

if (!msd.connect()) {
goto again;
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, could these gotos just be a continue statement inside this while loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree, I will update.

while (msd.connected()) {
Thread::wait(500);
}
while (fs.unmount()==-1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should really be checking for less than zero fs.unmount() < 0, since unmount may return a negative error code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree, iI will update

@chrissnow chrissnow mentioned this pull request Apr 26, 2017
@jamike jamike force-pushed the USBHostMSD_BockDevice branch 2 times, most recently from 07ac34f to 3233031 Compare April 27, 2017 09:35
@jamike
Copy link
Contributor Author

jamike commented Apr 27, 2017

Patch is updated : Comments taken into account and some more changes have been included in function USBHostMSD::read and USBHostMSD::program.

while(!msd.connect()) {
Thread::wait(500);
}
if (fs.mount(&msd) != 0) continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you fix the formatting for this if else?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before pushing the patch I have used the astyle.exe command from page https://docs.mbed.com/docs/mbed-os-handbook/en/5.1/cont/code_style/
To fix the above indentation issue I added option -j .
AStyle.exe --style=kr --indent=spaces=4 --indent-switches -j
This solves the following requirement.
•One true brace style (1TBS) - use braces for statements of type if, else, while and for (exception from K&R).

-j is taking into account the above remarks.

@jamike jamike force-pushed the USBHostMSD_BockDevice branch from 3233031 to d0df7fb Compare May 4, 2017 09:07
@screamerbg screamerbg changed the title Usb host msd bock device Usb host msd block device May 4, 2017
@adbridge
Copy link
Contributor

adbridge commented May 4, 2017

@0xc0170 are you happy with the review changes?

@theotherjimmy
Copy link
Contributor

@0xc0170 Could you review please?

@@ -29,13 +28,16 @@
#define GET_MAX_LUN (0xFE)
#define BO_MASS_STORAGE_RESET (0xFF)

USBHostMSD::USBHostMSD(const char * rootdir) : FATFileSystem(rootdir)
USBHostMSD::USBHostMSD()
Copy link
Contributor

@0xc0170 0xc0170 May 8, 2017

Choose a reason for hiding this comment

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

for changes like this, please note in the commit and in the PR description that this is a breaking change? Any change of API should be emphasised and provided with a strong reason for doing so.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The BlockDevice was not existing when the initial version has been developped.
When BlockDevice and fatfilesystem evolution has been introduced, USBHostMSD was no more working (USB: MSD Device #4131) .
Since USB stick is exchanging block write , block read on USB.
To let application using fatfilesystem on this BlockDevice seems in line with the mbed filesystem evolution.

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand. That's OK.

My intention for these type of changes is that a commit should contain information about breaking the compatibility - this warns all of us that this change is breaking, and any user pulling this commit should be warned. Something nice to have.

}

void USBHostMSD::init() {
void USBHostMSD::init_usb()
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this renamed? Is it because of init method conflict somewhere in the hierarchy? Can it be resolved differently?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As USBhostMSD inherits from BlockDevice and block device as a virtual method init.
It is better to rename the method relative to USB init , as init_usb . Also this method is protected so the renaming does not modify the behaviour for the user of this class.

uint8_t buf[1], res;
res = host->controlRead( dev, USB_RECIPIENT_INTERFACE | USB_DEVICE_TO_HOST | USB_REQUEST_TYPE_CLASS,
0xfe, 0, msd_intf, buf, 1);
USB_DBG("max lun: %d", buf[0]);
return res;
}

int USBHostMSD::disk_initialize() {
int USBHostMSD::init()
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for fixing the style. I would recommend sending this as separate PR, this is causing distraction from the actual changes in this PR - would be easier if its a separate patch

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 ll take it account in my next PR. (the fact that USB is not in good style does not help ...)

bd_size_t USBHostMSD::size() const
{
USB_DBG("FILESYSTEM: size ");
if (!disk_init)
Copy link
Contributor

Choose a reason for hiding this comment

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

if we are changing these lines, we shall update the style in here as it was done for the rest of the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree , I ll update soon.

tools/build.py Outdated
@@ -91,6 +91,12 @@
default=False,
help="Compile the DSP library")

parser.add_argument("-F", "--fat",
Copy link
Contributor

Choose a reason for hiding this comment

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

this is good for testing, but I would not send this to master now. The reason is that this fat file system is targeting mbed-os, and soon enough the new rtos will come that wont be supported in these scripts (use mbed-cli). Thus any tools/ changes in this PR shall be reverted. What do you think?

cc @sg-

@jamike jamike force-pushed the USBHostMSD_BockDevice branch from d0df7fb to af7acf8 Compare May 9, 2017 13:32
@0xc0170
Copy link
Contributor

0xc0170 commented May 15, 2017

Can you please rebase ? And regarding that --fat change, please remove it as requested above

@jamike jamike force-pushed the USBHostMSD_BockDevice branch from af7acf8 to 6401d48 Compare May 17, 2017 07:46
@jamike
Copy link
Contributor Author

jamike commented May 17, 2017

The patch is rebased and the Commit relative to mbed OS 2 test is removed.

@0xc0170
Copy link
Contributor

0xc0170 commented May 18, 2017

/morph test

1 similar comment
@adbridge
Copy link
Contributor

/morph test

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 297

Test failed!

@geky
Copy link
Contributor

geky commented May 22, 2017

@studavekar, could these be issues with the CI? The tests seem to not get past board flashing.

@studavekar
Copy link
Contributor

Doesn't look like there was issue with CI, seems like it was device specific issues with ARCH_PRO and other failure related NUCLEO_F429Z one of failure.

Will re-trigger and will see how that goes

/morph test

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 313

Test failed!

@adbridge
Copy link
Contributor

@studavekar looks like the NUCLEO_F429ZI became non-responsive, timeouts across the tests for 2 of the builds....

@adbridge
Copy link
Contributor

/morph test

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 333

All builds and test passed!

@sg- sg- merged commit 3122abe into ARMmbed:master May 26, 2017
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.

8 participants