usbdev: add Android Debug Bridge driver

This commit is contained in:
Simon Piriou 2020-10-24 23:02:04 +02:00 committed by Alan Carvalho de Assis
parent d452a05910
commit b405722276
4 changed files with 2391 additions and 0 deletions

View File

@ -568,6 +568,135 @@ config CDCACM_PRODUCTSTR
endif # !CDCACM_COMPOSITE
endif # CDCACM
menuconfig USBADB
bool "USB Android Debug Bridge (ADB) support"
default n
---help---
Enables USB Android Debug Bridge (ADB) support
if USBADB
menuconfig USBADB_COMPOSITE
bool "USBADB composite support"
default n
depends on USBDEV_COMPOSITE
---help---
Configure the ADB driver as part of a composite driver
(only if USBDEV_COMPOSITE is also defined)
if !USBADB_COMPOSITE
# In a composite device the EP0 config comes from the composite device
# and the EP-Number is configured dynamically via composite_initialize
config USBADB_EP0MAXPACKET
int "Endpoint 0 max packet size"
default 64
---help---
Endpoint 0 max packet size. Default 64.
# In a composite device the EP-Numbers are configured dynamically via
# composite_initialize
config USBADB_EPBULKOUT
int "Bulk OUT endpoint number"
default 1
---help---
The logical 7-bit address of a hardware endpoint that supports
bulk OUT operation. Default: 3
config USBADB_EPBULKIN
int "Bulk IN endpoint number"
default 2
---help---
The logical 7-bit address of a hardware endpoint that supports
bulk IN operation. Default: 2
endif
config USBADB_EPBULKOUT_FSSIZE
int "Bulk OUT full speed MAXPACKET size"
default 64
---help---
Max package size for the bulk OUT endpoint if full speed mode.
Default 64.
config USBADB_EPBULKOUT_HSSIZE
int "Bulk OUT out high speed MAXPACKET size"
default 512
---help---
Max package size for the bulk OUT endpoint if high speed mode.
Default 512.
config USBADB_EPBULKIN_FSSIZE
int "Bulk IN full speed MAXPACKET size"
default 64
---help---
Max package size for the bulk IN endpoint if full speed mode.
Default 64.
config USBADB_EPBULKIN_HSSIZE
int "Bulk IN high speed MAXPACKET size"
default 512
---help---
Max package size for the bulk IN endpoint if high speed mode.
Default 512.
config USBADB_NRDREQS
int "Number of read requests that can be in flight"
default 4
---help---
The number of read requests that can be in flight
config USBADB_NWRREQS
int "Number of write requests that can be in flight"
default 4
---help---
The number of write/read requests that can be in flight
if !USBADB_COMPOSITE
config USBADB_VENDORID
hex "Vendor ID"
default 0x18d1
---help---
The vendor ID code/string. Default is Google Inc.
config USBADB_PRODUCTID
hex "Product ID"
default 0x4e11
---help---
The product ID code/string. Default is Nexus One.
config USBADB_VENDORSTR
string "Vendor string"
default "NuttX"
config USBADB_PRODUCTSTR
string "Product string"
default "Debug Bridge"
config USBADB_SERIALSTR
string "Serial string"
default "1234"
endif # !USBADB_COMPOSITE
config USBADB_CONFIGSTR
string "Configuration descriptor string"
default "ADB Config"
config USBADB_INTERFACESTR
string "Interface descriptor string"
default "ADB Interface"
config USBADB_NPOLLWAITERS
int "Number of ADB poll waiters"
default 1
---help---
Maximum number of threads that can be waiting on poll().
endif # USBADB
menuconfig USBMSC
bool "USB Mass storage class device"
default n

View File

@ -65,6 +65,10 @@ ifeq ($(CONFIG_DFU),y)
CSRCS += dfu.c
endif
ifeq ($(CONFIG_USBADB),y)
CSRCS += adb.c
endif
ifeq ($(CONFIG_NET_CDCECM),y)
CSRCS += cdcecm.c
endif

2166
drivers/usbdev/adb.c Normal file

File diff suppressed because it is too large Load Diff

92
include/nuttx/usb/adb.h Normal file
View File

@ -0,0 +1,92 @@
/****************************************************************************
* include/nuttx/usb/adb.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_USB_ADB_H
#define __INCLUDE_NUTTX_USB_ADB_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/usb/usbdev.h>
/****************************************************************************
* Preprocessor definitions
****************************************************************************/
/* Indexes for devinfo.epno[] array.
* Used for composite device configuration.
*/
#define USBADB_NUM_EPS (2)
#define USBADB_EP_BULKIN_IDX (0)
#define USBADB_EP_BULKOUT_IDX (1)
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
# define EXTERN extern "C"
extern "C"
{
#else
# define EXTERN extern
#endif
/****************************************************************************
* Name: usbdev_adb_initialize
*
* Description:
* Initialize the Android Debug Bridge USB device driver.
*
* Returned Value:
* 0 on success, -errno on failure
*
****************************************************************************/
int usbdev_adb_initialize(void);
/****************************************************************************
* Name: usbdev_adb_get_composite_devdesc
*
* Description:
* Helper function to fill in some constants into the composite
* configuration struct.
*
* Input Parameters:
* dev - Pointer to the configuration struct we should fill
*
* Returned Value:
* None
*
****************************************************************************/
void usbdev_adb_get_composite_devdesc(struct composite_devdesc_s *dev);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __INCLUDE_NUTTX_USB_ADB_H */