board: add ADB example for stm32/photon
This commit is contained in:
parent
1f5786f5ea
commit
5892927aea
80
boards/arm/stm32/photon/configs/adb/defconfig
Normal file
80
boards/arm/stm32/photon/configs/adb/defconfig
Normal file
@ -0,0 +1,80 @@
|
||||
#
|
||||
# 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_ARCH_LEDS is not set
|
||||
# CONFIG_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
# CONFIG_NSH_CMDPARMS is not set
|
||||
CONFIG_ADBD_AUTHENTICATION=y
|
||||
CONFIG_ADBD_AUTH_PUBKEY=y
|
||||
CONFIG_ADBD_BOARD_INIT=y
|
||||
CONFIG_ADBD_DEVICE_ID="serialno"
|
||||
CONFIG_ADBD_FILE_SERVICE=y
|
||||
CONFIG_ADBD_LOGCAT_SERVICE=y
|
||||
CONFIG_ADBD_SHELL_SERVICE=y
|
||||
CONFIG_ADBD_USB_SERVER=y
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="photon"
|
||||
CONFIG_ARCH_BOARD_PHOTON=y
|
||||
CONFIG_ARCH_CHIP="stm32"
|
||||
CONFIG_ARCH_CHIP_STM32=y
|
||||
CONFIG_ARCH_CHIP_STM32F205RG=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_CLOCK_MONOTONIC=y
|
||||
CONFIG_DEBUG_ERROR=y
|
||||
CONFIG_DEBUG_FEATURES=y
|
||||
CONFIG_DEBUG_INFO=y
|
||||
CONFIG_DEBUG_WARN=y
|
||||
CONFIG_DEV_FIFO_SIZE=128
|
||||
CONFIG_DEV_PIPE_MAXSIZE=128
|
||||
CONFIG_DEV_PIPE_SIZE=128
|
||||
CONFIG_DEV_URANDOM=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_LIBUV=y
|
||||
CONFIG_LIBUV_PIPE=y
|
||||
CONFIG_LIBUV_STREAM=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MM_REGIONS=2
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PHOTON_DFU_BOOTLOADER=y
|
||||
CONFIG_PHOTON_IWDG=y
|
||||
CONFIG_PHOTON_WDG_THREAD=y
|
||||
CONFIG_PIPES=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_RAMLOG=y
|
||||
CONFIG_RAMLOG_BUFSIZE=2048
|
||||
CONFIG_RAMLOG_OVERWRITE=y
|
||||
CONFIG_RAMLOG_SYSLOG=y
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
CONFIG_START_YEAR=2011
|
||||
CONFIG_STM32_IWDG=y
|
||||
CONFIG_STM32_JTAG_SW_ENABLE=y
|
||||
CONFIG_STM32_OTGHS=y
|
||||
CONFIG_STM32_USART1=y
|
||||
CONFIG_SYSTEM_ADBD=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_USART1_SERIAL_CONSOLE=y
|
||||
CONFIG_USBADB=y
|
||||
CONFIG_USBDEV=y
|
||||
CONFIG_USBDEV_BUSPOWERED=y
|
||||
CONFIG_USERMAIN_STACKSIZE=3072
|
||||
CONFIG_USER_ENTRYPOINT="adbd_main"
|
@ -71,6 +71,10 @@ ifeq ($(CONFIG_RGBLED),y)
|
||||
CSRCS += stm32_rgbled.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USBDEV_COMPOSITE),y)
|
||||
CSRCS += stm32_composite.c
|
||||
endif
|
||||
|
||||
DEPPATH += --dep-path board
|
||||
VPATH += :board
|
||||
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)
|
||||
|
@ -52,6 +52,10 @@
|
||||
#include "photon.h"
|
||||
#include "stm32_wdg.h"
|
||||
|
||||
#ifdef CONFIG_USBADB
|
||||
# include <nuttx/usb/adb.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -60,10 +64,10 @@
|
||||
* Name: stm32_bringup
|
||||
*
|
||||
* Description:
|
||||
* Called either by board_initialize() if CONFIG_BOARD_LATE_INITIALIZE or by
|
||||
* board_app_initialize if CONFIG_LIB_BOARDCTL is selected. This function
|
||||
* initializes and configures all on-board features appropriate for the
|
||||
* selected configuration.
|
||||
* Called either by board_initialize() if CONFIG_BOARD_LATE_INITIALIZE or
|
||||
* by board_app_initialize if CONFIG_LIB_BOARDCTL is selected.
|
||||
* This function initializes and configures all on-board features
|
||||
* appropriate for the selected configuration.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -153,5 +157,26 @@ int stm32_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USBDEV_COMPOSITE
|
||||
|
||||
#ifndef CONFIG_BOARDCTL_USBDEVCTRL
|
||||
ret = board_composite_initialize(0);
|
||||
if (ret != OK)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize composite: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (board_composite_connect(0, 0) == NULL)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to connect composite: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif /* !CONFIG_BOARDCTL_USBDEVCTRL */
|
||||
#else
|
||||
#ifdef CONFIG_USBADB
|
||||
usbdev_adb_initialize();
|
||||
#endif
|
||||
#endif /* CONFIG_USBDEV_COMPOSITE */
|
||||
return ret;
|
||||
}
|
||||
|
164
boards/arm/stm32/photon/src/stm32_composite.c
Normal file
164
boards/arm/stm32/photon/src/stm32_composite.c
Normal file
@ -0,0 +1,164 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/stm32/photon/src/stm32_composite.c
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/adb.h>
|
||||
#include <nuttx/usb/composite.h>
|
||||
|
||||
#include "stm32.h"
|
||||
|
||||
#if defined(CONFIG_BOARDCTL_USBDEVCTRL) && defined(CONFIG_USBDEV_COMPOSITE)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_composite0_connect
|
||||
*
|
||||
* Description:
|
||||
* Connect the USB composite device on the specified USB device port for
|
||||
* configuration 0.
|
||||
*
|
||||
* Input Parameters:
|
||||
* port - The USB device port.
|
||||
*
|
||||
* Returned Value:
|
||||
* A non-NULL handle value is returned on success. NULL is returned on
|
||||
* any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static FAR void *board_composite0_connect(int port)
|
||||
{
|
||||
/* Here we are composing the configuration of the usb composite device.
|
||||
*
|
||||
* The standard is to use one CDC/ACM and one USB mass storage device.
|
||||
*/
|
||||
|
||||
/* Change "dev" array size to add more composite devs */
|
||||
|
||||
struct composite_devdesc_s dev[1];
|
||||
int ifnobase = 0;
|
||||
int strbase = (COMPOSITE_NSTRIDS) - 1;
|
||||
|
||||
int dev_idx = 0;
|
||||
|
||||
#ifdef CONFIG_USBADB
|
||||
/* Configure the ADB USB device */
|
||||
|
||||
/* Ask the adb driver to fill in the constants we didn't
|
||||
* know here.
|
||||
*/
|
||||
|
||||
usbdev_adb_get_composite_devdesc(&dev[dev_idx]);
|
||||
|
||||
/* Interfaces */
|
||||
|
||||
dev[dev_idx].devinfo.ifnobase = ifnobase; /* Offset to Interface-IDs */
|
||||
dev[dev_idx].minor = 0; /* The minor interface number */
|
||||
|
||||
/* Strings */
|
||||
|
||||
dev[dev_idx].devinfo.strbase = strbase; /* Offset to String Numbers */
|
||||
|
||||
/* Endpoints */
|
||||
|
||||
dev[dev_idx].devinfo.epno[USBADB_EP_BULKIN_IDX] = 1;
|
||||
dev[dev_idx].devinfo.epno[USBADB_EP_BULKOUT_IDX] = 2;
|
||||
|
||||
/* Count up the base numbers */
|
||||
|
||||
ifnobase += dev[dev_idx].devinfo.ninterfaces;
|
||||
strbase += dev[dev_idx].devinfo.nstrings;
|
||||
|
||||
dev_idx += 1;
|
||||
#endif
|
||||
|
||||
/* Add other composite devices here */
|
||||
|
||||
return composite_initialize(dev_idx, dev);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_composite_initialize
|
||||
*
|
||||
* Description:
|
||||
* Perform architecture specific initialization of a composite USB device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_composite_initialize(int port)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_composite_connect
|
||||
*
|
||||
* Description:
|
||||
* Connect the USB composite device on the specified USB device port using
|
||||
* the specified configuration. The interpretation of the configid is
|
||||
* board specific.
|
||||
*
|
||||
* Input Parameters:
|
||||
* port - The USB device port.
|
||||
* configid - The USB composite configuration
|
||||
*
|
||||
* Returned Value:
|
||||
* A non-NULL handle value is returned on success. NULL is returned on
|
||||
* any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR void *board_composite_connect(int port, int configid)
|
||||
{
|
||||
if (configid == 0)
|
||||
{
|
||||
return board_composite0_connect(port);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BOARDCTL_USBDEVCTRL && CONFIG_USBDEV_COMPOSITE */
|
Loading…
Reference in New Issue
Block a user