configs/stm32f4discovery: Add a USB MSC configuration
This commit is contained in:
parent
d02c0c05ae
commit
62e9c930bb
@ -1599,6 +1599,74 @@ Where <subdir> is one of the following:
|
||||
2015-04-30
|
||||
Appears to be fully functional.
|
||||
|
||||
12. Using USB Device as a Mass Storage for the host computer:
|
||||
|
||||
System Type --->
|
||||
STM32 Peripheral Support --->
|
||||
[*] OTG FS
|
||||
|
||||
Device Drivers --->
|
||||
[*] USB Device Driver Support --->
|
||||
[*] USB Mass storage class device --->
|
||||
[*] Mass storage removable
|
||||
|
||||
[*] RAM Disk Support
|
||||
|
||||
Board Selection --->
|
||||
[*] Enable boardctl() interface
|
||||
[*] Enable USB device controls
|
||||
|
||||
File Systems --->
|
||||
[*] FAT file system
|
||||
[*] FAT upper/lower names
|
||||
[*] FAT long file names
|
||||
|
||||
[*] PROCFS File System
|
||||
|
||||
Application Configuration --->
|
||||
System Libraries and NSH Add-Ons --->
|
||||
[*] USB Mass Storage Device Commands --->
|
||||
(/dev/ram0) LUN1 Device Path
|
||||
|
||||
Compile and flash the firmware in the board as usual, then in the nsh:
|
||||
|
||||
nsh> mkrd -m 0 -s 512 64
|
||||
|
||||
nsh> ls /dev
|
||||
/dev:
|
||||
console
|
||||
null
|
||||
ram0
|
||||
ttyS0
|
||||
|
||||
nsh> mkfatfs /dev/ram0
|
||||
|
||||
Connect a USB cable to STM32F4Discovery board (connector CN5) and run:
|
||||
|
||||
nsh> msconn
|
||||
mcsonn_main: Creating block drivers
|
||||
mcsonn_main: Configuring with NLUNS=1
|
||||
mcsonn_main: handle=1000a550
|
||||
mcsonn_main: Bind LUN=0 to /dev/ram0
|
||||
mcsonn_main: Connected
|
||||
|
||||
In this moment a 33KB disk should appear in your host computer. If you
|
||||
saved some file on this small disk you can now run disconnect command:
|
||||
|
||||
nsh> msdis
|
||||
msdis: Disconnected
|
||||
|
||||
Remove the USB cable from microUSB connector and run:
|
||||
|
||||
nsh> mount -t vfat /dev/ram0 /mnt
|
||||
|
||||
nsh> ls /mnt
|
||||
/mnt:
|
||||
TEST.TXT
|
||||
|
||||
nsh> cat /mnt/TEST.TXT
|
||||
Testing
|
||||
|
||||
nxlines:
|
||||
------
|
||||
An example using the NuttX graphics system (NX). This example focuses on
|
||||
|
@ -164,4 +164,8 @@ ifeq ($(CONFIG_BOARDCTL_UNIQUEID),y)
|
||||
CSRCS += stm32_uid.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_USBMSC),y)
|
||||
CSRCS += stm32_usbmsc.c
|
||||
endif
|
||||
|
||||
include $(TOPDIR)/configs/Board.mk
|
||||
|
85
configs/stm32f4discovery/src/stm32_usbmsc.c
Normal file
85
configs/stm32f4discovery/src/stm32_usbmsc.c
Normal file
@ -0,0 +1,85 @@
|
||||
/****************************************************************************
|
||||
* configs/stm32f4discovery/src/stm32_usbmsc.c
|
||||
*
|
||||
* Copyright (C) 2012, 2013, 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Configure and register the STM32 SPI-based MMC/SD block driver.
|
||||
*
|
||||
* 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>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#include "stm32.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#ifndef CONFIG_SYSTEM_USBMSC_DEVMINOR1
|
||||
# define CONFIG_SYSTEM_USBMSC_DEVMINOR1 0
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_usbmsc_initialize
|
||||
*
|
||||
* Description:
|
||||
* Perform architecture specific initialization of the USB MSC device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_usbmsc_initialize(int port)
|
||||
{
|
||||
/* If system/usbmsc is built as an NSH command, then SD slot should
|
||||
* already have been initialized in board_app_initialize() (see stm32_appinit.c).
|
||||
* In this case, there is nothing further to be done here.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NSH_BUILTIN_APPS
|
||||
return stm32_sdinitialize(CONFIG_SYSTEM_USBMSC_DEVMINOR1);
|
||||
#else
|
||||
return OK;
|
||||
#endif
|
||||
}
|
62
configs/stm32f4discovery/usbmsc/defconfig
Normal file
62
configs/stm32f4discovery/usbmsc/defconfig
Normal file
@ -0,0 +1,62 @@
|
||||
CONFIG_ARCH="arm"
|
||||
CONFIG_ARCH_BOARD="stm32f4discovery"
|
||||
CONFIG_ARCH_BOARD_STM32F4_DISCOVERY=y
|
||||
CONFIG_ARCH_BUTTONS=y
|
||||
CONFIG_ARCH_CHIP_STM32F407VG=y
|
||||
CONFIG_ARCH_CHIP_STM32=y
|
||||
# CONFIG_ARCH_FPU is not set
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_DISABLE_POLL=y
|
||||
CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y
|
||||
CONFIG_EXAMPLES_NSH=y
|
||||
CONFIG_FAT_LCNAMES=y
|
||||
CONFIG_FAT_LFN=y
|
||||
CONFIG_FS_FAT=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_INTELHEX_BINARY=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MAX_WDOGPARMS=2
|
||||
CONFIG_MM_REGIONS=2
|
||||
CONFIG_NFILE_DESCRIPTORS=8
|
||||
CONFIG_NFILE_STREAMS=8
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_DISABLE_IFUPDOWN=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_MQ_MSGS=4
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PREALLOC_WDOGS=8
|
||||
CONFIG_RAMDISK=y
|
||||
CONFIG_RAM_SIZE=114688
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_HPWORKPRIORITY=192
|
||||
CONFIG_SCHED_HPWORK=y
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_START_DAY=27
|
||||
CONFIG_START_YEAR=2013
|
||||
CONFIG_STM32_JTAG_SW_ENABLE=y
|
||||
CONFIG_STM32_OTGFS=y
|
||||
CONFIG_STM32_PWR=y
|
||||
CONFIG_STM32_SPI1=y
|
||||
CONFIG_STM32_USART2=y
|
||||
CONFIG_SYSLOG_CHAR=y
|
||||
CONFIG_SYSLOG_DEVPATH="/dev/ttyS0"
|
||||
CONFIG_SYSTEM_USBMSC_DEVPATH1="/dev/ram0"
|
||||
CONFIG_SYSTEM_USBMSC=y
|
||||
CONFIG_TASK_NAME_SIZE=0
|
||||
CONFIG_USART2_SERIAL_CONSOLE=y
|
||||
CONFIG_USBDEV=y
|
||||
CONFIG_USBMSC_REMOVABLE=y
|
||||
CONFIG_USBMSC=y
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
CONFIG_WDOG_INTRESERVE=1
|
Loading…
Reference in New Issue
Block a user