diff --git a/ChangeLog.txt b/ChangeLog.txt index 75f02754b..2d7b2eb9f 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -350,3 +350,6 @@ feature of the NxWidgets/NxWM unit tests. 6.23 2012-xx-xx Gregory Nutt <gnutt@nuttx.org> + + * vsn: Moved all NSH commands from vsn/ to system/. Deleted the vsn/ + directory. diff --git a/Kconfig b/Kconfig index 5543ba72d..ea9bd2d31 100644 --- a/Kconfig +++ b/Kconfig @@ -34,7 +34,3 @@ endmenu menu "System NSH Add-Ons" source "$APPSDIR/system/Kconfig" endmenu - -menu "VSN board Add-Ons" -source "$APPSDIR/vsn/Kconfig" -endmenu diff --git a/Makefile b/Makefile index 3a59fd6b4..d2b0ecdab 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ APPDIR = ${shell pwd} # list can be extended by the .config file as well CONFIGURED_APPS = -SUBDIRS = examples graphics interpreters modbus namedapp nshlib netutils system vsn +SUBDIRS = examples graphics interpreters modbus namedapp nshlib netutils system # There are two different mechanisms for obtaining the list of configured # directories: @@ -78,7 +78,6 @@ include namedapp/Make.defs include netutils/Make.defs include nshlib/Make.defs include system/Make.defs -include vsn/Make.defs # INSTALLED_APPS is the list of currently available application directories. It # is the same as CONFIGURED_APPS, but filtered to exclude any non-existent diff --git a/README.txt b/README.txt index f9c9ececd..7a379254e 100644 --- a/README.txt +++ b/README.txt @@ -107,7 +107,7 @@ NuttX is configured. .config is included in the toplevel apps/Makefile. As a minimum, this configuration file must define files to add to the CONFIGURED_APPS list like: - CONFIGURED_APPS += examples/hello vsn/poweroff + CONFIGURED_APPS += examples/hello system/poweroff Named Start-Up main() function ------------------------------ diff --git a/system/Kconfig b/system/Kconfig index 44bf5a2e6..d4d434665 100644 --- a/system/Kconfig +++ b/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/system/Make.defs b/system/Make.defs index a4aea2d31..3d10f84e5 100644 --- a/system/Make.defs +++ b/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/system/Makefile b/system/Makefile index 73eb60d15..d64bb54c6 100644 --- a/system/Makefile +++ b/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/system/free/free.c b/system/free/free.c index 3d9698ecb..c44cd5e22 100644 --- a/system/free/free.c +++ b/system/free/free.c @@ -33,57 +33,65 @@ * ****************************************************************************/ +/**************************************************************************** + * Included Files + ****************************************************************************/ + #include <nuttx/config.h> #include <nuttx/progmem.h> #include <stdio.h> #include <stdlib.h> - /**************************************************************************** * Private Functions ****************************************************************************/ - -/* \todo Max block size only works on uniform prog mem */ - -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; - } - 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; +/* 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; + } + 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/system/install/install.c b/system/install/install.c index 2f11c6434..fd14b7a6f 100644 --- a/system/install/install.c +++ b/system/install/install.c @@ -33,6 +33,10 @@ * ****************************************************************************/ +/**************************************************************************** + * Included Files + ****************************************************************************/ + #include <nuttx/config.h> #include <nuttx/progmem.h> #include <sys/stat.h> @@ -43,9 +47,8 @@ #include <string.h> #include <errno.h> - /**************************************************************************** - * 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 <page>\t\tInstalls application at or after <page>\n" "\t--margin <pages>\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) { + else if (status != 0) + { + if (stpage != 0xffff) + { + if ((page - stpage) > maxlen) + { + if (maxlen==-1) + { + /* First time found sth? */ - if (stpage != 0xFFFF) { - - if ( (page - stpage) > maxlen) { + 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; - } - - startaddr += count; - totalsize += count; - } - while(count); + int status; + int count; + int totalsize = 0; + char *buf; + FILE *fp; + + if ((buf = malloc(INSTALL_PROGRAMBLOCKSIZE)) == NULL) + { + return -ENOMEM; } - else totalsize = -errno; - - fclose(fp); - free(buf); - - return totalsize; + + 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; + } + while(count); + } + else + { + totalsize = -errno; + } + + fclose(fp); + free(buf); + + return totalsize; } - -void install_getscriptname(char *scriptname, const char *progname, const char *destdir) +static void install_getscriptname(char *scriptname, const char *progname, const char *destdir) { - const char * progonly; + 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); + /* I.e. as /usr/bin */ + + strcpy(scriptname, destdir); + + /* extract from i.e. /sdcard/demo -> /demo, together with / */ + + progonly = strrchr(progname, '/'); + strcat(scriptname, progonly); } - -int install_getprogsize(const char *progname) +static int install_getprogsize(const char *progname) { - struct stat fileinfo; - - if ( stat(progname, &fileinfo) < 0 ) - return -1; - - return fileinfo.st_size; + 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); + FILE *fp; - return 0; + 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; } - -int install_getlasthexvalue(FILE *fp, char delimiter) +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; - - do { - if ((page = up_progmem_getpage(addr)) < 0) { - status = -page; - break; + 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; } - - 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; - } - - /* Parse arguments */ - - for (i=1; i<argc; i++) { - if (argv[i][0]=='-' && argv[i][1]=='-' && i<=argc) { - - if (strcmp(argv[i]+2, "stack")==0) { - stacksize = atoi(argv[++i]); - } - else if (strcmp(argv[i]+2, "priority")==0) { - priority = atoi(argv[++i]); - } - else if (strcmp(argv[i]+2, "start")==0) { - startpage = atoi(argv[++i]); - } - else if (strcmp(argv[i]+2, "margin")==0) { - pagemargin = atoi(argv[++i]); - } - else if (strcmp(argv[i]+2, "remove")==0) { - action = ACTION_REMOVE; - } - else if (strcmp(argv[i]+2, "force")==0) { - action = ACTION_REINSTALL; - } - else fprintf(stderr, "Unknown option: %s\n", argv[i]); - } - else break; - } - - /* 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("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", - progsize, startaddr, startaddr + progsize); + 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]; - return 0; + /* Supported? */ + + if (!up_progmem_isuniform()) + { + fprintf(stderr, "Error: install supports uniform organization only.\n"); + return -1; } - - fprintf(stderr, install_help, argv[0], argv[0]); - return -1; + + /* Parse arguments */ + + for (i=1; i<argc; i++) + { + if (argv[i][0]=='-' && argv[i][1]=='-' && i<=argc) + { + if (strcmp(argv[i]+2, "stack")==0) + { + stacksize = atoi(argv[++i]); + } + else if (strcmp(argv[i]+2, "priority")==0) + { + priority = atoi(argv[++i]); + } + else if (strcmp(argv[i]+2, "start")==0) + { + startpage = atoi(argv[++i]); + } + else if (strcmp(argv[i]+2, "margin")==0) + { + pagemargin = atoi(argv[++i]); + } + else if (strcmp(argv[i]+2, "remove")==0) + { + action = ACTION_REMOVE; + } + else if (strcmp(argv[i]+2, "force")==0) + { + action = ACTION_REINSTALL; + } + else fprintf(stderr, "Unknown option: %s\n", argv[i]); + } + else + { + break; + } + } + + /* 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("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", + progsize, startaddr, startaddr + progsize); + return 0; + } + + fprintf(stderr, install_help, argv[0], argv[0]); + return -1; } diff --git a/system/poweroff/Kconfig b/system/poweroff/Kconfig new file mode 100644 index 000000000..ae8eac450 --- /dev/null +++ b/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/vsn/poweroff/Makefile b/system/poweroff/Makefile similarity index 99% rename from vsn/poweroff/Makefile rename to system/poweroff/Makefile index e58ecfa86..40465e957 100644 --- a/vsn/poweroff/Makefile +++ b/system/poweroff/Makefile @@ -1,5 +1,5 @@ ############################################################################ -# Makefile +# apps/system/poweroff/Makefile # # Copyright (C) 2011 Uros Platise. All rights reserved. # Author: Uros Platise <uros.platise@isotel.eu> diff --git a/vsn/poweroff/README.txt b/system/poweroff/README.txt similarity index 100% rename from vsn/poweroff/README.txt rename to system/poweroff/README.txt diff --git a/vsn/poweroff/poweroff.c b/system/poweroff/poweroff.c similarity index 64% rename from vsn/poweroff/poweroff.c rename to system/poweroff/poweroff.c index ca3f056e8..dd08b177a 100644 --- a/vsn/poweroff/poweroff.c +++ b/system/poweroff/poweroff.c @@ -1,5 +1,5 @@ /**************************************************************************** - * poweroff/poweroff.c + * apps/system/poweroff/poweroff.c * * Copyright (C) 2011 Uros Platise. All rights reserved. * Author: Uros Platise <uros.platise@isotel.eu> @@ -33,22 +33,31 @@ * ****************************************************************************/ +/**************************************************************************** + * Included Files + ****************************************************************************/ + #include <arch/board/power.h> +/**************************************************************************** + * 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; + /* 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/vsn/ramtron/Kconfig b/system/ramtron/Kconfig similarity index 55% rename from vsn/ramtron/Kconfig rename to system/ramtron/Kconfig index 14f358921..53d547e5f 100644 --- a/vsn/ramtron/Kconfig +++ b/system/ramtron/Kconfig @@ -3,12 +3,12 @@ # see misc/tools/kconfig-language.txt. # -config VSN_RAMTRON - bool "NSH ramtron command" +config SYSTEM_RAMTRON + bool "RAMTRON command" default n ---help--- - Enable support for the NSH ramtron command. + Enable support for the NSH RAMTRON command. -if VSN_RAMTRON +if SYSTEM_RAMTRON endif diff --git a/vsn/ramtron/Makefile b/system/ramtron/Makefile similarity index 99% rename from vsn/ramtron/Makefile rename to system/ramtron/Makefile index d930aa92c..030ef6d5c 100644 --- a/vsn/ramtron/Makefile +++ b/system/ramtron/Makefile @@ -1,5 +1,5 @@ ############################################################################ -# Makefile +# apps/system/ramtron/Makefile # # Copyright (C) 2011 Uros Platise. All rights reserved. # Author: Uros Platise <uros.platise@isotel.eu> diff --git a/vsn/ramtron/README.txt b/system/ramtron/README.txt similarity index 100% rename from vsn/ramtron/README.txt rename to system/ramtron/README.txt diff --git a/vsn/ramtron/ramtron.c b/system/ramtron/ramtron.c similarity index 92% rename from vsn/ramtron/ramtron.c rename to system/ramtron/ramtron.c index f1e8db100..cd4012787 100644 --- a/vsn/ramtron/ramtron.c +++ b/system/ramtron/ramtron.c @@ -63,6 +63,7 @@ int ramtron_start(int spino) 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); @@ -71,7 +72,8 @@ int ramtron_start(int spino) printf("RAMTRON: Device not found\n"); return -ENODEV; } - printf("RAMTRON: FM25V10 of size 128 kB\n"); + + 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); @@ -85,15 +87,18 @@ int ramtron_main(int argc, char *argv[]) { int spino; - if (argc == 3) { - spino = atoi(argv[2]); + if (argc == 3) + { + spino = atoi(argv[2]); - if (!strcmp(argv[1], "start")) { - return ramtron_start(spino); + if (!strcmp(argv[1], "start")) + { + return ramtron_start(spino); + } } - } - // todo: write protect + /* todo: write protect */ + printf("%s: <start> <spino>\n", argv[0]); return -1; } diff --git a/vsn/sdcard/Kconfig b/system/sdcard/Kconfig similarity index 84% rename from vsn/sdcard/Kconfig rename to system/sdcard/Kconfig index 8e6c13264..a1a8a1f32 100644 --- a/vsn/sdcard/Kconfig +++ b/system/sdcard/Kconfig @@ -3,12 +3,12 @@ # see misc/tools/kconfig-language.txt. # -config VSN_SDCARD +config SYSTEM_SDCARD bool "NSH sdcard command" default n ---help--- Enable support for the NSH sdcard command. -if VSN_SDCARD +if SYSTEM_SDCARD endif diff --git a/vsn/sdcard/Makefile b/system/sdcard/Makefile similarity index 99% rename from vsn/sdcard/Makefile rename to system/sdcard/Makefile index 213021b25..fef049a59 100644 --- a/vsn/sdcard/Makefile +++ b/system/sdcard/Makefile @@ -1,5 +1,5 @@ ############################################################################ -# Makefile +# apps/system/sdcard/Makefile # # Copyright (C) 2011 Uros Platise. All rights reserved. # Author: Uros Platise <uros.platise@isotel.eu> diff --git a/vsn/sdcard/README.txt b/system/sdcard/README.txt similarity index 100% rename from vsn/sdcard/README.txt rename to system/sdcard/README.txt diff --git a/vsn/sdcard/sdcard.c b/system/sdcard/sdcard.c similarity index 65% rename from vsn/sdcard/sdcard.c rename to system/sdcard/sdcard.c index a81e8432a..56ab74f44 100644 --- a/vsn/sdcard/sdcard.c +++ b/system/sdcard/sdcard.c @@ -1,5 +1,5 @@ /**************************************************************************** - * sdcard/sdcard.c + * apps/system/sdcard/sdcard.c * * Copyright (C) 2011 Uros Platise. All rights reserved. * Copyright (C) 2009 Gregory Nutt. All rights reserved. @@ -36,6 +36,10 @@ * ****************************************************************************/ +/**************************************************************************** + * Included Files + ****************************************************************************/ + #include <nuttx/config.h> #include <stdlib.h> @@ -48,15 +52,23 @@ # include <nuttx/mmcsd.h> #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 */ -int sdcard_start(int slotno) +static int sdcard_start(int slotno) { int ret; @@ -68,6 +80,7 @@ int sdcard_start(int slotno) 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 */ @@ -78,57 +91,71 @@ int sdcard_start(int slotno) 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); + 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]); } - else if (!strcmp(argv[1], "stop")) { - fprintf(stderr, "Not implemented yet\n"); + + /* Commands */ + + if (!strcmp(argv[1], "start")) + { + return sdcard_start(slotno); } - else if (!strcmp(argv[1], "insert")) { - if (sdio) { - sdio_mediachange(sdio, true); - return OK; + 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], "eject")) + { + if (sdio) + { + sdio_mediachange(sdio, false); + return OK; } } - else if (!strcmp(argv[1], "status")) { - printf("SDcard #%d Status:\n", slotno); + else if (!strcmp(argv[1], "status")) + { + printf("SDcard #%d Status:\n", slotno); #ifndef CONFIG_MMCSD_HAVECARDDETECT - printf("\t - Without SDcard detect capability\n"); + printf("\t - Without SDcard detect capability\n"); #endif - return 0; + return 0; } } - - printf("%s: <start|stop|insert|eject|status> {slotno}\n", argv[0]); - return -1; + + printf("%s: <start|stop|insert|eject|status> {slotno}\n", argv[0]); + return -1; } diff --git a/vsn/sysinfo/Kconfig b/system/sysinfo/Kconfig similarity index 84% rename from vsn/sysinfo/Kconfig rename to system/sysinfo/Kconfig index 38e0f16be..1f106dc8a 100644 --- a/vsn/sysinfo/Kconfig +++ b/system/sysinfo/Kconfig @@ -3,12 +3,11 @@ # see misc/tools/kconfig-language.txt. # -config VSN_SYSINFO +config SYSTEM_SYSINFO bool "NSH sysinfo command" default n ---help--- Enable support for the NSH sysinfo command. -if VSN_SYSINFO +if SYSTEM_SYSINFO endif - diff --git a/vsn/sysinfo/Makefile b/system/sysinfo/Makefile similarity index 99% rename from vsn/sysinfo/Makefile rename to system/sysinfo/Makefile index b4afc8a97..ead974277 100644 --- a/vsn/sysinfo/Makefile +++ b/system/sysinfo/Makefile @@ -1,5 +1,5 @@ ############################################################################ -# Makefile +# apps/system/sysinfo/Makefile # # Copyright (C) 2011 Uros Platise. All rights reserved. # Author: Uros Platise <uros.platise@isotel.eu> diff --git a/vsn/sysinfo/README.txt b/system/sysinfo/README.txt similarity index 100% rename from vsn/sysinfo/README.txt rename to system/sysinfo/README.txt diff --git a/vsn/sysinfo/sysinfo.c b/system/sysinfo/sysinfo.c similarity index 75% rename from vsn/sysinfo/sysinfo.c rename to system/sysinfo/sysinfo.c index 8625f9db7..019e910db 100644 --- a/vsn/sysinfo/sysinfo.c +++ b/system/sysinfo/sysinfo.c @@ -1,5 +1,5 @@ /**************************************************************************** - * sysinfo/sysinfo.c + * apps/system/sysinfo/sysinfo.c * * Copyright (C) 2011 Uros Platise. All rights reserved. * Author: Uros Platise <uros.platise@isotel.eu> @@ -32,18 +32,17 @@ * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************/ - -/** \file - * \brief System Information - * \author Uros Platise - * - * 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. + +/* 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 <nuttx/config.h> #include <nuttx/version.h> @@ -52,18 +51,19 @@ #include <stdio.h> #include <stdlib.h> +/**************************************************************************** + * 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 " + 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; + return 0; } diff --git a/vsn/Kconfig b/vsn/Kconfig deleted file mode 100644 index 1f0c25f16..000000000 --- a/vsn/Kconfig +++ /dev/null @@ -1,11 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see misc/tools/kconfig-language.txt. -# - -comment "VSN board add-ons" - -source "$APPSDIR/vsn/poweroff/Kconfig" -source "$APPSDIR/vsn/ramtron/Kconfig" -source "$APPSDIR/vsn/sdcard/Kconfig" -source "$APPSDIR/vsn/sysinfo/Kconfig" diff --git a/vsn/Make.defs b/vsn/Make.defs deleted file mode 100644 index 6d59ab838..000000000 --- a/vsn/Make.defs +++ /dev/null @@ -1,51 +0,0 @@ -############################################################################ -# apps/vsn/Make.defs -# Adds selected applications to apps/ build -# -# Copyright (C) 2012 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <gnutt@nuttx.org> -# -# 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. -# -############################################################################ - -ifeq ($(CONFIG_VSN_POWEROFF),y) -CONFIGURED_APPS += vsn/poweroff -endif - -ifeq ($(CONFIG_VSN_RAMTRON),y) -CONFIGURED_APPS += vsn/ramtron -endif - -ifeq ($(CONFIG_VSN_SDCARD),y) -CONFIGURED_APPS += vsn/sdcard -endif - -ifeq ($(CONFIG_VSN_SYSINFO),y) -CONFIGURED_APPS += vsn/sysinfo -endif diff --git a/vsn/Makefile b/vsn/Makefile deleted file mode 100644 index 21901d96d..000000000 --- a/vsn/Makefile +++ /dev/null @@ -1,71 +0,0 @@ -############################################################################ -# apps/vsn/Makefile -# -# Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <gnutt@nuttx.org> -# -# 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 $(TOPDIR)/.config # Current configuration - -# Sub-directories - -SUBDIRS = poweroff ramtron sdcard sysinfo - -all: nothing -.PHONY: nothing context depend clean distclean - -nothing: - -.context: - @for dir in $(SUBDIRS) ; do \ - $(MAKE) -C $$dir context TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"; \ - done - @touch $@ - -context: .context - -depend: - @for dir in $(SUBDIRS) ; do \ - $(MAKE) -C $$dir depend TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"; \ - done - -clean: - @for dir in $(SUBDIRS) ; do \ - $(MAKE) -C $$dir clean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"; \ - done - -distclean: clean - @for dir in $(SUBDIRS) ; do \ - $(MAKE) -C $$dir distclean TOPDIR="$(TOPDIR)" APPDIR=$(APPDIR); \ - done - --include Make.dep - diff --git a/vsn/poweroff/Kconfig b/vsn/poweroff/Kconfig deleted file mode 100644 index d0059a0d3..000000000 --- a/vsn/poweroff/Kconfig +++ /dev/null @@ -1,14 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see misc/tools/kconfig-language.txt. -# - -config VSN_POWEROFF - bool "NSH poweroff command" - default n - ---help--- - Enable support for the NSH poweroff command. - -if VSN_POWEROFF -endif -