[go: nahoru, domu]

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

REQ: Configurable constness of USB descriptors. #1541

Open
amalinowski75 opened this issue Apr 17, 2024 · 2 comments
Open

REQ: Configurable constness of USB descriptors. #1541

amalinowski75 opened this issue Apr 17, 2024 · 2 comments

Comments

@amalinowski75
Copy link

I've hit a problem with "constness" of field of structs of USB descriptors. In particular I had a problem with

const struct usb_endpoint_descriptor *endpoint; in usb_interface_descriptor struct in usbstd.h file.

The "const" qualifier prevents me from reconfiguring usb device in runtime. I need it as I need to change the configuration of composite devices (change their orders and the set of devices) on demand during the firmware execution. I overcame the problem by removing the qualifier from my copy of libopencm3 (submodule) but it's not an ideal solution.

I know the const qualifiers are in the code not without a reason but maybe I'm not alone and there are other people that need to have the structures in RAM to modify their fields and maybe we could make the constness configurable.

What do you think about that @karlp ?

@karlp
Copy link
Member
karlp commented Apr 18, 2024

Personally, I don't think it sounds like a good way to go. There's another PR that actually goes further to const the descriptors, so they can be entirely in flash, instead of being constructed into ram as they are now. (this is a big improvement for ram usage) But, I'm not goin to be doing any major work personally anyway, so see what other support you can drum up if you think this is a meaningful case. (You're the first person I've seen request it though, so perhaps consider if you can do this in other ways? pointing to alternate consts perhaps?)

@karlp karlp changed the title Configurable constness of USB descriptors. REQ: Configurable constness of USB descriptors. Apr 18, 2024
@amalinowski75
Copy link
Author

Yeah, I've seen this PR and I'm pretty aware of the fact that vast majority of developers are not interested in changing USB descriptors in runtime. I'm happy to be the first one here :)
I was thinking about creating a macro that could be either 'const' or empty depending on some definintion in Makefile.
I know people hate macros but that sounds like a pretty easy change. Of course it may be easy at first glance but in reality it may turn out to be a train of questions like which consts to macro-ize?, should be there some groups of cosnts, etc.
Anyway, at this point I'm going to create a fork of libopencm3 and use it for my project. Maybe I will come up with some PR for that in the future.
All I wanted was to see what's your opoinion on this kind of change and now I know it's not a song of the near future :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants