-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
usbus/msc: add CONFIG_USBUS_MSC_AUTO_MTD option to create LUNs on init #19356
Conversation
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'm quite puzzled by this PR right now.
I'd like the idea to initialize USBUS
through auto_init()
but on the other side, I don't think we should export all MTD devices by default and I don't like the idea of keeping the MSC ON all the time.
As I said in #19242, there are some use cases for this but I still don't think it should be the default behavior.
Boards which provides STDIO through CDC-ACM are tricky because in the current state, users need to have USB attached to the host to have the shell and configure which MTD devices to be exported. But we need to configure those devices before attaching USB to the host so we're a bit stuck here unless we accept to quickly detach/attach the USB (and thus, lose the serial connection for a few ms).
# Purposely disable auto_attach for this application | ||
CFLAGS += -DCONFIG_USBUS_AUTO_ATTACH=0 |
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 CONFIG_USBUS_MSC_AUTO_MTD
is set to 0, removing this will lead to issue in the application test.
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.
tbh I wonder why - attaching with no LUNs configured should be no problem if we then detach before adding LUNs, right?
I think I saw an empty (0 byte) device on the host instead, but that might be a bug.
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 CONFIG_USBUS_MSC_AUTO_MTD
is set to 0 and if we auto attach USB device. No LUNs will be available at the enumuration. Then host will asks the number of available LUNs to the device with an USB_MSC_SETUP_REQ_GML
request and answering 0 is not possible by the spec.
I guess we can remove it for now as CONFIG_USBUS_MSC_AUTO_MTD
is set by default.
I'll figured it out later.
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.
But can we simply not advertise the MSC endpoint if no LUNs are configured?
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.
Yup, but enable MSC at runtime will require to reset the USB and this might be troublesome for CDC-ACM stdio devices especially on Windows.
* @return MTD_0 for @p idx 0 and so on | ||
* NULL if no MTD device exists for the given index | ||
*/ | ||
static inline mtd_dev_t *mtd_default_get_dev(unsigned idx) |
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.
Just wondering here:
Why the default
part ? mtd_get_dev()
would fit well too.
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.
It only works if the MTD devices follow the default naming convention
Please squash. |
6fc64d4
to
73400cb
Compare
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.
ACK.
bors merge |
Build succeeded: |
Contribution description
I had some trouble combining
tests/usbus_msc
withstdio_cdc_acm
.Turns out the test was creating it's own usbus and was therefore not compatible with other modules that make use of usbus.
Fix this by adding USB MSC to
auto_init_usbus
and add a config optionCONFIG_USBUS_MSC_AUTO_MTD
to export all MTD devices on startup.Testing procedure
tests/usbus_msc
now provides all MTD devices via USB without manual configutaiton.More importantly, it now also works on boards that use
stdio_cdc_acm
likeadafruit-itsybitsy-m4
:Issues/PRs references