boards/spresense: add rndis composite support

This commit is contained in:
raiden00pl 2023-03-24 11:33:31 +01:00 committed by Alan Carvalho de Assis
parent 6caa9317f6
commit 17e8163b6e
3 changed files with 269 additions and 27 deletions

View File

@ -0,0 +1,160 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_MMCSD_HAVE_WRITEPROTECT is not set
# CONFIG_MMCSD_SPI is not set
# CONFIG_MTD_SMART_WEAR_LEVEL is not set
# CONFIG_STANDARD_SERIAL is not set
CONFIG_ALLOW_BSD_COMPONENTS=y
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="spresense"
CONFIG_ARCH_BOARD_COMMON=y
CONFIG_ARCH_BOARD_SPRESENSE=y
CONFIG_ARCH_CHIP="cxd56xx"
CONFIG_ARCH_CHIP_CXD56XX=y
CONFIG_ARCH_INTERRUPTSTACK=2048
CONFIG_ARCH_LEDS_CPU_ACTIVITY=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARMV7M_USEBASEPRI=y
CONFIG_AUDIO=y
CONFIG_AUDIO_CXD56=y
CONFIG_BOARDCTL_RESET=y
CONFIG_BOARD_LOOPSPERMSEC=5434
CONFIG_BOOT_RUNFROMISRAM=y
CONFIG_BUILTIN=y
CONFIG_CDCACM=y
CONFIG_CDCACM_COMPOSITE=y
CONFIG_CODECS_HASH_MD5=y
CONFIG_COMPOSITE_IAD=y
CONFIG_CXD56_AUDIO_BUFFER_SIZE=2048
CONFIG_CXD56_AUDIO_NUM_BUFFERS=64
CONFIG_CXD56_AUDIO_WORKER_STACKSIZE=1024
CONFIG_CXD56_BINARY=y
CONFIG_CXD56_SDCARD_AUTOMOUNT=y
CONFIG_CXD56_SDIO=y
CONFIG_CXD56_USBDEV=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DRIVERS_AUDIO=y
CONFIG_ELF=y
CONFIG_EXAMPLES_FTPC=y
CONFIG_EXAMPLES_FTPD=y
CONFIG_EXAMPLES_HELLO=m
CONFIG_EXAMPLES_TCPBLASTER=y
CONFIG_EXAMPLES_TCPBLASTER_GROUPSIZE=500
CONFIG_EXAMPLES_TCPBLASTER_SENDSIZE=1400
CONFIG_EXAMPLES_TCPBLASTER_SERVER=y
CONFIG_EXAMPLES_TCPBLASTER_SERVERIP=0x0a00010f
CONFIG_EXAMPLES_TCPBLASTER_TARGET2=y
CONFIG_EXAMPLES_WEBSERVER=y
CONFIG_FAT_LCNAMES=y
CONFIG_FAT_LFN=y
CONFIG_FS_AUTOMOUNTER=y
CONFIG_FS_FAT=y
CONFIG_FS_FATTIME=y
CONFIG_FS_PROCFS=y
CONFIG_FS_PROCFS_REGISTER=y
CONFIG_FS_SMARTFS=y
CONFIG_FTP_TMPDIR="/mnt/sd0"
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_I2C=y
CONFIG_INIT_ENTRYPOINT="spresense_main"
CONFIG_INIT_STACKSIZE=3072
CONFIG_IOB_NBUFFERS=128
CONFIG_IOB_THROTTLE=24
CONFIG_LIBC_ENVPATH=y
CONFIG_LIBC_EXECFUNCS=y
CONFIG_MEMCPY_VIK=y
CONFIG_MEMSET_64BIT=y
CONFIG_MEMSET_OPTSPEED=y
CONFIG_MQ_MAXMSGSIZE=64
CONFIG_MTD_BYTE_WRITE=y
CONFIG_MTD_PARTITION=y
CONFIG_MTD_SMART=y
CONFIG_MTD_SMART_ENABLE_CRC=y
CONFIG_MTD_SMART_SECTOR_SIZE=4096
CONFIG_NAME_MAX=128
CONFIG_NET=y
CONFIG_NETDB_DNSCLIENT=y
CONFIG_NETINIT_MACADDR_1=0xdeadbeff
CONFIG_NETINIT_NOMAC=y
CONFIG_NETINIT_THREAD=y
CONFIG_NETUTILS_CODECS=y
CONFIG_NETUTILS_DHCPC=y
CONFIG_NETUTILS_FTPC=y
CONFIG_NETUTILS_FTPD=y
CONFIG_NETUTILS_HTTPD_DIRLIST=y
CONFIG_NETUTILS_HTTPD_SENDFILE=y
CONFIG_NETUTILS_IPERF=y
CONFIG_NETUTILS_TELNETD=y
CONFIG_NETUTILS_WEBCLIENT=y
CONFIG_NETUTILS_WEBSERVER=y
CONFIG_NET_ARP_SEND=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_ETH_PKTSIZE=1514
CONFIG_NET_ICMP=y
CONFIG_NET_ICMP_SOCKET=y
CONFIG_NET_LL_GUARDSIZE=50
CONFIG_NET_LOOPBACK=y
CONFIG_NET_PKT=y
CONFIG_NET_ROUTE=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_TCP_WRITE_BUFFERS=y
CONFIG_NET_UDP=y
CONFIG_NFS=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILE_APPS=y
CONFIG_NSH_READLINE=y
CONFIG_NSH_SYMTAB=y
CONFIG_NSH_SYMTAB_ARRAYNAME="g_symtab"
CONFIG_NSH_SYMTAB_COUNTNAME="g_nsymbols"
CONFIG_NXPLAYER_HTTP_STREAMING_SUPPORT=y
CONFIG_NXPLAYER_MAINTHREAD_STACKSIZE=3072
CONFIG_NXPLAYER_PLAYTHREAD_STACKSIZE=3072
CONFIG_PATH_INITIAL="/mnt/sd0/bin"
CONFIG_PREALLOC_MQ_MSGS=64
CONFIG_PREALLOC_TIMERS=4
CONFIG_RAM_SIZE=1572864
CONFIG_RAM_START=0x0d000000
CONFIG_READLINE_CMD_HISTORY=y
CONFIG_RNDIS=y
CONFIG_RNDIS_COMPOSITE=y
CONFIG_RR_INTERVAL=200
CONFIG_RTC=y
CONFIG_RTC_ALARM=y
CONFIG_RTC_DRIVER=y
CONFIG_RTC_FREQUENCY=32768
CONFIG_RTC_HIRES=y
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_WAITPID=y
CONFIG_SENDFILE_BUFSIZE=1024
CONFIG_SMARTFS_ALIGNED_ACCESS=y
CONFIG_SMARTFS_MAXNAMLEN=30
CONFIG_SMARTFS_MULTI_ROOT_DIRS=y
CONFIG_SPI=y
CONFIG_SPRESENSE_EXTENSION=y
CONFIG_STACK_COLORATION=y
CONFIG_START_DAY=16
CONFIG_START_MONTH=7
CONFIG_START_YEAR=2019
CONFIG_SYMTAB_ORDEREDBYNAME=y
CONFIG_SYSLOG_TIMESTAMP=y
CONFIG_SYSTEM_COMPOSITE=y
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_NXPLAYER=y
CONFIG_SYSTEM_NXRECORDER=y
CONFIG_SYSTEM_PING=y
CONFIG_TESTING_OSTEST=y
CONFIG_UART1_SERIAL_CONSOLE=y
CONFIG_USBDEV=y
CONFIG_USBDEV_COMPOSITE=y
CONFIG_USBDEV_DMA=y
CONFIG_USBDEV_DUALSPEED=y

View File

@ -458,7 +458,7 @@ int cxd56_bringup(void)
up_pm_release_wakelock(&wlock);
#if defined(CONFIG_RNDIS)
#if defined(CONFIG_RNDIS) && !defined(CONFIG_RNDIS_COMPOSITE)
uint8_t mac[6];
mac[0] = 0xa0; /* TODO */
mac[1] = (CONFIG_NETINIT_MACADDR_2 >> (8 * 0)) & 0xff;

View File

@ -30,10 +30,50 @@
#include <nuttx/usb/usbdev.h>
#include <nuttx/usb/cdcacm.h>
#include <nuttx/usb/usbmsc.h>
#include <nuttx/usb/rndis.h>
#include <nuttx/usb/composite.h>
#if defined(CONFIG_BOARDCTL_USBDEVCTRL) && defined(CONFIG_USBDEV_COMPOSITE)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#if defined(CONFIG_RNDIS_COMPOSITE) && defined(CONFIG_CDCACM_COMPOSITE) && \
defined(CONFIG_USBMSC_COMPOSITE)
# error Configuration not supported, not enough endpoints
#elif defined(CONFIG_RNDIS_COMPOSITE) && defined(CONFIG_USBMSC_COMPOSITE)
# define RNDIS_EP_INTIN (3)
# define RNDIS_EP_BULKIN (1)
# define RNDIS_EP_BULKOUT (2)
# define USBMSC_EP_BULKIN (4)
# define USBMSC_EP_BULKOUT (5)
#elif defined(CONFIG_CDCACM_COMPOSITE) && defined(CONFIG_USBMSC_COMPOSITE)
# define CDCACM_EP_INTIN (3)
# define CDCACM_EP_BULKIN (1)
# define CDCACM_EP_BULKOUT (2)
# define USBMSC_EP_BULKIN (4)
# define USBMSC_EP_BULKOUT (5)
#elif defined(CONFIG_RNDIS_COMPOSITE) && defined(CONFIG_CDCACM_COMPOSITE)
# define RNDIS_EP_INTIN (3)
# define RNDIS_EP_BULKIN (1)
# define RNDIS_EP_BULKOUT (2)
# define CDCACM_EP_INTIN (6)
# define CDCACM_EP_BULKIN (4)
# define CDCACM_EP_BULKOUT (5)
#elif defined(CONFIG_RNDIS_COMPOSITE)
# define RNDIS_EP_INTIN (3)
# define RNDIS_EP_BULKIN (1)
# define RNDIS_EP_BULKOUT (2)
#elif defined(CONFIG_CDCACM_COMPOSITE)
# define CDCACM_EP_INTIN (3)
# define CDCACM_EP_BULKIN (1)
# define CDCACM_EP_BULKOUT (2)
#elif defined(CONFIG_USBMSC_COMPOSITE)
# define USBMSC_EP_BULKIN (1)
# define USBMSC_EP_BULKOUT (2)
#endif
/****************************************************************************
* Private Data
****************************************************************************/
@ -185,81 +225,123 @@ void *board_composite_connect(int port, int configid)
* The standard is to use one CDC/ACM and one USB mass storage device.
*/
struct composite_devdesc_s dev[2];
int ifnobase = 0;
int strbase = COMPOSITE_NSTRIDS;
int dev_idx = 0;
if (configid == 0)
{
#ifdef CONFIG_USBMSC_COMPOSITE
struct composite_devdesc_s dev[2];
int ifnobase = 0;
int strbase = COMPOSITE_NSTRIDS;
#ifdef CONFIG_RNDIS_COMPOSITE
/* Configure the RNDIS USB device */
/* Ask the rndis driver to fill in the constants we didn't
* know here.
*/
usbdev_rndis_get_composite_devdesc(&dev[dev_idx]);
/* Interfaces */
dev[dev_idx].devinfo.ifnobase = ifnobase;
dev[dev_idx].minor = 0;
/* Strings */
dev[dev_idx].devinfo.strbase = strbase;
/* Endpoints */
dev[dev_idx].devinfo.epno[RNDIS_EP_INTIN_IDX] = RNDIS_EP_INTIN;
dev[dev_idx].devinfo.epno[RNDIS_EP_BULKIN_IDX] = RNDIS_EP_BULKIN;
dev[dev_idx].devinfo.epno[RNDIS_EP_BULKOUT_IDX] = RNDIS_EP_BULKOUT;
/* Count up the base numbers */
ifnobase += dev[dev_idx].devinfo.ninterfaces;
strbase += dev[dev_idx].devinfo.nstrings;
dev_idx += 1;
#endif
#ifdef CONFIG_USBMSC_COMPOSITE
/* Configure the mass storage device device */
/* Ask the usbmsc driver to fill in the constants we didn't
* know here.
*/
usbmsc_get_composite_devdesc(&dev[0]);
usbmsc_get_composite_devdesc(&dev[dev_idx]);
/* Overwrite and correct some values... */
/* The callback functions for the USBMSC class */
dev[0].classobject = board_mscclassobject;
dev[0].uninitialize = board_mscuninitialize;
dev[dev_idx].classobject = board_mscclassobject;
dev[dev_idx].uninitialize = board_mscuninitialize;
/* Interfaces */
dev[0].devinfo.ifnobase = ifnobase; /* Offset to Interface-IDs */
dev[0].minor = 0; /* The minor interface number */
dev[dev_idx].devinfo.ifnobase = ifnobase; /* Offset to Interface-IDs */
dev[dev_idx].minor = 0; /* The minor interface number */
/* Strings */
dev[0].devinfo.strbase = strbase; /* Offset to String Numbers */
dev[dev_idx].devinfo.strbase = strbase; /* Offset to String Numbers */
/* Endpoints */
dev[0].devinfo.epno[USBMSC_EP_BULKIN_IDX] = 1;
dev[0].devinfo.epno[USBMSC_EP_BULKOUT_IDX] = 2;
dev[dev_idx].devinfo.epno[USBMSC_EP_BULKIN_IDX] = USBMSC_EP_BULKIN;
dev[dev_idx].devinfo.epno[USBMSC_EP_BULKOUT_IDX] = USBMSC_EP_BULKOUT;
/* Count up the base numbers */
ifnobase += dev[0].devinfo.ninterfaces;
strbase += dev[0].devinfo.nstrings;
ifnobase += dev[dev_idx].devinfo.ninterfaces;
strbase += dev[dev_idx].devinfo.nstrings;
dev_idx += 1;
#endif
#ifdef CONFIG_CDCACM_COMPOSITE
/* Configure the CDC/ACM device */
/* Ask the cdcacm driver to fill in the constants we didn't
* know here.
*/
cdcacm_get_composite_devdesc(&dev[1]);
cdcacm_get_composite_devdesc(&dev[dev_idx]);
/* Overwrite and correct some values... */
/* The callback functions for the CDC/ACM class */
dev[1].classobject = cdcacm_classobject;
dev[1].uninitialize = cdcacm_uninitialize;
dev[dev_idx].classobject = cdcacm_classobject;
dev[dev_idx].uninitialize = cdcacm_uninitialize;
/* Interfaces */
dev[1].devinfo.ifnobase = ifnobase; /* Offset to Interface-IDs */
dev[1].minor = 0; /* The minor interface number */
dev[dev_idx].devinfo.ifnobase = ifnobase; /* Offset to Interface-IDs */
dev[dev_idx].minor = 0; /* The minor interface number */
/* Strings */
dev[1].devinfo.strbase = strbase; /* Offset to String Numbers */
dev[dev_idx].devinfo.strbase = strbase; /* Offset to String Numbers */
/* Endpoints */
dev[1].devinfo.epno[CDCACM_EP_INTIN_IDX] = 3;
dev[1].devinfo.epno[CDCACM_EP_BULKIN_IDX] = 4;
dev[1].devinfo.epno[CDCACM_EP_BULKOUT_IDX] = 5;
dev[dev_idx].devinfo.epno[CDCACM_EP_INTIN_IDX] = CDCACM_EP_INTIN;
dev[dev_idx].devinfo.epno[CDCACM_EP_BULKIN_IDX] = CDCACM_EP_BULKIN;
dev[dev_idx].devinfo.epno[CDCACM_EP_BULKOUT_IDX] = CDCACM_EP_BULKOUT;
return composite_initialize(2, dev);
#else
return NULL;
/* Count up the base numbers */
ifnobase += dev[dev_idx].devinfo.ninterfaces;
strbase += dev[dev_idx].devinfo.nstrings;
dev_idx += 1;
#endif
return composite_initialize(dev_idx, dev);
}
else
{