Skip to content

USB fixes and improvements #5874

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
Jan 26, 2018
Merged

Conversation

c1728p9
Copy link
Contributor

@c1728p9 c1728p9 commented Jan 17, 2018

  • Fix local static initialization in USB
  • Remove use of deprecated attach in USB
  • Fix clearing of ISTAT in Kinetis USB

@c1728p9
Copy link
Contributor Author

c1728p9 commented Jan 17, 2018

CC @ashok-rao @Sissors

@c1728p9
Copy link
Contributor Author

c1728p9 commented Jan 17, 2018

/morph build

@c1728p9
Copy link
Contributor Author

c1728p9 commented Jan 17, 2018

@Sissors this doesn't fix the Kinetis USB issues discussed earlier. That will be in a separate PR. This is just general fixes and improvements.

@mbed-ci
Copy link

mbed-ci commented Jan 17, 2018

Build : SUCCESS

Build number : 887
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/5874/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build

@mbed-ci
Copy link

mbed-ci commented Jan 17, 2018

@mbed-ci
Copy link

mbed-ci commented Jan 17, 2018

@@ -619,20 +621,27 @@ uint8_t * USBAudio::configurationDesc() {
// Terminator
0 // bLength
};

MBED_ASSERT(sizeof(configDescriptorTemp) == sizeof(deviceDescriptor));
memcpy(deviceDescriptor, configDescriptorTemp, sizeof(configDescriptor));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wrong variable in memcpy

The local static initialization in USB was causing multiple problems:
-Configurable descriptor values are set only once
-USB descriptor initialization causes a trap in debug builds since
 this is acquiring a mutex in an interrupt handler
-Extra ram used since all descriptors  are in RAM

This patch fixes these problems by making fixed descriptors
static const so they are stored in flash and never need to be
initialized and by making descriptors that do change a member
of the class so they are always initialized when requested
rather than once though lazy static local initialization.
Attach callbacks with the assignment operator rather than with the
deprecated attach function. This fixes deprecation warnings.

This patch also adds the ability to attach a Callback directly.
The ISTAT register is write 1 to clear. Because of this ORing this
register with itself fill clear all bits that are set. This patch
updates the code to use plain assignment so only desired
bit is cleared.
@c1728p9 c1728p9 force-pushed the usb_fixes_and_improvements branch from fcd3f81 to beaac15 Compare January 18, 2018 02:56
@c1728p9
Copy link
Contributor Author

c1728p9 commented Jan 18, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Jan 18, 2018

Build : SUCCESS

Build number : 890
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/5874/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build

@mbed-ci
Copy link

mbed-ci commented Jan 18, 2018

@mbed-ci
Copy link

mbed-ci commented Jan 18, 2018

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 22, 2018

@c1728p9 Is this backward compatible changes? I would say it is not based on the diff here. Is this intentional?

@c1728p9
Copy link
Contributor Author

c1728p9 commented Jan 22, 2018

@0xc0170 the intent was to be backwards compatible. What are you concerned with? The only place this may cause issues is with USB classes outside of mbed-os which override the descriptor functions (as the return value was changes to const). If this is the problem you are concerned with then I could remove that part of this PR.

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 23, 2018

What are you concerned with? The only place this may cause issues is with USB classes outside of mbed-os which override the descriptor functions (as the return value was changes to const). If this is the problem you are concerned with then I could remove that part of this PR.

Yes, those changes I had on my mind as they are not binary compatible. Just concerned about breaking a user space. The rest looks good.

@Sissors
Copy link
Contributor

Sissors commented Jan 28, 2018

I tried to see if this solved my issues, however USBDevice lib is not linked to here apparently, and hasn't been updated in half a year (https://os.mbed.com/users/mbed_official/code/USBDevice/). It says it is legacy and refers to mbed-os, but as far as I can see mbed-os does not include USBDevice. Then again these days I don't understand mbed anymore anyway, so maybe just me.

@c1728p9
Copy link
Contributor Author

c1728p9 commented Feb 1, 2018

@Sissors unfortunately, the changes are only in mbed-os right now. To try out the changes copy this directory from mbed-os:
https://github.com/ARMmbed/mbed-os/tree/master/features/unsupported/USBDevice

@Sissors
Copy link
Contributor

Sissors commented Feb 1, 2018

Makes you wonder first why it is not synced to the USBDevice lib. But still. I got mbd-os imported in my project in the online compiler, and maybe I am missing something, but I can't find a USBDevice class, and the compiler also does not find it if I just include it.

Of course it could be setup in an offline compiler, but then I first needs to setup everything again.

Edit: Online compiler also cannot handle importing from sub-folders of a Github. I guess I'll try just importing all files via manual import, but still would be nice if USBDevice was actually get up to date.

@bmcdonnell-ionx
Copy link
Contributor

bmcdonnell-ionx commented Aug 29, 2018

EDIT: moved to #7928.

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 29, 2018

@bmcdonnell-ionx Thanks for the review, can you create a new issue please ? It improves the visibility.

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.

6 participants