From da69f6df556fec034a858e03d2c397a18b9fd4a3 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 5 Dec 2016 11:58:58 -0600 Subject: [PATCH] SAM4CMP-DB: Add hooks to auto-mount the procfs file system on startup in board bring-up logic. --- configs/sam4cmp-db/nsh/defconfig | 21 ++++--- configs/sam4cmp-db/src/Makefile | 6 ++ configs/sam4cmp-db/src/sam4cmp-db.h | 12 ++++ configs/sam4cmp-db/src/sam_appinit.c | 88 ++++++++++++++++++++++++++++ configs/sam4cmp-db/src/sam_boot.c | 11 +--- configs/sam4cmp-db/src/sam_bringup.c | 81 +++++++++++++++++++++++++ 6 files changed, 204 insertions(+), 15 deletions(-) create mode 100644 configs/sam4cmp-db/src/sam_appinit.c create mode 100644 configs/sam4cmp-db/src/sam_bringup.c diff --git a/configs/sam4cmp-db/nsh/defconfig b/configs/sam4cmp-db/nsh/defconfig index 8dc7937a078..8541fc330e7 100644 --- a/configs/sam4cmp-db/nsh/defconfig +++ b/configs/sam4cmp-db/nsh/defconfig @@ -16,7 +16,7 @@ CONFIG_HOST_LINUX=y # # Build Configuration # -CONFIG_APPS_DIR="../apps" +# CONFIG_APPS_DIR="../apps" CONFIG_BUILD_FLAT=y # CONFIG_BUILD_2PASS is not set @@ -90,7 +90,6 @@ CONFIG_ARCH_ARM=y # CONFIG_ARCH_HC is not set # CONFIG_ARCH_MIPS is not set # CONFIG_ARCH_MISOC is not set -# CONFIG_ARCH_RGMP is not set # CONFIG_ARCH_RENESAS is not set # CONFIG_ARCH_RISCV is not set # CONFIG_ARCH_SIM is not set @@ -112,7 +111,6 @@ CONFIG_ARCH="arm" # CONFIG_ARCH_CHIP_IMX6 is not set # CONFIG_ARCH_CHIP_KINETIS is not set # CONFIG_ARCH_CHIP_KL is not set -# CONFIG_ARCH_CHIP_LC823450 is not set # CONFIG_ARCH_CHIP_LM is not set # CONFIG_ARCH_CHIP_TIVA is not set # CONFIG_ARCH_CHIP_LPC11XX is not set @@ -343,7 +341,14 @@ CONFIG_ARCH_BOARD="sam4cmp-db" # Board-Specific Options # # CONFIG_BOARD_CRASHDUMP is not set -# CONFIG_LIB_BOARDCTL is not set +CONFIG_LIB_BOARDCTL=y +# CONFIG_BOARDCTL_RESET is not set +# CONFIG_BOARDCTL_UNIQUEID is not set +# CONFIG_BOARDCTL_TSCTEST is not set +# CONFIG_BOARDCTL_ADCTEST is not set +# CONFIG_BOARDCTL_PWMTEST is not set +# CONFIG_BOARDCTL_GRAPHICS is not set +# CONFIG_BOARDCTL_IOCTL is not set # # RTOS Features @@ -703,6 +708,8 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # CONFIG_ARCH_OPTIMIZED_FUNCTIONS is not set CONFIG_ARCH_HAVE_TLS=y # CONFIG_TLS is not set +# CONFIG_LIBC_IPv4_ADDRCONV is not set +# CONFIG_LIBC_IPv6_ADDRCONV is not set # CONFIG_LIBC_NETDB is not set # CONFIG_NETDB_HOSTFILE is not set @@ -755,10 +762,10 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024 # CONFIG_EXAMPLES_NRF24L01TERM is not set CONFIG_EXAMPLES_NSH=y # CONFIG_EXAMPLES_NULL is not set +# CONFIG_EXAMPLES_NX is not set # CONFIG_EXAMPLES_NXFFS is not set # CONFIG_EXAMPLES_NXHELLO is not set # CONFIG_EXAMPLES_NXIMAGE is not set -# CONFIG_EXAMPLES_NX is not set # CONFIG_EXAMPLES_NXLINES is not set # CONFIG_EXAMPLES_NXTERM is not set # CONFIG_EXAMPLES_NXTEXT is not set @@ -774,7 +781,6 @@ CONFIG_EXAMPLES_OSTEST_WAITRESULT=y # CONFIG_EXAMPLES_PPPD is not set # CONFIG_EXAMPLES_RFID_READUID is not set # CONFIG_EXAMPLES_RGBLED is not set -# CONFIG_EXAMPLES_RGMP is not set # CONFIG_EXAMPLES_SENDMAIL is not set # CONFIG_EXAMPLES_SERIALBLASTER is not set # CONFIG_EXAMPLES_SERIALRX is not set @@ -790,6 +796,7 @@ CONFIG_EXAMPLES_SMP_STACKSIZE=2048 # CONFIG_EXAMPLES_TELNETD is not set # CONFIG_EXAMPLES_TIFF is not set # CONFIG_EXAMPLES_TOUCHSCREEN is not set +# CONFIG_EXAMPLES_USBSERIAL is not set # CONFIG_EXAMPLES_USBTERM is not set # CONFIG_EXAMPLES_WATCHDOG is not set # CONFIG_EXAMPLES_WEBSERVER is not set @@ -928,7 +935,7 @@ CONFIG_NSH_FILEIOSIZE=512 # CONFIG_NSH_CONSOLE=y # CONFIG_NSH_ALTCONDEV is not set -# CONFIG_NSH_ARCHINIT is not set +CONFIG_NSH_ARCHINIT=y # CONFIG_NSH_LOGIN is not set # CONFIG_NSH_CONSOLE_LOGIN is not set diff --git a/configs/sam4cmp-db/src/Makefile b/configs/sam4cmp-db/src/Makefile index 2463d7e8670..1dd2e0485ce 100644 --- a/configs/sam4cmp-db/src/Makefile +++ b/configs/sam4cmp-db/src/Makefile @@ -38,4 +38,10 @@ ASRCS = CSRCS = sam_boot.c +ifeq ($(CONFIG_LIB_BOARDCTL),y) +CSRCS += sam_appinit.c sam_bringup.c +else ifeq ($(CONFIG_BOARD_INITIALIZE),y) +CSRCS += sam_bringup.c +endif + include $(TOPDIR)/configs/Board.mk diff --git a/configs/sam4cmp-db/src/sam4cmp-db.h b/configs/sam4cmp-db/src/sam4cmp-db.h index e6656145713..9fab435d5af 100644 --- a/configs/sam4cmp-db/src/sam4cmp-db.h +++ b/configs/sam4cmp-db/src/sam4cmp-db.h @@ -64,5 +64,17 @@ * Public Functions ************************************************************************************/ +/************************************************************************************ + * Name: sam_bringup + * + * Description: + * Bring up board features + * + ************************************************************************************/ + +#if defined(CONFIG_LIB_BOARDCTL) || defined(CONFIG_BOARD_INITIALIZE) +int sam_bringup(void); +#endif + #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_SAM4CMP_DB_SRC_SAM4CMP_DB_H */ diff --git a/configs/sam4cmp-db/src/sam_appinit.c b/configs/sam4cmp-db/src/sam_appinit.c new file mode 100644 index 00000000000..6bab1d57519 --- /dev/null +++ b/configs/sam4cmp-db/src/sam_appinit.c @@ -0,0 +1,88 @@ +/**************************************************************************** + * config/sam4cmp-db/src/sam_appinit.c + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include + +#include "sam4cmp-db.h" + +#ifdef CONFIG_LIB_BOARDCTL + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform application specific initialization. This function is never + * called directly from application code, but only indirectly via the + * (non-standard) boardctl() interface using the command BOARDIOC_INIT. + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initalization logic and the the + * matching application logic. The value cold be such things as a + * mode enumeration value, a set of DIP switch switch settings, a + * pointer to configuration data read from a file or serial FLASH, + * or whatever you would like to do with it. Every implementation + * should accept zero/NULL as a default configuration. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ + +int board_app_initialize(uintptr_t arg) +{ +#ifndef CONFIG_BOARD_INITIALIZE + /* Perform board initialization */ + + return sam_bringup(); +#else + return OK; +#endif +} + +#endif /* CONFIG_LIB_BOARDCTL */ diff --git a/configs/sam4cmp-db/src/sam_boot.c b/configs/sam4cmp-db/src/sam_boot.c index ee34da638d4..f883f0add6d 100644 --- a/configs/sam4cmp-db/src/sam_boot.c +++ b/configs/sam4cmp-db/src/sam_boot.c @@ -45,14 +45,6 @@ #include "sam4cmp-db.h" -/************************************************************************************ - * Pre-processor Definitions - ************************************************************************************/ - -/************************************************************************************ - * Private Functions - ************************************************************************************/ - /************************************************************************************ * Public Functions ************************************************************************************/ @@ -87,5 +79,8 @@ void sam_boardinitialize(void) #ifdef CONFIG_BOARD_INITIALIZE void board_initialize(void) { + /* Perform board initialization */ + + (void)sam_bringup(); } #endif /* CONFIG_BOARD_INITIALIZE */ diff --git a/configs/sam4cmp-db/src/sam_bringup.c b/configs/sam4cmp-db/src/sam_bringup.c new file mode 100644 index 00000000000..fbfe1a4106d --- /dev/null +++ b/configs/sam4cmp-db/src/sam_bringup.c @@ -0,0 +1,81 @@ +/**************************************************************************** + * config/sam4cmp-db/src/sam_bringup.c + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#include +#include + +#include +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: sam_bringup + * + * Description: + * Bring up board features + * + ****************************************************************************/ + +int sam_bringup(void) +{ + int ret; + +#ifdef CONFIG_FS_PROCFS + /* Mount the procfs file system */ + + ret = mount(NULL, "/proc", "procfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret); + } +#endif + + /* If we got here then perhaps not all initialization was successful, but + * at least enough succeeded to bring-up NSH with perhaps reduced + * capabilities. + */ + + UNUSED(ret); + return OK; +}