From b5c7f41c5d509c16005d20f64f4ee6b6ac6944d2 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 21 Apr 2014 18:16:44 -0600 Subject: [PATCH] SAM4S Xplained: Add logic to autostart the USB monitor --- .../src/sam4s-xplained-pro.h | 23 +++++++++++++- configs/sam4s-xplained-pro/src/sam_nsh.c | 31 +++++++++++++++---- 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/configs/sam4s-xplained-pro/src/sam4s-xplained-pro.h b/configs/sam4s-xplained-pro/src/sam4s-xplained-pro.h index 9b3a2f713d..9226f2d0d7 100644 --- a/configs/sam4s-xplained-pro/src/sam4s-xplained-pro.h +++ b/configs/sam4s-xplained-pro/src/sam4s-xplained-pro.h @@ -57,6 +57,8 @@ #define HAVE_HSMCI 1 #define HAVE_PROC 1 +#define HAVE_USBDEV 1 +#undef HAVE_USBMONITOR /* HSMCI */ /* Can't support MMC/SD if the card interface is not enabled */ @@ -71,7 +73,7 @@ /* Can't support MMC/SD features if mountpoints are disabled */ -if defined(HAVE_HSMCI) && defined(CONFIG_DISABLE_MOUNTPOINT) +#if defined(HAVE_HSMCI) && defined(CONFIG_DISABLE_MOUNTPOINT) # warning Mountpoints disabled. No MMC/SD support # undef HAVE_HSMCI #endif @@ -88,6 +90,25 @@ if defined(HAVE_HSMCI) && defined(CONFIG_DISABLE_MOUNTPOINT) # undef HAVE_HSMCI #endif +/* USB Device */ +/* CONFIG_SAM34_UDP and CONFIG_USBDEV must be defined, or there is no USB + * device. + */ + +#if !defined(CONFIG_SAM34_UDP) || !defined(CONFIG_USBDEV) +# undef HAVE_USBDEV +#endif + +/* Check if we should enable the USB monitor before starting NSH */ + +#ifndef HAVE_USBDEV +# undef CONFIG_USBDEV_TRACE +#endif + +#if !defined(CONFIG_SYSTEM_USBMONITOR) && !defined(CONFIG_USBDEV_TRACE) +# undef HAVE_USBMONITOR +#endif + /* There are four LEDs on board the SAM4S Xplained board, two of these can be * controlled by software in the SAM4S: * diff --git a/configs/sam4s-xplained-pro/src/sam_nsh.c b/configs/sam4s-xplained-pro/src/sam_nsh.c index 4c1909c190..ce4de7f570 100644 --- a/configs/sam4s-xplained-pro/src/sam_nsh.c +++ b/configs/sam4s-xplained-pro/src/sam_nsh.c @@ -1,6 +1,6 @@ /**************************************************************************** * config/sam4s-xplained-pro/src/sam_nsh.c - * + * * Copyright (C) 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * @@ -50,6 +50,14 @@ # include #endif +#ifdef CONFIG_CDCACM +# include +#endif + +#ifdef CONFIG_PL2303 +# include +#endif + #include "sam4s-xplained-pro.h" /**************************************************************************** @@ -86,7 +94,7 @@ int nsh_archinitialize(void) { -#if (defined(HAVE_HSMCI) || defined (HAVE_PROC)) +#if defined(HAVE_HSMCI) || defined (HAVE_PROC) || defined(HAVE_USBMONITOR) int ret; #endif @@ -94,7 +102,7 @@ int nsh_archinitialize(void) #ifdef HAVE_HSMCI /* Initialize the HSMCI driver */ - + ret = sam_hsmci_initialize(); if (ret < 0) { @@ -105,20 +113,31 @@ int nsh_archinitialize(void) #ifdef HAVE_PROC /* mount the proc filesystem */ - + ret = mount(NULL, "/proc", "procfs", 0, NULL); if (ret < 0) { - fdbg("ERROR: Failed to mount the PROC filesystem: %d\n", errno); + message("ERROR: Failed to mount the PROC filesystem: %d\n", errno); return ret; } #endif +#ifdef HAVE_USBMONITOR + /* Start the USB Monitor */ + + ret = usbmonitor_start(0, NULL); + if (ret != OK) + { + message("nsh_archinitialize: Start USB monitor: %d\n", ret); + return ret; + } +#endif + #warning "add automount config...." ret = mount("/dev/mmcsd0", "/fat", "vfat", 0, NULL); if (ret < 0) { - fdbg("ERROR: Failed to mount the FAT filesystem: %d\n", errno); + message("ERROR: Failed to mount the FAT filesystem: %d\n", errno); return ret; }