Massive name change USB STRG -> USB MSC
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4335 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
c2266ac99a
commit
29ecefa25a
@ -85,7 +85,7 @@ endif
|
||||
ifeq ($(CONFIG_EXAMPLES_TOUCHSCREEN_BUILTIN),y)
|
||||
CNTXTDIRS += touchscreen
|
||||
endif
|
||||
ifeq ($(CONFIG_EXAMPLES_USBSTRG_BUILTIN),y)
|
||||
ifeq ($(CONFIG_EXAMPLES_USBMSC_BUILTIN),y)
|
||||
CNTXTDIRS += usbstorage
|
||||
endif
|
||||
ifeq ($(CONFIG_EXAMPLES_USBTERM_BUILTIN),y)
|
||||
|
@ -1034,57 +1034,57 @@ examples/usbstorage
|
||||
the device using the USB storage class driver. In order to use this
|
||||
example, your board-specific logic must provide the function:
|
||||
|
||||
void usbstrg_archinitialize(void);
|
||||
void usbmsc_archinitialize(void);
|
||||
|
||||
This function will be called by the example/usbstorage in order to
|
||||
do the actual registration of the block device drivers. For examples
|
||||
of the implementation of usbstrg_archinitialize() see
|
||||
configs/mcu123-lpc124x/src/up_usbstrg.c or
|
||||
configs/stm3210e-eval/src/usbstrg.c
|
||||
of the implementation of usbmsc_archinitialize() see
|
||||
configs/mcu123-lpc124x/src/up_usbmsc.c or
|
||||
configs/stm3210e-eval/src/usbmsc.c
|
||||
|
||||
Configuration options:
|
||||
|
||||
CONFIG_EXAMPLES_USBSTRG_BUILTIN
|
||||
CONFIG_EXAMPLES_USBMSC_BUILTIN
|
||||
This example can be built as two NSH "built-in" commands if this option
|
||||
is selection: 'msconn' will connect the USB mass storage device; 'msdis'
|
||||
will disconnect the USB storage device.
|
||||
CONFIG_EXAMPLES_USBSTRG_NLUNS
|
||||
CONFIG_EXAMPLES_USBMSC_NLUNS
|
||||
Defines the number of logical units (LUNs) exported by the USB storage
|
||||
driver. Each LUN corresponds to one exported block driver (or partition
|
||||
of a block driver). May be 1, 2, or 3. Default is 1.
|
||||
CONFIG_EXAMPLES_USBSTRG_DEVMINOR1
|
||||
CONFIG_EXAMPLES_USBMSC_DEVMINOR1
|
||||
The minor device number of the block driver for the first LUN. For
|
||||
example, N in /dev/mmcsdN. Used for registering the block driver. Default
|
||||
is zero.
|
||||
CONFIG_EXAMPLES_USBSTRG_DEVPATH1
|
||||
CONFIG_EXAMPLES_USBMSC_DEVPATH1
|
||||
The full path to the registered block driver. Default is "/dev/mmcsd0"
|
||||
CONFIG_EXAMPLES_USBSTRG_DEVMINOR2 and CONFIG_EXAMPLES_USBSTRG_DEVPATH2
|
||||
Similar parameters that would have to be provided if CONFIG_EXAMPLES_USBSTRG_NLUNS
|
||||
CONFIG_EXAMPLES_USBMSC_DEVMINOR2 and CONFIG_EXAMPLES_USBMSC_DEVPATH2
|
||||
Similar parameters that would have to be provided if CONFIG_EXAMPLES_USBMSC_NLUNS
|
||||
is 2 or 3. No defaults.
|
||||
CONFIG_EXAMPLES_USBSTRG_DEVMINOR3 and CONFIG_EXAMPLES_USBSTRG_DEVPATH3
|
||||
Similar parameters that would have to be provided if CONFIG_EXAMPLES_USBSTRG_NLUNS
|
||||
CONFIG_EXAMPLES_USBMSC_DEVMINOR3 and CONFIG_EXAMPLES_USBMSC_DEVPATH3
|
||||
Similar parameters that would have to be provided if CONFIG_EXAMPLES_USBMSC_NLUNS
|
||||
is 3. No defaults.
|
||||
CONFIG_EXAMPLES_USBSTRG_DEBUGMM
|
||||
CONFIG_EXAMPLES_USBMSC_DEBUGMM
|
||||
Enables some debug tests to check for memory usage and memory leaks.
|
||||
|
||||
If CONFIG_USBDEV_TRACE is enabled (or CONFIG_DEBUG and CONFIG_DEBUG_USB), then
|
||||
the example code will also manage the USB trace output. The amount of trace output
|
||||
can be controlled using:
|
||||
|
||||
CONFIG_EXAMPLES_USBSTRG_TRACEINIT
|
||||
CONFIG_EXAMPLES_USBMSC_TRACEINIT
|
||||
Show initialization events
|
||||
CONFIG_EXAMPLES_USBSTRG_TRACECLASS
|
||||
CONFIG_EXAMPLES_USBMSC_TRACECLASS
|
||||
Show class driver events
|
||||
CONFIG_EXAMPLES_USBSTRG_TRACETRANSFERS
|
||||
CONFIG_EXAMPLES_USBMSC_TRACETRANSFERS
|
||||
Show data transfer events
|
||||
CONFIG_EXAMPLES_USBSTRG_TRACECONTROLLER
|
||||
CONFIG_EXAMPLES_USBMSC_TRACECONTROLLER
|
||||
Show controller events
|
||||
CONFIG_EXAMPLES_USBSTRG_TRACEINTERRUPTS
|
||||
CONFIG_EXAMPLES_USBMSC_TRACEINTERRUPTS
|
||||
Show interrupt-related events.
|
||||
|
||||
Error results are always shown in the trace output
|
||||
|
||||
NOTE 1: When built as an NSH add-on command (CONFIG_EXAMPLES_USBSTRG_BUILTIN=y),
|
||||
NOTE 1: When built as an NSH add-on command (CONFIG_EXAMPLES_USBMSC_BUILTIN=y),
|
||||
Caution should be used to assure that the SD drive (or other storage device) is
|
||||
not in use when the USB storage device is configured. Specifically, the SD
|
||||
driver should be unmounted like:
|
||||
|
@ -1,8 +1,8 @@
|
||||
############################################################################
|
||||
# apps/examples/usbstorage/Makefile
|
||||
#
|
||||
# Copyright (C) 2008, 2010-2011 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
# Copyright (C) 2008, 2010-2012 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
@ -40,7 +40,7 @@ include $(APPDIR)/Make.defs
|
||||
# USB device mass storage example
|
||||
|
||||
ASRCS =
|
||||
CSRCS = usbstrg_main.c
|
||||
CSRCS = usbmsc_main.c
|
||||
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||
@ -86,7 +86,7 @@ $(COBJS): %$(OBJEXT): %.c
|
||||
@touch .built
|
||||
|
||||
.context:
|
||||
ifeq ($(CONFIG_EXAMPLES_USBSTRG_BUILTIN),y)
|
||||
ifeq ($(CONFIG_EXAMPLES_USBMSC_BUILTIN),y)
|
||||
$(call REGISTER,$(APPNAME1),$(PRIORITY1),$(STACKSIZE1),$(APPNAME1)_main)
|
||||
$(call REGISTER,$(APPNAME2),$(PRIORITY2),$(STACKSIZE2),$(APPNAME2)_main)
|
||||
@touch $@
|
||||
|
@ -1,8 +1,8 @@
|
||||
/****************************************************************************
|
||||
* examples/usbstorage/usbstrg.h
|
||||
* examples/usbstorage/usbmsc.h
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
* Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -33,8 +33,8 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __EXAMPLES_USBSTORAGE_USBSTRG_H
|
||||
#define __EXAMPLES_USBSTORAGE_USBSTRG_H
|
||||
#ifndef __EXAMPLES_USBSTORAGE_USBMSC_H
|
||||
#define __EXAMPLES_USBSTORAGE_USBMSC_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
@ -49,34 +49,34 @@
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_USBSTRG_NLUNS
|
||||
# define CONFIG_EXAMPLES_USBSTRG_NLUNS 1
|
||||
#ifndef CONFIG_EXAMPLES_USBMSC_NLUNS
|
||||
# define CONFIG_EXAMPLES_USBMSC_NLUNS 1
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_USBSTRG_DEVMINOR1
|
||||
# define CONFIG_EXAMPLES_USBSTRG_DEVMINOR1 0
|
||||
#ifndef CONFIG_EXAMPLES_USBMSC_DEVMINOR1
|
||||
# define CONFIG_EXAMPLES_USBMSC_DEVMINOR1 0
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_USBSTRG_DEVPATH1
|
||||
# define CONFIG_EXAMPLES_USBSTRG_DEVPATH1 "/dev/mmcsd0"
|
||||
#ifndef CONFIG_EXAMPLES_USBMSC_DEVPATH1
|
||||
# define CONFIG_EXAMPLES_USBMSC_DEVPATH1 "/dev/mmcsd0"
|
||||
#endif
|
||||
|
||||
#if CONFIG_EXAMPLES_USBSTRG_NLUNS > 1
|
||||
# ifndef CONFIG_EXAMPLES_USBSTRG_DEVMINOR2
|
||||
# error "CONFIG_EXAMPLES_USBSTRG_DEVMINOR2 for LUN=2"
|
||||
#if CONFIG_EXAMPLES_USBMSC_NLUNS > 1
|
||||
# ifndef CONFIG_EXAMPLES_USBMSC_DEVMINOR2
|
||||
# error "CONFIG_EXAMPLES_USBMSC_DEVMINOR2 for LUN=2"
|
||||
# endif
|
||||
# ifndef CONFIG_EXAMPLES_USBSTRG_DEVPATH2
|
||||
# error "CONFIG_EXAMPLES_USBSTRG_DEVPATH2 for LUN=2"
|
||||
# ifndef CONFIG_EXAMPLES_USBMSC_DEVPATH2
|
||||
# error "CONFIG_EXAMPLES_USBMSC_DEVPATH2 for LUN=2"
|
||||
# endif
|
||||
# if CONFIG_EXAMPLES_USBSTRG_NLUNS > 2
|
||||
# ifndef CONFIG_EXAMPLES_USBSTRG_DEVMINOR3
|
||||
# error "CONFIG_EXAMPLES_USBSTRG_DEVMINOR2 for LUN=3"
|
||||
# if CONFIG_EXAMPLES_USBMSC_NLUNS > 2
|
||||
# ifndef CONFIG_EXAMPLES_USBMSC_DEVMINOR3
|
||||
# error "CONFIG_EXAMPLES_USBMSC_DEVMINOR2 for LUN=3"
|
||||
# endif
|
||||
# ifndef CONFIG_EXAMPLES_USBSTRG_DEVPATH2
|
||||
# error "CONFIG_EXAMPLES_USBSTRG_DEVPATH2 for LUN=3"
|
||||
# ifndef CONFIG_EXAMPLES_USBMSC_DEVPATH2
|
||||
# error "CONFIG_EXAMPLES_USBMSC_DEVPATH2 for LUN=3"
|
||||
# endif
|
||||
# if CONFIG_EXAMPLES_USBSTRG_NLUNS > 3
|
||||
# error "CONFIG_EXAMPLES_USBSTRG_NLUNS must be {1,2,3}"
|
||||
# if CONFIG_EXAMPLES_USBMSC_NLUNS > 3
|
||||
# error "CONFIG_EXAMPLES_USBMSC_NLUNS must be {1,2,3}"
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
@ -109,17 +109,17 @@
|
||||
* order to avoid name collisions.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_EXAMPLES_USBSTRG_BUILTIN) || defined(CONFIG_EXAMPLES_USBSTRG_DEBUGMM)
|
||||
struct usbstrg_state_s
|
||||
#if defined(CONFIG_EXAMPLES_USBMSC_BUILTIN) || defined(CONFIG_EXAMPLES_USBMSC_DEBUGMM)
|
||||
struct usbmsc_state_s
|
||||
{
|
||||
/* This is the handle that references to this particular USB storage driver
|
||||
* instance. It is only needed if the USB mass storage device example is
|
||||
* built using CONFIG_EXAMPLES_USBSTRG_BUILTIN. In this case, the value
|
||||
* built using CONFIG_EXAMPLES_USBMSC_BUILTIN. In this case, the value
|
||||
* of the driver handle must be remembered between the 'msconn' and 'msdis'
|
||||
* commands.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_USBSTRG_BUILTIN
|
||||
#ifdef CONFIG_EXAMPLES_USBMSC_BUILTIN
|
||||
FAR void *mshandle;
|
||||
#endif
|
||||
|
||||
@ -127,7 +127,7 @@ struct usbstrg_state_s
|
||||
* usage and for tracking down memoryh leaks.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_USBSTRG_DEBUGMM
|
||||
#ifdef CONFIG_EXAMPLES_USBMSC_DEBUGMM
|
||||
struct mallinfo mmstart; /* Memory usage before the connection */
|
||||
struct mallinfo mmprevious; /* The last memory usage sample */
|
||||
struct mallinfo mmcurrent; /* The current memory usage sample */
|
||||
@ -143,8 +143,8 @@ struct usbstrg_state_s
|
||||
* order to avoid name collisions.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_EXAMPLES_USBSTRG_BUILTIN) || defined(CONFIG_EXAMPLES_USBSTRG_DEBUGMM)
|
||||
extern struct usbstrg_state_s g_usbstrg;
|
||||
#if defined(CONFIG_EXAMPLES_USBMSC_BUILTIN) || defined(CONFIG_EXAMPLES_USBMSC_DEBUGMM)
|
||||
extern struct usbmsc_state_s g_usbmsc;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
@ -152,7 +152,7 @@ extern struct usbstrg_state_s g_usbstrg;
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbstrg_archinitialize
|
||||
* Name: usbmsc_archinitialize
|
||||
*
|
||||
* Description:
|
||||
* Perform architecture specific initialization. This function must
|
||||
@ -161,6 +161,6 @@ extern struct usbstrg_state_s g_usbstrg;
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
extern int usbstrg_archinitialize(void);
|
||||
extern int usbmsc_archinitialize(void);
|
||||
|
||||
#endif /* __EXAMPLES_USBSTORAGE_USBSTRG_H */
|
||||
#endif /* __EXAMPLES_USBSTORAGE_USBMSC_H */
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* examples/usbstorage/usbstrg_main.c
|
||||
* examples/usbstorage/usbmsc_main.c
|
||||
*
|
||||
* Copyright (C) 2008-2011 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2008-2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -48,13 +48,13 @@
|
||||
#include <nuttx/usb/usbdev.h>
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
|
||||
#include "usbstrg.h"
|
||||
#include "usbmsc.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_USBSTRG_TRACEINIT
|
||||
#ifdef CONFIG_EXAMPLES_USBMSC_TRACEINIT
|
||||
# define TRACE_INIT_BITS (TRACE_INIT_BIT)
|
||||
#else
|
||||
# define TRACE_INIT_BITS (0)
|
||||
@ -62,26 +62,26 @@
|
||||
|
||||
#define TRACE_ERROR_BITS (TRACE_DEVERROR_BIT|TRACE_CLSERROR_BIT)
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_USBSTRG_TRACECLASS
|
||||
#ifdef CONFIG_EXAMPLES_USBMSC_TRACECLASS
|
||||
# define TRACE_CLASS_BITS (TRACE_CLASS_BIT|TRACE_CLASSAPI_BIT|TRACE_CLASSSTATE_BIT)
|
||||
#else
|
||||
# define TRACE_CLASS_BITS (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_USBSTRG_TRACETRANSFERS
|
||||
#ifdef CONFIG_EXAMPLES_USBMSC_TRACETRANSFERS
|
||||
# define TRACE_TRANSFER_BITS (TRACE_OUTREQQUEUED_BIT|TRACE_INREQQUEUED_BIT|TRACE_READ_BIT|\
|
||||
TRACE_WRITE_BIT|TRACE_COMPLETE_BIT)
|
||||
#else
|
||||
# define TRACE_TRANSFER_BITS (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_USBSTRG_TRACECONTROLLER
|
||||
#ifdef CONFIG_EXAMPLES_USBMSC_TRACECONTROLLER
|
||||
# define TRACE_CONTROLLER_BITS (TRACE_EP_BIT|TRACE_DEV_BIT)
|
||||
#else
|
||||
# define TRACE_CONTROLLER_BITS (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_USBSTRG_TRACEINTERRUPTS
|
||||
#ifdef CONFIG_EXAMPLES_USBMSC_TRACEINTERRUPTS
|
||||
# define TRACE_INTERRUPT_BITS (TRACE_INTENTRY_BIT|TRACE_INTDECODE_BIT|TRACE_INTEXIT_BIT)
|
||||
#else
|
||||
# define TRACE_INTERRUPT_BITS (0)
|
||||
@ -98,8 +98,8 @@
|
||||
* order to avoid name collisions.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_EXAMPLES_USBSTRG_BUILTIN) || defined(CONFIG_EXAMPLES_USBSTRG_DEBUGMM)
|
||||
struct usbstrg_state_s g_usbstrg;
|
||||
#if defined(CONFIG_EXAMPLES_USBMSC_BUILTIN) || defined(CONFIG_EXAMPLES_USBMSC_DEBUGMM)
|
||||
struct usbmsc_state_s g_usbmsc;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
@ -110,7 +110,7 @@ struct usbstrg_state_s g_usbstrg;
|
||||
* Name: show_memory_usage
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_USBSTRG_DEBUGMM
|
||||
#ifdef CONFIG_EXAMPLES_USBMSC_DEBUGMM
|
||||
static void show_memory_usage(struct mallinfo *mmbefore,
|
||||
struct mallinfo *mmafter)
|
||||
{
|
||||
@ -140,28 +140,28 @@ static void show_memory_usage(struct mallinfo *mmbefore,
|
||||
* Name: check_test_memory_usage
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_USBSTRG_DEBUGMM
|
||||
#ifdef CONFIG_EXAMPLES_USBMSC_DEBUGMM
|
||||
static void check_test_memory_usage(FAR const char *msg)
|
||||
{
|
||||
/* Get the current memory usage */
|
||||
|
||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
g_usbstrg.mmcurrent = mallinfo();
|
||||
g_usbmsc.mmcurrent = mallinfo();
|
||||
#else
|
||||
(void)mallinfo(&g_usbstrg.mmcurrent);
|
||||
(void)mallinfo(&g_usbmsc.mmcurrent);
|
||||
#endif
|
||||
|
||||
/* Show the change from the previous time */
|
||||
|
||||
message("\%s:\n", msg);
|
||||
show_memory_usage(&g_usbstrg.mmprevious, &g_usbstrg.mmcurrent);
|
||||
show_memory_usage(&g_usbmsc.mmprevious, &g_usbmsc.mmcurrent);
|
||||
|
||||
/* Set up for the next test */
|
||||
|
||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
g_usbstrg.mmprevious = g_usbstrg.mmcurrent;
|
||||
g_usbmsc.mmprevious = g_usbmsc.mmcurrent;
|
||||
#else
|
||||
memcpy(&g_usbstrg.mmprevious, &g_usbstrg.mmcurrent, sizeof(struct mallinfo));
|
||||
memcpy(&g_usbmsc.mmprevious, &g_usbmsc.mmcurrent, sizeof(struct mallinfo));
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
@ -172,32 +172,32 @@ static void check_test_memory_usage(FAR const char *msg)
|
||||
* Name: check_test_memory_usage
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_USBSTRG_DEBUGMM
|
||||
#ifdef CONFIG_EXAMPLES_USBMSC_DEBUGMM
|
||||
static void final_memory_usage(FAR const char *msg)
|
||||
{
|
||||
/* Get the current memory usage */
|
||||
|
||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
g_usbstrg.mmcurrent = mallinfo();
|
||||
g_usbmsc.mmcurrent = mallinfo();
|
||||
#else
|
||||
(void)mallinfo(&g_usbstrg.mmcurrent);
|
||||
(void)mallinfo(&g_usbmsc.mmcurrent);
|
||||
#endif
|
||||
|
||||
/* Show the change from the previous time */
|
||||
|
||||
message("\n%s:\n", msg);
|
||||
show_memory_usage(&g_usbstrg.mmstart, &g_usbstrg.mmcurrent);
|
||||
show_memory_usage(&g_usbmsc.mmstart, &g_usbmsc.mmcurrent);
|
||||
}
|
||||
#else
|
||||
# define final_memory_usage(msg)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbstrg_enumerate
|
||||
* Name: usbmsc_enumerate
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_USBDEV_TRACE
|
||||
static int usbstrg_enumerate(struct usbtrace_s *trace, void *arg)
|
||||
static int usbmsc_enumerate(struct usbtrace_s *trace, void *arg)
|
||||
{
|
||||
switch (trace->event)
|
||||
{
|
||||
@ -383,13 +383,13 @@ static int usbstrg_enumerate(struct usbtrace_s *trace, void *arg)
|
||||
*
|
||||
* Description:
|
||||
* This is the main program that configures the USB mass storage device
|
||||
* and exports the LUN(s). If CONFIG_EXAMPLES_USBSTRG_BUILTIN is defined
|
||||
* and exports the LUN(s). If CONFIG_EXAMPLES_USBMSC_BUILTIN is defined
|
||||
* in the NuttX configuration, then this program can be executed by
|
||||
* entering the "msconn" command at the NSH console.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_USBSTRG_BUILTIN
|
||||
#ifdef CONFIG_EXAMPLES_USBMSC_BUILTIN
|
||||
# define MAIN_NAME msconn_main
|
||||
# define MAIN_NAME_STRING "msconn"
|
||||
#else
|
||||
@ -406,26 +406,26 @@ int MAIN_NAME(int argc, char *argv[])
|
||||
* do a little error checking to assure that we are not being called re-entrantly.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_USBSTRG_BUILTIN
|
||||
#ifdef CONFIG_EXAMPLES_USBMSC_BUILTIN
|
||||
|
||||
/* Check if there is a non-NULL USB mass storage device handle (meaning that the
|
||||
* USB mass storage device is already configured).
|
||||
*/
|
||||
|
||||
if (g_usbstrg.mshandle)
|
||||
if (g_usbmsc.mshandle)
|
||||
{
|
||||
message(MAIN_NAME_STRING ": ERROR: Already connected\n");
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_USBSTRG_DEBUGMM
|
||||
#ifdef CONFIG_EXAMPLES_USBMSC_DEBUGMM
|
||||
# ifdef CONFIG_CAN_PASS_STRUCTS
|
||||
g_usbstrg.mmstart = mallinfo();
|
||||
g_usbstrg.mmprevious = g_usbstrg.mmstart;
|
||||
g_usbmsc.mmstart = mallinfo();
|
||||
g_usbmsc.mmprevious = g_usbmsc.mmstart;
|
||||
# else
|
||||
(void)mallinfo(&g_usbstrg.mmstart);
|
||||
memcpy(&g_usbstrg.mmprevious, &g_usbstrg.mmstart, sizeof(struct mallinfo));
|
||||
(void)mallinfo(&g_usbmsc.mmstart);
|
||||
memcpy(&g_usbmsc.mmprevious, &g_usbmsc.mmstart, sizeof(struct mallinfo));
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ -437,82 +437,82 @@ int MAIN_NAME(int argc, char *argv[])
|
||||
/* Register block drivers (architecture-specific) */
|
||||
|
||||
message(MAIN_NAME_STRING ": Creating block drivers\n");
|
||||
ret = usbstrg_archinitialize();
|
||||
ret = usbmsc_archinitialize();
|
||||
if (ret < 0)
|
||||
{
|
||||
message(MAIN_NAME_STRING ": usbstrg_archinitialize failed: %d\n", -ret);
|
||||
message(MAIN_NAME_STRING ": usbmsc_archinitialize failed: %d\n", -ret);
|
||||
return 2;
|
||||
}
|
||||
check_test_memory_usage("After usbstrg_archinitialize()");
|
||||
check_test_memory_usage("After usbmsc_archinitialize()");
|
||||
|
||||
/* Then exports the LUN(s) */
|
||||
|
||||
message(MAIN_NAME_STRING ": Configuring with NLUNS=%d\n", CONFIG_EXAMPLES_USBSTRG_NLUNS);
|
||||
ret = usbstrg_configure(CONFIG_EXAMPLES_USBSTRG_NLUNS, &handle);
|
||||
message(MAIN_NAME_STRING ": Configuring with NLUNS=%d\n", CONFIG_EXAMPLES_USBMSC_NLUNS);
|
||||
ret = usbmsc_configure(CONFIG_EXAMPLES_USBMSC_NLUNS, &handle);
|
||||
if (ret < 0)
|
||||
{
|
||||
message(MAIN_NAME_STRING ": usbstrg_configure failed: %d\n", -ret);
|
||||
usbstrg_uninitialize(handle);
|
||||
message(MAIN_NAME_STRING ": usbmsc_configure failed: %d\n", -ret);
|
||||
usbmsc_uninitialize(handle);
|
||||
return 3;
|
||||
}
|
||||
message(MAIN_NAME_STRING ": handle=%p\n", handle);
|
||||
check_test_memory_usage("After usbstrg_configure()");
|
||||
check_test_memory_usage("After usbmsc_configure()");
|
||||
|
||||
message(MAIN_NAME_STRING ": Bind LUN=0 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH1);
|
||||
ret = usbstrg_bindlun(handle, CONFIG_EXAMPLES_USBSTRG_DEVPATH1, 0, 0, 0, false);
|
||||
message(MAIN_NAME_STRING ": Bind LUN=0 to %s\n", CONFIG_EXAMPLES_USBMSC_DEVPATH1);
|
||||
ret = usbmsc_bindlun(handle, CONFIG_EXAMPLES_USBMSC_DEVPATH1, 0, 0, 0, false);
|
||||
if (ret < 0)
|
||||
{
|
||||
message(MAIN_NAME_STRING ": usbstrg_bindlun failed for LUN 1 using %s: %d\n",
|
||||
CONFIG_EXAMPLES_USBSTRG_DEVPATH1, -ret);
|
||||
usbstrg_uninitialize(handle);
|
||||
message(MAIN_NAME_STRING ": usbmsc_bindlun failed for LUN 1 using %s: %d\n",
|
||||
CONFIG_EXAMPLES_USBMSC_DEVPATH1, -ret);
|
||||
usbmsc_uninitialize(handle);
|
||||
return 4;
|
||||
}
|
||||
check_test_memory_usage("After usbstrg_bindlun()");
|
||||
check_test_memory_usage("After usbmsc_bindlun()");
|
||||
|
||||
#if CONFIG_EXAMPLES_USBSTRG_NLUNS > 1
|
||||
#if CONFIG_EXAMPLES_USBMSC_NLUNS > 1
|
||||
|
||||
message(MAIN_NAME_STRING ": Bind LUN=1 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH2);
|
||||
ret = usbstrg_bindlun(handle, CONFIG_EXAMPLES_USBSTRG_DEVPATH2, 1, 0, 0, false);
|
||||
message(MAIN_NAME_STRING ": Bind LUN=1 to %s\n", CONFIG_EXAMPLES_USBMSC_DEVPATH2);
|
||||
ret = usbmsc_bindlun(handle, CONFIG_EXAMPLES_USBMSC_DEVPATH2, 1, 0, 0, false);
|
||||
if (ret < 0)
|
||||
{
|
||||
message(MAIN_NAME_STRING ": usbstrg_bindlun failed for LUN 2 using %s: %d\n",
|
||||
CONFIG_EXAMPLES_USBSTRG_DEVPATH2, -ret);
|
||||
usbstrg_uninitialize(handle);
|
||||
message(MAIN_NAME_STRING ": usbmsc_bindlun failed for LUN 2 using %s: %d\n",
|
||||
CONFIG_EXAMPLES_USBMSC_DEVPATH2, -ret);
|
||||
usbmsc_uninitialize(handle);
|
||||
return 5;
|
||||
}
|
||||
check_test_memory_usage("After usbstrg_bindlun() #2");
|
||||
check_test_memory_usage("After usbmsc_bindlun() #2");
|
||||
|
||||
#if CONFIG_EXAMPLES_USBSTRG_NLUNS > 2
|
||||
#if CONFIG_EXAMPLES_USBMSC_NLUNS > 2
|
||||
|
||||
message(MAIN_NAME_STRING ": Bind LUN=2 to %s\n", CONFIG_EXAMPLES_USBSTRG_DEVPATH3);
|
||||
ret = usbstrg_bindlun(handle, CONFIG_EXAMPLES_USBSTRG_DEVPATH3, 2, 0, 0, false);
|
||||
message(MAIN_NAME_STRING ": Bind LUN=2 to %s\n", CONFIG_EXAMPLES_USBMSC_DEVPATH3);
|
||||
ret = usbmsc_bindlun(handle, CONFIG_EXAMPLES_USBMSC_DEVPATH3, 2, 0, 0, false);
|
||||
if (ret < 0)
|
||||
{
|
||||
message(MAIN_NAME_STRING ": usbstrg_bindlun failed for LUN 3 using %s: %d\n",
|
||||
CONFIG_EXAMPLES_USBSTRG_DEVPATH3, -ret);
|
||||
usbstrg_uninitialize(handle);
|
||||
message(MAIN_NAME_STRING ": usbmsc_bindlun failed for LUN 3 using %s: %d\n",
|
||||
CONFIG_EXAMPLES_USBMSC_DEVPATH3, -ret);
|
||||
usbmsc_uninitialize(handle);
|
||||
return 6;
|
||||
}
|
||||
check_test_memory_usage("After usbstrg_bindlun() #3");
|
||||
check_test_memory_usage("After usbmsc_bindlun() #3");
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
ret = usbstrg_exportluns(handle);
|
||||
ret = usbmsc_exportluns(handle);
|
||||
if (ret < 0)
|
||||
{
|
||||
message(MAIN_NAME_STRING ": usbstrg_exportluns failed: %d\n", -ret);
|
||||
usbstrg_uninitialize(handle);
|
||||
message(MAIN_NAME_STRING ": usbmsc_exportluns failed: %d\n", -ret);
|
||||
usbmsc_uninitialize(handle);
|
||||
return 7;
|
||||
}
|
||||
check_test_memory_usage("After usbstrg_exportluns()");
|
||||
check_test_memory_usage("After usbmsc_exportluns()");
|
||||
|
||||
/* It this program was configued as an NSH command, then just exit now.
|
||||
* Also, if signals are not enabled (and, hence, sleep() is not supported.
|
||||
* then we have not real option but to exit now.
|
||||
*/
|
||||
|
||||
#if !defined(CONFIG_EXAMPLES_USBSTRG_BUILTIN) && !defined(CONFIG_DISABLE_SIGNALS)
|
||||
#if !defined(CONFIG_EXAMPLES_USBMSC_BUILTIN) && !defined(CONFIG_DISABLE_SIGNALS)
|
||||
|
||||
/* Otherwise, this thread will hang around and monitor the USB storage activity */
|
||||
|
||||
@ -523,11 +523,11 @@ int MAIN_NAME(int argc, char *argv[])
|
||||
|
||||
# ifdef CONFIG_USBDEV_TRACE
|
||||
message("\nuser_start: USB TRACE DATA:\n");
|
||||
ret = usbtrace_enumerate(usbstrg_enumerate, NULL);
|
||||
ret = usbtrace_enumerate(usbmsc_enumerate, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
message(MAIN_NAME_STRING ": usbtrace_enumerate failed: %d\n", -ret);
|
||||
usbstrg_uninitialize(handle);
|
||||
usbmsc_uninitialize(handle);
|
||||
return 8;
|
||||
}
|
||||
check_test_memory_usage("After usbtrace_enumerate()");
|
||||
@ -535,14 +535,14 @@ int MAIN_NAME(int argc, char *argv[])
|
||||
message(MAIN_NAME_STRING ": Still alive\n");
|
||||
# endif
|
||||
}
|
||||
#elif defined(CONFIG_EXAMPLES_USBSTRG_BUILTIN)
|
||||
#elif defined(CONFIG_EXAMPLES_USBMSC_BUILTIN)
|
||||
|
||||
/* Return the USB mass storage device handle so it can be used by the 'misconn'
|
||||
* command.
|
||||
*/
|
||||
|
||||
message(MAIN_NAME_STRING ": Connected\n");
|
||||
g_usbstrg.mshandle = handle;
|
||||
g_usbmsc.mshandle = handle;
|
||||
check_test_memory_usage("After MS connection");
|
||||
|
||||
#else /* defined(CONFIG_DISABLE_SIGNALS) */
|
||||
@ -563,18 +563,18 @@ int MAIN_NAME(int argc, char *argv[])
|
||||
*
|
||||
* Description:
|
||||
* This is a program entry point that will disconnet the USB mass storage
|
||||
* device. This program is only available if CONFIG_EXAMPLES_USBSTRG_BUILTIN
|
||||
* device. This program is only available if CONFIG_EXAMPLES_USBMSC_BUILTIN
|
||||
* is defined in the NuttX configuration. In that case, this program can
|
||||
* be executed by entering the "msdis" command at the NSH console.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_USBSTRG_BUILTIN
|
||||
#ifdef CONFIG_EXAMPLES_USBMSC_BUILTIN
|
||||
int msdis_main(int argc, char *argv[])
|
||||
{
|
||||
/* First check if the USB mass storage device is already connected */
|
||||
|
||||
if (!g_usbstrg.mshandle)
|
||||
if (!g_usbmsc.mshandle)
|
||||
{
|
||||
message("msdis: ERROR: Not connected\n");
|
||||
return 1;
|
||||
@ -583,10 +583,10 @@ int msdis_main(int argc, char *argv[])
|
||||
|
||||
/* Then disconnect the device and uninitialize the USB mass storage driver */
|
||||
|
||||
usbstrg_uninitialize(g_usbstrg.mshandle);
|
||||
g_usbstrg.mshandle = NULL;
|
||||
usbmsc_uninitialize(g_usbmsc.mshandle);
|
||||
g_usbmsc.mshandle = NULL;
|
||||
message("msdis: Disconnected\n");
|
||||
check_test_memory_usage("After usbstrg_uninitialize()");
|
||||
check_test_memory_usage("After usbmsc_uninitialize()");
|
||||
|
||||
/* Dump debug memory usage */
|
||||
|
Loading…
x
Reference in New Issue
Block a user