Skip to content

Commit 5b24917

Browse files
zhhyu7xiaoxiang781216
authored andcommitted
usb_cdcmbim: add mbim device driver
./build.sh sim:usbdev -j12 sudo gdb nuttx/nuttx -ex "source nuttx/tools/gdb/__init__.py" below command to create mbim NIC on host nsh> conn 3 NuttX's MBIM device implementation adds an additional MBIM network card to the NuttX system, which can debug the data communication with the host, but this network card is unnecessary and needs to be removed when the business actually uses this driver, And the cdcncm_receive method needs to be re-implemented. Signed-off-by: zhanghongyu <[email protected]>
1 parent 271f765 commit 5b24917

File tree

7 files changed

+852
-156
lines changed

7 files changed

+852
-156
lines changed

boards/sim/sim/sim/configs/usbdev/defconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ CONFIG_NETUTILS_TELNETD=y
5757
CONFIG_NET_BINDTODEVICE=y
5858
CONFIG_NET_BROADCAST=y
5959
CONFIG_NET_CDCECM=y
60+
CONFIG_NET_CDCMBIM=y
6061
CONFIG_NET_CDCNCM=y
6162
CONFIG_NET_ETH_PKTSIZE=1518
6263
CONFIG_NET_ICMP_SOCKET=y
@@ -71,6 +72,7 @@ CONFIG_NET_IPFORWARD_NSTRUCT=100
7172
CONFIG_NET_IPv6=y
7273
CONFIG_NET_MAX_RECV_BUFSIZE=65535
7374
CONFIG_NET_MAX_SEND_BUFSIZE=65535
75+
CONFIG_NET_MBIM=y
7476
CONFIG_NET_NAT=y
7577
CONFIG_NET_RECV_BUFSIZE=16384
7678
CONFIG_NET_SEND_BUFSIZE=16384

boards/sim/sim/sim/src/sim_composite.c

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,53 @@ static void *board_composite2_connect(int port)
258258
return composite_initialize(composite_getdevdescs(), dev, dev_idx);
259259
}
260260

261+
/****************************************************************************
262+
* Name: board_composite3_connect
263+
*
264+
* Description:
265+
* Connect the USB composite device on the specified USB device port for
266+
* configuration 3.
267+
*
268+
* Input Parameters:
269+
* port - The USB device port.
270+
*
271+
* Returned Value:
272+
* A non-NULL handle value is returned on success. NULL is returned on
273+
* any failure.
274+
*
275+
****************************************************************************/
276+
277+
static void *board_composite3_connect(int port)
278+
{
279+
struct composite_devdesc_s dev[1];
280+
int dev_idx = 0;
281+
282+
#ifdef CONFIG_NET_CDCMBIM
283+
/* Configure the CDC/NCM device */
284+
285+
cdcmbim_get_composite_devdesc(&dev[dev_idx]);
286+
287+
/* Interfaces */
288+
289+
dev[dev_idx].devinfo.ifnobase = 0;
290+
dev[dev_idx].minor = 0;
291+
292+
/* Strings */
293+
294+
dev[dev_idx].devinfo.strbase = COMPOSITE_NSTRIDS - 1;
295+
296+
/* Endpoints */
297+
298+
dev[dev_idx].devinfo.epno[CDCNCM_EP_INTIN_IDX] = 5;
299+
dev[dev_idx].devinfo.epno[CDCNCM_EP_BULKIN_IDX] = 6;
300+
dev[dev_idx].devinfo.epno[CDCNCM_EP_BULKOUT_IDX] = 7;
301+
302+
dev_idx += 1;
303+
#endif
304+
305+
return composite_initialize(composite_getdevdescs(), dev, dev_idx);
306+
}
307+
261308
/****************************************************************************
262309
* Public Functions
263310
****************************************************************************/
@@ -303,10 +350,14 @@ void *board_composite_connect(int port, int configid)
303350
{
304351
return board_composite1_connect(port);
305352
}
306-
else
353+
else if (configid == 2)
307354
{
308355
return board_composite2_connect(port);
309356
}
357+
else
358+
{
359+
return board_composite3_connect(port);
360+
}
310361
}
311362

312363
#endif /* CONFIG_BOARDCTL_USBDEVCTRL && CONFIG_USBDEV_COMPOSITE */

drivers/usbdev/Kconfig

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,16 @@ menuconfig NET_CDCNCM
12481248

12491249
if NET_CDCNCM
12501250

1251+
config NET_CDCMBIM
1252+
bool "CDC-MBIM Ethernet-over-USB"
1253+
default n
1254+
---help---
1255+
This option may require CONFIG_NETDEV_LATEINIT=y, otherwise the
1256+
power-up initialization may call the non-existent xxx_netinitialize().
1257+
This option is not automatically selected because it may be that
1258+
you have an additional network device that requires the early
1259+
xxx_netinitialize() call.
1260+
12511261
menuconfig CDCNCM_COMPOSITE
12521262
bool "CDC/NCM composite support"
12531263
default n
@@ -1385,9 +1395,17 @@ config CDCNCM_VENDORSTR
13851395
default "NuttX"
13861396

13871397
config CDCNCM_PRODUCTSTR
1388-
string "Product string"
1398+
string "CDCNCM Product string"
13891399
default "CDC/NCM Ethernet"
13901400

1401+
if NET_CDCMBIM
1402+
1403+
config CDCMBIM_PRODUCTSTR
1404+
string "CDCMBIM Product string"
1405+
default "CDC/MBIM Ethernet"
1406+
1407+
endif # NET_CDCMBIM
1408+
13911409
endif # !CDCNCM_COMPOSITE
13921410

13931411
config CDCNCM_QUOTA_TX

0 commit comments

Comments
 (0)