From d427872bd6350f521eda8376f7d017569c60796c Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 13 Nov 2017 16:46:45 -0600 Subject: [PATCH] configs/stm32f429i-disco: Add logic to auto-mount procfs. Enable procfs in all configurations that use NSH. --- configs/stm32f429i-disco/fb/defconfig | 1 - configs/stm32f429i-disco/lcd/defconfig | 1 + configs/stm32f429i-disco/nsh/defconfig | 1 + configs/stm32f429i-disco/src/stm32_bringup.c | 51 +++++-------------- .../stm32f429i-disco/src/stm32f429i-disco.h | 44 ++++++++++++++++ configs/stm32f429i-disco/usbmsc/defconfig | 1 + configs/stm32f429i-disco/usbnsh/defconfig | 1 + 7 files changed, 62 insertions(+), 38 deletions(-) diff --git a/configs/stm32f429i-disco/fb/defconfig b/configs/stm32f429i-disco/fb/defconfig index 4869b544d5..8b35f1cf60 100644 --- a/configs/stm32f429i-disco/fb/defconfig +++ b/configs/stm32f429i-disco/fb/defconfig @@ -18,7 +18,6 @@ CONFIG_DRIVERS_VIDEO=y CONFIG_EXAMPLES_FB=y CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y CONFIG_EXAMPLES_NSH=y -CONFIG_FS_PROCFS_REGISTER=y CONFIG_FS_PROCFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y diff --git a/configs/stm32f429i-disco/lcd/defconfig b/configs/stm32f429i-disco/lcd/defconfig index 523f657c0e..58276ac31e 100644 --- a/configs/stm32f429i-disco/lcd/defconfig +++ b/configs/stm32f429i-disco/lcd/defconfig @@ -21,6 +21,7 @@ CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y CONFIG_EXAMPLES_NSH=y CONFIG_EXAMPLES_NX_BPP=16 CONFIG_EXAMPLES_NX=y +CONFIG_FS_PROCFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y CONFIG_HEAP2_BASE=0xD0000000 diff --git a/configs/stm32f429i-disco/nsh/defconfig b/configs/stm32f429i-disco/nsh/defconfig index f6d7516ef8..bd5a68a343 100644 --- a/configs/stm32f429i-disco/nsh/defconfig +++ b/configs/stm32f429i-disco/nsh/defconfig @@ -15,6 +15,7 @@ CONFIG_DEBUG_SYMBOLS=y CONFIG_DISABLE_POLL=y CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y CONFIG_EXAMPLES_NSH=y +CONFIG_FS_PROCFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y CONFIG_HEAP2_BASE=0xD0000000 diff --git a/configs/stm32f429i-disco/src/stm32_bringup.c b/configs/stm32f429i-disco/src/stm32_bringup.c index 1135bc633c..3ba8a5c213 100644 --- a/configs/stm32f429i-disco/src/stm32_bringup.c +++ b/configs/stm32f429i-disco/src/stm32_bringup.c @@ -39,6 +39,7 @@ #include +#include #include #include #include @@ -80,43 +81,6 @@ #include "stm32.h" #include "stm32f429i-disco.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration ************************************************************/ - -#define HAVE_USBDEV 1 -#define HAVE_USBHOST 1 -#define HAVE_USBMONITOR 1 - -/* Can't support USB host or device features if USB OTG HS is not enabled */ - -#ifndef CONFIG_STM32_OTGHS -# undef HAVE_USBDEV -# undef HAVE_USBHOST -# undef HAVE_USBMONITOR -#endif - -/* Can't support USB device monitor if USB device is not enabled */ - -#ifndef CONFIG_USBDEV -# undef HAVE_USBDEV -# undef HAVE_USBMONITOR -#endif - -/* Can't support USB host is USB host is not enabled */ - -#ifndef CONFIG_USBHOST -# undef HAVE_USBHOST -#endif - -/* Check if we should enable the USB monitor before starting NSH */ - -#if !defined(CONFIG_USBDEV_TRACE) || !defined(CONFIG_USBMONITOR) -# undef HAVE_USBMONITOR -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -147,6 +111,19 @@ int stm32_bringup(void) #endif int ret; +#ifdef HAVE_PROC + /* mount the proc filesystem */ + + ret = mount(NULL, CONFIG_NSH_PROC_MOUNTPOINT, "procfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, + "ERROR: Failed to mount the PROC filesystem: %d (%d)\n", + ret, errno); + return ret; + } +#endif + /* Configure SPI-based devices */ #ifdef CONFIG_STM32_SPI4 diff --git a/configs/stm32f429i-disco/src/stm32f429i-disco.h b/configs/stm32f429i-disco/src/stm32f429i-disco.h index bbf5746747..46355dcdc1 100644 --- a/configs/stm32f429i-disco/src/stm32f429i-disco.h +++ b/configs/stm32f429i-disco/src/stm32f429i-disco.h @@ -56,6 +56,50 @@ ****************************************************************************/ /* Configuration ************************************************************/ + +#define HAVE_PROC 1 +#define HAVE_USBDEV 1 +#define HAVE_USBHOST 1 +#define HAVE_USBMONITOR 1 + +/* Can't support USB host or device features if USB OTG HS is not enabled */ + +#ifndef CONFIG_STM32_OTGHS +# undef HAVE_USBDEV +# undef HAVE_USBHOST +# undef HAVE_USBMONITOR +#endif + +/* Can't support USB device monitor if USB device is not enabled */ + +#ifndef CONFIG_USBDEV +# undef HAVE_USBDEV +# undef HAVE_USBMONITOR +#endif + +/* Can't support USB host is USB host is not enabled */ + +#ifndef CONFIG_USBHOST +# undef HAVE_USBHOST +#endif + +/* Check if we should enable the USB monitor before starting NSH */ + +#if !defined(CONFIG_USBDEV_TRACE) || !defined(CONFIG_USBMONITOR) +# undef HAVE_USBMONITOR +#endif + +/* Check if we have the procfs file system */ + +#if !defined(CONFIG_FS_PROCFS) +# undef HAVE_PROC +#endif + +#if defined(HAVE_PROC) && defined(CONFIG_DISABLE_MOUNTPOINT) +# warning Mountpoints disabled. No procfs support +# undef HAVE_PROC +#endif + /* How many SPI modules does this chip support? */ #if STM32_NSPI < 1 diff --git a/configs/stm32f429i-disco/usbmsc/defconfig b/configs/stm32f429i-disco/usbmsc/defconfig index ed9ff1bfde..7f6e1cd8e5 100644 --- a/configs/stm32f429i-disco/usbmsc/defconfig +++ b/configs/stm32f429i-disco/usbmsc/defconfig @@ -16,6 +16,7 @@ CONFIG_DISABLE_POLL=y CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y CONFIG_EXAMPLES_NSH=y CONFIG_FS_FAT=y +CONFIG_FS_PROCFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y CONFIG_HEAP2_BASE=0xD0000000 diff --git a/configs/stm32f429i-disco/usbnsh/defconfig b/configs/stm32f429i-disco/usbnsh/defconfig index 67ff0112e9..9d2c2356fc 100644 --- a/configs/stm32f429i-disco/usbnsh/defconfig +++ b/configs/stm32f429i-disco/usbnsh/defconfig @@ -23,6 +23,7 @@ CONFIG_DISABLE_POLL=y CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y CONFIG_EXAMPLES_NSH=y CONFIG_FS_FAT=y +CONFIG_FS_PROCFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y CONFIG_HEAP2_BASE=0xD0000000