Merged in masayuki2009/nuttx.nuttx/rndis_on_spresense (pull request #895)
rndis on spresense * arch/arm/src/cxd56xx: Fix ep0 out packet handling in cxd56_usbdev.c This change fixes to handle ep0 out packet which exceeds EP0_MAXSIZE. For example, 76 bytes of out packet is sent from rndis host during rndis negotiation and finally the packet is split into two out packets (64 bytes out packet + 12 bytes out packet). To handle these packets, actual ep0reqlen is stored during ep0 out setup stage, and if all out packets are received, it dispatches to cxd56_ep0setup(), otherwise, it sets up the internal USB DMA to receive remaining out packets. Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com> * configs/spresense: Add support for rndis configuration Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com> Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
parent
5cd2a1ae68
commit
06aa50e9bb
@ -104,7 +104,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_SETUP_MAXDATASIZE
|
||||
# define CONFIG_USBDEV_SETUP_MAXDATASIZE CONFIG_USBDEV_EP0_MAXSIZE
|
||||
# define CONFIG_USBDEV_SETUP_MAXDATASIZE (CONFIG_USBDEV_EP0_MAXSIZE * 4)
|
||||
#endif
|
||||
|
||||
#define CONFIG_DEFAULT_PHY_CFG0 \
|
||||
@ -386,6 +386,7 @@ struct cxd56_usbdev_s
|
||||
|
||||
uint8_t ep0data[CONFIG_USBDEV_SETUP_MAXDATASIZE];
|
||||
uint16_t ep0datlen;
|
||||
uint16_t ep0reqlen;
|
||||
|
||||
/* The endpoint list */
|
||||
|
||||
@ -1269,6 +1270,8 @@ static inline void cxd56_ep0setup(FAR struct cxd56_usbdev_s *priv)
|
||||
value = GETUINT16(priv->ctrl.value);
|
||||
len = GETUINT16(priv->ctrl.len);
|
||||
|
||||
priv->ep0reqlen = len;
|
||||
|
||||
uinfo("type=%02x req=%02x value=%04x index=%04x len=%04x\n",
|
||||
priv->ctrl.type, priv->ctrl.req, value, index, len);
|
||||
|
||||
@ -1525,6 +1528,7 @@ static int cxd56_epinterrupt(int irq, FAR void *context)
|
||||
uint32_t eps;
|
||||
uint32_t stat;
|
||||
uint32_t ctrl;
|
||||
uint16_t len;
|
||||
int n;
|
||||
|
||||
eps = getreg32(CXD56_USB_DEV_EP_INTR);
|
||||
@ -1670,33 +1674,49 @@ static int cxd56_epinterrupt(int irq, FAR void *context)
|
||||
putreg32(USB_INT_OUT_DATA, CXD56_USB_OUT_EP_STATUS(n));
|
||||
if (n == 0)
|
||||
{
|
||||
priv->ep0datlen = g_ep0out.status & DESC_SIZE_MASK;
|
||||
len = g_ep0out.status & DESC_SIZE_MASK;
|
||||
|
||||
/* Reset DMA descriptor for next packet */
|
||||
|
||||
g_ep0out.status = privep->ep.maxpacket | DESC_LAST;
|
||||
|
||||
/* Ready to receive the next SETUP packet */
|
||||
|
||||
ctrl = getreg32(CXD56_USB_OUT_EP_CONTROL(0));
|
||||
putreg32(ctrl | USB_SNAK | USB_RRDY,
|
||||
CXD56_USB_OUT_EP_CONTROL(0));
|
||||
|
||||
/* Dispatch setup packet and out transaction */
|
||||
|
||||
if (priv->ep0datlen > 0)
|
||||
if (0 < len)
|
||||
{
|
||||
memcpy(priv->ep0data, (const void *)g_ep0out.buf,
|
||||
priv->ep0datlen);
|
||||
ASSERT(priv->ep0datlen + len <= sizeof(priv->ep0data));
|
||||
|
||||
memcpy(priv->ep0data + priv->ep0datlen,
|
||||
(const void *)g_ep0out.buf,
|
||||
len);
|
||||
|
||||
priv->ep0datlen += len;
|
||||
}
|
||||
|
||||
/* Dispatch to cxd56_ep0setup if received all OUT data */
|
||||
|
||||
if (priv->ep0datlen == priv->ep0reqlen)
|
||||
{
|
||||
if (((priv->ctrl.type & USB_REQ_TYPE_MASK) !=
|
||||
USB_REQ_TYPE_STANDARD) &&
|
||||
USB_REQ_ISOUT(priv->ctrl.type))
|
||||
{
|
||||
/* Ready to receive the next setup packet */
|
||||
|
||||
ctrl = getreg32(CXD56_USB_OUT_EP_CONTROL(0));
|
||||
putreg32(ctrl | USB_SNAK | USB_RRDY,
|
||||
CXD56_USB_OUT_EP_CONTROL(0));
|
||||
|
||||
cxd56_ep0setup(priv);
|
||||
priv->ep0datlen = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Ready to receive the next OUT packet */
|
||||
|
||||
ctrl = getreg32(CXD56_USB_OUT_EP_CONTROL(0));
|
||||
putreg32(ctrl | USB_CNAK | USB_RRDY,
|
||||
CXD56_USB_OUT_EP_CONTROL(0));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
97
configs/spresense/rndis/defconfig
Normal file
97
configs/spresense/rndis/defconfig
Normal file
@ -0,0 +1,97 @@
|
||||
#
|
||||
# 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_STANDARD_SERIAL is not set
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="spresense"
|
||||
CONFIG_ARCH_BOARD_SPRESENSE=y
|
||||
CONFIG_ARCH_CHIP_CXD56XX=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARMV7M_USEBASEPRI=y
|
||||
CONFIG_BOARDCTL_RESET=y
|
||||
CONFIG_BOARDCTL_USBDEVCTRL=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=5434
|
||||
CONFIG_BOOT_RUNFROMISRAM=y
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_CLOCK_MONOTONIC=y
|
||||
CONFIG_CODECS_HASH_MD5=y
|
||||
CONFIG_CXD56_SDIO=y
|
||||
CONFIG_CXD56_USBDEV=y
|
||||
CONFIG_DEBUG_FULLOPT=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_EXAMPLES_HELLO=y
|
||||
CONFIG_EXAMPLES_WEBSERVER=y
|
||||
CONFIG_FAT_LCNAMES=y
|
||||
CONFIG_FAT_LFN=y
|
||||
CONFIG_FAT_MAXFNAME=64
|
||||
CONFIG_FS_FAT=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_FS_PROCFS_REGISTER=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_I2C=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MAX_WDOGPARMS=2
|
||||
CONFIG_MMCSD=y
|
||||
CONFIG_MMCSD_SDIO=y
|
||||
CONFIG_NET=y
|
||||
CONFIG_NETDB_DNSCLIENT=y
|
||||
CONFIG_NETDEVICES=y
|
||||
CONFIG_NETINIT_MACADDR_1=0xdeadbeff
|
||||
CONFIG_NETINIT_NOMAC=y
|
||||
CONFIG_NETINIT_THREAD=y
|
||||
CONFIG_NETUTILS_CODECS=y
|
||||
CONFIG_NETUTILS_DHCPC=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=1500
|
||||
CONFIG_NET_ICMP=y
|
||||
CONFIG_NET_ICMP_SOCKET=y
|
||||
CONFIG_NET_LOOPBACK=y
|
||||
CONFIG_NET_PKT=y
|
||||
CONFIG_NET_ROUTE=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_TCP=y
|
||||
CONFIG_NET_UDP=y
|
||||
CONFIG_NET_UDP_BINDTODEVICE=y
|
||||
CONFIG_NFILE_DESCRIPTORS=8
|
||||
CONFIG_NFILE_STREAMS=8
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_NSH_TELNETD_CLIENTSTACKSIZE=3072
|
||||
CONFIG_NSH_WGET_USERAGENT="NuttX/7.2x.x (; http://www.nuttx.org/)"
|
||||
CONFIG_PREALLOC_MQ_MSGS=4
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PREALLOC_WDOGS=16
|
||||
CONFIG_RAM_SIZE=1572864
|
||||
CONFIG_RAM_START=0x0d000000
|
||||
CONFIG_READLINE_CMD_HISTORY=y
|
||||
CONFIG_RNDIS=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_LPWORK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_SPI=y
|
||||
CONFIG_STACK_COLORATION=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_NSH_CXXINITIALIZE=y
|
||||
CONFIG_SYSTEM_PING=y
|
||||
CONFIG_TELNET_CHARACTER_MODE=y
|
||||
CONFIG_UART1_SERIAL_CONSOLE=y
|
||||
CONFIG_USBDEV=y
|
||||
CONFIG_USBDEV_DMA=y
|
||||
CONFIG_USBDEV_DUALSPEED=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
@ -68,4 +68,8 @@ ifeq ($(CONFIG_USBMSC),y)
|
||||
CSRCS += cxd56_usbmsc.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NETDEVICES),y)
|
||||
CSRCS += cxd56_netinit.c
|
||||
endif
|
||||
|
||||
include $(TOPDIR)/configs/Board.mk
|
||||
|
@ -48,6 +48,10 @@
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#ifdef CONFIG_RNDIS
|
||||
#include <nuttx/usb/rndis.h>
|
||||
#endif
|
||||
|
||||
#include <arch/chip/pm.h>
|
||||
#include "chip.h"
|
||||
|
||||
@ -234,5 +238,16 @@ int cxd56_bringup(void)
|
||||
|
||||
up_pm_release_wakelock(&wlock);
|
||||
|
||||
#if defined(CONFIG_RNDIS)
|
||||
uint8_t mac[6];
|
||||
mac[0] = 0xa0; /* TODO */
|
||||
mac[1] = (CONFIG_NETINIT_MACADDR_2 >> (8 * 0)) & 0xff;
|
||||
mac[2] = (CONFIG_NETINIT_MACADDR_1 >> (8 * 3)) & 0xff;
|
||||
mac[3] = (CONFIG_NETINIT_MACADDR_1 >> (8 * 2)) & 0xff;
|
||||
mac[4] = (CONFIG_NETINIT_MACADDR_1 >> (8 * 1)) & 0xff;
|
||||
mac[5] = (CONFIG_NETINIT_MACADDR_1 >> (8 * 0)) & 0xff;
|
||||
usbdev_rndis_initialize(mac);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
55
configs/spresense/src/cxd56_netinit.c
Normal file
55
configs/spresense/src/cxd56_netinit.c
Normal file
@ -0,0 +1,55 @@
|
||||
/****************************************************************************
|
||||
* configs/spresense/src/cxd56_netinit.c
|
||||
*
|
||||
* Copyright 2019 Sony Home Entertainment & Sound Products Inc.
|
||||
* Author: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_netinitialize
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NET) && !defined(CONFIG_NETDEV_LATEINIT)
|
||||
void up_netinitialize(void)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user