-
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
Changes from all commits
b6d2209
092009e
f3dc90c
bbda852
73400cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (C) 2023 ML!PA Consulting GmbH | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
/** | ||
* @ingroup drivers_mtd | ||
* @{ | ||
* @brief Default MTD device configuration | ||
* | ||
* Helpers for generic MTD use. | ||
* | ||
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com> | ||
*/ | ||
#ifndef MTD_DEFAULT_H | ||
#define MTD_DEFAULT_H | ||
|
||
#include "board.h" | ||
#include "mtd.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief Number of MTD devices | ||
*/ | ||
#ifndef MTD_NUMOF | ||
#if defined(MTD_3) | ||
#define MTD_NUMOF 4 | ||
#elif defined(MTD_2) | ||
#define MTD_NUMOF 3 | ||
#elif defined(MTD_1) | ||
#define MTD_NUMOF 2 | ||
#elif defined(MTD_0) | ||
#define MTD_NUMOF 1 | ||
#else | ||
#define MTD_NUMOF 0 | ||
#endif | ||
#endif | ||
|
||
/** | ||
* @brief Get the default MTD device by index | ||
* | ||
* @param[in] idx Index of the MTD device | ||
* | ||
* @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) | ||
{ | ||
switch (idx) { | ||
#ifdef MTD_0 | ||
case 0: return MTD_0; | ||
#endif | ||
#ifdef MTD_1 | ||
case 1: return MTD_1; | ||
#endif | ||
#ifdef MTD_2 | ||
case 2: return MTD_2; | ||
#endif | ||
#ifdef MTD_3 | ||
case 3: return MTD_3; | ||
#endif | ||
} | ||
|
||
return NULL; | ||
} | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* MTD_DEFAULT_H */ | ||
/** @} */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,6 @@ USEMODULE += ps | |
USEMODULE += shell | ||
USEMODULE += usbus_msc | ||
USEMODULE += ztimer_msec | ||
# Purposely disable auto_attach for this application | ||
CFLAGS += -DCONFIG_USBUS_AUTO_ATTACH=0 | ||
Comment on lines
-21
to
-22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. If I guess we can remove it for now as I'll figured it out later. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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. |
||
|
||
# Change this to 0 show compiler invocation lines by default: | ||
QUIET ?= 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.
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