From a82d39f9a9a5e47ea25532c55a09fd481649a5b7 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 3 Oct 2012 23:36:54 +0000 Subject: Delete the apps/vsn directory (moved commands to apps/system) git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5208 42af7a65-404d-4744-a932-0658087f49c3 --- apps/system/Kconfig | 20 +- apps/system/Make.defs | 17 ++ apps/system/Makefile | 2 +- apps/system/free/free.c | 80 +++--- apps/system/install/install.c | 606 ++++++++++++++++++++++------------------ apps/system/poweroff/Kconfig | 16 ++ apps/system/poweroff/Makefile | 114 ++++++++ apps/system/poweroff/README.txt | 5 + apps/system/poweroff/poweroff.c | 63 +++++ apps/system/ramtron/Kconfig | 14 + apps/system/ramtron/Makefile | 114 ++++++++ apps/system/ramtron/README.txt | 7 + apps/system/ramtron/ramtron.c | 104 +++++++ apps/system/sdcard/Kconfig | 14 + apps/system/sdcard/Makefile | 114 ++++++++ apps/system/sdcard/README.txt | 7 + apps/system/sdcard/sdcard.c | 161 +++++++++++ apps/system/sysinfo/Kconfig | 13 + apps/system/sysinfo/Makefile | 114 ++++++++ apps/system/sysinfo/README.txt | 6 + apps/system/sysinfo/sysinfo.c | 69 +++++ 21 files changed, 1347 insertions(+), 313 deletions(-) create mode 100644 apps/system/poweroff/Kconfig create mode 100644 apps/system/poweroff/Makefile create mode 100644 apps/system/poweroff/README.txt create mode 100644 apps/system/poweroff/poweroff.c create mode 100644 apps/system/ramtron/Kconfig create mode 100644 apps/system/ramtron/Makefile create mode 100644 apps/system/ramtron/README.txt create mode 100644 apps/system/ramtron/ramtron.c create mode 100644 apps/system/sdcard/Kconfig create mode 100644 apps/system/sdcard/Makefile create mode 100644 apps/system/sdcard/README.txt create mode 100644 apps/system/sdcard/sdcard.c create mode 100644 apps/system/sysinfo/Kconfig create mode 100644 apps/system/sysinfo/Makefile create mode 100644 apps/system/sysinfo/README.txt create mode 100644 apps/system/sysinfo/sysinfo.c (limited to 'apps/system') diff --git a/apps/system/Kconfig b/apps/system/Kconfig index 44bf5a2e6..d4d434665 100644 --- a/apps/system/Kconfig +++ b/apps/system/Kconfig @@ -3,7 +3,7 @@ # see misc/tools/kconfig-language.txt. # -menu "Custom free memory command" +menu "Custom Free Memory Command" source "$APPSDIR/system/free/Kconfig" endmenu @@ -15,6 +15,22 @@ menu "FLASH Program Installation" source "$APPSDIR/system/install/Kconfig" endmenu -menu "readline() support" +menu "readline()" source "$APPSDIR/system/readline/Kconfig" endmenu + +menu "Power Off" +source "$APPSDIR/system/poweroff/Kconfig" +endmenu + +menu "RAMTRON" +source "$APPSDIR/system/ramtron/Kconfig" +endmenu + +menu "SD Card" +source "$APPSDIR/system/sdcard/Kconfig" +endmenu + +menu "Sysinfo" +source "$APPSDIR/system/sysinfo/Kconfig" +endmenu diff --git a/apps/system/Make.defs b/apps/system/Make.defs index a4aea2d31..3d10f84e5 100644 --- a/apps/system/Make.defs +++ b/apps/system/Make.defs @@ -49,3 +49,20 @@ endif ifeq ($(CONFIG_SYSTEM_READLINE),y) CONFIGURED_APPS += system/readline endif + +ifeq ($(CONFIG_SYSTEM_POWEROFF),y) +CONFIGURED_APPS += system/poweroff +endif + +ifeq ($(CONFIG_SYSTEM_RAMTRON),y) +CONFIGURED_APPS += system/ramtron +endif + +ifeq ($(CONFIG_SYSTEM_SDCARD),y) +CONFIGURED_APPS += system/sdcard +endif + +ifeq ($(CONFIG_SYSTEM_SYSINFO),y) +CONFIGURED_APPS += system/sysinfo +endif + diff --git a/apps/system/Makefile b/apps/system/Makefile index 73eb60d15..d64bb54c6 100644 --- a/apps/system/Makefile +++ b/apps/system/Makefile @@ -37,7 +37,7 @@ # Sub-directories containing system task -SUBDIRS = free i2c install readline +SUBDIRS = free i2c install readline poweroff ramtron sdcard sysinfo # Create the list of installed runtime modules (INSTALLED_DIRS) diff --git a/apps/system/free/free.c b/apps/system/free/free.c index 3d9698ecb..c44cd5e22 100644 --- a/apps/system/free/free.c +++ b/apps/system/free/free.c @@ -33,57 +33,65 @@ * ****************************************************************************/ +/**************************************************************************** + * Included Files + ****************************************************************************/ + #include #include #include #include - /**************************************************************************** * Private Functions ****************************************************************************/ - -/* \todo Max block size only works on uniform prog mem */ - -void free_getprogmeminfo(struct mallinfo * mem) + +/* TODO Max block size only works on uniform prog mem */ + +static void free_getprogmeminfo(struct mallinfo * mem) { - uint16_t page = 0, stpage = 0xFFFF; - uint16_t pagesize = 0; - int status; - - mem->arena = 0; - mem->fordblks = 0; - mem->uordblks = 0; - mem->mxordblk = 0; - - for (status=0, page=0; status >= 0; page++) { - - status = up_progmem_ispageerased(page); - pagesize = up_progmem_pagesize(page); - - mem->arena += pagesize; - - /* Is this beginning of new free space section */ - if (status == 0) { - if (stpage == 0xFFFF) stpage = page; - mem->fordblks += pagesize; + uint16_t page = 0, stpage = 0xFFFF; + uint16_t pagesize = 0; + int status; + + mem->arena = 0; + mem->fordblks = 0; + mem->uordblks = 0; + mem->mxordblk = 0; + + for (status=0, page=0; status >= 0; page++) + { + status = up_progmem_ispageerased(page); + pagesize = up_progmem_pagesize(page); + + mem->arena += pagesize; + + /* Is this beginning of new free space section */ + + if (status == 0) + { + if (stpage == 0xFFFF) stpage = page; + mem->fordblks += pagesize; } - else if (status != 0) { - mem->uordblks += pagesize; - - if (stpage != 0xFFFF && up_progmem_isuniform()) { - stpage = page - stpage; - if (stpage > mem->mxordblk) - mem->mxordblk = stpage; - stpage = 0xFFFF; + else if (status != 0) + { + mem->uordblks += pagesize; + + if (stpage != 0xFFFF && up_progmem_isuniform()) + { + stpage = page - stpage; + if (stpage > mem->mxordblk) + { + mem->mxordblk = stpage; + } + stpage = 0xFFFF; } } } - - mem->mxordblk *= pagesize; -} + mem->mxordblk *= pagesize; +} /**************************************************************************** * Public Functions diff --git a/apps/system/install/install.c b/apps/system/install/install.c index 2f11c6434..fd14b7a6f 100644 --- a/apps/system/install/install.c +++ b/apps/system/install/install.c @@ -33,6 +33,10 @@ * ****************************************************************************/ +/**************************************************************************** + * Included Files + ****************************************************************************/ + #include #include #include @@ -43,9 +47,8 @@ #include #include - /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #define ACTION_INSTALL 0x01 @@ -55,12 +58,11 @@ #define INSTALL_PROGRAMBLOCKSIZE 1024 - /**************************************************************************** * Private data ****************************************************************************/ -const char *install_help = +static const char *install_help = "Installs XIP program into flash and creates a start-up script in the\n" "destination directory.\n\n" "Usage:\t%s [options] source-file.xip destination-directory\n\n" @@ -72,341 +74,397 @@ const char *install_help = "\t--force\t\t\tReplaces existing installation\n" "\t--start \t\tInstalls application at or after \n" "\t--margin \tLeave some free space after the kernel (default 16)\n"; - -const char *install_script_text = + +static const char *install_script_text = "# XIP stacksize=%x priority=%x size=%x\n"; - -const char *install_script_exec = + +static const char *install_script_exec = "exec 0x%x\n"; - - + /**************************************************************************** * Private functions ****************************************************************************/ -int install_getstartpage(int startpage, int pagemargin, int desiredsize) +static int install_getstartpage(int startpage, int pagemargin, int desiredsize) { - uint16_t page = 0, stpage = 0xFFFF; - uint16_t pagesize = 0; - int maxlen = -1; - int maxlen_start = 0xFFFF; - int status; - - for (status=0, page=0; status >= 0; page++) { - - status = up_progmem_ispageerased(page); - pagesize = up_progmem_pagesize(page); - - /* Is this beginning of new free space section */ - if (status == 0) { - if (stpage == 0xFFFF) stpage = page; + uint16_t page = 0, stpage = 0xffff; + uint16_t pagesize = 0; + int maxlen = -1; + int maxlen_start = 0xffff; + int status; + + for (status=0, page=0; status >= 0; page++) + { + status = up_progmem_ispageerased(page); + pagesize = up_progmem_pagesize(page); + + /* Is this beginning of new free space section */ + + if (status == 0) + { + if (stpage == 0xffff) stpage = page; } - else if (status != 0) { - - if (stpage != 0xFFFF) { - - if ( (page - stpage) > maxlen) { + else if (status != 0) + { + if (stpage != 0xffff) + { + if ((page - stpage) > maxlen) + { + if (maxlen==-1) + { + /* First time found sth? */ + + stpage += pagemargin; + maxlen = 0; + } - if (maxlen==-1) { /* First time found sth? */ - stpage += pagemargin; - maxlen = 0; + if(stpage < startpage) + { + stpage = startpage; } - - if(stpage < startpage) - stpage = startpage; - - if (page > stpage) { - maxlen = page - stpage; - maxlen_start = stpage; + + if (page > stpage) + { + maxlen = page - stpage; + maxlen_start = stpage; } - - if (maxlen*pagesize >= desiredsize) { - /* printf("Found page at %d ... %d\n", stpage, page); */ - return maxlen_start*pagesize; + + if (maxlen*pagesize >= desiredsize) + { + /* printf("Found page at %d ... %d\n", stpage, page); */ + return maxlen_start*pagesize; } } - - stpage = 0xFFFF; + + stpage = 0xffff; } } } - - /* Requested space is not available */ - - return -1; -} + /* Requested space is not available */ + + return -1; +} -int install_programflash(int startaddr, const char *source) +static int install_programflash(int startaddr, const char *source) { - int status; - int count; - int totalsize = 0; - char *buf; - FILE *fp; - - if ( (buf = malloc(INSTALL_PROGRAMBLOCKSIZE)) == NULL ) - return -errno; - - if ( (fp=fopen(source, "r")) ) { - do { - count = fread(buf, 1, INSTALL_PROGRAMBLOCKSIZE, fp); - - if ( (status = up_progmem_write(startaddr, buf, count)) < 0) { - totalsize = status; - break; + int status; + int count; + int totalsize = 0; + char *buf; + FILE *fp; + + if ((buf = malloc(INSTALL_PROGRAMBLOCKSIZE)) == NULL) + { + return -ENOMEM; + } + + if ((fp = fopen(source, "r"))) + { + do + { + count = fread(buf, 1, INSTALL_PROGRAMBLOCKSIZE, fp); + + if ((status = up_progmem_write(startaddr, buf, count)) < 0) + { + totalsize = status; + break; } - - startaddr += count; - totalsize += count; + + startaddr += count; + totalsize += count; } - while(count); + while(count); + } + else + { + totalsize = -errno; } - else totalsize = -errno; - - fclose(fp); - free(buf); - - return totalsize; -} + fclose(fp); + free(buf); -void install_getscriptname(char *scriptname, const char *progname, const char *destdir) -{ - const char * progonly; - - /* I.e. as /usr/bin */ - strcpy(scriptname, destdir); - - /* extract from i.e. /sdcard/demo -> /demo, together with / */ - progonly = strrchr(progname, '/'); - strcat(scriptname, progonly); + return totalsize; } - -int install_getprogsize(const char *progname) +static void install_getscriptname(char *scriptname, const char *progname, const char *destdir) { - struct stat fileinfo; - - if ( stat(progname, &fileinfo) < 0 ) - return -1; - - return fileinfo.st_size; + const char * progonly; + + /* I.e. as /usr/bin */ + + strcpy(scriptname, destdir); + + /* extract from i.e. /sdcard/demo -> /demo, together with / */ + + progonly = strrchr(progname, '/'); + strcat(scriptname, progonly); } +static int install_getprogsize(const char *progname) +{ + struct stat fileinfo; + + if (stat(progname, &fileinfo) < 0) + { + return -1; + } + + return fileinfo.st_size; +} -int install_alreadyexists(const char *scriptname) +static int install_alreadyexists(const char *scriptname) { - FILE *fp; - - if ( (fp=fopen(scriptname, "r"))==NULL ) - return 0; - - fclose(fp); + FILE *fp; + + if ((fp = fopen(scriptname, "r")) == NULL) + { + return 0; + } + + fclose(fp); return 1; } - -int install_createscript(int addr, int stacksize, int progsize, - int priority, const char *scriptname) +static int install_createscript(int addr, int stacksize, int progsize, + int priority, const char *scriptname) { - FILE *fp; - - if ( (fp=fopen(scriptname, "w+"))==NULL ) - return -errno; - - fprintf(fp, install_script_text, stacksize, priority, progsize); - fprintf(fp, install_script_exec, addr); - - fflush(fp); - fclose(fp); - - return 0; -} + FILE *fp; + + if ((fp = fopen(scriptname, "w+")) == NULL) + { + return -errno; + } + fprintf(fp, install_script_text, stacksize, priority, progsize); + fprintf(fp, install_script_exec, addr); -int install_getlasthexvalue(FILE *fp, char delimiter) + fflush(fp); + fclose(fp); + + return 0; +} + +static int install_getlasthexvalue(FILE *fp, char delimiter) { - char buf[128]; - char *p; - - if (fgets(buf, 127, fp)) { - if ( (p = strrchr(buf, delimiter)) ) { - return strtol(p+1, NULL, 16); + char buf[128]; + char *p; + + if (fgets(buf, 127, fp)) + { + if ((p = strrchr(buf, delimiter))) + { + return strtol(p+1, NULL, 16); } } - return -1; -} + return -1; +} -int install_remove(const char *scriptname) +static int install_remove(const char *scriptname) { - FILE *fp; - int progsize, addr, freedsize; - uint16_t page; - int status = 0; - - /* Parse script */ - - if ( (fp=fopen(scriptname, "r")) ) { - progsize = install_getlasthexvalue(fp,'='); - addr = install_getlasthexvalue(fp,' '); - freedsize = progsize; + FILE *fp; + int progsize, addr, freedsize; + uint16_t page; + int status = 0; + + /* Parse script */ + + if ((fp = fopen(scriptname, "r"))) + { + progsize = install_getlasthexvalue(fp,'='); + addr = install_getlasthexvalue(fp,' '); + freedsize = progsize; + } + else + { + return -errno; + } + + fclose(fp); + + /* Remove pages */ + + if (progsize <= 0 || addr <= 0) + { + return -EIO; } - else return -errno; - - fclose(fp); - - /* Remove pages */ - - if (progsize <= 0 || addr <= 0) - return -EIO; - - do { - if ((page = up_progmem_getpage(addr)) < 0) { - status = -page; - break; + + do + { + if ((page = up_progmem_getpage(addr)) < 0) + { + status = -page; + break; } - - if ( up_progmem_erasepage(page) < 0) { - status = -page; - break; + + if (up_progmem_erasepage(page) < 0) + { + status = -page; + break; } - - addr += up_progmem_pagesize(page); - progsize -= up_progmem_pagesize(page); - - } while(progsize > 0); - - if (status < 0) return status; - - /* Remove script file */ - - if (unlink(scriptname) < 0) return -errno; - - return freedsize; + + addr += up_progmem_pagesize(page); + progsize -= up_progmem_pagesize(page); + + } + while(progsize > 0); + + if (status < 0) + { + return status; + } + + /* Remove script file */ + + if (unlink(scriptname) < 0) + { + return -errno; + } + + return freedsize; } /**************************************************************************** - * Start + * Public Functions ****************************************************************************/ int install_main(int argc, char *argv[]) { - int i; - int progsize; - int scrsta; - int stacksize = 4096; - int priority = SCHED_PRIORITY_DEFAULT; - int pagemargin = 16; - int startpage = 0; - int startaddr = 0; - int action = ACTION_INSTALL; - char scriptname[128]; - - /* Supported? */ - - if ( !up_progmem_isuniform() ) { - fprintf(stderr, "Error: install supports uniform organization only.\n"); - return -1; + int i; + int progsize; + int scrsta; + int stacksize = 4096; + int priority = SCHED_PRIORITY_DEFAULT; + int pagemargin = 16; + int startpage = 0; + int startaddr = 0; + int action = ACTION_INSTALL; + char scriptname[128]; + + /* Supported? */ + + if (!up_progmem_isuniform()) + { + fprintf(stderr, "Error: install supports uniform organization only.\n"); + return -1; } - - /* Parse arguments */ - - for (i=1; i argc-1) { - action = ACTION_INSUFPARAM; - break; /* are there sufficient parameters */ - } - if ( (scrsta=install_remove(argv[i])) < 0) { - fprintf(stderr, "Could not remove program: %s\n", strerror(-scrsta) ); + + /* Do the job */ + + switch(action & 1) + { + case ACTION_REMOVE: + if (i > argc-1) + { + action = ACTION_INSUFPARAM; + break; /* are there sufficient parameters */ + } + + if ((scrsta=install_remove(argv[i])) < 0) + { + fprintf(stderr, "Could not remove program: %s\n", strerror(-scrsta)); + return -1; + } + + printf("Removed %s and freed %d bytes\n", argv[i], scrsta); + return 0; + + case ACTION_INSTALL: + if (i > argc-2) + { + action = ACTION_INSUFPARAM; + break; /* are there sufficient parameters */ + } + + install_getscriptname(scriptname, argv[i], argv[i+1]); + + /* script-exists? */ + + if (install_alreadyexists(scriptname) == 1) + { + if (action != ACTION_REINSTALL) + { + fprintf(stderr, "Program with that name already exists.\n"); + return -EEXIST; + } + + if ((scrsta = install_remove(scriptname)) < 0) + { + fprintf(stderr, "Could not remove program: %s\n", strerror(-scrsta)); return -1; - } - printf("Removed %s and freed %d bytes\n", argv[i], scrsta); - return 0; - - - case ACTION_INSTALL: - if (i > argc-2) { - action = ACTION_INSUFPARAM; - break; /* are there sufficient parameters */ - } - - install_getscriptname(scriptname, argv[i], argv[i+1]); - - // script-exists? - if (install_alreadyexists(scriptname)==1) { - - if (action != ACTION_REINSTALL) { - fprintf(stderr, "Program with that name already exists.\n"); - return -EEXIST; - } - - if ( (scrsta=install_remove(scriptname)) < 0) { - fprintf(stderr, "Could not remove program: %s\n", strerror(-scrsta) ); - return -1; - } - - printf("Replacing %s\n", scriptname); - } - - startaddr = install_getstartpage(startpage, pagemargin, install_getprogsize(argv[i]) ); - if (startpage < 0) { - fprintf(stderr, "Not enough memory\n"); - return -ENOMEM; - } - - if ( (progsize = install_programflash(startaddr, argv[i])) <= 0) { - fprintf(stderr, "Error writing program memory: %s\n" + } + + printf("Replacing %s\n", scriptname); + } + + startaddr = install_getstartpage(startpage, pagemargin, install_getprogsize(argv[i])); + if (startpage < 0) + { + fprintf(stderr, "Not enough memory\n"); + return -ENOMEM; + } + + if ((progsize = install_programflash(startaddr, argv[i])) <= 0) + { + fprintf(stderr, "Error writing program memory: %s\n" "Note: Flash pages are not released, so you may try again and program will be\n" - " written in other pages.\n", strerror(-progsize) ); - - return -EIO; - } - if ( (scrsta = install_createscript(startaddr, stacksize, progsize, - priority, scriptname)) < 0) { - fprintf(stderr, "Error writing program script at %s: %s\n", - argv[i+1], strerror(-scrsta) ); - return -EIO; - } - - printf("Installed application of size %d bytes to program memory [%xh - %xh].\n", + " written in other pages.\n", strerror(-progsize)); + return -EIO; + } + + if ((scrsta = install_createscript(startaddr, stacksize, progsize, + priority, scriptname)) < 0) + { + fprintf(stderr, "Error writing program script at %s: %s\n", + argv[i+1], strerror(-scrsta)); + return -EIO; + } + + printf("Installed application of size %d bytes to program memory [%xh - %xh].\n", progsize, startaddr, startaddr + progsize); - - return 0; + return 0; } - - fprintf(stderr, install_help, argv[0], argv[0]); - return -1; + + fprintf(stderr, install_help, argv[0], argv[0]); + return -1; } diff --git a/apps/system/poweroff/Kconfig b/apps/system/poweroff/Kconfig new file mode 100644 index 000000000..ae8eac450 --- /dev/null +++ b/apps/system/poweroff/Kconfig @@ -0,0 +1,16 @@ +# +# For a description of the syntax of this configuration file, +# see misc/tools/kconfig-language.txt. +# + +config SYSTEM_POWEROFF + bool "Power-Off command" + default n + ---help--- + Enable support for the NSH poweroff command. NOTE: This option + provides the NSH power-off command only. It requires board-specific + support to actually implement the power-off. + +if SYSTEM_POWEROFF +endif + diff --git a/apps/system/poweroff/Makefile b/apps/system/poweroff/Makefile new file mode 100644 index 000000000..40465e957 --- /dev/null +++ b/apps/system/poweroff/Makefile @@ -0,0 +1,114 @@ +############################################################################ +# apps/system/poweroff/Makefile +# +# Copyright (C) 2011 Uros Platise. All rights reserved. +# Author: Uros Platise +# 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. +# +############################################################################ + +# TODO, this makefile should run make under the app dirs, instead of +# sourcing the Make.defs! + +-include $(TOPDIR)/.config +-include $(TOPDIR)/Make.defs +include $(APPDIR)/Make.defs + +ifeq ($(WINTOOL),y) +INCDIROPT = -w +endif + +# Hello Application +# TODO: appname can be automatically extracted from the directory name + +APPNAME = poweroff +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = 768 + +ASRCS = +CSRCS = poweroff.c + +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +ifeq ($(WINTOOL),y) + BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" +else + BIN = "$(APPDIR)/libapps$(LIBEXT)" +endif + +ROOTDEPPATH = --dep-path . + +# Common build + +VPATH = + +all: .built +.PHONY: context depend clean distclean + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +.built: $(OBJS) + @( for obj in $(OBJS) ; do \ + $(call ARCHIVE, $(BIN), $${obj}); \ + done ; ) + @touch .built + +# Register application + +.context: + $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) + @touch $@ + +context: .context + +# Create dependencies + +.depend: Makefile $(SRCS) + @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @touch $@ + +depend: .depend + +clean: + @rm -f *.o *~ .*.swp .built + $(call CLEAN) + +distclean: clean + @rm -f .context Make.dep .depend + +-include Make.dep diff --git a/apps/system/poweroff/README.txt b/apps/system/poweroff/README.txt new file mode 100644 index 000000000..e02180e5a --- /dev/null +++ b/apps/system/poweroff/README.txt @@ -0,0 +1,5 @@ + +This application provides poweroff command + + Source: NuttX + Date: 13. March 2011 diff --git a/apps/system/poweroff/poweroff.c b/apps/system/poweroff/poweroff.c new file mode 100644 index 000000000..dd08b177a --- /dev/null +++ b/apps/system/poweroff/poweroff.c @@ -0,0 +1,63 @@ +/**************************************************************************** + * apps/system/poweroff/poweroff.c + * + * Copyright (C) 2011 Uros Platise. All rights reserved. + * Author: Uros Platise + * + * 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 + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int poweroff_main(int argc, char *argv[]) +{ + /* TODO: + * - replace this by sending general system signal to shutdown, where i.e. nsh + * must issue down script (it may check whether nsh is running before spawning + * a new process with nsh poweroff) + * - wait for some time (~0.5 second for VSN), that SDcard is flashed and synced + * - call poweroff + * + * TODO on boot: + * - if external key is pressed, do not start the nsh! but wait until it is released + * (to get rid of bad mounts of the sdcard etc.) this could be handled in the + * button driver immediately on system boot + */ + + board_power_off(); + return 0; +} diff --git a/apps/system/ramtron/Kconfig b/apps/system/ramtron/Kconfig new file mode 100644 index 000000000..53d547e5f --- /dev/null +++ b/apps/system/ramtron/Kconfig @@ -0,0 +1,14 @@ +# +# For a description of the syntax of this configuration file, +# see misc/tools/kconfig-language.txt. +# + +config SYSTEM_RAMTRON + bool "RAMTRON command" + default n + ---help--- + Enable support for the NSH RAMTRON command. + +if SYSTEM_RAMTRON +endif + diff --git a/apps/system/ramtron/Makefile b/apps/system/ramtron/Makefile new file mode 100644 index 000000000..030ef6d5c --- /dev/null +++ b/apps/system/ramtron/Makefile @@ -0,0 +1,114 @@ +############################################################################ +# apps/system/ramtron/Makefile +# +# Copyright (C) 2011 Uros Platise. All rights reserved. +# Author: Uros Platise +# 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. +# +############################################################################ + +# TODO, this makefile should run make under the app dirs, instead of +# sourcing the Make.defs! + +-include $(TOPDIR)/.config +-include $(TOPDIR)/Make.defs +include $(APPDIR)/Make.defs + +ifeq ($(WINTOOL),y) +INCDIROPT = -w +endif + +# Hello Application +# TODO: appname can be automatically extracted from the directory name + +APPNAME = ramtron +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = 1024 + +ASRCS = +CSRCS = ramtron.c + +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +ifeq ($(WINTOOL),y) + BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" +else + BIN = "$(APPDIR)/libapps$(LIBEXT)" +endif + +ROOTDEPPATH = --dep-path . + +# Common build + +VPATH = + +all: .built +.PHONY: context depend clean distclean + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +.built: $(OBJS) + @( for obj in $(OBJS) ; do \ + $(call ARCHIVE, $(BIN), $${obj}); \ + done ; ) + @touch .built + +# Register application + +.context: + $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) + @touch $@ + +context: .context + +# Create dependencies + +.depend: Makefile $(SRCS) + @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @touch $@ + +depend: .depend + +clean: + @rm -f *.o *~ .*.swp .built + $(call CLEAN) + +distclean: clean + @rm -f .context Make.dep .depend + +-include Make.dep diff --git a/apps/system/ramtron/README.txt b/apps/system/ramtron/README.txt new file mode 100644 index 000000000..152774b66 --- /dev/null +++ b/apps/system/ramtron/README.txt @@ -0,0 +1,7 @@ + +This application provides RAMTRON tool/lib to start, stop or to perform +RAMTRON custom operations. + + Source: NuttX + Author: Uros Platise + Date: 18. March 2011 diff --git a/apps/system/ramtron/ramtron.c b/apps/system/ramtron/ramtron.c new file mode 100644 index 000000000..cd4012787 --- /dev/null +++ b/apps/system/ramtron/ramtron.c @@ -0,0 +1,104 @@ +/**************************************************************************** + * ramtron/ramtron.c + * + * Copyright (C) 2011 Uros Platise. All rights reserved. + * Copyright (C) 2009 Gregory Nutt. All rights reserved. + * + * Authors: Uros Platise + * 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. + * + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include + +#include +#include + +FAR struct mtd_dev_s *ramtron_initialize(FAR struct spi_dev_s *dev); + +int ramtron_start(int spino) +{ + FAR struct spi_dev_s *spi; + FAR struct mtd_dev_s *mtd; + int retval; + + /* Get the SPI port */ + + spi = up_spiinitialize(spino); + if (!spi) + { + printf("RAMTRON: Failed to initialize SPI%d\n", spino); + return -ENODEV; + } + + printf("RAMTRON: Initialized SPI%d\n", spino); + + mtd = (struct mtd_dev_s *)ramtron_initialize(spi); + if (!mtd) + { + printf("RAMTRON: Device not found\n"); + return -ENODEV; + } + + printf("RAMTRON: FM25V10 of size 128 kB\n"); + //printf("RAMTRON: %s of size %d B\n", ramtron_getpart(mtd), ramtron_getsize(mtd) ); + + retval = ftl_initialize(0, mtd); + printf("RAMTRON: FTL Initialized (returns with %d)\n", retval); + + return OK; +} + + +int ramtron_main(int argc, char *argv[]) +{ + int spino; + + if (argc == 3) + { + spino = atoi(argv[2]); + + if (!strcmp(argv[1], "start")) + { + return ramtron_start(spino); + } + } + + /* todo: write protect */ + + printf("%s: \n", argv[0]); + return -1; +} diff --git a/apps/system/sdcard/Kconfig b/apps/system/sdcard/Kconfig new file mode 100644 index 000000000..a1a8a1f32 --- /dev/null +++ b/apps/system/sdcard/Kconfig @@ -0,0 +1,14 @@ +# +# For a description of the syntax of this configuration file, +# see misc/tools/kconfig-language.txt. +# + +config SYSTEM_SDCARD + bool "NSH sdcard command" + default n + ---help--- + Enable support for the NSH sdcard command. + +if SYSTEM_SDCARD +endif + diff --git a/apps/system/sdcard/Makefile b/apps/system/sdcard/Makefile new file mode 100644 index 000000000..fef049a59 --- /dev/null +++ b/apps/system/sdcard/Makefile @@ -0,0 +1,114 @@ +############################################################################ +# apps/system/sdcard/Makefile +# +# Copyright (C) 2011 Uros Platise. All rights reserved. +# Author: Uros Platise +# 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. +# +############################################################################ + +# TODO, this makefile should run make under the app dirs, instead of +# sourcing the Make.defs! + +-include $(TOPDIR)/.config +-include $(TOPDIR)/Make.defs +include $(APPDIR)/Make.defs + +ifeq ($(WINTOOL),y) +INCDIROPT = -w +endif + +# Hello Application +# TODO: appname can be automatically extracted from the directory name + +APPNAME = sdcard +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = 1024 + +ASRCS = +CSRCS = sdcard.c + +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +ifeq ($(WINTOOL),y) + BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" +else + BIN = "$(APPDIR)/libapps$(LIBEXT)" +endif + +ROOTDEPPATH = --dep-path . + +# Common build + +VPATH = + +all: .built +.PHONY: context depend clean distclean + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +.built: $(OBJS) + @( for obj in $(OBJS) ; do \ + $(call ARCHIVE, $(BIN), $${obj}); \ + done ; ) + @touch .built + +# Register application + +.context: + $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) + @touch $@ + +context: .context + +# Create dependencies + +.depend: Makefile $(SRCS) + @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @touch $@ + +depend: .depend + +clean: + @rm -f *.o *~ .*.swp .built + $(call CLEAN) + +distclean: clean + @rm -f .context Make.dep .depend + +-include Make.dep diff --git a/apps/system/sdcard/README.txt b/apps/system/sdcard/README.txt new file mode 100644 index 000000000..332aa26cf --- /dev/null +++ b/apps/system/sdcard/README.txt @@ -0,0 +1,7 @@ + +This application provides SDcard tool/lib to start, stop, eject or insert +a memory card. + + Source: NuttX + Author: Uros Platise + Date: 18. March 2011 diff --git a/apps/system/sdcard/sdcard.c b/apps/system/sdcard/sdcard.c new file mode 100644 index 000000000..56ab74f44 --- /dev/null +++ b/apps/system/sdcard/sdcard.c @@ -0,0 +1,161 @@ +/**************************************************************************** + * apps/system/sdcard/sdcard.c + * + * Copyright (C) 2011 Uros Platise. All rights reserved. + * Copyright (C) 2009 Gregory Nutt. All rights reserved. + * + * Authors: Uros Platise + * 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 + +#ifdef CONFIG_STM32_SDIO +# include +# include +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +FAR struct sdio_dev_s *sdio_initialize(int slotno); +void sdio_mediachange(FAR struct sdio_dev_s *dev, bool cardinslot); + +// TODO get the structure out from the slot number +static FAR struct sdio_dev_s *sdio = NULL; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/* Create device device for the SDIO-based MMC/SD block driver */ + +static int sdcard_start(int slotno) +{ + int ret; + + /* First, get an instance of the SDIO interface */ + + sdio = sdio_initialize(slotno); + if (!sdio) + { + printf("SDIO: Failed to initialize slot %d\n", slotno); + return -ENODEV; + } + + printf("SDIO: Initialized slot %d\n", slotno); + + /* Now bind the SPI interface to the MMC/SD driver */ + + ret = mmcsd_slotinitialize(slotno, sdio); + if (ret != OK) + { + printf("SDIO: Failed to bind to the MMC/SD driver: %d\n", ret); + return ret; + } + + printf("SDIO: Successfully bound to the MMC/SD driver\n"); + + /* Then let's guess and say that there is a card in the slot. I need to check to + * see if the VSN board supports a GPIO to detect if there is a card in + * the slot. + */ + sdio_mediachange(sdio, true); + + return OK; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int sdcard_main(int argc, char *argv[]) +{ + int slotno = 0; + + if (argc >= 2) { + + /* The 3rd argument is expected to be a slot number, if given */ + + if (argc==3) + { + slotno = atoi(argv[2]); + } + + /* Commands */ + + if (!strcmp(argv[1], "start")) + { + return sdcard_start(slotno); + } + else if (!strcmp(argv[1], "stop")) + { + fprintf(stderr, "Not implemented yet\n"); + } + else if (!strcmp(argv[1], "insert")) + { + if (sdio) + { + sdio_mediachange(sdio, true); + return OK; + } + } + else if (!strcmp(argv[1], "eject")) + { + if (sdio) + { + sdio_mediachange(sdio, false); + return OK; + } + } + else if (!strcmp(argv[1], "status")) + { + printf("SDcard #%d Status:\n", slotno); +#ifndef CONFIG_MMCSD_HAVECARDDETECT + printf("\t - Without SDcard detect capability\n"); +#endif + return 0; + } + } + + printf("%s: {slotno}\n", argv[0]); + return -1; +} diff --git a/apps/system/sysinfo/Kconfig b/apps/system/sysinfo/Kconfig new file mode 100644 index 000000000..1f106dc8a --- /dev/null +++ b/apps/system/sysinfo/Kconfig @@ -0,0 +1,13 @@ +# +# For a description of the syntax of this configuration file, +# see misc/tools/kconfig-language.txt. +# + +config SYSTEM_SYSINFO + bool "NSH sysinfo command" + default n + ---help--- + Enable support for the NSH sysinfo command. + +if SYSTEM_SYSINFO +endif diff --git a/apps/system/sysinfo/Makefile b/apps/system/sysinfo/Makefile new file mode 100644 index 000000000..ead974277 --- /dev/null +++ b/apps/system/sysinfo/Makefile @@ -0,0 +1,114 @@ +############################################################################ +# apps/system/sysinfo/Makefile +# +# Copyright (C) 2011 Uros Platise. All rights reserved. +# Author: Uros Platise +# 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. +# +############################################################################ + +# TODO, this makefile should run make under the app dirs, instead of +# sourcing the Make.defs! + +-include $(TOPDIR)/.config +-include $(TOPDIR)/Make.defs +include $(APPDIR)/Make.defs + +ifeq ($(WINTOOL),y) +INCDIROPT = -w +endif + +# Hello Application +# TODO: appname can be automatically extracted from the directory name + +APPNAME = sysinfo +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = 768 + +ASRCS = +CSRCS = sysinfo.c + +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +ifeq ($(WINTOOL),y) + BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" +else + BIN = "$(APPDIR)/libapps$(LIBEXT)" +endif + +ROOTDEPPATH = --dep-path . + +# Common build + +VPATH = + +all: .built +.PHONY: context depend clean distclean + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +.built: $(OBJS) + @( for obj in $(OBJS) ; do \ + $(call ARCHIVE, $(BIN), $${obj}); \ + done ; ) + @touch .built + +# Register application + +.context: + $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) + @touch $@ + +context: .context + +# Create dependencies + +.depend: Makefile $(SRCS) + @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @touch $@ + +depend: .depend + +clean: + @rm -f *.o *~ .*.swp .built + $(call CLEAN) + +distclean: clean + @rm -f .context Make.dep .depend + +-include Make.dep diff --git a/apps/system/sysinfo/README.txt b/apps/system/sysinfo/README.txt new file mode 100644 index 000000000..3792f4a59 --- /dev/null +++ b/apps/system/sysinfo/README.txt @@ -0,0 +1,6 @@ + +This application provides access to System Information + + Source: NuttX + Date: 15. April 2011 + Author: Uros Platise diff --git a/apps/system/sysinfo/sysinfo.c b/apps/system/sysinfo/sysinfo.c new file mode 100644 index 000000000..019e910db --- /dev/null +++ b/apps/system/sysinfo/sysinfo.c @@ -0,0 +1,69 @@ +/**************************************************************************** + * apps/system/sysinfo/sysinfo.c + * + * Copyright (C) 2011 Uros Platise. All rights reserved. + * Author: Uros Platise + * + * 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. + * + ****************************************************************************/ + +/* Collects and reports system information. + * + * TODO: Gather information also from low-level devices, kernel/sched, clock, + * and further reporting as: sysinfo rtc, or sysinfo sched, ... with + * sysinfo help to report all of the options. + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +#include +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int sysinfo_main(int argc, char *argv[]) +{ + printf("System Information:\n"); + printf("\tNuttX Version:\t" CONFIG_VERSION_STRING + " Build: %d\n", CONFIG_VERSION_BUILD); + printf("\tSystem Time:\t%d [s] UTC " +#ifdef CONFIG_RTC + "Hardware RTC Support" +#endif + "\n", time(NULL) ); + return 0; +} -- cgit v1.2.3