-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Conversation
With regard to the adoption of the block device api, this looks great! |
printf("file system mounted\n"); | ||
|
||
if (!msd.connect()) { | ||
goto again; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree, iI will update
07ac34f
to
3233031
Compare
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
3233031
to
d0df7fb
Compare
@0xc0170 are you happy with the review changes? |
@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() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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-
d0df7fb
to
af7acf8
Compare
Can you please rebase ? And regarding that --fat change, please remove it as requested above |
af7acf8
to
6401d48
Compare
The patch is rebased and the Commit relative to mbed OS 2 test is removed. |
/morph test |
1 similar comment
/morph test |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputTest failed! |
@studavekar, could these be issues with the CI? The tests seem to not get past board flashing. |
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 |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputTest failed! |
@studavekar looks like the NUCLEO_F429ZI became non-responsive, timeouts across the tests for 2 of the builds.... |
/morph test |
Result: SUCCESSYour command has finished executing! Here's what you wrote!
OutputAll builds and test passed! |
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