Add support for STM32F107 OTG FS (doesn't work) and update USB support for Viewtools STM32F107~

This commit is contained in:
Gregory Nutt 2013-12-26 09:22:37 -06:00
parent 6a04f59a9d
commit f4d13c4acb
7 changed files with 244 additions and 26 deletions

View File

@ -145,17 +145,95 @@ USB Interface
7 Shield N/A N/A
8 Shield N/A N/A
9 Shield N/A N/A
PE11 USB_EN GPIO controlled soft pull-up
PE11 USB_EN GPIO controlled soft pull-up (if J51 closed)
NOTES:
1. GPIO_OTGFS_VBUS (F107) should not be configured. No VBUS sensing
2. GPIO_OTGFS_SOF (F107) is not used
3. The OTG FS module has is own, internal soft pull-up logic. J51 should
be open so that PE11 activity does effect USB.
Configuration
-------------
To be provided. Some logic is in place, leveraged from other boards.
But this logic is not full implemented, not has it ever been built or\
tested.
STM32F103 Configuration
-----------------------
System Type -> STM32 Peripheral Support
CONFIG_STM32_USB=y : Enable USB FS device
Device Drivers
CONFIG_USBDEV : USB device support
STATUS: All of the code is in place, but no testing has been performed.
STM32F107 Configuration
-----------------------
System Type -> STM32 Peripheral Support
CONFIG_STM32_OTGFS=y : Enable OTG FS
Device Drivers
CONFIG_USBDEV : USB device support
STATUS: All of the code is in place, but USB is not yet functional.
CDC/ACM Configuration
---------------------
This will select the CDC/ACM serial device. Defaults for the other
options should be okay.
Device Drivers -> USB Device Driver Support
CONFIG_CDCACM=y : Enable the CDC/ACM device
The following setting enables an example that can can be used to control
the CDC/ACM device. It will add two new NSH commands:
a. sercon will connect the USB serial device (creating /dev/ttyACM0), and
b. serdis which will disconnect the USB serial device (destroying
/dev/ttyACM0).
Application Configuration -> Examples:
CONFIG_SYSTEM_CDCACM=y : Enable an CDC/ACM example
USB MSC Configuration
---------------------
[WARNING: This configuration has not yet been verified]
The Mass Storage Class (MSC) class driver can be selected in order to
export the microSD card to the host computer. MSC support is selected:
Device Drivers -> USB Device Driver Support
CONFIG_USBMSC=y : Enable the USB MSC class driver
CONFIG_USBMSC_EPBULKOUT=1 : Use EP1 for the BULK OUT endpoint
CONFIG_USBMSC_EPBULKIN=2 : Use EP2 for the BULK IN endpoint
The following setting enables an add-on that can can be used to control
the USB MSC device. It will add two new NSH commands:
a. msconn will connect the USB serial device and export the microSD
card to the host, and
b. msdis which will disconnect the USB serial device.
Application Configuration -> System Add-Ons:
CONFIG_SYSTEM_USBMSC=y : Enable the USBMSC add-on
CONFIG_SYSTEM_USBMSC_NLUNS=1 : One LUN
CONFIG_SYSTEM_USBMSC_DEVMINOR1=0 : Minor device zero
CONFIG_SYSTEM_USBMSC_DEVPATH1="/dev/mmcsd0"
: Use a single, LUN: The microSD
: block driver.
NOTES:
a. To prevent file system corruption, make sure that the microSD is un-
mounted *before* exporting the mass storage device to the host:
nsh> umount /mnt/sdcard
nsh> mscon
The microSD can be re-mounted after the mass storage class is disconnected:
nsh> msdis
nsh> mount -t vfat /dev/mtdblock0 /mnt/at25
microSD Card Interface
======================
@ -183,9 +261,44 @@ microSD Card Interface
cannot be used with the STM32F107 (unless the pin-out just happens to match up
with an SPI-based card interface???)
Configuration
-------------
To be provided (for the STM32F103 only)
Configuration (STM32F103 only)
------------------------------
[WARNING: This configuration has not yet been verified]
Enabling SDIO-based MMC/SD support:
System Type->STM32 Peripheral Support
CONFIG_STM32_SDIO=y : Enable SDIO support
CONFIG_STM32_DMA2=y : DMA2 is needed by the driver
Device Drivers -> MMC/SD Driver Support
CONFIG_MMCSD=y : Enable MMC/SD support
CONFIG_MMSCD_NSLOTS=1 : One slot per driver instance
CONFIG_MMCSD_HAVECARDDETECT=y : Supports card-detect PIOs
CONFIG_MMCSD_MMCSUPPORT=n : Interferes with some SD cards
CONFIG_MMCSD_SPI=n : No SPI-based MMC/SD support
CONFIG_MMCSD_SDIO=y : SDIO-based MMC/SD support
CONFIG_SDIO_DMA=y : Use SDIO DMA
CONFIG_SDIO_BLOCKSETUP=y : Needs to know block sizes
Library Routines
CONFIG_SCHED_WORKQUEUE=y : Driver needs work queue support
Application Configuration -> NSH Library
CONFIG_NSH_ARCHINIT=y : NSH board-initialization
Using the SD card
-----------------
1) After booting, an SDIO device will appear as /dev/mmcsd0
2) If you try mounting an SD card with nothing in the slot, the
mount will fail:
nsh> mount -t vfat /dev/mmcsd1 /mnt/sd1
nsh: mount: mount failed: 19
STATUS: All of the code is in place, but no testing has been performed.
ViewTool DP83848 Ethernet Module
================================
@ -424,6 +537,9 @@ Configurations
CONFIG_WINDOWS_CYGWIN=y : POSIX environment under windows
CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y : CodeSourcery for Windows
6. USB support is disabled by default. See the section above entitled,
"USB Interface"
nsh:
This configuration directory provide the basic NuttShell (NSH).
@ -453,6 +569,9 @@ Configurations
CONFIG_WINDOWS_CYGWIN=y : POSIX environment under windows
CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y : CodeSourcery for Windows
4. USB support is disabled by default. See the section above entitled,
"USB Interface"
highpri:
This configuration was used to verify the NuttX high priority, nested

View File

@ -102,7 +102,10 @@
#define STM32_APB1_TIM6_CLKIN (STM32_PCLK1_FREQUENCY)
#define STM32_APB1_TIM7_CLKIN (STM32_PCLK1_FREQUENCY)
/* USB divider -- Divide PLL clock by 1.5 */
/* USB divider -- Divide PLL clock by 1.5
*
* USB clock = PLLOUT / 1.5 = 72MHz / 1.5 = 48MHz
*/
#define STM32_CFGR_USBPRE 0

View File

@ -106,9 +106,19 @@
#define STM32_APB1_TIM6_CLKIN (STM32_PCLK1_FREQUENCY)
#define STM32_APB1_TIM7_CLKIN (STM32_PCLK1_FREQUENCY)
/* USB divider -- Divide PLL clock by 1.5
*
* USB clock = PLLOUT / 1.5 = 72MHz / 1.5 = 48MHz
*/
#define STM32_CFGR_USBPRE 0
/* MCO output driven by PLL3. From above, we already have PLL3 input frequency as:
*
* STM32_PLL_PREDIV2 = 5, 25MHz / 5 => 5MHz
* STM32_PLL_PREDIV2 = 5, 25MHz / 5 => 5MHz
*
* NOTE: The Viewtool DP83848C module has its on, on-board 50MHz clock. No
* MCO clock need be provided on that board.
*/
#if defined(CONFIG_STM32_MII_MCO) || defined(CONFIG_STM32_RMII_MCO)

View File

@ -46,6 +46,22 @@
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* Default MMC/SD SLOT number */
#ifdef HAVE_MMCSD
# if defined(CONFIG_NSH_MMCSDSLOTNO) && CONFIG_NSH_MMCSDSLOTNO != VIEWTOOL_MMCSD_SLOTNO
# error "Only one MMC/SD slot: VIEWTOOL_MMCSD_SLOTNO"
# undef CONFIG_NSH_MMCSDSLOTNO
# define CONFIG_NSH_MMCSDSLOTNO VIEWTOOL_MMCSD_SLOTNO
# endif
# ifndef CONFIG_NSH_MMCSDSLOTNO
# define CONFIG_NSH_MMCSDSLOTNO VIEWTOOL_MMCSD_SLOTNO
# endif
#endif
#endif
/* Debug ********************************************************************/
@ -77,5 +93,9 @@
int nsh_archinitialize(void)
{
#ifdef HAVE_MMCSD
return stm32_sdinitialize(CONFIG_NSH_MMCSDSLOTNO);
#else
return OK;
#endif
}

View File

@ -54,13 +54,6 @@
* Pre-processor Definitions
************************************************************************************/
#ifdef CONFIG_USBDEV
# define HAVE_USB 1
#else
# warning CONFIG_STM32_OTGFS (F107) or CONFIG_STM32_USB (F103) is enabled but CONFIG_USBDEV is not
# undef HAVE_USB
#endif
/************************************************************************************
* Private Data
************************************************************************************/
@ -85,12 +78,33 @@
void stm32_usbdev_initialize(void)
{
/* The OTG FS has an internal soft pull-up. No GPIO configuration is required */
#warning REVISIT: The Viewtool board does, indeed, have a soft connect GPIO
/* Configure the OTG FS VBUS sensing GPIO and power enable GPIO */
#warning REVISIT: GPIO setup
#ifdef CONFIG_ARCH_CHIP_STM32F103VCT6
stm32_configgpio(GPIO_USB_PULLUP);
#endif
}
/************************************************************************************
* Name: stm32_usbpullup
*
* Description:
* If USB is supported and the board supports a pullup via GPIO (for USB software
* connect and disconnect), then the board software must provide stm32_pullup.
* See include/nuttx/usb/usbdev.h for additional description of this method.
* Alternatively, if no pull-up GPIO the following EXTERN can be redefined to be
* NULL.
*
************************************************************************************/
#ifdef CONFIG_ARCH_CHIP_STM32F103VCT6
int stm32_usbpullup(FAR struct usbdev_s *dev, bool enable)
{
usbtrace(TRACE_DEVPULLUP, (uint16_t)enable);
stm32_gpiowrite(GPIO_USB_PULLUP, !enable);
return OK;
}
#endif
/************************************************************************************
* Name: stm32_usbsuspend
*

View File

@ -54,7 +54,7 @@
/* Configuration ************************************************************/
#ifndef CONFIG_SYSTEM_USBMSC_DEVMINOR1
# define CONFIG_SYSTEM_USBMSC_DEVMINOR1 0
# define CONFIG_SYSTEM_USBMSC_DEVMINOR1 VIEWTOOL_MMCSD_SLOTNO
#endif
/* Debug ********************************************************************/
@ -92,11 +92,11 @@
int usbmsc_archinitialize(void)
{
/* If system/usbmsc is built as an NSH command, then SD slot should
* already have been initized in nsh_archinitialize() (see up_nsh.c). In
* already have been initialized in nsh_archinitialize() (see up_nsh.c). In
* this case, there is nothing further to be done here.
*/
#ifndef CONFIG_NSH_BUILTIN_APPS
#if defined(HAVE_MMCSD) && !defined(CONFIG_NSH_BUILTIN_APPS)
return stm32_sdinitialize(CONFIG_SYSTEM_USBMSC_DEVMINOR1);
#else
return OK;

View File

@ -46,6 +46,51 @@
/******************************************************************************
* Pre-processor Definitions
******************************************************************************/
/* Configuration **************************************************************/
/* Assume that everything is supported */
#define HAVE_USBDEV 1
#define HAVE_MMCSD 1
/* Handle chip differences */
#if defined(CONFIG_ARCH_CHIP_STM32F103VCT6)
# undef CONFIG_STM32_OTGFS
#elif defined(CONFIG_ARCH_CHIP_STM32F107VC)
# undef CONFIG_STM32_USB
# undef CONFIG_STM32_SDIO
#else
# error Unknown chip on Viewtool board
# undef HAVE_USBDEV
# undef HAVE_MMCSD
#endif
/* Check if USB is enabled */
#if !defined(CONFIG_STM32_OTGFS) && !defined(CONFIG_STM32_USB)
# undef HAVE_USBDEV
#elif !defined(CONFIG_USBDEV)
# warning CONFIG_STM32_OTGFS (F107) or CONFIG_STM32_USB (F103) is enabled but CONFIG_USBDEV is not
# undef HAVE_USB
#endif
/* Can't support MMC/SD features if the SDIO peripheral is disabled */
#ifndef CONFIG_STM32_SDIO
# undef HAVE_MMCSD
#endif
/* Can't support MMC/SD features if mountpoints are disabled */
#ifdef CONFIG_DISABLE_MOUNTPOINT
# undef HAVE_MMCSD
#endif
/* Default MMC/SD slot number/device minor number */
#define VIEWTOOL_MMCSD_SLOTNO 0
/* GPIO Configuration *********************************************************/
/* LEDs
*
* There are four LEDs on the ViewTool STM32F103/F107 board that can be controlled
@ -114,7 +159,7 @@
*/
#ifdef CONFIG_ARCH_CHIP_STM32F103VCT6
# define GPIO_SD_CD (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_EXTI|GPIO_PORTA|GPIO_PIN8)
# define GPIO_SD_CD (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_EXTI|GPIO_PORTA|GPIO_PIN8)
#endif
/* USB
@ -137,13 +182,20 @@
* 7 Shield N/A N/A
* 8 Shield N/A N/A
* 9 Shield N/A N/A
* PE11 USB_EN GPIO controlled soft pull-up
* PE11 USB_EN GPIO controlled soft pull-up (if J51 closed)
*
* NOTES:
* 1. GPIO_OTGFS_VBUS (F107) should not be configured. No VBUS sensing
* 2. GPIO_OTGFS_SOF (F107) is not used
* 3. The OTG FS module has is own, internal soft pull-up logic. J51 should
* be open so that PE11 activity does effect USB.
*/
#ifdef CONFIG_ARCH_CHIP_STM32F103VCT6
# define GPIO_USB_PULLUP (GPIO_OUTPUT|GPIO_CNF_OUTOD|GPIO_MODE_50MHz|\
GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN11)
#endif
/************************************************************************************
* Public Functions
************************************************************************************/