From af051009ba52505ed53acdfb18f7fef37d3454b0 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 6 Sep 2013 17:21:57 -0600 Subject: [PATCH] Suppress attempts to manage USB trace if the USB MSC example is built as an NSH built-in application. In that case, USB MSC does not do a good job managing trace data and gets in the way of other things that can do a better job (like NSH or the USB monitor). --- ChangeLog.txt | 4 ++++ examples/usbmsc/Kconfig | 19 +++++++++++++------ examples/usbmsc/usbmsc_main.c | 8 +++++--- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 7a4441591..41fa573e4 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -628,4 +628,8 @@ * apps/examples/pwm: Clean-up some configuration confusion (2013-9-5). * apps/netutils/dhcpd/dhcpd.c: Fix calculation of the next lease address. SourceForge bug #21 from Paolo Messina (2013-9-6). + * apps/examples/usbmsc: Don't try to control USB trace if we are + an NSH built-in task. In that case our attempts are inadequate + and only interfere with with other logic that is attempting to + to do the same thing (in NSH or in the USB monitor) (2013-9-6). diff --git a/examples/usbmsc/Kconfig b/examples/usbmsc/Kconfig index 1681b181f..9940fe482 100644 --- a/examples/usbmsc/Kconfig +++ b/examples/usbmsc/Kconfig @@ -70,10 +70,20 @@ config EXAMPLES_USBMSC_DEBUGMM ---help--- Enables some debug tests to check for memory usage and memory leaks. +config EXAMPLES_USBMSC_TRACE + bool "Trace USB activity" + default n + depends on (USBDEV_TRACE || DEBUG_USB) && !NSH_BUILTIN_APPS + ---help--- + If this example is built as a standalone task and if USB device tracing is + enabled, then this example can be configured to unobtrusively monitor + USB activity by selecting this option. + +if EXAMPLES_USBMSC_TRACE + config EXAMPLES_USBMSC_TRACEINIT bool "USB Trace Initialization" default n - depends on USBDEV_TRACE || DEBUG_USB ---help--- If USBDEV_TRACE is enabled (or DEBUG and DEBUG_USB), then the example code will also manage the USB trace output. The @@ -83,7 +93,6 @@ config EXAMPLES_USBMSC_TRACEINIT config EXAMPLES_USBMSC_TRACECLASS bool "USB Trace Class" default n - depends on USBDEV_TRACE || DEBUG_USB ---help--- If USBDEV_TRACE is enabled (or DEBUG and DEBUG_USB), then the example code will also manage the USB trace output. The @@ -93,7 +102,6 @@ config EXAMPLES_USBMSC_TRACECLASS config EXAMPLES_USBMSC_TRACETRANSFERS bool "USB Trace Transfers" default n - depends on USBDEV_TRACE || DEBUG_USB ---help--- If USBDEV_TRACE is enabled (or DEBUG and DEBUG_USB), then the example code will also manage the USB trace output. The @@ -103,7 +111,6 @@ config EXAMPLES_USBMSC_TRACETRANSFERS config EXAMPLES_USBMSC_TRACECONTROLLER bool "USB Trace Device Controller Events" default n - depends on USBDEV_TRACE || DEBUG_USB ---help--- If USBDEV_TRACE is enabled (or DEBUG and DEBUG_USB), then the example code will also manage the USB trace output. The @@ -113,12 +120,12 @@ config EXAMPLES_USBMSC_TRACECONTROLLER config EXAMPLES_USBMSC_TRACEINTERRUPTS bool "USB Trace Device Controller Interrupt Events" default n - depends on USBDEV_TRACE || DEBUG_USB ---help--- If USBDEV_TRACE is enabled (or DEBUG and DEBUG_USB), then the example code will also manage the USB trace output. The amount of trace output can be controlled this configuration value: This setting will show USB device controller interrupt-related events. -endif +endif # EXAMPLES_USBMSC_TRACE +endif # EXAMPLES_USBMSC diff --git a/examples/usbmsc/usbmsc_main.c b/examples/usbmsc/usbmsc_main.c index 4ff59f9da..95875c423 100644 --- a/examples/usbmsc/usbmsc_main.c +++ b/examples/usbmsc/usbmsc_main.c @@ -196,7 +196,7 @@ static void final_memory_usage(FAR const char *msg) * Name: usbmsc_enumerate ****************************************************************************/ -#ifdef CONFIG_USBDEV_TRACE +#ifdef CONFIG_EXAMPLES_USBMSC_TRACE static int usbmsc_enumerate(struct usbtrace_s *trace, void *arg) { switch (trace->event) @@ -423,8 +423,10 @@ int msconn_main(int argc, char *argv[]) /* Initialize USB trace output IDs */ +#ifdef CONFIG_EXAMPLES_USBMSC_TRACE usbtrace_enable(TRACE_BITSET); check_test_memory_usage("After usbtrace_enable()"); +#endif /* Register block drivers (architecture-specific) */ @@ -513,9 +515,9 @@ int msconn_main(int argc, char *argv[]) msgflush(); sleep(5); -# ifdef CONFIG_USBDEV_TRACE +# ifdef CONFIG_EXAMPLES_USBMSC_TRACE message("\nmsconn_main: USB TRACE DATA:\n"); - ret = usbtrace_enumerate(usbmsc_enumerate, NULL); + ret = usbtrace_enumerate(usbmsc_enumerate, NULL); if (ret < 0) { message("msconn_main: usbtrace_enumerate failed: %d\n", -ret);