From 60889d41f6f43ac396d2f7bb71a8bcd166f9ca66 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sat, 4 Aug 2012 22:17:37 +0000 Subject: [PATCH 01/13] Update NSH documentation; Add option to reduce size of help commnd without completely eliminating it git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5009 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- apps/nshlib/README.txt | 13 +++++++++++-- apps/nshlib/nsh_parse.c | 23 +++++++++++++++++++---- nuttx/Documentation/NuttShell.html | 25 ++++++++++++++++++++++--- 3 files changed, 52 insertions(+), 9 deletions(-) diff --git a/apps/nshlib/README.txt b/apps/nshlib/README.txt index 7dbae8e63e..a6cb2d7d7d 100644 --- a/apps/nshlib/README.txt +++ b/apps/nshlib/README.txt @@ -371,9 +371,15 @@ o get [-b|-n] [-f ] -h Selects either binary ("octect") or test ("netascii") transfer mode. Default: text. -o help +o help [-v] [] - Presents summary information about each command to console. + Presents summary information about NSH commands to console. Options: + + -v + Show verbose output will full command usage + + + Show full command usage only for this command o ifconfig @@ -889,6 +895,9 @@ also allow it to squeeze into very small memory footprints. CONFIG_NSH_DISABLE_UNSET, CONFIG_NSH_DISABLE_USLEEP, CONFIG_NSH_DISABLE_WGET, CONFIG_NSH_DISABLE_XD +Verbose help output can be suppressed by defining CONFIG_NSH_HELP_TERSE. In that +case, the help command is still available but will be slightly smaller. + NSH-Specific Configuration Settings ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/apps/nshlib/nsh_parse.c b/apps/nshlib/nsh_parse.c index b79461bba6..0494443979 100644 --- a/apps/nshlib/nsh_parse.c +++ b/apps/nshlib/nsh_parse.c @@ -211,7 +211,11 @@ static const struct cmdmap_s g_cmdmap[] = #endif #ifndef CONFIG_NSH_DISABLE_HELP - { "help", cmd_help, 1, 3, "[-v] [cmd]" }, +# ifdef CONFIG_NSH_HELP_TERSE + { "help", cmd_help, 1, 2, "[]" }, +#else + { "help", cmd_help, 1, 3, "[-v] []" }, +# endif #endif #ifdef CONFIG_NET @@ -453,7 +457,7 @@ static inline void help_cmdlist(FAR struct nsh_vtbl_s *vtbl) * Name: help_usage ****************************************************************************/ -#ifndef CONFIG_NSH_DISABLE_HELP +#if !defined(CONFIG_NSH_DISABLE_HELP) && !defined(CONFIG_NSH_HELP_TERSE) static inline void help_usage(FAR struct nsh_vtbl_s *vtbl) { nsh_output(vtbl, "NSH command forms:\n"); @@ -526,7 +530,7 @@ static int help_cmd(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd) * Name: help_allcmds ****************************************************************************/ -#ifndef CONFIG_NSH_DISABLE_HELP +#if !defined(CONFIG_NSH_DISABLE_HELP) && !defined(CONFIG_NSH_HELP_TERSE) static inline void help_allcmds(FAR struct nsh_vtbl_s *vtbl) { FAR const struct cmdmap_s *cmdmap; @@ -569,12 +573,15 @@ static inline void help_builtins(FAR struct nsh_vtbl_s *vtbl) #ifndef CONFIG_NSH_DISABLE_HELP static int cmd_help(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { - bool verbose = false; FAR const char *cmd = NULL; +#ifdef CONFIG_NSH_HELP_TERSE + bool verbose = false; int i; +#endif /* The command may be followed by a verbose option */ +#ifdef CONFIG_NSH_HELP_TERSE i = 1; if (argc > i) { @@ -598,6 +605,12 @@ static int cmd_help(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { help_usage(vtbl); } +#else + if (argc > 1) + { + cmd = argv[1]; + } +#endif /* Are we showing help on a single command? */ @@ -612,6 +625,7 @@ static int cmd_help(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { /* In verbose mode, show detailed help for all commands */ +#ifdef CONFIG_NSH_HELP_TERSE if (verbose) { nsh_output(vtbl, "Where is one of:\n"); @@ -621,6 +635,7 @@ static int cmd_help(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) /* Otherwise, just show the list of command names */ else +#endif { nsh_output(vtbl, "help usage:"); help_cmd(vtbl, "help"); diff --git a/nuttx/Documentation/NuttShell.html b/nuttx/Documentation/NuttShell.html index 249bf26369..8e57e27b22 100644 --- a/nuttx/Documentation/NuttShell.html +++ b/nuttx/Documentation/NuttShell.html @@ -1046,12 +1046,27 @@ get [-b|-n] [-f <local-path>] -h <ip-address> <remote-path>

Command Syntax:

    -help
    +help [-v] [<cmd>]
     

Synopsis. - Presents summary information about each command to console. + Presents summary information about NSH commands to console.

+

Options:

+
    + + + + + + + + +
    -v + how verbose output will full command usage. +
    <cmd> + Show full command usage only for this command. +
@@ -2031,7 +2046,7 @@ nsh> - + @@ -2192,6 +2207,10 @@ nsh> 4 CONFIG_FS_WRITABLE is not a user configuration but is set automatically if any writable filesystem is selected. At present, this is only CONFIG_FS_FAT.
+ 5 + Verbose help output can be suppressed by defining CONFIG_NSH_HELP_TERSE. + In that case, the help command is still available but will be slightly smaller. +

CONFIG_NSH_DISABLE_GET
helphelp5
CONFIG_NSH_DISABLE_HELP
From fca1ea81db5a621d2110d5d652b2886af66fdfa3 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 5 Aug 2012 17:44:11 +0000 Subject: [PATCH 02/13] I learned how to spell PSEUDO git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5010 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- apps/examples/pashello/README.txt | 2 +- apps/nshlib/README.txt | 16 +- apps/nshlib/nsh_parse.c | 17 +- misc/pascal/include/podefs.h | 408 +++++----- misc/pascal/insn16/include/pinsn16.h | 816 ++++++++++---------- misc/pascal/insn16/libinsn/pdasm.c | 2 +- misc/pascal/insn16/prun/pexec.c | 2 +- misc/pascal/insn32/doc/insn32.txt | 238 +++--- misc/pascal/insn32/include/pinsn32.h | 852 ++++++++++----------- misc/pascal/insn32/libinsn/pdasm.c | 2 +- misc/pascal/pascal/pgen.c | 2 +- nuttx/ChangeLog | 2 +- nuttx/Documentation/NfsHowto.html | 776 +++++++++---------- nuttx/Documentation/NuttShell.html | 6 +- nuttx/TODO | 4 +- nuttx/configs/lincoln60/README.txt | 2 +- nuttx/configs/lpc4330-xplorer/README.txt | 2 +- nuttx/configs/mbed/README.txt | 2 +- nuttx/configs/olimex-lpc1766stk/README.txt | 2 +- nuttx/fs/fs_closedir.c | 8 +- nuttx/fs/fs_files.c | 2 +- nuttx/fs/fs_foreachinode.c | 2 +- nuttx/fs/fs_foreachmountpoint.c | 2 +- nuttx/fs/fs_internal.h | 8 +- nuttx/fs/fs_opendir.c | 16 +- nuttx/fs/fs_readdir.c | 30 +- nuttx/fs/fs_rewinddir.c | 12 +- nuttx/fs/fs_seekdir.c | 14 +- nuttx/fs/fs_stat.c | 10 +- nuttx/fs/fs_statfs.c | 8 +- nuttx/fs/fs_syslog.c | 2 +- nuttx/fs/fs_unregisterblockdriver.c | 2 +- nuttx/fs/fs_unregisterdriver.c | 2 +- nuttx/include/nuttx/fs/dirent.h | 10 +- nuttx/include/nuttx/fs/fs.h | 8 +- 35 files changed, 1644 insertions(+), 1645 deletions(-) diff --git a/apps/examples/pashello/README.txt b/apps/examples/pashello/README.txt index b976f18cf3..b198469665 100644 --- a/apps/examples/pashello/README.txt +++ b/apps/examples/pashello/README.txt @@ -30,5 +30,5 @@ device.c device.c implements a simple device driver. Reads from this device will access the in-memory copy of hello.pex This device driver is - registered as /dev/pashello in the psuedo filesystem. + registered as /dev/pashello in the pseudo filesystem. diff --git a/apps/nshlib/README.txt b/apps/nshlib/README.txt index a6cb2d7d7d..d8edd89695 100644 --- a/apps/nshlib/README.txt +++ b/apps/nshlib/README.txt @@ -505,14 +505,14 @@ o mkfatfs Format a fat file system on the block device specified by path. NSH provides this command to access the mkfatfs() NuttX API. - This block device must reside in the NuttX psuedo filesystem and + This block device must reside in the NuttX pseudo filesystem and must have been created by some call to register_blockdriver() (see include/nuttx/fs/fs.h). o mkfifo Creates a FIFO character device anywhere in the pseudo file system, - creating whatever psuedo directories that may be needed to complete + creating whatever pseudo directories that may be needed to complete the full path. By convention, however, device drivers are place in the standard /dev directory. After it is created, the FIFO device may be used as any other device driver. NSH provides this command @@ -584,7 +584,7 @@ o mount [-t ] If the mount parameters are provied on the command after the 'mount' command, then the 'mount' command will mount a file system in the - NuttX psuedo-file system. 'mount' performs a three way association, + NuttX pseudo-file system. 'mount' performs a three way association, binding: File system. The '-t ' option identifies the type of @@ -592,19 +592,19 @@ o mount [-t ] of this writing, vfat is the only supported value for Block Device. The argument is the full or relative - path to a block driver inode in the psuedo filesystem. By convention, + path to a block driver inode in the pseudo filesystem. By convention, this is a name under the /dev sub-directory. This must have been previously formatted with the same file system type as specified by - Mount Point. The mount point is the location in the psuedo file + Mount Point. The mount point is the location in the pseudo file system where the mounted volume will appear. This mount point - can only reside in the NuttX psuedo filesystem. By convention, this + can only reside in the NuttX pseudo filesystem. By convention, this mount point is a subdirectory under /mnt. The mount command will - create whatever psuedo directories that may be needed to complete + create whatever pseudo directories that may be needed to complete the full path but the full path must not already exist. - After the volume has been mounted in the NuttX psuedo file + After the volume has been mounted in the NuttX pseudo file system, it may be access in the same way as other objects in the file system. diff --git a/apps/nshlib/nsh_parse.c b/apps/nshlib/nsh_parse.c index 0494443979..165f842fc3 100644 --- a/apps/nshlib/nsh_parse.c +++ b/apps/nshlib/nsh_parse.c @@ -88,12 +88,12 @@ # define MAX_ARGV_ENTRIES (NSH_MAX_ARGUMENTS+4) #endif -/* Help layout */ +/* Help command summary layout */ #define MAX_CMDLEN 12 -#define CMDS_PER_LINE 5 +#define CMDS_PER_LINE 6 -#define NUM_CMDS (sizeof(g_cmdmap)/sizeof(struct cmdmap_s)) +#define NUM_CMDS ((sizeof(g_cmdmap)/sizeof(struct cmdmap_s)) - 1) #define NUM_CMD_ROWS ((NUM_CMDS + (CMDS_PER_LINE-1)) / CMDS_PER_LINE) /**************************************************************************** @@ -443,7 +443,7 @@ static inline void help_cmdlist(FAR struct nsh_vtbl_s *vtbl) for (i = 0; i < NUM_CMD_ROWS; i++) { nsh_output(vtbl, " "); - for (j = 0, k = i; j < CMDS_PER_LINE && k < NUM_CMDS; j++, k += CMDS_PER_LINE) + for (j = 0, k = i; j < CMDS_PER_LINE && k < NUM_CMDS; j++, k += NUM_CMD_ROWS) { nsh_output(vtbl, "%-12s", g_cmdmap[k].cmd); } @@ -516,6 +516,7 @@ static int help_cmd(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd) { /* Yes... show it */ + nsh_output(vtbl, "%s usage:", cmd); help_showcmd(vtbl, cmdmap); return OK; } @@ -574,14 +575,14 @@ static inline void help_builtins(FAR struct nsh_vtbl_s *vtbl) static int cmd_help(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { FAR const char *cmd = NULL; -#ifdef CONFIG_NSH_HELP_TERSE +#ifndef CONFIG_NSH_HELP_TERSE bool verbose = false; int i; #endif /* The command may be followed by a verbose option */ -#ifdef CONFIG_NSH_HELP_TERSE +#ifndef CONFIG_NSH_HELP_TERSE i = 1; if (argc > i) { @@ -618,14 +619,13 @@ static int cmd_help(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { /* Yes.. show the single command */ - nsh_output(vtbl, "%s usage:", cmd); help_cmd(vtbl, cmd); } else { /* In verbose mode, show detailed help for all commands */ -#ifdef CONFIG_NSH_HELP_TERSE +#ifndef CONFIG_NSH_HELP_TERSE if (verbose) { nsh_output(vtbl, "Where is one of:\n"); @@ -637,7 +637,6 @@ static int cmd_help(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) else #endif { - nsh_output(vtbl, "help usage:"); help_cmd(vtbl, "help"); nsh_output(vtbl, "\n"); help_cmdlist(vtbl); diff --git a/misc/pascal/include/podefs.h b/misc/pascal/include/podefs.h index 25d0042b61..9d372b4029 100644 --- a/misc/pascal/include/podefs.h +++ b/misc/pascal/include/podefs.h @@ -1,204 +1,204 @@ -/*********************************************************************** - * podefs.h - * Logical P-code operation code definitions - * - * Copyright (C) 2008-2009 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. - * - ***********************************************************************/ - -#ifndef __PODEFS_H -#define __PODEFS_H - -/* These definitions represent logical operations as needed by the - * the compiler. The specific INSN generation layer must interpret - * these requests as is appropriate to the supported INSNS. - */ - -enum pcode_e -{ - - /**------------------------------------------------------------------- - * OPCODES WITH NO ARGUMENTS - **-------------------------------------------------------------------**/ - - /* Program control (No stack arguments) */ - - opNOP = 0, - - /* Arithmetic & logical & and integer conversions (One stack argument) */ - - opNEG, opABS, opINC, opDEC, opNOT, - - /* Arithmetic & logical (Two stack arguments) */ - - opADD, opSUB, opMUL, opDIV, opMOD, opSLL, opSRL, opSRA, opOR, opAND, - - /* Comparisons (One stack argument) */ - - opEQUZ, opNEQZ, opLTZ, opGTEZ, opGTZ, opLTEZ, - - /* Comparisons (Two stack arguments) */ - - opEQU, opNEQ, opLT, opGTE, opGT, opLTE, - opBIT, - - /* Load Immediate */ - - opLDI, opLDIB, opLDIM, - - /* Store Immediate */ - - opSTI, opSTIB, opSTIM, - - /* Data stack */ - - opDUP, opPUSHS, opPOPS, - - /* Program control (No stack arguments) - * Behavior: - * Pop return address - * Pop saved base register (BR) - * Discard saved base address - * Set program counter (PC) to return address - */ - - opRET, - - /* System Functions (No stack arguments) */ - - opEND, - - /**------------------------------------------------------------------- - ** OPCODES WITH ONE ARGUMENT - **-------------------------------------------------------------------**/ - - /* Floating point operations: arg = FP op-code */ - - opFLOAT, - - /* Program control: arg = unsigned label (One stack argument) */ - - opJEQUZ, opJNEQZ, - - /* Program control: arg = unsigned label (no stack arguments) */ - - opJMP, - - /* Program control: arg = unsigned label (One stack argument) */ - - opJEQU, opJNEQ, opJLT, opJGTE, opJGT, opJLTE, - - /* Load: arg = unsigned base offset */ - - opLD, opLDH, opLDB, opLDM, - - /* Store: arg = unsigned base offset */ - - opST, opSTB, opSTM, - - /* Load Indexed: arg = unsigned base offset */ - - opLDX, opLDXB, opLDXM, - - /* Store Indexed: arg16 = unsigned base offset */ - - opSTX, opSTXB, opSTXM, - - /* Load address relative to stack base: arg = unsigned offset */ - - opLA, - - /* Load absolute stack address: arg = RODATA offset (No stack arguments) */ - - opLAC, - - /* Data stack: arg = 16 bit signed data (no stack arguments) */ - - opPUSH, opINDS, - - /* Load address relative to stack base: arg1 = unsigned offset, TOS=index */ - - opLAX, - - /* System functions: arg = 16-bit library call identifier */ - - opLIB, - - /* Program control: arg = unsigned label (no stack arguments) */ - - opLABEL, - - /**------------------------------------------------------------------- - ** OPCODES WITH TWO ARGUMENTS - **-------------------------------------------------------------------**/ - - /* Program Control: arg1 = level; arg2 = unsigned label */ - - opPCAL, - - /* Load: arg1 = level; arg2 = signed frame offset */ - - opLDS, opLDSH, opLDSB, opLDSM, - - /* Store: arg1 = level; arg2 = signed frame offset */ - - opSTS, opSTSB, opSTSM, - - /* Load Indexed: arg1 = level; arg2 = signed frame offset */ - - opLDSX, opLDSXB, opLDSXM, - - /* Store Indexed: arg1 = level; arg2 = signed frame offset */ - - opSTSX, opSTSXB, opSTSXM, - - /* FOR LAS/LASX arg1 = level; arg2 = signed frame offset - * (no stack arguments) - */ - - opLAS, opLASX, - - /* System calls: - * For SYSIO: arg1 = file number; arg2 = sub-function code - */ - - opSYSIO, - - /* Psuedo-operations: - * For LINE: arg1 = file number; arg2 = line number - */ - - opLINE, - - NUM_OPCODES -}; - -#endif /* __PODEFS_H */ +/*********************************************************************** + * podefs.h + * Logical P-code operation code definitions + * + * Copyright (C) 2008-2009 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. + * + ***********************************************************************/ + +#ifndef __PODEFS_H +#define __PODEFS_H + +/* These definitions represent logical operations as needed by the + * the compiler. The specific INSN generation layer must interpret + * these requests as is appropriate to the supported INSNS. + */ + +enum pcode_e +{ + + /**------------------------------------------------------------------- + * OPCODES WITH NO ARGUMENTS + **-------------------------------------------------------------------**/ + + /* Program control (No stack arguments) */ + + opNOP = 0, + + /* Arithmetic & logical & and integer conversions (One stack argument) */ + + opNEG, opABS, opINC, opDEC, opNOT, + + /* Arithmetic & logical (Two stack arguments) */ + + opADD, opSUB, opMUL, opDIV, opMOD, opSLL, opSRL, opSRA, opOR, opAND, + + /* Comparisons (One stack argument) */ + + opEQUZ, opNEQZ, opLTZ, opGTEZ, opGTZ, opLTEZ, + + /* Comparisons (Two stack arguments) */ + + opEQU, opNEQ, opLT, opGTE, opGT, opLTE, + opBIT, + + /* Load Immediate */ + + opLDI, opLDIB, opLDIM, + + /* Store Immediate */ + + opSTI, opSTIB, opSTIM, + + /* Data stack */ + + opDUP, opPUSHS, opPOPS, + + /* Program control (No stack arguments) + * Behavior: + * Pop return address + * Pop saved base register (BR) + * Discard saved base address + * Set program counter (PC) to return address + */ + + opRET, + + /* System Functions (No stack arguments) */ + + opEND, + + /**------------------------------------------------------------------- + ** OPCODES WITH ONE ARGUMENT + **-------------------------------------------------------------------**/ + + /* Floating point operations: arg = FP op-code */ + + opFLOAT, + + /* Program control: arg = unsigned label (One stack argument) */ + + opJEQUZ, opJNEQZ, + + /* Program control: arg = unsigned label (no stack arguments) */ + + opJMP, + + /* Program control: arg = unsigned label (One stack argument) */ + + opJEQU, opJNEQ, opJLT, opJGTE, opJGT, opJLTE, + + /* Load: arg = unsigned base offset */ + + opLD, opLDH, opLDB, opLDM, + + /* Store: arg = unsigned base offset */ + + opST, opSTB, opSTM, + + /* Load Indexed: arg = unsigned base offset */ + + opLDX, opLDXB, opLDXM, + + /* Store Indexed: arg16 = unsigned base offset */ + + opSTX, opSTXB, opSTXM, + + /* Load address relative to stack base: arg = unsigned offset */ + + opLA, + + /* Load absolute stack address: arg = RODATA offset (No stack arguments) */ + + opLAC, + + /* Data stack: arg = 16 bit signed data (no stack arguments) */ + + opPUSH, opINDS, + + /* Load address relative to stack base: arg1 = unsigned offset, TOS=index */ + + opLAX, + + /* System functions: arg = 16-bit library call identifier */ + + opLIB, + + /* Program control: arg = unsigned label (no stack arguments) */ + + opLABEL, + + /**------------------------------------------------------------------- + ** OPCODES WITH TWO ARGUMENTS + **-------------------------------------------------------------------**/ + + /* Program Control: arg1 = level; arg2 = unsigned label */ + + opPCAL, + + /* Load: arg1 = level; arg2 = signed frame offset */ + + opLDS, opLDSH, opLDSB, opLDSM, + + /* Store: arg1 = level; arg2 = signed frame offset */ + + opSTS, opSTSB, opSTSM, + + /* Load Indexed: arg1 = level; arg2 = signed frame offset */ + + opLDSX, opLDSXB, opLDSXM, + + /* Store Indexed: arg1 = level; arg2 = signed frame offset */ + + opSTSX, opSTSXB, opSTSXM, + + /* FOR LAS/LASX arg1 = level; arg2 = signed frame offset + * (no stack arguments) + */ + + opLAS, opLASX, + + /* System calls: + * For SYSIO: arg1 = file number; arg2 = sub-function code + */ + + opSYSIO, + + /* Pseudo-operations: + * For LINE: arg1 = file number; arg2 = line number + */ + + opLINE, + + NUM_OPCODES +}; + +#endif /* __PODEFS_H */ diff --git a/misc/pascal/insn16/include/pinsn16.h b/misc/pascal/insn16/include/pinsn16.h index a966f7aa36..92f3354004 100644 --- a/misc/pascal/insn16/include/pinsn16.h +++ b/misc/pascal/insn16/include/pinsn16.h @@ -1,408 +1,408 @@ -/**************************************************************************** - * pinsn16.h - * 16-bit P-code operation code definitions - * - * Copyright (C) 2008 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. - * - ****************************************************************************/ - -#ifndef __PINSN16_H -#define __PINSN16_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/* Op-code bit definitions */ - -#define o16 (0x80) -#define o8 (0x40) - -/* Opcode Encoding Summary: - * - * NO ARGS arg8 ONLY arg16 ONLY BOTH - * 00xx xxxx 01xx xxxx 10xx xxxx 11xx xxxx - * xx00 0000 NOP --- --- --- - * xx00 0001 NEG --- --- --- - * xx00 0010 ABS --- --- --- - * xx00 0011 INC --- --- --- - * xx00 0100 DEC --- --- --- - * xx00 0101 NOT --- --- --- - * xx00 0110 ADD --- --- --- - * xx00 0111 SUB --- --- --- - * xx00 1000 MUL --- --- PCAL l,ilbl - * xx00 1001 DIV --- --- --- - * xx00 1010 MOD --- --- --- - * xx00 1011 SLL --- --- --- - * xx00 1100 SRL --- --- --- - * xx00 1101 SRA --- --- --- - * xx00 1110 OR --- --- --- - * xx00 1111 AND --- --- --- - * - * xx01 0000 EQUZ --- JEQUZ ilbl --- - * xx01 0001 NEQZ --- JNEQZ ilbl --- - * xx01 0010 LTZ --- JLTZ ilbl --- - * xx01 0011 GTEZ --- JGTEZ ilbl --- - * xx01 0100 GTZ --- JGTZ ilbl --- - * xx01 0101 LTEZ --- JLTEZ ilbl --- - * xx01 0110 --- --- JMP ilbl --- - * xx01 0111 --- --- --- --- - * xx01 1000 EQU --- JEQU ilbl --- - * xx01 1001 NEQ --- JNEQ ilbl --- - * xx01 1010 LT --- JLT ilbl --- - * xx01 1011 GTE --- JGTE ilbl --- - * xx01 1100 GT --- JGT ilbl --- - * xx01 1101 LTE --- JLTE ilbl --- - * xx01 1110 --- --- --- --- - * xx01 1111 BIT --- --- --- - * - * xx10 0000 LDI --- LD uoffs LDS lvl,offs - * xx10 0001 LDIH --- LDH uoffs LDSH lvl,offs - * xx10 0010 LDIB --- LDB uoffs LDSB lvl,offs - * xx10 0011 LDIM --- LDM uoffs LDSM lvl,offs - * xx10 0100 STI --- ST uoffs STS lvl,offs - * xx10 0101 STIH --- STH uoffs STSH lvl,offs - * xx10 0110 STIB --- STB uoffs STSB lvl,offs - * xx10 0111 STIM --- STM uoffs STSM lvl,offs - * xx10 1000 DUP --- LDX uoffs LDSX lvl,offs - * xx10 1001 DUPH --- LDXH uoffs LDSXH lvl,offs - * xx10 1010 PUSHS --- LDXB uoffs LDSXB lvl,offs - * xx10 1011 POPS --- LDXM uoffs LDSXM lvl,offs - * xx10 1100 --- --- STX uoffs STSX lvl,offs - * xx10 1101 --- --- STXH uoffs STSXH lvl,offs - * xx10 1110 --- --- STXB uoffs STSXB lvl,offs - * xx10 1111 RET --- STXM uoffs STSXM lvl,offs - * - * xx11 0000 --- FLOAT fop LA uoffs LAS lvl,offs - * xx11 0001 --- --- LAC dlbl --- - * xx11 0010 --- --- --- --- - * xx11 0011 --- --- --- --- - * xx11 0100 --- PUSHB n PUSH nn --- - * xx11 0101 --- --- INDS nn --- - * xx11 0110 --- --- --- --- - * xx11 0111 --- --- --- --- - * xx11 1000 --- --- LAX uoffs LASX lvl,offs - * xx11 1001 --- --- LIB lop SYSIO fn,sop - * xx11 1010 --- --- --- --- - * xx11 1011 --- --- --- --- - * xx11 1100 --- --- --- --- - * xx11 1101 --- --- --- --- - * xx11 1110 --- --- --- --- - * xx11 1111 END --- *LABEL ilbl *LINE fn,lineno - * - * KEY: - * n = 8-bit value (unsigned) - * lvl = 8-bit static nesting level offset (unsigned) - * vt = 8-bit type code (unsigned) - * nn = 16-bit value (signed) - * fop = 8-bit floating point operation - * sop = 16-bit sysio operation - * lop = 16-bit library call identifier - * fn = 8-bit file number - * ilbl = instruction space label - * dlbl = stack data label - * offs = 16-bit frame offset (signed) - * uoffs = 16-bit base offset (unsigned) - * c = string follows psuedo-operation - * * = Indicates pseudo-operations (these are removed - * after final fixup of the object file). - */ - -/** OPCODES WITH NO ARGUMENTS ***********************************************/ - -/* Program control (No stack arguments) */ - -#define oNOP (0x00) - -/* Arithmetic & logical & and integer conversions (One 16-bit stack argument) */ - -#define oNEG (0x01) -#define oABS (0x02) -#define oINC (0x03) -#define oDEC (0x04) -#define oNOT (0x05) - -/* Arithmetic & logical (Two 16-bit stack arguments) */ - -#define oADD (0x06) -#define oSUB (0x07) -#define oMUL (0x08) -#define oDIV (0x09) -#define oMOD (0x0a) -#define oSLL (0x0b) -#define oSRL (0x0c) -#define oSRA (0x0d) -#define oOR (0x0e) -#define oAND (0x0f) - -/* Comparisons (One 16-bit stack argument) */ - -#define oEQUZ (0x10) -#define oNEQZ (0x11) -#define oLTZ (0x12) -#define oGTEZ (0x13) -#define oGTZ (0x14) -#define oLTEZ (0x15) - -/* 0x16-0x17 -- unassigned */ - -/* Comparisons (Two 16-bit stack arguments) */ - -#define oEQU (0x18) -#define oNEQ (0x19) -#define oLT (0x1a) -#define oGTE (0x1b) -#define oGT (0x1c) -#define oLTE (0x1d) - -/* 0x1e -- unassigned */ - -#define oBIT (0x1f) - -/* Load Immediate */ - -#define oLDI (0x20) /* (One 16-bit stack argument) */ -#define oLDIH (0x21) /* (One 16-bit stack argument) */ -#define oLDIB (0x22) /* (One 16-bit stack argument) */ -#define oLDIM (0x23) /* (Two 16-bit stack arguments) */ - -/* Store Immediate */ - -#define oSTI (0x24) /* (One 32-bit and one 16-bit stack arguments) */ -#define oSTIH (0x25) /* (Two 16-bit stack arguments) */ -#define oSTIB (0x26) /* (Two 16-bit stack arguments) */ -#define oSTIM (0x27) /* (Two + n 16-bit stack arguments) */ - -/* Data stack */ - -#define oDUP (0x28) /* (One 32-bit stack argument */ -#define oDUPH (0x29) /* (One 16-bit stack argument) */ - -/* 0x2a - 0x2b -- unassigned */ - -#define oPUSHS (0x2a) /* No arguments */ -#define oPOPS (0x2b) /* (One 16-bit stack argument) */ - -/* 0x2c - 0x2e -- unassigned */ - -/* Program control (No stack arguments) - * Behavior: - * Pop return address - * Pop saved base register (BR) - * Discard saved base address - * Set program counter (PC) to return address - */ - -#define oRET (0x2f) - -/* 0x30 - 0x3e -- unassigned */ - -/* System Functions (No stack arguments) */ - -#define oEND (0x3f) - -/** OPCODES WITH SINGLE BYTE ARGUMENT (arg8) ********************************/ - -/* (o8|0x00)-(o8|0x2f) -- unassigned */ - -/* Floating point operations: arg8 = FP op-code */ - -#define oFLOAT (o8|0x30) - -/* (o8|0x31)-(o8|0x33) -- unassigned */ - -/* Data stack: arg8 = 8 bit unsigned data (no stack arguments) */ - -#define oPUSHB (o8|0x34) - -/* (o8|0x35)-(o8|0x3f) -- unassigned */ - -/** OPCODES WITH SINGLE 16-BIT ARGUMENT (arg16) *****************************/ - -/* (o16|0x00)-(o16|0x0f) -- unassigned */ - -/* Program control: arg16 = unsigned label (One 16-bit stack argument) */ - -#define oJEQUZ (o16|0x10) -#define oJNEQZ (o16|0x11) -#define oJLTZ (o16|0x12) -#define oJGTEZ (o16|0x13) -#define oJGTZ (o16|0x14) -#define oJLTEZ (o16|0x15) - -/* Program control: arg16 = unsigned label (no stack arguments) */ - -#define oJMP (o16|0x16) - -/* (o16|0x17) -- unassigned */ - -/* Program control: arg16 = unsigned label (One 16-bit stack argument) */ - -#define oJEQU (o16|0x18) -#define oJNEQ (o16|0x19) -#define oJLT (o16|0x1a) -#define oJGTE (o16|0x1b) -#define oJGT (o16|0x1c) -#define oJLTE (o16|0x1d) - -/* (o16|0x1e)-(o16|0x1f) -- unassigned */ - -/* Load: arg16 = unsigned base offset */ - -#define oLD (o16|0x20) /* (no stack arguments) */ -#define oLDH (o16|0x21) /* (no stack arguments) */ -#define oLDB (o16|0x22) /* (no stack arguments) */ -#define oLDM (o16|0x23) /* (One 16-bit stack argument) */ - -/* Store: arg16 = unsigned base offset */ - -#define oST (o16|0x24) /* (One 32-bit stack argument) */ -#define oSTH (o16|0x25) /* (One 16-bit stack argument) */ -#define oSTB (o16|0x26) /* (One 16-bit stack argument) */ -#define oSTM (o16|0x27) /* (One+n 16-bit stack arguments) */ - -/* Load Indexed: arg16 = unsigned base offset */ - -#define oLDX (o16|0x28) /* (One 16-bit stack argument) */ -#define oLDXH (o16|0x29) /* (One 16-bit stack argument) */ -#define oLDXB (o16|0x2a) /* (One 16-bit stack argument) */ -#define oLDXM (o16|0x2b) /* (Two 16-bit stack arguments) */ - -/* Store Indexed: arg16 = unsigned base offset */ - -#define oSTX (o16|0x2c) /* (One 32-bit + one 16-bit stack arguments) */ -#define oSTXH (o16|0x2d) /* (Two 16-bit stack arguments) */ -#define oSTXB (o16|0x2e) /* (Two 16-bit stack arguments) */ -#define oSTXM (o16|0x2f) /* (Two+n 16-bit stack arguments) */ - -/* Load address relative to stack base: arg16 = unsigned offset */ - -#define oLA (o16|0x30) - -/* Load absolute stack address: arg16 = RODATA offset (No stack arguments) */ - -#define oLAC (o16|0x31) - -/* (o16|0x32)-(o16|0x33) -- unassigned */ - -/* Data stack: arg16 = 16 bit signed data (no stack arguments) */ - -#define oPUSH (o16|0x34) -#define oINDS (o16|0x35) - -/* (o16|0x34)-(o16|0x37) -- unassigned */ - -/* Load address relative to stack base: arg16 = unsigned offset, TOS=index */ - -#define oLAX (o16|0x38) - -/* System functions: arg16 = 16-bit library call identifier */ - -#define oLIB (o16|0x39) - -/* (o16|0x3a)-(o16|0x3e) -- unassigned */ - -/* Program control: arg16 = unsigned label (no stack arguments) */ - -#define oLABEL (o16|0x3f) - -/** OPCODES WITH 24-BITS OF ARGUMENET (arg8 + arg16) ************************/ - -/* (o16|o8|0x00)-(o8|o16|0x07) -- unassigned */ - -/* Program Control: arg8 = level; arg16 = unsigned label - * (No stack arguments) - * Behavior: - * Push base address of level - * Push base register (BR) value - * Set new base register value (BR) as top of stack - * Push return address - * Set program counter (PC) for address associated with label - */ - -#define oPCAL (o16|o8|0x08) - -/* (o16|o8|0x09)-(o8|o16|0x1f) -- unassigned */ - -/* Load: arg8 = level; arg16 = signed frame offset */ - -#define oLDS (o16|o8|0x20) /* (no stack arguments) */ -#define oLDSH (o16|o8|0x21) /* (no stack arguments) */ -#define oLDSB (o16|o8|0x22) /* (no stack arguments) */ -#define oLDSM (o16|o8|0x23) /* (One 16-bit stack argument) */ - -/* Store: arg8 = level; arg16 = signed frame offset */ - -#define oSTS (o16|o8|0x24) /* (One 32-bit stack argument) */ -#define oSTSH (o16|o8|0x25) /* (One 16-bit stack argument) */ -#define oSTSB (o16|o8|0x26) /* (One 16-bit stack argument) */ -#define oSTSM (o16|o8|0x27) /* (One+n 16-bit stack arguments) */ - -/* Load Indexed: arg8 = level; arg16 = signed frame offset */ - -#define oLDSX (o16|o8|0x28) /* (One 16-bit stack argument) */ -#define oLDSXH (o16|o8|0x29) /* (One 16-bit stack argument) */ -#define oLDSXB (o16|o8|0x2a) /* (One 16-bit stack argument) */ -#define oLDSXM (o16|o8|0x2b) /* (Two 16-bit stack arguments) */ - -/* Store Indexed: arg8 = level; arg16 = signed frame offset */ - -#define oSTSX (o16|o8|0x2c) /* (One 32-bit + one 16-bit stack arguments) */ -#define oSTSXH (o16|o8|0x2d) /* (Two 16-bit stack arguments) */ -#define oSTSXB (o16|o8|0x2e) /* (Two 16-bit stack arguments) */ -#define oSTSXM (o16|o8|0x2f) /* (Two+n 16-bit stack arguments) */ - -/* FOR LAS/LASX arg8 = level; arg16 = signed frame offset - * (no stack arguments) - */ - -#define oLAS (o16|o8|0x30) -#define oLASX (o16|o8|0x38) - -/* System calls: - * For SYSIO: arg8 = file number; arg16 = sub-function code - */ - -#define oSYSIO (o16|o8|0x39) - -/* (o16|o8|0x3a)-(o8|o16|0x3e) -- unassigned */ - -/* Psuedo-operations: - * For LINE: arg8 = file number; arg16 = line number - */ - -#define oLINE (o16|o8|0x3f) - -#endif /* __PINSN16_H */ +/**************************************************************************** + * pinsn16.h + * 16-bit P-code operation code definitions + * + * Copyright (C) 2008 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. + * + ****************************************************************************/ + +#ifndef __PINSN16_H +#define __PINSN16_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +/* Op-code bit definitions */ + +#define o16 (0x80) +#define o8 (0x40) + +/* Opcode Encoding Summary: + * + * NO ARGS arg8 ONLY arg16 ONLY BOTH + * 00xx xxxx 01xx xxxx 10xx xxxx 11xx xxxx + * xx00 0000 NOP --- --- --- + * xx00 0001 NEG --- --- --- + * xx00 0010 ABS --- --- --- + * xx00 0011 INC --- --- --- + * xx00 0100 DEC --- --- --- + * xx00 0101 NOT --- --- --- + * xx00 0110 ADD --- --- --- + * xx00 0111 SUB --- --- --- + * xx00 1000 MUL --- --- PCAL l,ilbl + * xx00 1001 DIV --- --- --- + * xx00 1010 MOD --- --- --- + * xx00 1011 SLL --- --- --- + * xx00 1100 SRL --- --- --- + * xx00 1101 SRA --- --- --- + * xx00 1110 OR --- --- --- + * xx00 1111 AND --- --- --- + * + * xx01 0000 EQUZ --- JEQUZ ilbl --- + * xx01 0001 NEQZ --- JNEQZ ilbl --- + * xx01 0010 LTZ --- JLTZ ilbl --- + * xx01 0011 GTEZ --- JGTEZ ilbl --- + * xx01 0100 GTZ --- JGTZ ilbl --- + * xx01 0101 LTEZ --- JLTEZ ilbl --- + * xx01 0110 --- --- JMP ilbl --- + * xx01 0111 --- --- --- --- + * xx01 1000 EQU --- JEQU ilbl --- + * xx01 1001 NEQ --- JNEQ ilbl --- + * xx01 1010 LT --- JLT ilbl --- + * xx01 1011 GTE --- JGTE ilbl --- + * xx01 1100 GT --- JGT ilbl --- + * xx01 1101 LTE --- JLTE ilbl --- + * xx01 1110 --- --- --- --- + * xx01 1111 BIT --- --- --- + * + * xx10 0000 LDI --- LD uoffs LDS lvl,offs + * xx10 0001 LDIH --- LDH uoffs LDSH lvl,offs + * xx10 0010 LDIB --- LDB uoffs LDSB lvl,offs + * xx10 0011 LDIM --- LDM uoffs LDSM lvl,offs + * xx10 0100 STI --- ST uoffs STS lvl,offs + * xx10 0101 STIH --- STH uoffs STSH lvl,offs + * xx10 0110 STIB --- STB uoffs STSB lvl,offs + * xx10 0111 STIM --- STM uoffs STSM lvl,offs + * xx10 1000 DUP --- LDX uoffs LDSX lvl,offs + * xx10 1001 DUPH --- LDXH uoffs LDSXH lvl,offs + * xx10 1010 PUSHS --- LDXB uoffs LDSXB lvl,offs + * xx10 1011 POPS --- LDXM uoffs LDSXM lvl,offs + * xx10 1100 --- --- STX uoffs STSX lvl,offs + * xx10 1101 --- --- STXH uoffs STSXH lvl,offs + * xx10 1110 --- --- STXB uoffs STSXB lvl,offs + * xx10 1111 RET --- STXM uoffs STSXM lvl,offs + * + * xx11 0000 --- FLOAT fop LA uoffs LAS lvl,offs + * xx11 0001 --- --- LAC dlbl --- + * xx11 0010 --- --- --- --- + * xx11 0011 --- --- --- --- + * xx11 0100 --- PUSHB n PUSH nn --- + * xx11 0101 --- --- INDS nn --- + * xx11 0110 --- --- --- --- + * xx11 0111 --- --- --- --- + * xx11 1000 --- --- LAX uoffs LASX lvl,offs + * xx11 1001 --- --- LIB lop SYSIO fn,sop + * xx11 1010 --- --- --- --- + * xx11 1011 --- --- --- --- + * xx11 1100 --- --- --- --- + * xx11 1101 --- --- --- --- + * xx11 1110 --- --- --- --- + * xx11 1111 END --- *LABEL ilbl *LINE fn,lineno + * + * KEY: + * n = 8-bit value (unsigned) + * lvl = 8-bit static nesting level offset (unsigned) + * vt = 8-bit type code (unsigned) + * nn = 16-bit value (signed) + * fop = 8-bit floating point operation + * sop = 16-bit sysio operation + * lop = 16-bit library call identifier + * fn = 8-bit file number + * ilbl = instruction space label + * dlbl = stack data label + * offs = 16-bit frame offset (signed) + * uoffs = 16-bit base offset (unsigned) + * c = string follows pseudo-operation + * * = Indicates pseudo-operations (these are removed + * after final fixup of the object file). + */ + +/** OPCODES WITH NO ARGUMENTS ***********************************************/ + +/* Program control (No stack arguments) */ + +#define oNOP (0x00) + +/* Arithmetic & logical & and integer conversions (One 16-bit stack argument) */ + +#define oNEG (0x01) +#define oABS (0x02) +#define oINC (0x03) +#define oDEC (0x04) +#define oNOT (0x05) + +/* Arithmetic & logical (Two 16-bit stack arguments) */ + +#define oADD (0x06) +#define oSUB (0x07) +#define oMUL (0x08) +#define oDIV (0x09) +#define oMOD (0x0a) +#define oSLL (0x0b) +#define oSRL (0x0c) +#define oSRA (0x0d) +#define oOR (0x0e) +#define oAND (0x0f) + +/* Comparisons (One 16-bit stack argument) */ + +#define oEQUZ (0x10) +#define oNEQZ (0x11) +#define oLTZ (0x12) +#define oGTEZ (0x13) +#define oGTZ (0x14) +#define oLTEZ (0x15) + +/* 0x16-0x17 -- unassigned */ + +/* Comparisons (Two 16-bit stack arguments) */ + +#define oEQU (0x18) +#define oNEQ (0x19) +#define oLT (0x1a) +#define oGTE (0x1b) +#define oGT (0x1c) +#define oLTE (0x1d) + +/* 0x1e -- unassigned */ + +#define oBIT (0x1f) + +/* Load Immediate */ + +#define oLDI (0x20) /* (One 16-bit stack argument) */ +#define oLDIH (0x21) /* (One 16-bit stack argument) */ +#define oLDIB (0x22) /* (One 16-bit stack argument) */ +#define oLDIM (0x23) /* (Two 16-bit stack arguments) */ + +/* Store Immediate */ + +#define oSTI (0x24) /* (One 32-bit and one 16-bit stack arguments) */ +#define oSTIH (0x25) /* (Two 16-bit stack arguments) */ +#define oSTIB (0x26) /* (Two 16-bit stack arguments) */ +#define oSTIM (0x27) /* (Two + n 16-bit stack arguments) */ + +/* Data stack */ + +#define oDUP (0x28) /* (One 32-bit stack argument */ +#define oDUPH (0x29) /* (One 16-bit stack argument) */ + +/* 0x2a - 0x2b -- unassigned */ + +#define oPUSHS (0x2a) /* No arguments */ +#define oPOPS (0x2b) /* (One 16-bit stack argument) */ + +/* 0x2c - 0x2e -- unassigned */ + +/* Program control (No stack arguments) + * Behavior: + * Pop return address + * Pop saved base register (BR) + * Discard saved base address + * Set program counter (PC) to return address + */ + +#define oRET (0x2f) + +/* 0x30 - 0x3e -- unassigned */ + +/* System Functions (No stack arguments) */ + +#define oEND (0x3f) + +/** OPCODES WITH SINGLE BYTE ARGUMENT (arg8) ********************************/ + +/* (o8|0x00)-(o8|0x2f) -- unassigned */ + +/* Floating point operations: arg8 = FP op-code */ + +#define oFLOAT (o8|0x30) + +/* (o8|0x31)-(o8|0x33) -- unassigned */ + +/* Data stack: arg8 = 8 bit unsigned data (no stack arguments) */ + +#define oPUSHB (o8|0x34) + +/* (o8|0x35)-(o8|0x3f) -- unassigned */ + +/** OPCODES WITH SINGLE 16-BIT ARGUMENT (arg16) *****************************/ + +/* (o16|0x00)-(o16|0x0f) -- unassigned */ + +/* Program control: arg16 = unsigned label (One 16-bit stack argument) */ + +#define oJEQUZ (o16|0x10) +#define oJNEQZ (o16|0x11) +#define oJLTZ (o16|0x12) +#define oJGTEZ (o16|0x13) +#define oJGTZ (o16|0x14) +#define oJLTEZ (o16|0x15) + +/* Program control: arg16 = unsigned label (no stack arguments) */ + +#define oJMP (o16|0x16) + +/* (o16|0x17) -- unassigned */ + +/* Program control: arg16 = unsigned label (One 16-bit stack argument) */ + +#define oJEQU (o16|0x18) +#define oJNEQ (o16|0x19) +#define oJLT (o16|0x1a) +#define oJGTE (o16|0x1b) +#define oJGT (o16|0x1c) +#define oJLTE (o16|0x1d) + +/* (o16|0x1e)-(o16|0x1f) -- unassigned */ + +/* Load: arg16 = unsigned base offset */ + +#define oLD (o16|0x20) /* (no stack arguments) */ +#define oLDH (o16|0x21) /* (no stack arguments) */ +#define oLDB (o16|0x22) /* (no stack arguments) */ +#define oLDM (o16|0x23) /* (One 16-bit stack argument) */ + +/* Store: arg16 = unsigned base offset */ + +#define oST (o16|0x24) /* (One 32-bit stack argument) */ +#define oSTH (o16|0x25) /* (One 16-bit stack argument) */ +#define oSTB (o16|0x26) /* (One 16-bit stack argument) */ +#define oSTM (o16|0x27) /* (One+n 16-bit stack arguments) */ + +/* Load Indexed: arg16 = unsigned base offset */ + +#define oLDX (o16|0x28) /* (One 16-bit stack argument) */ +#define oLDXH (o16|0x29) /* (One 16-bit stack argument) */ +#define oLDXB (o16|0x2a) /* (One 16-bit stack argument) */ +#define oLDXM (o16|0x2b) /* (Two 16-bit stack arguments) */ + +/* Store Indexed: arg16 = unsigned base offset */ + +#define oSTX (o16|0x2c) /* (One 32-bit + one 16-bit stack arguments) */ +#define oSTXH (o16|0x2d) /* (Two 16-bit stack arguments) */ +#define oSTXB (o16|0x2e) /* (Two 16-bit stack arguments) */ +#define oSTXM (o16|0x2f) /* (Two+n 16-bit stack arguments) */ + +/* Load address relative to stack base: arg16 = unsigned offset */ + +#define oLA (o16|0x30) + +/* Load absolute stack address: arg16 = RODATA offset (No stack arguments) */ + +#define oLAC (o16|0x31) + +/* (o16|0x32)-(o16|0x33) -- unassigned */ + +/* Data stack: arg16 = 16 bit signed data (no stack arguments) */ + +#define oPUSH (o16|0x34) +#define oINDS (o16|0x35) + +/* (o16|0x34)-(o16|0x37) -- unassigned */ + +/* Load address relative to stack base: arg16 = unsigned offset, TOS=index */ + +#define oLAX (o16|0x38) + +/* System functions: arg16 = 16-bit library call identifier */ + +#define oLIB (o16|0x39) + +/* (o16|0x3a)-(o16|0x3e) -- unassigned */ + +/* Program control: arg16 = unsigned label (no stack arguments) */ + +#define oLABEL (o16|0x3f) + +/** OPCODES WITH 24-BITS OF ARGUMENET (arg8 + arg16) ************************/ + +/* (o16|o8|0x00)-(o8|o16|0x07) -- unassigned */ + +/* Program Control: arg8 = level; arg16 = unsigned label + * (No stack arguments) + * Behavior: + * Push base address of level + * Push base register (BR) value + * Set new base register value (BR) as top of stack + * Push return address + * Set program counter (PC) for address associated with label + */ + +#define oPCAL (o16|o8|0x08) + +/* (o16|o8|0x09)-(o8|o16|0x1f) -- unassigned */ + +/* Load: arg8 = level; arg16 = signed frame offset */ + +#define oLDS (o16|o8|0x20) /* (no stack arguments) */ +#define oLDSH (o16|o8|0x21) /* (no stack arguments) */ +#define oLDSB (o16|o8|0x22) /* (no stack arguments) */ +#define oLDSM (o16|o8|0x23) /* (One 16-bit stack argument) */ + +/* Store: arg8 = level; arg16 = signed frame offset */ + +#define oSTS (o16|o8|0x24) /* (One 32-bit stack argument) */ +#define oSTSH (o16|o8|0x25) /* (One 16-bit stack argument) */ +#define oSTSB (o16|o8|0x26) /* (One 16-bit stack argument) */ +#define oSTSM (o16|o8|0x27) /* (One+n 16-bit stack arguments) */ + +/* Load Indexed: arg8 = level; arg16 = signed frame offset */ + +#define oLDSX (o16|o8|0x28) /* (One 16-bit stack argument) */ +#define oLDSXH (o16|o8|0x29) /* (One 16-bit stack argument) */ +#define oLDSXB (o16|o8|0x2a) /* (One 16-bit stack argument) */ +#define oLDSXM (o16|o8|0x2b) /* (Two 16-bit stack arguments) */ + +/* Store Indexed: arg8 = level; arg16 = signed frame offset */ + +#define oSTSX (o16|o8|0x2c) /* (One 32-bit + one 16-bit stack arguments) */ +#define oSTSXH (o16|o8|0x2d) /* (Two 16-bit stack arguments) */ +#define oSTSXB (o16|o8|0x2e) /* (Two 16-bit stack arguments) */ +#define oSTSXM (o16|o8|0x2f) /* (Two+n 16-bit stack arguments) */ + +/* FOR LAS/LASX arg8 = level; arg16 = signed frame offset + * (no stack arguments) + */ + +#define oLAS (o16|o8|0x30) +#define oLASX (o16|o8|0x38) + +/* System calls: + * For SYSIO: arg8 = file number; arg16 = sub-function code + */ + +#define oSYSIO (o16|o8|0x39) + +/* (o16|o8|0x3a)-(o8|o16|0x3e) -- unassigned */ + +/* Pseudo-operations: + * For LINE: arg8 = file number; arg16 = line number + */ + +#define oLINE (o16|o8|0x3f) + +#endif /* __PINSN16_H */ diff --git a/misc/pascal/insn16/libinsn/pdasm.c b/misc/pascal/insn16/libinsn/pdasm.c index b6c1ecb318..4da71869ac 100644 --- a/misc/pascal/insn16/libinsn/pdasm.c +++ b/misc/pascal/insn16/libinsn/pdasm.c @@ -431,7 +431,7 @@ static const struct /* 0xfd */ { invOp, NOARG16 }, /* 0xfe */ { invOp, NOARG16 }, -/* Psuedo-operations: +/* Pseudo-operations: * For LINE: arg8 = file number; arg16 = line number */ diff --git a/misc/pascal/insn16/prun/pexec.c b/misc/pascal/insn16/prun/pexec.c index af68c49fb1..46df53c2c3 100644 --- a/misc/pascal/insn16/prun/pexec.c +++ b/misc/pascal/insn16/prun/pexec.c @@ -2185,7 +2185,7 @@ static int pexec32(FAR struct pexec_s *st, uint8_t opcode, uint8_t imm8, uint16_ ret = pexec_sysio(st, imm8, imm16); break; - /* Psuedo-operations: (No stack arguments) + /* Pseudo-operations: (No stack arguments) * For LINE: imm8 = file number; imm16 = line number */ diff --git a/misc/pascal/insn32/doc/insn32.txt b/misc/pascal/insn32/doc/insn32.txt index ff1416ca58..3bb7bc700b 100644 --- a/misc/pascal/insn32/doc/insn32.txt +++ b/misc/pascal/insn32/doc/insn32.txt @@ -1,119 +1,119 @@ -32-bit op-code bit definitions - -Machine model: - - SPB 32-bit Pascal stack base address - SP 32-bit Pascal stack pointer - LSP 32-bit Level stack pointer - CSB 32-bit Character stack base address - CSP 32-bit Character stack pointer - DS 32-bit Data size register (for multiple reg transfers) - PC 32-bit Program Counter - CC Condition code register - --- Volatile general purpose registers - --- Static general purpose registers - -Condition codes: Z(ero), N(egative) - - +=====+=====+ - | Z | N | - +=====+=====+=====+ - | EQ | 1 | - | - | NEQ | 0 | - | - | LT | - | 1 | - | GTE | - | 0 | - | GT | 0 | 0 | - | LTE | 1 | 1 | - +=====+=====+=====+ - -Opcode Encoding Summary: - - 0rxx xxxx 1rxxx xxxx -xr00 0000 NOP LD uoffs4 -xr00 0001 NEG LDH uoffs3 -xr00 0010 ABS LDB uoffs -xr00 0011 INC LDM uoffs4 -xr00 0100 DEC ST uoffs4 -xr00 0101 NOT STH uoffs2 -xr00 0110 ADD STB uoffs -xr00 0111 SUB STM uoffs4 -xr00 1000 MUL LDX uoffs4 -xr00 1001 DIV LDXH uoffs2 -xr00 1010 MOD LDXB uoffs -xr00 1011 SLL LDXM uoffs4 -xr00 1100 SRL STX uoffs4 -xr00 1101 SRA STXH uoffs2 -xr00 1110 OR STXB uoffs -xr00 1111 AND STXM uoffs - -xr01 0000 EQUZ JEQUZ ilbl -xr01 0001 NEQZ JNEQZ ilbl -xr01 0010 LTZ JLTZ ilbl -xr01 0011 GTEZ JGTEZ ilbl -xr01 0100 GTZ JGTZ ilbl -xr01 0101 LTEZ JLTEZ ilbl -xr01 0110 --- JMP ilbl -xr01 0111 --- PUSH nn -xr01 1000 EQU JEQU ilbl -xr01 1001 NEQ JNEQ ilbl -xr01 1010 LT JLT ilbl -xr01 1011 GTE JGTE ilbl -xr01 1100 GT JGT ilbl -xr01 1101 LTE JLTE ilbl -xr01 1110 --- --- -xr01 1111 BIT INDS nn - -xr10 0000 LDI LDS offs4 -xr10 0001 LDIH LDSH offs3 -xr10 0010 LDIB LDSB offs -xr10 0011 LDIM LDSM offs4 -xr10 0100 STI STS offs4 -xr10 0101 STIH STSH offs2 -xr10 0110 STIB STSB offs -xr10 0111 STIM STSM offs4 -xr10 1000 DUP LDSX offs4 -xr10 1001 --- LDSXH offs2 -xr10 1010 PUSHS LDSXB offs -xr10 1011 POPS LDSXM offs4 -xr10 1100 --- STSX offs4 -xr10 1101 --- STSXH offs2 -xr10 1110 --- STSXB offs -xr10 1111 RET STSXM offs - -xr11 0000 --- LA uoffs -xr11 0001 --- LAS offs -xr11 0010 --- LAC dlbl -xr11 0011 --- --- -xr11 0100 --- LAX uoffs -xr11 0101 --- LASX offs -xr11 0110 --- SLSP level -xr11 0111 --- SDC uu -xr11 1000 --- --- -xr11 1001 --- PCAL ilbl -xr11 1010 --- SYSIO fn,sop -xr11 1011 --- LIB lop -xr11 1100 --- FLOAT fop -xr11 1101 --- *LABEL ilbl -xr11 1110 --- *INCLUDE fn -xr11 1111 END *LINE lineno - -KEY: - r = Reserved bit (must be zero) - fn = 8-bit file number - lvl = 8-bit static nexting level - sop = 17-bit sysio operation - lineno = 17-bit line number - nn = 32-bit constant value (signed) - uu = 32-bit constant value (unsigned) - fop = 32-bit floating point operation - lop = 32-bit library call identifier - ilbl = 32-bit Instruction space label number - dlbl = 32-stack data label - offs4 = 32-bit word offset with respect to LSP (signed) - offs2 = 32-bit halfword offset with respect to LSP (signed) - offs = 32-bit byte offset with respect to LSP (signed) - uoffs4 = 32-bit word offset with respect to SPB (unsigned) - uoffs2 = 32-bit halfword offset with respect to SPB (unsigned) - uoffs = 32-bit byte offset with respect to SPB (unsigned) - c = string follows psuedo-operation - = Indicates pseudo-operations (these are removed +32-bit op-code bit definitions + +Machine model: + + SPB 32-bit Pascal stack base address + SP 32-bit Pascal stack pointer + LSP 32-bit Level stack pointer + CSB 32-bit Character stack base address + CSP 32-bit Character stack pointer + DS 32-bit Data size register (for multiple reg transfers) + PC 32-bit Program Counter + CC Condition code register + --- Volatile general purpose registers + --- Static general purpose registers + +Condition codes: Z(ero), N(egative) + + +=====+=====+ + | Z | N | + +=====+=====+=====+ + | EQ | 1 | - | + | NEQ | 0 | - | + | LT | - | 1 | + | GTE | - | 0 | + | GT | 0 | 0 | + | LTE | 1 | 1 | + +=====+=====+=====+ + +Opcode Encoding Summary: + + 0rxx xxxx 1rxxx xxxx +xr00 0000 NOP LD uoffs4 +xr00 0001 NEG LDH uoffs3 +xr00 0010 ABS LDB uoffs +xr00 0011 INC LDM uoffs4 +xr00 0100 DEC ST uoffs4 +xr00 0101 NOT STH uoffs2 +xr00 0110 ADD STB uoffs +xr00 0111 SUB STM uoffs4 +xr00 1000 MUL LDX uoffs4 +xr00 1001 DIV LDXH uoffs2 +xr00 1010 MOD LDXB uoffs +xr00 1011 SLL LDXM uoffs4 +xr00 1100 SRL STX uoffs4 +xr00 1101 SRA STXH uoffs2 +xr00 1110 OR STXB uoffs +xr00 1111 AND STXM uoffs + +xr01 0000 EQUZ JEQUZ ilbl +xr01 0001 NEQZ JNEQZ ilbl +xr01 0010 LTZ JLTZ ilbl +xr01 0011 GTEZ JGTEZ ilbl +xr01 0100 GTZ JGTZ ilbl +xr01 0101 LTEZ JLTEZ ilbl +xr01 0110 --- JMP ilbl +xr01 0111 --- PUSH nn +xr01 1000 EQU JEQU ilbl +xr01 1001 NEQ JNEQ ilbl +xr01 1010 LT JLT ilbl +xr01 1011 GTE JGTE ilbl +xr01 1100 GT JGT ilbl +xr01 1101 LTE JLTE ilbl +xr01 1110 --- --- +xr01 1111 BIT INDS nn + +xr10 0000 LDI LDS offs4 +xr10 0001 LDIH LDSH offs3 +xr10 0010 LDIB LDSB offs +xr10 0011 LDIM LDSM offs4 +xr10 0100 STI STS offs4 +xr10 0101 STIH STSH offs2 +xr10 0110 STIB STSB offs +xr10 0111 STIM STSM offs4 +xr10 1000 DUP LDSX offs4 +xr10 1001 --- LDSXH offs2 +xr10 1010 PUSHS LDSXB offs +xr10 1011 POPS LDSXM offs4 +xr10 1100 --- STSX offs4 +xr10 1101 --- STSXH offs2 +xr10 1110 --- STSXB offs +xr10 1111 RET STSXM offs + +xr11 0000 --- LA uoffs +xr11 0001 --- LAS offs +xr11 0010 --- LAC dlbl +xr11 0011 --- --- +xr11 0100 --- LAX uoffs +xr11 0101 --- LASX offs +xr11 0110 --- SLSP level +xr11 0111 --- SDC uu +xr11 1000 --- --- +xr11 1001 --- PCAL ilbl +xr11 1010 --- SYSIO fn,sop +xr11 1011 --- LIB lop +xr11 1100 --- FLOAT fop +xr11 1101 --- *LABEL ilbl +xr11 1110 --- *INCLUDE fn +xr11 1111 END *LINE lineno + +KEY: + r = Reserved bit (must be zero) + fn = 8-bit file number + lvl = 8-bit static nexting level + sop = 17-bit sysio operation + lineno = 17-bit line number + nn = 32-bit constant value (signed) + uu = 32-bit constant value (unsigned) + fop = 32-bit floating point operation + lop = 32-bit library call identifier + ilbl = 32-bit Instruction space label number + dlbl = 32-stack data label + offs4 = 32-bit word offset with respect to LSP (signed) + offs2 = 32-bit halfword offset with respect to LSP (signed) + offs = 32-bit byte offset with respect to LSP (signed) + uoffs4 = 32-bit word offset with respect to SPB (unsigned) + uoffs2 = 32-bit halfword offset with respect to SPB (unsigned) + uoffs = 32-bit byte offset with respect to SPB (unsigned) + c = string follows pseudo-operation + = Indicates pseudo-operations (these are removed diff --git a/misc/pascal/insn32/include/pinsn32.h b/misc/pascal/insn32/include/pinsn32.h index e92202402d..29cf363e78 100644 --- a/misc/pascal/insn32/include/pinsn32.h +++ b/misc/pascal/insn32/include/pinsn32.h @@ -1,426 +1,426 @@ -/**************************************************************************** - * pinsn32.h - * 32-bit P-code operation code definitions - * - * Copyright (C) 2008 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. - * - ****************************************************************************/ - -#ifndef __PINSN32_H -#define __PINSN32_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/* 32-bit op-code bit definitions - * - * Machine model: - * - * SPB 32-bit Pascal stack base address - * SP 32-bit Pascal stack pointer - * LSP 32-bit Level stack pointer - * CSB 32-bit Character stack base address - * CSP 32-bit Character stack pointer - * DS 32-bit Data size register (for multiple reg transfers) - * PC 32-bit Program Counter - * CC Condition code register - * --- Volatile general purpose registers - * --- Static general purpose registers - * - * Condition codes: Z(ero), N(egative) - * - * +=====+=====+ - * | Z | N | - * +=====+=====+=====+ - * | EQ | 1 | - | - * | NEQ | 0 | - | - * | LT | - | 1 | - * | GTE | - | 0 | - * | GT | 0 | 0 | - * | LTE | 1 | 1 | - * +=====+=====+=====+ - * - * Opcode Encoding Summary: - * - * 0rxx xxxx 1rxxx xxxx - * xr00 0000 NOP LD uoffs4 - * xr00 0001 NEG LDH uoffs3 - * xr00 0010 ABS LDB uoffs - * xr00 0011 INC LDM uoffs4 - * xr00 0100 DEC ST uoffs4 - * xr00 0101 NOT STH uoffs2 - * xr00 0110 ADD STB uoffs - * xr00 0111 SUB STM uoffs4 - * xr00 1000 MUL LDX uoffs4 - * xr00 1001 DIV LDXH uoffs2 - * xr00 1010 MOD LDXB uoffs - * xr00 1011 SLL LDXM uoffs4 - * xr00 1100 SRL STX uoffs4 - * xr00 1101 SRA STXH uoffs2 - * xr00 1110 OR STXB uoffs - * xr00 1111 AND STXM uoffs - * - * xr01 0000 EQUZ JEQUZ ilbl - * xr01 0001 NEQZ JNEQZ ilbl - * xr01 0010 LTZ JLTZ ilbl - * xr01 0011 GTEZ JGTEZ ilbl - * xr01 0100 GTZ JGTZ ilbl - * xr01 0101 LTEZ JLTEZ ilbl - * xr01 0110 --- JMP ilbl - * xr01 0111 --- PUSH nn - * xr01 1000 EQU JEQU ilbl - * xr01 1001 NEQ JNEQ ilbl - * xr01 1010 LT JLT ilbl - * xr01 1011 GTE JGTE ilbl - * xr01 1100 GT JGT ilbl - * xr01 1101 LTE JLTE ilbl - * xr01 1110 --- --- - * xr01 1111 BIT INDS nn - * - * xr10 0000 LDI LDS offs4 - * xr10 0001 LDIH LDSH offs3 - * xr10 0010 LDIB LDSB offs - * xr10 0011 LDIM LDSM offs4 - * xr10 0100 STI STS offs4 - * xr10 0101 STIH STSH offs2 - * xr10 0110 STIB STSB offs - * xr10 0111 STIM STSM offs4 - * xr10 1000 DUP LDSX offs4 - * xr10 1001 --- LDSXH offs2 - * xr10 1010 PUSHS LDSXB offs - * xr10 1011 POPS LDSXM offs4 - * xr10 1100 --- STSX offs4 - * xr10 1101 --- STSXH offs2 - * xr10 1110 --- STSXB offs - * xr10 1111 RET STSXM offs - * - * xr11 0000 --- LA uoffs - * xr11 0001 --- LAS offs - * xr11 0010 --- LAC dlbl - * xr11 0011 --- --- - * xr11 0100 --- LAX uoffs - * xr11 0101 --- LASX offs - * xr11 0110 --- SLSP level - * xr11 0111 --- SDC uu - * xr11 1000 --- --- - * xr11 1001 --- PCAL ilbl - * xr11 1010 --- SYSIO fn,sop - * xr11 1011 --- LIB lop - * xr11 1100 --- FLOAT fop - * xr11 1101 --- *LABEL ilbl - * xr11 1110 --- *INCLUDE fn - * xr11 1111 END *LINE lineno - * - * KEY: - * r = Reserved bit (must be zero) - * fn = 8-bit file number - * lvl = 8-bit static nexting level - * sop = 17-bit sysio operation - * lineno = 17-bit line number - * nn = 32-bit constant value (signed) - * uu = 32-bit constant value (unsigned) - * fop = 32-bit floating point operation - * lop = 32-bit library call identifier - * ilbl = 32-bit Instruction space label number - * dlbl = 32-stack data label - * offs4 = 32-bit word offset with respect to LSP (signed) - * offs2 = 32-bit halfword offset with respect to LSP (signed) - * offs = 32-bit byte offset with respect to LSP (signed) - * uoffs4 = 32-bit word offset with respect to SPB (unsigned) - * uoffs2 = 32-bit halfword offset with respect to SPB (unsigned) - * uoffs = 32-bit byte offset with respect to SPB (unsigned) - * c = string follows psuedo-operation - * * = Indicates pseudo-operations (these are removed - * after final fixup of the object file). - */ - -#define o32 (0x80) - -#define GETOP(o) ((o)->op) -#define PUTOP(o,v) do { (o)->op = (v); } while (0) - -#define GETARG(o) ((o)->arg) -#define PUTARG(o,a) do { (o)->arg = (a); } while (0) - -#define ARGONES 0xffffffff - -/* The opcode binary is stored in big endian order (so that the opcode - * always comes first). The following definitions simplify ordering - * of byte accesses. - */ - -#ifdef CONFIG_ENDIAN_BIG -# define opB1 0 -# define opB2 1 -# define opB3 2 -# define opB4 3 -#else -# define opB1 3 -# define opB2 2 -# define opB3 1 -# define opB4 0 -#endif - -/** 1-BYTE OPCODES WITH NO ARGUMENTS (other than stack arguments) ***********/ - -/* Program control (No stack arguments) */ - -#define oNOP (0x00) - -/* Arithmetic & logical & and integer conversions (One 32-bit stack - * argument) - */ - -#define oNEG (0x01) -#define oABS (0x02) -#define oINC (0x03) -#define oDEC (0x04) -#define oNOT (0x05) -#define oADD (0x06) -#define oSUB (0x07) -#define oMUL (0x08) -#define oDIV (0x09) -#define oMOD (0x0a) -#define oSLL (0x0b) -#define oSRL (0x0c) -#define oSRA (0x0d) -#define oOR (0x0e) -#define oAND (0x0f) - -/* Comparisons (One 32-bit stack argument) */ - -#define oEQUZ (0x10) -#define oNEQZ (0x11) -#define oLTZ (0x12) -#define oGTEZ (0x13) -#define oGTZ (0x14) -#define oLTEZ (0x15) - -/* Comparisons (Two 32-bit stack arguments) */ - -#define oEQU (0x18) -#define oNEQ (0x19) -#define oLT (0x1a) -#define oGTE (0x1b) -#define oGT (0x1c) -#define oLTE (0x1d) -#define oBIT (0x1f) - -/* Load Immediate */ - -#define oLDI (0x20) /* (One 32-bit stack argument) */ -#define oLDIH (0x21) /* (One 32-bit stack argument) */ -#define oLDIB (0x22) /* (One 32-bit stack argument) */ -#define oLDIM (0x23) /* (Two 32-bit stack argument) */ - -/* Store Immediate */ - -#define oSTI (0x24) /* (Two 32-bit stack argument) */ -#define oSTIH (0x25) /* (Two 32-bit stack argument) */ -#define oSTIB (0x26) /* (Two 32-bit stack argument) */ -#define oSTIM (0x27) /* (Two+n 32-bit stack argument) */ - -/* Data stack */ - -#define oDUP (0x28) /* (One 32-bit stack argument) */ -#define oDUPH (0x29) /* (One 32-bit stack argument) */ -#define oPUSHS (0x2a) /* No stack arguments */ -#define oPOPS (0x2b) /* (One 32-bit stack argument) */ - -/* Program control (No stack arguments) - * Behavior: - * Pop return address - * Pop saved base register (BR) - * Discard saved base address - * Set program counter (PC) to return address - */ - -#define oRET (0x2f) - -/* System Functions (No stack arguments) */ - -#define oEND (0x3f) - -/** 4-BYTE OPCODES INCLUDING ONE 32-BIT ARGUMENT ****************************/ - -/* Load: arg = unsigned base offset */ - -#define oLD (o32|0x00) /* No stack arguments */ -#define oLDH (o32|0x01) /* No stack arguments */ -#define oLDB (o32|0x02) /* No stack arguments */ -#define oLDM (o32|0x03) /* One 32-bit stack argument */ - -/* Store: arg = unsigned base offset */ - -#define oST (o32|0x04) /* One 32-bit stack argument */ -#define oSTH (o32|0x05) /* One 32-bit stack argument */ -#define oSTB (o32|0x06) /* One 32-bit stack argument */ -#define oSTM (o32|0x07) /* One+n 32-bit stack argument */ - -/* Load Indexed: arg = unsigned base offset */ - -#define oLDX (o32|0x08) /* One 32-bit stack argument */ -#define oLDXH (o32|0x09) /* One 32-bit stack argument */ -#define oLDXB (o32|0x0a) /* One 32-bit stack argument */ -#define oLDXM (o32|0x0b) /* Two 32-bit stack argument */ - -/* Store Indexed: arg = unsigned base offset */ - -#define oSTX (o32|0x0c) /* Two 32-bit stack argument */ -#define oSTXH (o32|0x0d) /* Two 32-bit stack argument */ -#define oSTXB (o32|0x0e) /* Two 32-bit stack argument */ -#define oSTXM (o32|0x0f) /* Two+n 32-bit stack argument */ - -/* Program control: arg = unsigned label (One 32-bit stack argument) */ - -#define oJEQUZ (o32|0x10) -#define oJNEQZ (o32|0x11) -#define oJLTZ (o32|0x12) -#define oJGTEZ (o32|0x13) -#define oJGTZ (o32|0x14) -#define oJLTEZ (o32|0x15) - -/* Program control: arg = unsigned label (no stack arguments) */ - -#define oJMP (o32|0x16) - -/* Data stack: arg = 32 bit signed data (no stack arguments) */ - -#define oPUSH (o32|0x17) - -/* Program control: arg = unsigned label (One 32-bit stack argument) */ - -#define oJEQU (o32|0x18) -#define oJNEQ (o32|0x19) -#define oJLT (o32|0x1a) -#define oJGTE (o32|0x1b) -#define oJGT (o32|0x1c) -#define oJLTE (o32|0x1d) - -/* Data stack: arg = 32 bit signed data (no stack arguments) */ - -#define oINDS (o32|0x1f) - -/* Load: Uses LSP; arg = signed frame offset */ - -#define oLDS (o32|0x20) /* No stack arguments */ -#define oLDSH (o32|0x21) /* No stack arguments */ -#define oLDSB (o32|0x22) /* No stack arguments */ -#define oLDSM (o32|0x23) /* One 32-bit stack argument */ - -/* Store: Uses LSP; arg = signed frame offset */ - -#define oSTS (o32|0x24) /* One 32-bit stack argument */ -#define oSTSH (o32|0x25) /* One 32-bit stack argument */ -#define oSTSB (o32|0x26) /* One 32-bit stack argument */ -#define oSTSM (o32|0x27) /* One+n 32-bit stack argument */ - -/* Load Indexed: Uses LSP; arg = signed frame offset */ - -#define oLDSX (o32|0x28) /* One 32-bit stack argument */ -#define oLDSXH (o32|0x29) /* One 32-bit stack argument */ -#define oLDSXB (o32|0x2a) /* One 32-bit stack argument */ -#define oLDSXM (o32|0x2b) /* Two 32-bit stack argument */ - -/* Store Indexed: Uses LSP; arg = signed frame offset */ - -#define oSTSX (o32|0x2c) /* Two 32-bit stack argument */ -#define oSTSXH (o32|0x2d) /* Two 32-bit stack argument */ -#define oSTSXB (o32|0x2e) /* Two 32-bit stack argument */ -#define oSTSXM (o32|0x2f) /* Two+n 32-bit stack argument */ - -/* Load address relative to stack base: arg = unsigned offset */ - -#define oLA (o32|0x30) - -/* Load address: Uses SLP, arg = signed frame offset */ - -#define oLAS (o32|0x31) /* No stack arguments */ - -/* Load absolute stack address: arg = RODATA offset (No stack arguments) */ - -#define oLAC (o32|0x32) - -/* Load address relative to stack base: arg = unsigned offset, TOS=index */ - -#define oLAX (o32|0x34) - -/* Load address indexed: Uses SLP, arg = signed frame offset */ - -#define oLASX (o32|0x35) /* No stack arguments */ - -/* Set LSP: arg = new level that evaluates to LSP value */ - -#define oSLSP (o32|0x36) - -/* Set DS: arg = new byte count in DS register */ - -#define oSDC (o32|0x37) - -/* Program Control: Uses LSP; arg = unsigned label - * (No stack arguments) - * Behavior: - * Push base address of level - * Push base register (BR) value - * Set new base register value (BR) as top of stack - * Push return address - * Set program counter (PC) for address associated with label - */ - -#define oPCAL (o32|0x39) - -/* System calls: arg = file number | sub-function code */ - -#define oSYSIO (o32|0x3a) - -/* System functions: arg = 32-bit library call identifier */ - -#define oLIB (o32|0x3b) - -/* Floating point operations: arg = FP op-code */ - -#define oFLOAT (o32|0x3c) - -/* Program control: arg = unsigned label (no stack arguments) */ - -#define oLABEL (o32|0x3d) - -/* Psuedo-operations: arg = file number OR line number */ - -#define oINCLUDE (o32|0x3e) -#define oLINE (o32|0x3f) - -#endif /* __PINSN32_H */ +/**************************************************************************** + * pinsn32.h + * 32-bit P-code operation code definitions + * + * Copyright (C) 2008 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. + * + ****************************************************************************/ + +#ifndef __PINSN32_H +#define __PINSN32_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +/* 32-bit op-code bit definitions + * + * Machine model: + * + * SPB 32-bit Pascal stack base address + * SP 32-bit Pascal stack pointer + * LSP 32-bit Level stack pointer + * CSB 32-bit Character stack base address + * CSP 32-bit Character stack pointer + * DS 32-bit Data size register (for multiple reg transfers) + * PC 32-bit Program Counter + * CC Condition code register + * --- Volatile general purpose registers + * --- Static general purpose registers + * + * Condition codes: Z(ero), N(egative) + * + * +=====+=====+ + * | Z | N | + * +=====+=====+=====+ + * | EQ | 1 | - | + * | NEQ | 0 | - | + * | LT | - | 1 | + * | GTE | - | 0 | + * | GT | 0 | 0 | + * | LTE | 1 | 1 | + * +=====+=====+=====+ + * + * Opcode Encoding Summary: + * + * 0rxx xxxx 1rxxx xxxx + * xr00 0000 NOP LD uoffs4 + * xr00 0001 NEG LDH uoffs3 + * xr00 0010 ABS LDB uoffs + * xr00 0011 INC LDM uoffs4 + * xr00 0100 DEC ST uoffs4 + * xr00 0101 NOT STH uoffs2 + * xr00 0110 ADD STB uoffs + * xr00 0111 SUB STM uoffs4 + * xr00 1000 MUL LDX uoffs4 + * xr00 1001 DIV LDXH uoffs2 + * xr00 1010 MOD LDXB uoffs + * xr00 1011 SLL LDXM uoffs4 + * xr00 1100 SRL STX uoffs4 + * xr00 1101 SRA STXH uoffs2 + * xr00 1110 OR STXB uoffs + * xr00 1111 AND STXM uoffs + * + * xr01 0000 EQUZ JEQUZ ilbl + * xr01 0001 NEQZ JNEQZ ilbl + * xr01 0010 LTZ JLTZ ilbl + * xr01 0011 GTEZ JGTEZ ilbl + * xr01 0100 GTZ JGTZ ilbl + * xr01 0101 LTEZ JLTEZ ilbl + * xr01 0110 --- JMP ilbl + * xr01 0111 --- PUSH nn + * xr01 1000 EQU JEQU ilbl + * xr01 1001 NEQ JNEQ ilbl + * xr01 1010 LT JLT ilbl + * xr01 1011 GTE JGTE ilbl + * xr01 1100 GT JGT ilbl + * xr01 1101 LTE JLTE ilbl + * xr01 1110 --- --- + * xr01 1111 BIT INDS nn + * + * xr10 0000 LDI LDS offs4 + * xr10 0001 LDIH LDSH offs3 + * xr10 0010 LDIB LDSB offs + * xr10 0011 LDIM LDSM offs4 + * xr10 0100 STI STS offs4 + * xr10 0101 STIH STSH offs2 + * xr10 0110 STIB STSB offs + * xr10 0111 STIM STSM offs4 + * xr10 1000 DUP LDSX offs4 + * xr10 1001 --- LDSXH offs2 + * xr10 1010 PUSHS LDSXB offs + * xr10 1011 POPS LDSXM offs4 + * xr10 1100 --- STSX offs4 + * xr10 1101 --- STSXH offs2 + * xr10 1110 --- STSXB offs + * xr10 1111 RET STSXM offs + * + * xr11 0000 --- LA uoffs + * xr11 0001 --- LAS offs + * xr11 0010 --- LAC dlbl + * xr11 0011 --- --- + * xr11 0100 --- LAX uoffs + * xr11 0101 --- LASX offs + * xr11 0110 --- SLSP level + * xr11 0111 --- SDC uu + * xr11 1000 --- --- + * xr11 1001 --- PCAL ilbl + * xr11 1010 --- SYSIO fn,sop + * xr11 1011 --- LIB lop + * xr11 1100 --- FLOAT fop + * xr11 1101 --- *LABEL ilbl + * xr11 1110 --- *INCLUDE fn + * xr11 1111 END *LINE lineno + * + * KEY: + * r = Reserved bit (must be zero) + * fn = 8-bit file number + * lvl = 8-bit static nexting level + * sop = 17-bit sysio operation + * lineno = 17-bit line number + * nn = 32-bit constant value (signed) + * uu = 32-bit constant value (unsigned) + * fop = 32-bit floating point operation + * lop = 32-bit library call identifier + * ilbl = 32-bit Instruction space label number + * dlbl = 32-stack data label + * offs4 = 32-bit word offset with respect to LSP (signed) + * offs2 = 32-bit halfword offset with respect to LSP (signed) + * offs = 32-bit byte offset with respect to LSP (signed) + * uoffs4 = 32-bit word offset with respect to SPB (unsigned) + * uoffs2 = 32-bit halfword offset with respect to SPB (unsigned) + * uoffs = 32-bit byte offset with respect to SPB (unsigned) + * c = string follows pseudo-operation + * * = Indicates pseudo-operations (these are removed + * after final fixup of the object file). + */ + +#define o32 (0x80) + +#define GETOP(o) ((o)->op) +#define PUTOP(o,v) do { (o)->op = (v); } while (0) + +#define GETARG(o) ((o)->arg) +#define PUTARG(o,a) do { (o)->arg = (a); } while (0) + +#define ARGONES 0xffffffff + +/* The opcode binary is stored in big endian order (so that the opcode + * always comes first). The following definitions simplify ordering + * of byte accesses. + */ + +#ifdef CONFIG_ENDIAN_BIG +# define opB1 0 +# define opB2 1 +# define opB3 2 +# define opB4 3 +#else +# define opB1 3 +# define opB2 2 +# define opB3 1 +# define opB4 0 +#endif + +/** 1-BYTE OPCODES WITH NO ARGUMENTS (other than stack arguments) ***********/ + +/* Program control (No stack arguments) */ + +#define oNOP (0x00) + +/* Arithmetic & logical & and integer conversions (One 32-bit stack + * argument) + */ + +#define oNEG (0x01) +#define oABS (0x02) +#define oINC (0x03) +#define oDEC (0x04) +#define oNOT (0x05) +#define oADD (0x06) +#define oSUB (0x07) +#define oMUL (0x08) +#define oDIV (0x09) +#define oMOD (0x0a) +#define oSLL (0x0b) +#define oSRL (0x0c) +#define oSRA (0x0d) +#define oOR (0x0e) +#define oAND (0x0f) + +/* Comparisons (One 32-bit stack argument) */ + +#define oEQUZ (0x10) +#define oNEQZ (0x11) +#define oLTZ (0x12) +#define oGTEZ (0x13) +#define oGTZ (0x14) +#define oLTEZ (0x15) + +/* Comparisons (Two 32-bit stack arguments) */ + +#define oEQU (0x18) +#define oNEQ (0x19) +#define oLT (0x1a) +#define oGTE (0x1b) +#define oGT (0x1c) +#define oLTE (0x1d) +#define oBIT (0x1f) + +/* Load Immediate */ + +#define oLDI (0x20) /* (One 32-bit stack argument) */ +#define oLDIH (0x21) /* (One 32-bit stack argument) */ +#define oLDIB (0x22) /* (One 32-bit stack argument) */ +#define oLDIM (0x23) /* (Two 32-bit stack argument) */ + +/* Store Immediate */ + +#define oSTI (0x24) /* (Two 32-bit stack argument) */ +#define oSTIH (0x25) /* (Two 32-bit stack argument) */ +#define oSTIB (0x26) /* (Two 32-bit stack argument) */ +#define oSTIM (0x27) /* (Two+n 32-bit stack argument) */ + +/* Data stack */ + +#define oDUP (0x28) /* (One 32-bit stack argument) */ +#define oDUPH (0x29) /* (One 32-bit stack argument) */ +#define oPUSHS (0x2a) /* No stack arguments */ +#define oPOPS (0x2b) /* (One 32-bit stack argument) */ + +/* Program control (No stack arguments) + * Behavior: + * Pop return address + * Pop saved base register (BR) + * Discard saved base address + * Set program counter (PC) to return address + */ + +#define oRET (0x2f) + +/* System Functions (No stack arguments) */ + +#define oEND (0x3f) + +/** 4-BYTE OPCODES INCLUDING ONE 32-BIT ARGUMENT ****************************/ + +/* Load: arg = unsigned base offset */ + +#define oLD (o32|0x00) /* No stack arguments */ +#define oLDH (o32|0x01) /* No stack arguments */ +#define oLDB (o32|0x02) /* No stack arguments */ +#define oLDM (o32|0x03) /* One 32-bit stack argument */ + +/* Store: arg = unsigned base offset */ + +#define oST (o32|0x04) /* One 32-bit stack argument */ +#define oSTH (o32|0x05) /* One 32-bit stack argument */ +#define oSTB (o32|0x06) /* One 32-bit stack argument */ +#define oSTM (o32|0x07) /* One+n 32-bit stack argument */ + +/* Load Indexed: arg = unsigned base offset */ + +#define oLDX (o32|0x08) /* One 32-bit stack argument */ +#define oLDXH (o32|0x09) /* One 32-bit stack argument */ +#define oLDXB (o32|0x0a) /* One 32-bit stack argument */ +#define oLDXM (o32|0x0b) /* Two 32-bit stack argument */ + +/* Store Indexed: arg = unsigned base offset */ + +#define oSTX (o32|0x0c) /* Two 32-bit stack argument */ +#define oSTXH (o32|0x0d) /* Two 32-bit stack argument */ +#define oSTXB (o32|0x0e) /* Two 32-bit stack argument */ +#define oSTXM (o32|0x0f) /* Two+n 32-bit stack argument */ + +/* Program control: arg = unsigned label (One 32-bit stack argument) */ + +#define oJEQUZ (o32|0x10) +#define oJNEQZ (o32|0x11) +#define oJLTZ (o32|0x12) +#define oJGTEZ (o32|0x13) +#define oJGTZ (o32|0x14) +#define oJLTEZ (o32|0x15) + +/* Program control: arg = unsigned label (no stack arguments) */ + +#define oJMP (o32|0x16) + +/* Data stack: arg = 32 bit signed data (no stack arguments) */ + +#define oPUSH (o32|0x17) + +/* Program control: arg = unsigned label (One 32-bit stack argument) */ + +#define oJEQU (o32|0x18) +#define oJNEQ (o32|0x19) +#define oJLT (o32|0x1a) +#define oJGTE (o32|0x1b) +#define oJGT (o32|0x1c) +#define oJLTE (o32|0x1d) + +/* Data stack: arg = 32 bit signed data (no stack arguments) */ + +#define oINDS (o32|0x1f) + +/* Load: Uses LSP; arg = signed frame offset */ + +#define oLDS (o32|0x20) /* No stack arguments */ +#define oLDSH (o32|0x21) /* No stack arguments */ +#define oLDSB (o32|0x22) /* No stack arguments */ +#define oLDSM (o32|0x23) /* One 32-bit stack argument */ + +/* Store: Uses LSP; arg = signed frame offset */ + +#define oSTS (o32|0x24) /* One 32-bit stack argument */ +#define oSTSH (o32|0x25) /* One 32-bit stack argument */ +#define oSTSB (o32|0x26) /* One 32-bit stack argument */ +#define oSTSM (o32|0x27) /* One+n 32-bit stack argument */ + +/* Load Indexed: Uses LSP; arg = signed frame offset */ + +#define oLDSX (o32|0x28) /* One 32-bit stack argument */ +#define oLDSXH (o32|0x29) /* One 32-bit stack argument */ +#define oLDSXB (o32|0x2a) /* One 32-bit stack argument */ +#define oLDSXM (o32|0x2b) /* Two 32-bit stack argument */ + +/* Store Indexed: Uses LSP; arg = signed frame offset */ + +#define oSTSX (o32|0x2c) /* Two 32-bit stack argument */ +#define oSTSXH (o32|0x2d) /* Two 32-bit stack argument */ +#define oSTSXB (o32|0x2e) /* Two 32-bit stack argument */ +#define oSTSXM (o32|0x2f) /* Two+n 32-bit stack argument */ + +/* Load address relative to stack base: arg = unsigned offset */ + +#define oLA (o32|0x30) + +/* Load address: Uses SLP, arg = signed frame offset */ + +#define oLAS (o32|0x31) /* No stack arguments */ + +/* Load absolute stack address: arg = RODATA offset (No stack arguments) */ + +#define oLAC (o32|0x32) + +/* Load address relative to stack base: arg = unsigned offset, TOS=index */ + +#define oLAX (o32|0x34) + +/* Load address indexed: Uses SLP, arg = signed frame offset */ + +#define oLASX (o32|0x35) /* No stack arguments */ + +/* Set LSP: arg = new level that evaluates to LSP value */ + +#define oSLSP (o32|0x36) + +/* Set DS: arg = new byte count in DS register */ + +#define oSDC (o32|0x37) + +/* Program Control: Uses LSP; arg = unsigned label + * (No stack arguments) + * Behavior: + * Push base address of level + * Push base register (BR) value + * Set new base register value (BR) as top of stack + * Push return address + * Set program counter (PC) for address associated with label + */ + +#define oPCAL (o32|0x39) + +/* System calls: arg = file number | sub-function code */ + +#define oSYSIO (o32|0x3a) + +/* System functions: arg = 32-bit library call identifier */ + +#define oLIB (o32|0x3b) + +/* Floating point operations: arg = FP op-code */ + +#define oFLOAT (o32|0x3c) + +/* Program control: arg = unsigned label (no stack arguments) */ + +#define oLABEL (o32|0x3d) + +/* Pseudo-operations: arg = file number OR line number */ + +#define oINCLUDE (o32|0x3e) +#define oLINE (o32|0x3f) + +#endif /* __PINSN32_H */ diff --git a/misc/pascal/insn32/libinsn/pdasm.c b/misc/pascal/insn32/libinsn/pdasm.c index 75d79d7b62..31d45088fc 100644 --- a/misc/pascal/insn32/libinsn/pdasm.c +++ b/misc/pascal/insn32/libinsn/pdasm.c @@ -303,7 +303,7 @@ static const struct optab_s g_sArg32OpTable[64] = /* 0xbd */ { NULL, LABEL_DEC }, - /* Psuedo-operations: arg = file number OR line number */ + /* Pseudo-operations: arg = file number OR line number */ /* 0xbe */ { "INCLUDE ", FILENO }, /* 0xbf */ { "LINE ", LINENO }, diff --git a/misc/pascal/pascal/pgen.c b/misc/pascal/pascal/pgen.c index fc108e3a6c..25d4d956b4 100644 --- a/misc/pascal/pascal/pgen.c +++ b/misc/pascal/pascal/pgen.c @@ -272,7 +272,7 @@ void pas_GenerateIoOperation(uint16_t ioOpcode, uint16_t fileNumber) } /***********************************************************************/ -/* Generate a psuedo call to a built-in, standard pascal function */ +/* Generate a pseudo call to a built-in, standard pascal function */ void pas_BuiltInFunctionCall(uint16_t libOpcode) { diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 1061f39ae5..6fd4979433 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3119,7 +3119,7 @@ function called stm32_clockenable() that can be used by PM logic to re-start the PLL after re-awakening from deep sleep modes. * fs/fs_foreachinode.c and fs/fs_foreachmountpoint.c: All logic to traverse - inodes and mountpoints in the NuttX psuedo-file system. + inodes and mountpoints in the NuttX pseudo-file system. * fs/fat/fs_fat32.c: Max. filename length reported by statfs() was wrong if FAT long file names were enabled. * lib/stdio/lib_libvsprintf.c: Fieldwidth and justification were not diff --git a/nuttx/Documentation/NfsHowto.html b/nuttx/Documentation/NfsHowto.html index 0f08f4abe5..0fee8baf77 100644 --- a/nuttx/Documentation/NfsHowto.html +++ b/nuttx/Documentation/NfsHowto.html @@ -1,388 +1,388 @@ - - -NFS Client How-To - - -

- -
- - - -
-

NFS Client How-To

-

Last Updated: June 18, 2012

-
-

- - - - - -
-

Table of Contents

-
- -
- - - -
- - - - - -
- Adding NFS to the NuttX Configuration -
- - - - - -
- Mount Interface -
- - - - - -
- NFS Mount Command -
- - - - - -
- Configuring the NFS server (Ubuntu) -
-
- - - - - -
-

Adding NFS to the NuttX Configuration

-
- -

- The NFS client is easily added to your configuration: - You simply need to add CONFIG_NFS to your nuttx/.config file. - There are, however, a few dependencies on other system settings: -

-
    -
  1. - First, there are number of things that you must configure in order to be able to use any file system: -
  2. -
      -
    • - CONFIG_NFILE_DESCRIPTORS > 0. You must include support for file descriptors. -
    • -
    • - CONFIG_DISABLE_MOUNTPOINT=n. You must include support for mount points in the psuedo-file system. -
    • -
    -
  3. - And there are several dependencies on the networking configuration. - At a minimum, you need to have the following selections: -
  4. -
      -
    • - CONFIG_NET=y. General networking support. -
    • -
    • - CONFIG_NET_UDP=y. Support for UDP. -
    • -
    -
- - - - - -
-

Mount Interface

-
- -

- A low-level, C-callable interface is provided to mount a file system. - That interface is called mount() and is mentioned in the porting guide and is prototyped in the header file include/sys/mount.h: -

-
    -int mount(const char *source, const char *target, const char *filesystemtype, unsigned long mountflags, const void *data);
    -
-

- Synopsis: - mount() attaches the filesystem specified by the source block device name into the root file system at the path specified by target. -

-

- Input Paramters: -

    -
  • source. A null-terminated string providing the fill path to a block driver in the NuttX psuedo-file system. -
  • target. The location in the NuttX psuedo-file system where the volume will be mounted. -
  • filesystemtype. A string identifying the type of file system to use. -
  • mountflags. Various flags that can be used to qualify how the file system is mounted. -
  • data. Opaque data that is passed to the file system with the mount occurs. -
-

-

- Returned Values - Zero is returned on success; -1 is returned on an error and errno is set appropriately: -

    -
  • EACCES. - A component of a path was not searchable or mounting a read-onlyfilesystem was attempted without giving the MS_RDONLY flag. -
  • -
  • EBUSY. - source is already mounted. -
  • -
  • EFAULT. - One of the pointer arguments points outside the user address space. -
  • -
  • EINVAL. - source had an invalid superblock. -
  • -
  • ENODEV. - filesystemtype not configured -
  • -
  • ENOENT. - A pathname was empty or had a nonexistent component. -
  • -
  • ENOMEM. - Could not allocate a memory to copy filenames or data into. -
  • -
  • ENOTBLK. - source is not a block device -
  • -
-

-

- This same interface can be used to mount a remote, NFS file system using some special parameters. - The NFS mount differs from the normal file system mount in that: (1) there is no block driver for the NFS file system, and (2) special parameters must be passed as data to describe the remote NFS server. - Thus the following code snippet might represent how an NFS file system is mounted: -

-
    -#include <sys/mount.h>
    -#include <nuttx/fs/nfs.h>
    -
    -struct nfs_args data;
    -char *mountpoint;
    -
    -ret = mount(NULL, mountpoint, string "nfs", 0, (FAR void *)&data);
    -
-

- NOTE that: (1) the block driver paramter is NULL. - The mount() is smart enough to know that no block driver is needed with the NFS file system. - (2) The NFS file system is identified with the simple string "nfs" - (3) A reference to struct nfs_args is passed as an NFS-specific argument. -

-

- The NFS-specific interface is described in the file include/nuttx/fs/nfs.h. - There you can see that struct nfs_args is defined as: -

-
    -struct nfs_args
    -{
    -  uint8_t  addrlen;               /* Length of address */
    -  uint8_t  sotype;                /* Socket type */
    -  uint8_t  flags;                 /* Flags, determines if following are valid: */
    -  uint8_t  timeo;                 /* Time value in deciseconds (with NFSMNT_TIMEO) */
    -  uint8_t  retrans;               /* Times to retry send (with NFSMNT_RETRANS) */
    -  uint16_t wsize;                 /* Write size in bytes (with NFSMNT_WSIZE) */
    -  uint16_t rsize;                 /* Read size in bytes (with NFSMNT_RSIZE) */
    -  uint16_t readdirsize;           /* readdir size in bytes (with NFSMNT_READDIRSIZE) */
    -  char    *path;                  /* Server's path of the directory being mount */
    -  struct   sockaddr_storage addr; /* File server address (requires 32-bit alignment) */
    -};
    -
- - - - - -
-

NFS Mount Command

-
- -

- The NuttShell (NSH) also supports a command called nfsmount - that can be used to mount a remote file system via the NSH command line. -

-

- Command Syntax: -

-
    -nfsmount <server-address> <mount-point> <remote-path>
    -
-

- Synopsis. - The nfsmount command mounts a network file system in the NuttX psuedo filesystem. - The nfsmount will use NFSv3 UDP protocol to mount the remote file system. -

-

- Command Line Arguments. - The nfsmount takes three arguments: -

-
    -
  1. - The <server-address> is the IP address of the server exporting the file system you wish to mount. - This implementation of NFS for the NuttX RTOS is only for a local area network, so the server and client must be in the same network. -
  2. -
  3. - The <mount-point > is the location in the NuttX pseudo filesystem where the mounted volume will appear. - This mount point can only reside in the NuttX pseudo filesystem. - By convention, this mount point is a subdirectory under /mnt. - The mount command will create whatever psuedo directories that may be needed to complete the full path (but the full path must not already exist). -
  4. -
  5. - The <remote-path> is the file system / directory being exported from server. - This / directory must have been configured for exportation on the server before when the NFS server was set up. -
  6. -
- -

- After the volume has been mounted in the NuttX pseudo filesystem, it may be access in the same way as other objects in the file system. -

-

- Example. - Suppose the the NFS server has been configured to export the directory /export/shared. - The the following command would mount that file system (assuming that the target also has privileges to mount the file system). -

-
    -NuttShell (NSH)
    -nsh> ls /mnt
    -/mnt:
    -nsh: ls: no such directory: /mnt
    -nsh> nfsmount 10.0.0.1 /mnt/nfs /export/shared
    -nsh> ls -l /mnt/nfs
    -/mnt/nfs:
    - drwxrwxrwx   4096 ..
    - drwxrwxrwx   4096 testdir/
    - -rw-rw-rw-      6 ctest.txt
    - -rw-r--r--     15 btest.txt
    - drwxrwxrwx   4096 .
    -nsh> echo "This is a test" >/mnt/nfs/testdir/testfile.txt
    -nsh> ls -l /mnt/nfs/testdir
    -/mnt/nfs/testdir:
    - -rw-rw-rw-     21 another.txt
    - drwxrwxrwx   4096 ..
    - drwxrwxrwx   4096 .
    - -rw-rw-rw-     16 testfile.txt
    -nsh> cat /mnt/nfs/testdir/testfile.txt
    -This is a test
    -
- - - - - -
-

Configuring the NFS server (Ubuntu)

-
- -

- Setting up the server will be done in two steps: - First, setting up the configuration file for NFS, and then starting the NFS services. - But first, you need to install the nfs server on Ubuntu with the these two commands: -

-
    -# sudo apt-get install nfs-common
    -# sudo apt-get install nfs-kernel-server
    -
- -

- After that, we need to make or choose the directory we want to export from the NFS server. - In our case, we are going to make a new directory called /export. -

-
    -# sudo mkdir /export
    -
-

- It is important that /export directory allow access to everyone (777 permissions) as we will be accessing the NFS share from the client with no authentication. -

-
    -# sudo chmod 777 /export
    -
-

- When all this is done, we will need to edit the configuration file to set up an NFS server: /etc/exports. - This file contains a list of entries; - each entry indicates a volume that is shared and how it is shared. - For more information for a complete description of all the setup options for this file you can check in the man pages (man export).

- An entry in /etc/exports will typically look like this: -

-
    -directory machine1(option11,option12)
    -
-

- So for our example we export /export to the client 10.0.0.2 add the entry: -

-
    -/export 10.0.0.2(rw)
    -
-

- In our case we are using all the default options except for the ro that we replaced with rw so that our client will have read and write access to the directory that we are exporting. -

-

- After we do all the require configurations, we are ready to start the server with the next command: -

-
    -# sudo /etc/init.d/nfs-kernel-server start
    -
-

- Note: If you later decide to add more NFS exports to the /etc/exports file, you will need to either restart NFS daemon -or run command exportfs. -

-
    -# sudo /etc/init.d/nfs-kernel-server start 
    -
-

Or

-
    -# exportfs -ra
    -
-

- Now we can check if the export directory and our mount point is properly set up. -

-
    -# sudo showmount -e
    -# sudo showmount -a
    -
-

- And also we can verify if NFS is running in the system with: -

-

-

    -# rpcinfo –p
    -program vers proto   port
    -   100000   2   tcp    111  portmapper
    -   100000   2   udp    111  portmapper
    -   100011   1   udp   749  rquotad
    -   100011   2   udp   749  rquotad
    -   100005   1   udp    759  mountd
    -   100005   1   tcp    761  mountd
    -   100005   2   udp    764  mountd
    -   100005   2   tcp    766  mountd
    -   100005   3   udp    769  mountd
    -   100005   3   tcp    771  mountd
    -   100003   2   udp   2049  nfs
    -   100003   3   udp   2049  nfs
    -   300019   1   tcp    830  amd
    -   300019   1   udp    831  amd
    -   100024   1   udp    944  status
    -   100024   1   tcp    946  status
    -   100021   1   udp   1042  nlockmgr
    -   100021   3   udp   1042  nlockmgr
    -   100021   4   udp   1042  nlockmgr
    -   100021   1   tcp   1629  nlockmgr
    -   100021   3   tcp   1629  nlockmgr
    -   100021   4   tcp   1629  nlockmgr
    -
-

- Now your NFS sever is sharing /export directory to be accessed. -

- - - + + +NFS Client How-To + + +

+ + + + + +
+

NFS Client How-To

+

Last Updated: June 18, 2012

+
+

+ + + + + +
+

Table of Contents

+
+ +
+ + + +
+ + + + + +
+ Adding NFS to the NuttX Configuration +
+ + + + + +
+ Mount Interface +
+ + + + + +
+ NFS Mount Command +
+ + + + + +
+ Configuring the NFS server (Ubuntu) +
+
+ + + + + +
+

Adding NFS to the NuttX Configuration

+
+ +

+ The NFS client is easily added to your configuration: + You simply need to add CONFIG_NFS to your nuttx/.config file. + There are, however, a few dependencies on other system settings: +

+
    +
  1. + First, there are number of things that you must configure in order to be able to use any file system: +
  2. +
      +
    • + CONFIG_NFILE_DESCRIPTORS > 0. You must include support for file descriptors. +
    • +
    • + CONFIG_DISABLE_MOUNTPOINT=n. You must include support for mount points in the pseudo-file system. +
    • +
    +
  3. + And there are several dependencies on the networking configuration. + At a minimum, you need to have the following selections: +
  4. +
      +
    • + CONFIG_NET=y. General networking support. +
    • +
    • + CONFIG_NET_UDP=y. Support for UDP. +
    • +
    +
+ + + + + +
+

Mount Interface

+
+ +

+ A low-level, C-callable interface is provided to mount a file system. + That interface is called mount() and is mentioned in the porting guide and is prototyped in the header file include/sys/mount.h: +

+
    +int mount(const char *source, const char *target, const char *filesystemtype, unsigned long mountflags, const void *data);
    +
+

+ Synopsis: + mount() attaches the filesystem specified by the source block device name into the root file system at the path specified by target. +

+

+ Input Paramters: +

    +
  • source. A null-terminated string providing the fill path to a block driver in the NuttX pseudo-file system. +
  • target. The location in the NuttX pseudo-file system where the volume will be mounted. +
  • filesystemtype. A string identifying the type of file system to use. +
  • mountflags. Various flags that can be used to qualify how the file system is mounted. +
  • data. Opaque data that is passed to the file system with the mount occurs. +
+

+

+ Returned Values + Zero is returned on success; -1 is returned on an error and errno is set appropriately: +

    +
  • EACCES. + A component of a path was not searchable or mounting a read-onlyfilesystem was attempted without giving the MS_RDONLY flag. +
  • +
  • EBUSY. + source is already mounted. +
  • +
  • EFAULT. + One of the pointer arguments points outside the user address space. +
  • +
  • EINVAL. + source had an invalid superblock. +
  • +
  • ENODEV. + filesystemtype not configured +
  • +
  • ENOENT. + A pathname was empty or had a nonexistent component. +
  • +
  • ENOMEM. + Could not allocate a memory to copy filenames or data into. +
  • +
  • ENOTBLK. + source is not a block device +
  • +
+

+

+ This same interface can be used to mount a remote, NFS file system using some special parameters. + The NFS mount differs from the normal file system mount in that: (1) there is no block driver for the NFS file system, and (2) special parameters must be passed as data to describe the remote NFS server. + Thus the following code snippet might represent how an NFS file system is mounted: +

+
    +#include <sys/mount.h>
    +#include <nuttx/fs/nfs.h>
    +
    +struct nfs_args data;
    +char *mountpoint;
    +
    +ret = mount(NULL, mountpoint, string "nfs", 0, (FAR void *)&data);
    +
+

+ NOTE that: (1) the block driver paramter is NULL. + The mount() is smart enough to know that no block driver is needed with the NFS file system. + (2) The NFS file system is identified with the simple string "nfs" + (3) A reference to struct nfs_args is passed as an NFS-specific argument. +

+

+ The NFS-specific interface is described in the file include/nuttx/fs/nfs.h. + There you can see that struct nfs_args is defined as: +

+
    +struct nfs_args
    +{
    +  uint8_t  addrlen;               /* Length of address */
    +  uint8_t  sotype;                /* Socket type */
    +  uint8_t  flags;                 /* Flags, determines if following are valid: */
    +  uint8_t  timeo;                 /* Time value in deciseconds (with NFSMNT_TIMEO) */
    +  uint8_t  retrans;               /* Times to retry send (with NFSMNT_RETRANS) */
    +  uint16_t wsize;                 /* Write size in bytes (with NFSMNT_WSIZE) */
    +  uint16_t rsize;                 /* Read size in bytes (with NFSMNT_RSIZE) */
    +  uint16_t readdirsize;           /* readdir size in bytes (with NFSMNT_READDIRSIZE) */
    +  char    *path;                  /* Server's path of the directory being mount */
    +  struct   sockaddr_storage addr; /* File server address (requires 32-bit alignment) */
    +};
    +
+ + + + + +
+

NFS Mount Command

+
+ +

+ The NuttShell (NSH) also supports a command called nfsmount + that can be used to mount a remote file system via the NSH command line. +

+

+ Command Syntax: +

+
    +nfsmount <server-address> <mount-point> <remote-path>
    +
+

+ Synopsis. + The nfsmount command mounts a network file system in the NuttX pseudo filesystem. + The nfsmount will use NFSv3 UDP protocol to mount the remote file system. +

+

+ Command Line Arguments. + The nfsmount takes three arguments: +

+
    +
  1. + The <server-address> is the IP address of the server exporting the file system you wish to mount. + This implementation of NFS for the NuttX RTOS is only for a local area network, so the server and client must be in the same network. +
  2. +
  3. + The <mount-point > is the location in the NuttX pseudo filesystem where the mounted volume will appear. + This mount point can only reside in the NuttX pseudo filesystem. + By convention, this mount point is a subdirectory under /mnt. + The mount command will create whatever pseudo directories that may be needed to complete the full path (but the full path must not already exist). +
  4. +
  5. + The <remote-path> is the file system / directory being exported from server. + This / directory must have been configured for exportation on the server before when the NFS server was set up. +
  6. +
+ +

+ After the volume has been mounted in the NuttX pseudo filesystem, it may be access in the same way as other objects in the file system. +

+

+ Example. + Suppose the the NFS server has been configured to export the directory /export/shared. + The the following command would mount that file system (assuming that the target also has privileges to mount the file system). +

+
    +NuttShell (NSH)
    +nsh> ls /mnt
    +/mnt:
    +nsh: ls: no such directory: /mnt
    +nsh> nfsmount 10.0.0.1 /mnt/nfs /export/shared
    +nsh> ls -l /mnt/nfs
    +/mnt/nfs:
    + drwxrwxrwx   4096 ..
    + drwxrwxrwx   4096 testdir/
    + -rw-rw-rw-      6 ctest.txt
    + -rw-r--r--     15 btest.txt
    + drwxrwxrwx   4096 .
    +nsh> echo "This is a test" >/mnt/nfs/testdir/testfile.txt
    +nsh> ls -l /mnt/nfs/testdir
    +/mnt/nfs/testdir:
    + -rw-rw-rw-     21 another.txt
    + drwxrwxrwx   4096 ..
    + drwxrwxrwx   4096 .
    + -rw-rw-rw-     16 testfile.txt
    +nsh> cat /mnt/nfs/testdir/testfile.txt
    +This is a test
    +
+ + + + + +
+

Configuring the NFS server (Ubuntu)

+
+ +

+ Setting up the server will be done in two steps: + First, setting up the configuration file for NFS, and then starting the NFS services. + But first, you need to install the nfs server on Ubuntu with the these two commands: +

+
    +# sudo apt-get install nfs-common
    +# sudo apt-get install nfs-kernel-server
    +
+ +

+ After that, we need to make or choose the directory we want to export from the NFS server. + In our case, we are going to make a new directory called /export. +

+
    +# sudo mkdir /export
    +
+

+ It is important that /export directory allow access to everyone (777 permissions) as we will be accessing the NFS share from the client with no authentication. +

+
    +# sudo chmod 777 /export
    +
+

+ When all this is done, we will need to edit the configuration file to set up an NFS server: /etc/exports. + This file contains a list of entries; + each entry indicates a volume that is shared and how it is shared. + For more information for a complete description of all the setup options for this file you can check in the man pages (man export).

+ An entry in /etc/exports will typically look like this: +

+
    +directory machine1(option11,option12)
    +
+

+ So for our example we export /export to the client 10.0.0.2 add the entry: +

+
    +/export 10.0.0.2(rw)
    +
+

+ In our case we are using all the default options except for the ro that we replaced with rw so that our client will have read and write access to the directory that we are exporting. +

+

+ After we do all the require configurations, we are ready to start the server with the next command: +

+
    +# sudo /etc/init.d/nfs-kernel-server start
    +
+

+ Note: If you later decide to add more NFS exports to the /etc/exports file, you will need to either restart NFS daemon +or run command exportfs. +

+
    +# sudo /etc/init.d/nfs-kernel-server start 
    +
+

Or

+
    +# exportfs -ra
    +
+

+ Now we can check if the export directory and our mount point is properly set up. +

+
    +# sudo showmount -e
    +# sudo showmount -a
    +
+

+ And also we can verify if NFS is running in the system with: +

+

+

    +# rpcinfo –p
    +program vers proto   port
    +   100000   2   tcp    111  portmapper
    +   100000   2   udp    111  portmapper
    +   100011   1   udp   749  rquotad
    +   100011   2   udp   749  rquotad
    +   100005   1   udp    759  mountd
    +   100005   1   tcp    761  mountd
    +   100005   2   udp    764  mountd
    +   100005   2   tcp    766  mountd
    +   100005   3   udp    769  mountd
    +   100005   3   tcp    771  mountd
    +   100003   2   udp   2049  nfs
    +   100003   3   udp   2049  nfs
    +   300019   1   tcp    830  amd
    +   300019   1   udp    831  amd
    +   100024   1   udp    944  status
    +   100024   1   tcp    946  status
    +   100021   1   udp   1042  nlockmgr
    +   100021   3   udp   1042  nlockmgr
    +   100021   4   udp   1042  nlockmgr
    +   100021   1   tcp   1629  nlockmgr
    +   100021   3   tcp   1629  nlockmgr
    +   100021   4   tcp   1629  nlockmgr
    +
+

+ Now your NFS sever is sharing /export directory to be accessed. +

+ + + diff --git a/nuttx/Documentation/NuttShell.html b/nuttx/Documentation/NuttShell.html index 8e57e27b22..0413a46956 100644 --- a/nuttx/Documentation/NuttShell.html +++ b/nuttx/Documentation/NuttShell.html @@ -1400,7 +1400,7 @@ mkfifo <path>

Synopsis. Creates a FIFO character device anywhere in the pseudo file system, creating - whatever psuedo directories that may be needed to complete the <path>. + whatever pseudo directories that may be needed to complete the <path>. By convention, however, device drivers are place in the standard /dev directory. After it is created, the FIFO device may be used as any other device driver. NSH provides this command to access the mkfifo() NuttX API. @@ -1492,7 +1492,7 @@ mount -t <fstype> <block-device> <dir-path> If no paramters are provided on the command line after the mount command, then the mount command will enumerate all of the current mountpoints on the console.

- If the mount parameters are provied on the command after the mount command, then the mount command will mount a file system in the NuttX psuedo-file system. + If the mount parameters are provied on the command after the mount command, then the mount command will mount a file system in the NuttX pseudo-file system. mount' performs a three way association, binding:

    @@ -1513,7 +1513,7 @@ mount -t <fstype> <block-device> <dir-path> pseudo filesystem where the mounted volume will appear. This mount point can only reside in the NuttX pseudo filesystem. By convention, this mount point is a subdirectory under /mnt. - The mount command will create whatever psuedo directories that may be needed to complete the + The mount command will create whatever pseudo directories that may be needed to complete the full path but the full path must not already exist.
diff --git a/nuttx/TODO b/nuttx/TODO index a4bad193ec..e2abce7f40 100644 --- a/nuttx/TODO +++ b/nuttx/TODO @@ -703,9 +703,9 @@ o File system / Generic drivers (fs/, drivers/) Title: REMOVING PIPES AND FIFOS Description: There is no way to remove a FIFO or PIPE created in the - psuedo filesystem. Once created, they persist indefinitely + pseudo filesystem. Once created, they persist indefinitely and cannot be unlinked. This is actually a more generic - issue: unlink does not work for anything in the psuedo- + issue: unlink does not work for anything in the pseudo- filesystem. Status: Open, but partially resolved: pipe buffer is at least freed when there are not open references to the pipe/FIFO. diff --git a/nuttx/configs/lincoln60/README.txt b/nuttx/configs/lincoln60/README.txt index 7a06a852bb..6ad37d363c 100644 --- a/nuttx/configs/lincoln60/README.txt +++ b/nuttx/configs/lincoln60/README.txt @@ -413,7 +413,7 @@ host operations. To make these modifications, do the following: When this change is made, NSH should be extended to support USB flash devices. When a FLASH device is inserted, you should see a device -appear in the /dev (psuedo) directory. The device name should be +appear in the /dev (pseudo) directory. The device name should be like /dev/sda, /dev/sdb, etc. The USB mass storage device, is present it can be mounted from the NSH command line like: diff --git a/nuttx/configs/lpc4330-xplorer/README.txt b/nuttx/configs/lpc4330-xplorer/README.txt index a5c0709ea4..4ebe89d9ed 100644 --- a/nuttx/configs/lpc4330-xplorer/README.txt +++ b/nuttx/configs/lpc4330-xplorer/README.txt @@ -829,7 +829,7 @@ host operations. To make these modifications, do the following: When this change is made, NSH should be extended to support USB flash devices. When a FLASH device is inserted, you should see a device -appear in the /dev (psuedo) directory. The device name should be +appear in the /dev (pseudo) directory. The device name should be like /dev/sda, /dev/sdb, etc. The USB mass storage device, is present it can be mounted from the NSH command line like: diff --git a/nuttx/configs/mbed/README.txt b/nuttx/configs/mbed/README.txt index 3366ed320e..0b98d90853 100755 --- a/nuttx/configs/mbed/README.txt +++ b/nuttx/configs/mbed/README.txt @@ -384,7 +384,7 @@ host operations. To make these modifications, do the following: When this change is made, NSH should be extended to support USB flash devices. When a FLASH device is inserted, you should see a device -appear in the /dev (psuedo) directory. The device name should be +appear in the /dev (pseudo) directory. The device name should be like /dev/sda, /dev/sdb, etc. The USB mass storage device, is present it can be mounted from the NSH command line like: diff --git a/nuttx/configs/olimex-lpc1766stk/README.txt b/nuttx/configs/olimex-lpc1766stk/README.txt index b2a1ad5fa2..b81826e301 100755 --- a/nuttx/configs/olimex-lpc1766stk/README.txt +++ b/nuttx/configs/olimex-lpc1766stk/README.txt @@ -788,7 +788,7 @@ USB host operations. To make these modifications, do the following: When this change is made, NSH should be extended to support USB flash devices. When a FLASH device is inserted, you should see a device -appear in the /dev (psuedo) directory. The device name should be +appear in the /dev (pseudo) directory. The device name should be like /dev/sda, /dev/sdb, etc. The USB mass storage device, is present it can be mounted from the NSH command line like: diff --git a/nuttx/fs/fs_closedir.c b/nuttx/fs/fs_closedir.c index fe09944787..ba4f129618 100644 --- a/nuttx/fs/fs_closedir.c +++ b/nuttx/fs/fs_closedir.c @@ -96,7 +96,7 @@ int closedir(FAR DIR *dirp) */ #ifndef CONFIG_DISABLE_MOUNTPOINT - if (INODE_IS_MOUNTPT(inode) && !DIRENT_ISPSUEDONODE(idir->fd_flags)) + if (INODE_IS_MOUNTPT(inode) && !DIRENT_ISPSEUDONODE(idir->fd_flags)) { /* The node is a file system mointpoint. Verify that the mountpoint * supports the closedir() method (not an error if it does not) @@ -117,13 +117,13 @@ int closedir(FAR DIR *dirp) else #endif { - /* The node is part of the root psuedo file system, release + /* The node is part of the root pseudo file system, release * our contained reference to the 'next' inode. */ - if (idir->u.psuedo.fd_next) + if (idir->u.pseudo.fd_next) { - inode_release(idir->u.psuedo.fd_next); + inode_release(idir->u.pseudo.fd_next); } } diff --git a/nuttx/fs/fs_files.c b/nuttx/fs/fs_files.c index 033cd8c63b..425e7c73f8 100644 --- a/nuttx/fs/fs_files.c +++ b/nuttx/fs/fs_files.c @@ -342,7 +342,7 @@ int files_dup(FAR struct file *filep1, FAR struct file *filep2) #endif #endif { - /* Open the psuedo file or device driver */ + /* Open the pseudo file or device driver */ ret = inode->u.i_ops->open(filep2); } diff --git a/nuttx/fs/fs_foreachinode.c b/nuttx/fs/fs_foreachinode.c index 08630263b2..c5874c669b 100644 --- a/nuttx/fs/fs_foreachinode.c +++ b/nuttx/fs/fs_foreachinode.c @@ -171,7 +171,7 @@ int foreach_inodelevel(FAR struct inode *node, struct inode_path_s *info) * when the callback 'handler' returns a non-zero value, or when all of * the inodes have been visited. * - * NOTE 1: Use with caution... The psuedo-file system is locked throughout + * NOTE 1: Use with caution... The pseudo-file system is locked throughout * the traversal. * NOTE 2: The search algorithm is recursive and could, in principle, use * an indeterminant amount of stack space. This will not usually be a diff --git a/nuttx/fs/fs_foreachmountpoint.c b/nuttx/fs/fs_foreachmountpoint.c index e7a6206506..74e3e8356a 100644 --- a/nuttx/fs/fs_foreachmountpoint.c +++ b/nuttx/fs/fs_foreachmountpoint.c @@ -154,7 +154,7 @@ static int mountpoint_filter(FAR struct inode *node, * mountpoint inodes. It is intended to support the mount() command to * when the mount command is used to enumerate mounts. * - * NOTE 1: Use with caution... The psuedo-file system is locked throughout + * NOTE 1: Use with caution... The pseudo-file system is locked throughout * the traversal. * NOTE 2: The search algorithm is recursive and could, in principle, use * an indeterminant amount of stack space. This will not usually be a diff --git a/nuttx/fs/fs_internal.h b/nuttx/fs/fs_internal.h index dbabb63d1b..786c683dcb 100644 --- a/nuttx/fs/fs_internal.h +++ b/nuttx/fs/fs_internal.h @@ -75,10 +75,10 @@ /* Mountpoint fd_flags values */ -#define DIRENTFLAGS_PSUEDONODE 1 +#define DIRENTFLAGS_PSEUDONODE 1 -#define DIRENT_SETPSUEDONODE(f) do (f) |= DIRENTFLAGS_PSUEDONODE; while (0) -#define DIRENT_ISPSUEDONODE(f) (((f) & DIRENTFLAGS_PSUEDONODE) != 0) +#define DIRENT_SETPSEUDONODE(f) do (f) |= DIRENTFLAGS_PSEUDONODE; while (0) +#define DIRENT_ISPSEUDONODE(f) (((f) & DIRENTFLAGS_PSEUDONODE) != 0) /**************************************************************************** * Public Types @@ -236,7 +236,7 @@ EXTERN void inode_release(FAR struct inode *inode); * when the callback 'handler' returns a non-zero value, or when all of * the inodes have been visited. * - * NOTE 1: Use with caution... The psuedo-file system is locked throughout + * NOTE 1: Use with caution... The pseudo-file system is locked throughout * the traversal. * NOTE 2: The search algorithm is recursive and could, in principle, use * an indeterminant amount of stack space. This will not usually be a diff --git a/nuttx/fs/fs_opendir.c b/nuttx/fs/fs_opendir.c index a52c538fe2..1c87c984dd 100644 --- a/nuttx/fs/fs_opendir.c +++ b/nuttx/fs/fs_opendir.c @@ -138,19 +138,19 @@ static inline int open_mountpoint(FAR struct inode *inode, static void open_pseudodir(FAR struct inode *inode, FAR struct fs_dirent_s *dir) { - /* We have a valid psuedo-filesystem node. Take two references on the + /* We have a valid pseudo-filesystem node. Take two references on the * inode -- one for the parent (fd_root) and one for the child (fd_next). * Note that we do not call inode_addref because we are holding the tree * semaphore and that would result in deadlock. */ inode->i_crefs += 2; - dir->u.psuedo.fd_next = inode; /* This is the next node to use for readdir() */ + dir->u.pseudo.fd_next = inode; /* This is the next node to use for readdir() */ - /* Flag the inode as belonging to the psuedo-filesystem */ + /* Flag the inode as belonging to the pseudo-filesystem */ #ifndef CONFIG_DISABLE_MOUNTPOINT - DIRENT_SETPSUEDONODE(dir->fd_flags); + DIRENT_SETPSEUDONODE(dir->fd_flags); #endif } @@ -242,7 +242,7 @@ FAR DIR *opendir(FAR const char *path) } /* Populate the DIR structure and return it to the caller. The way that - * we do this depends on whenever this is a "normal" psuedo-file-system + * we do this depends on whenever this is a "normal" pseudo-file-system * inode or a file system mountpoint. */ @@ -262,7 +262,7 @@ FAR DIR *opendir(FAR const char *path) open_pseudodir(inode, dir); } - /* Is this a node in the psuedo filesystem? Or a mountpoint? If the node + /* Is this a node in the pseudo filesystem? Or a mountpoint? If the node * is the root (bisroot == TRUE), then this is a special case. */ @@ -280,7 +280,7 @@ FAR DIR *opendir(FAR const char *path) #endif else { - /* The node is part of the root psuedo file system. Does the inode have a child? + /* The node is part of the root pseudo file system. Does the inode have a child? * If so that the child would be the 'root' of a list of nodes under * the directory. */ @@ -292,7 +292,7 @@ FAR DIR *opendir(FAR const char *path) goto errout_with_direntry; } - /* It looks we have a valid psuedo-filesystem directory node. */ + /* It looks we have a valid pseudo-filesystem directory node. */ open_pseudodir(inode, dir); } diff --git a/nuttx/fs/fs_readdir.c b/nuttx/fs/fs_readdir.c index 8df1bf655d..f5b2663927 100644 --- a/nuttx/fs/fs_readdir.c +++ b/nuttx/fs/fs_readdir.c @@ -53,16 +53,16 @@ ****************************************************************************/ /**************************************************************************** - * Name: readpsuedodir + * Name: readpseudodir ****************************************************************************/ -static inline int readpsuedodir(struct fs_dirent_s *idir) +static inline int readpseudodir(struct fs_dirent_s *idir) { FAR struct inode *prev; /* Check if we are at the end of the list */ - if (!idir->u.psuedo.fd_next) + if (!idir->u.pseudo.fd_next) { /* End of file and error conditions are not distinguishable * with readdir. Here we return -ENOENT to signal the end @@ -74,21 +74,21 @@ static inline int readpsuedodir(struct fs_dirent_s *idir) /* Copy the inode name into the dirent structure */ - strncpy(idir->fd_dir.d_name, idir->u.psuedo.fd_next->i_name, NAME_MAX+1); + strncpy(idir->fd_dir.d_name, idir->u.pseudo.fd_next->i_name, NAME_MAX+1); /* If the node has file operations, we will say that it is * a file. */ idir->fd_dir.d_type = 0; - if (idir->u.psuedo.fd_next->u.i_ops) + if (idir->u.pseudo.fd_next->u.i_ops) { #ifndef CONFIG_DISABLE_MOUNTPOINT - if (INODE_IS_BLOCK(idir->u.psuedo.fd_next)) + if (INODE_IS_BLOCK(idir->u.pseudo.fd_next)) { idir->fd_dir.d_type |= DTYPE_BLK; } - if (INODE_IS_MOUNTPT(idir->u.psuedo.fd_next)) + if (INODE_IS_MOUNTPT(idir->u.pseudo.fd_next)) { idir->fd_dir.d_type |= DTYPE_DIRECTORY; } @@ -103,7 +103,7 @@ static inline int readpsuedodir(struct fs_dirent_s *idir) * is a directory. NOTE: that the node can be both! */ - if (idir->u.psuedo.fd_next->i_child || !idir->u.psuedo.fd_next->u.i_ops) + if (idir->u.pseudo.fd_next->i_child || !idir->u.pseudo.fd_next->u.i_ops) { idir->fd_dir.d_type |= DTYPE_DIRECTORY; } @@ -112,14 +112,14 @@ static inline int readpsuedodir(struct fs_dirent_s *idir) inode_semtake(); - prev = idir->u.psuedo.fd_next; - idir->u.psuedo.fd_next = prev->i_peer; /* The next node to visit */ + prev = idir->u.pseudo.fd_next; + idir->u.pseudo.fd_next = prev->i_peer; /* The next node to visit */ - if (idir->u.psuedo.fd_next) + if (idir->u.pseudo.fd_next) { /* Increment the reference count on this next node */ - idir->u.psuedo.fd_next->i_crefs++; + idir->u.pseudo.fd_next->i_crefs++; } inode_semgive(); @@ -179,7 +179,7 @@ FAR struct dirent *readdir(DIR *dirp) #ifndef CONFIG_DISABLE_MOUNTPOINT inode = idir->fd_root; - if (INODE_IS_MOUNTPT(inode) && !DIRENT_ISPSUEDONODE(idir->fd_flags)) + if (INODE_IS_MOUNTPT(inode) && !DIRENT_ISPSEUDONODE(idir->fd_flags)) { /* The node is a file system mointpoint. Verify that the mountpoint * supports the readdir() method @@ -198,9 +198,9 @@ FAR struct dirent *readdir(DIR *dirp) else #endif { - /* The node is part of the root psuedo file system */ + /* The node is part of the root pseudo file system */ - ret = readpsuedodir(idir); + ret = readpseudodir(idir); } /* ret < 0 is an error. Special case: ret = -ENOENT is end of file */ diff --git a/nuttx/fs/fs_rewinddir.c b/nuttx/fs/fs_rewinddir.c index a0e2be7d88..c22c15f181 100644 --- a/nuttx/fs/fs_rewinddir.c +++ b/nuttx/fs/fs_rewinddir.c @@ -52,10 +52,10 @@ ****************************************************************************/ /**************************************************************************** - * Name: rewindpsuedodir + * Name: rewindpseudodir ****************************************************************************/ -static inline void rewindpsuedodir(struct fs_dirent_s *idir) +static inline void rewindpseudodir(struct fs_dirent_s *idir) { struct inode *prev; @@ -63,8 +63,8 @@ static inline void rewindpsuedodir(struct fs_dirent_s *idir) /* Reset the position to the beginning */ - prev = idir->u.psuedo.fd_next; /* (Save to delete later) */ - idir->u.psuedo.fd_next = idir->fd_root; /* The next node to visit */ + prev = idir->u.pseudo.fd_next; /* (Save to delete later) */ + idir->u.pseudo.fd_next = idir->fd_root; /* The next node to visit */ idir->fd_position = 0; /* Reset position */ /* Increment the reference count on the root=next node. We @@ -138,8 +138,8 @@ void rewinddir(FAR DIR *dirp) else #endif { - /* The node is part of the root psuedo file system */ + /* The node is part of the root pseudo file system */ - rewindpsuedodir(idir); + rewindpseudodir(idir); } } diff --git a/nuttx/fs/fs_seekdir.c b/nuttx/fs/fs_seekdir.c index ec530c67d0..781d35f27e 100644 --- a/nuttx/fs/fs_seekdir.c +++ b/nuttx/fs/fs_seekdir.c @@ -53,10 +53,10 @@ ****************************************************************************/ /**************************************************************************** - * Name: seekpsuedodir + * Name: seekpseudodir ****************************************************************************/ -static inline void seekpsuedodir(struct fs_dirent_s *idir, off_t offset) +static inline void seekpseudodir(struct fs_dirent_s *idir, off_t offset) { struct inode *curr; struct inode *prev; @@ -76,7 +76,7 @@ static inline void seekpsuedodir(struct fs_dirent_s *idir, off_t offset) else { pos = idir->fd_position; - curr = idir->u.psuedo.fd_next; + curr = idir->u.pseudo.fd_next; } /* Traverse the peer list starting at the 'root' of the @@ -90,8 +90,8 @@ static inline void seekpsuedodir(struct fs_dirent_s *idir, off_t offset) /* Now get the inode to vist next time that readdir() is called */ - prev = idir->u.psuedo.fd_next; - idir->u.psuedo.fd_next = curr; /* The next node to visit (might be null) */ + prev = idir->u.pseudo.fd_next; + idir->u.pseudo.fd_next = curr; /* The next node to visit (might be null) */ idir->fd_position = pos; /* Might be beyond the last dirent */ if (curr) @@ -223,8 +223,8 @@ void seekdir(FAR DIR *dirp, off_t offset) else #endif { - /* The node is part of the root psuedo file system */ + /* The node is part of the root pseudo file system */ - seekpsuedodir(idir, offset); + seekpseudodir(idir, offset); } } diff --git a/nuttx/fs/fs_stat.c b/nuttx/fs/fs_stat.c index 5cb3420818..cf27e87a6c 100644 --- a/nuttx/fs/fs_stat.c +++ b/nuttx/fs/fs_stat.c @@ -51,10 +51,10 @@ ****************************************************************************/ /**************************************************************************** - * Name: statpsuedo + * Name: statpseudo ****************************************************************************/ -static inline int statpsuedo(FAR struct inode *inode, FAR struct stat *buf) +static inline int statpseudo(FAR struct inode *inode, FAR struct stat *buf) { /* Most of the stat entries just do not apply */ @@ -92,7 +92,7 @@ static inline int statpsuedo(FAR struct inode *inode, FAR struct stat *buf) { /* If it has no operations, then it must just be a intermediate * node in the inode tree. It is something like a directory. - * We'll say that all psuedo-directories are read-able but not + * We'll say that all pseudo-directories are read-able but not * write-able. */ @@ -195,9 +195,9 @@ int stat(const char *path, FAR struct stat *buf) else #endif { - /* The node is part of the root psuedo file system */ + /* The node is part of the root pseudo file system */ - ret = statpsuedo(inode, buf); + ret = statpseudo(inode, buf); } /* Check if the stat operation was successful */ diff --git a/nuttx/fs/fs_statfs.c b/nuttx/fs/fs_statfs.c index 540eb86bb3..df7321bbd7 100644 --- a/nuttx/fs/fs_statfs.c +++ b/nuttx/fs/fs_statfs.c @@ -52,10 +52,10 @@ ****************************************************************************/ /**************************************************************************** - * Name: statpsuedo + * Name: statpseudo ****************************************************************************/ -static inline int statpsuedofs(FAR struct inode *inode, FAR struct statfs *buf) +static inline int statpseudofs(FAR struct inode *inode, FAR struct statfs *buf) { memset(buf, 0, sizeof(struct statfs)); buf->f_type = PROC_SUPER_MAGIC; @@ -137,9 +137,9 @@ int statfs(FAR const char *path, FAR struct statfs *buf) else #endif { - /* The node is part of the root psuedo file system */ + /* The node is part of the root pseudo file system */ - ret = statpsuedofs(inode, buf); + ret = statpseudofs(inode, buf); } /* Check if the statfs operation was successful */ diff --git a/nuttx/fs/fs_syslog.c b/nuttx/fs/fs_syslog.c index 1fe8c03a1c..1d569082a3 100644 --- a/nuttx/fs/fs_syslog.c +++ b/nuttx/fs/fs_syslog.c @@ -319,7 +319,7 @@ int syslog_initialize(void) SYSLOG_OFLAGS, 0666); } - /* No... then it must be a character driver in the NuttX psuedo- + /* No... then it must be a character driver in the NuttX pseudo- * file system. */ diff --git a/nuttx/fs/fs_unregisterblockdriver.c b/nuttx/fs/fs_unregisterblockdriver.c index 4ee9016fce..4d169fddfa 100644 --- a/nuttx/fs/fs_unregisterblockdriver.c +++ b/nuttx/fs/fs_unregisterblockdriver.c @@ -71,7 +71,7 @@ * Name: unregister_blockdriver * * Description: - * Remove the block driver inode at 'path' from the psuedo-file system + * Remove the block driver inode at 'path' from the pseudo-file system * ****************************************************************************/ diff --git a/nuttx/fs/fs_unregisterdriver.c b/nuttx/fs/fs_unregisterdriver.c index 7537274b54..c9ac0b6192 100644 --- a/nuttx/fs/fs_unregisterdriver.c +++ b/nuttx/fs/fs_unregisterdriver.c @@ -71,7 +71,7 @@ * Name: unregister_driver * * Description: - * Remove the character driver inode at 'path' from the psuedo-file system + * Remove the character driver inode at 'path' from the pseudo-file system * ****************************************************************************/ diff --git a/nuttx/include/nuttx/fs/dirent.h b/nuttx/include/nuttx/fs/dirent.h index 8aad4242b8..75867c87ae 100644 --- a/nuttx/include/nuttx/fs/dirent.h +++ b/nuttx/include/nuttx/fs/dirent.h @@ -65,12 +65,12 @@ * reference, a position, a dirent structure, and file-system-specific * information. * - * For the root psuedo-file system, we need retain only the 'next' inode + * For the root pseudo-file system, we need retain only the 'next' inode * need for the next readdir() operation. We hold a reference on this * inode so we know that it will persist until closedir is called. */ -struct fs_psuedodir_s +struct fs_pseudodir_s { struct inode *fd_next; /* The inode for the next call to readdir() */ }; @@ -140,7 +140,7 @@ struct fs_dirent_s { /* This is the node that was opened by opendir. The type of the inode * determines the way that the readdir() operations are performed. For the - * psuedo root psuedo-file system, it is also used to support rewind. + * pseudo root pseudo-file system, it is also used to support rewind. * * We hold a reference on this inode so we know that it will persist until * closedir() is called (although inodes linked to this inode may change). @@ -166,9 +166,9 @@ struct fs_dirent_s union { - /* Private data used by the built-in psuedo-file system */ + /* Private data used by the built-in pseudo-file system */ - struct fs_psuedodir_s psuedo; + struct fs_pseudodir_s pseudo; /* Private data used by other file systems */ diff --git a/nuttx/include/nuttx/fs/fs.h b/nuttx/include/nuttx/fs/fs.h index 07d28597e8..81f81622f6 100644 --- a/nuttx/include/nuttx/fs/fs.h +++ b/nuttx/include/nuttx/fs/fs.h @@ -199,7 +199,7 @@ union inode_ops_u #endif }; -/* This structure represents one inode in the Nuttx psuedo-file system */ +/* This structure represents one inode in the Nuttx pseudo-file system */ struct inode { @@ -342,7 +342,7 @@ EXTERN void weak_function fs_initialize(void); * mountpoint inodes. It is intended to support the mount() command to * when the mount command is used to enumerate mounts. * - * NOTE 1: Use with caution... The psuedo-file system is locked throughout + * NOTE 1: Use with caution... The pseudo-file system is locked throughout * the traversal. * NOTE 2: The search algorithm is recursive and could, in principle, use * an indeterminant amount of stack space. This will not usually be a @@ -415,7 +415,7 @@ EXTERN int register_blockdriver(const char *path, * Name: unregister_driver * * Description: - * Remove the character driver inode at 'path' from the psuedo-file system + * Remove the character driver inode at 'path' from the pseudo-file system * ****************************************************************************/ @@ -426,7 +426,7 @@ EXTERN int unregister_driver(const char *path); * Name: unregister_blockdriver * * Description: - * Remove the block driver inode at 'path' from the psuedo-file system + * Remove the block driver inode at 'path' from the pseudo-file system * ****************************************************************************/ From 45b832c6ffd0ef41c84bfdbc9e02d2e6e839f0c3 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 6 Aug 2012 00:29:53 +0000 Subject: [PATCH 03/13] cosmetic git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5011 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/lib/stdio/lib_dtoa.c | 194 ++++++++++++++++++++++++++-------- nuttx/lib/stdio/lib_libdtoa.c | 8 +- 2 files changed, 153 insertions(+), 49 deletions(-) diff --git a/nuttx/lib/stdio/lib_dtoa.c b/nuttx/lib/stdio/lib_dtoa.c index 894af4f424..b8c7db9803 100644 --- a/nuttx/lib/stdio/lib_dtoa.c +++ b/nuttx/lib/stdio/lib_dtoa.c @@ -970,7 +970,9 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) word0(d) &= ~Sign_bit; /* clear sign bit */ } else - *sign = 0; + { + *sign = 0; + } #if defined(IEEE_Arith) # ifdef IEEE_Arith @@ -1040,17 +1042,22 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) i -= (Bias + (P - 1) - 1) + 1; denorm = 1; } + ds = (d2 - 1.5) * 0.289529654602168 + 0.1760912590558 + i * 0.301029995663981; k = (int)ds; if (ds < 0. && ds != k) - k--; /* want k = floor(ds) */ + { + k--; /* want k = floor(ds) */ + } k_check = 1; + if (k >= 0 && k <= Ten_pmax) { if (d < tens[k]) k--; k_check = 0; } + j = bbits - i - 1; if (j >= 0) { @@ -1062,6 +1069,7 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) b2 = -j; s2 = 0; } + if (k >= 0) { b5 = 0; @@ -1074,14 +1082,19 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) b5 = -k; s5 = 0; } + if (mode < 0 || mode > 9) - mode = 0; + { + mode = 0; + } + try_quick = 1; if (mode > 5) { mode -= 4; try_quick = 0; } + leftright = 1; switch (mode) { @@ -1091,14 +1104,19 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) i = 18; ndigits = 0; break; + case 2: leftright = 0; /* no break */ case 4: if (ndigits <= 0) - ndigits = 1; + { + ndigits = 1; + } + ilim = ilim1 = i = ndigits; break; + case 3: leftright = 0; /* no break */ @@ -1107,18 +1125,24 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) ilim = i; ilim1 = i - 1; if (i <= 0) - i = 1; + { + i = 1; + } } + j = sizeof(unsigned long); - for (result_k = 0; (signed)(sizeof(Bigint) - sizeof(unsigned long) + j) <= i; + for (result_k = 0; + (signed)(sizeof(Bigint) - sizeof(unsigned long) + j) <= i; j <<= 1) - result_k++; + { + result_k++; + } + result = Balloc(result_k); s = s0 = (char *)result; if (ilim >= 0 && ilim <= Quick_max && try_quick) { - /* Try to get by with floating-point arithmetic. */ i = 0; @@ -1126,10 +1150,12 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) k0 = k; ilim0 = ilim; ieps = 2; /* conservative */ + if (k > 0) { ds = tens[k & 0xf]; j = k >> 4; + if (j & Bletch) { /* prevent overflows */ @@ -1137,33 +1163,44 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) d /= bigtens[n_bigtens - 1]; ieps++; } + for (; j; j >>= 1, i++) - if (j & 1) - { - ieps++; - ds *= bigtens[i]; - } + { + if (j & 1) + { + ieps++; + ds *= bigtens[i]; + } + } + d /= ds; } else if ((j_1 = -k)) { d *= tens[j_1 & 0xf]; for (j = j_1 >> 4; j; j >>= 1, i++) - if (j & 1) - { - ieps++; - d *= bigtens[i]; - } + { + if (j & 1) + { + ieps++; + d *= bigtens[i]; + } + } } + if (k_check && d < 1. && ilim > 0) { if (ilim1 <= 0) - goto fast_failed; + { + goto fast_failed; + } + ilim = ilim1; k--; d *= 10.; ieps++; } + eps = ieps * d + 7.; word0(eps) -= (P - 1) * Exp_msk1; if (ilim == 0) @@ -1176,10 +1213,12 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) goto no_digits; goto fast_failed; } + #ifndef No_leftright if (leftright) { /* Use Steele & White method of only generating digits needed. */ + eps = 0.5 / tens[ilim - 1] - eps; for (i = 0;;) { @@ -1200,6 +1239,7 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) { #endif /* Generate ilim digits, then fix them up. */ + eps *= tens[ilim - 1]; for (i = 1;; i++, d *= 10.) { @@ -1234,6 +1274,7 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) if (be >= 0 && k <= Int_max) { /* Yes. */ + ds = tens[k]; if (ndigits < 0 && ilim <= 0) { @@ -1242,6 +1283,7 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) goto no_digits; goto one_digit; } + for (i = 1;; i++) { L = (int)(d / ds); @@ -1273,8 +1315,11 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) break; } if (!(d *= 10.)) - break; + { + break; + } } + goto ret1; } @@ -1304,10 +1349,12 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) i = 0; } } + b2 += i; s2 += i; mhi = i2b(1); } + if (m2 > 0 && s2 > 0) { i = m2 < s2 ? m2 : s2; @@ -1315,6 +1362,7 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) m2 -= i; s2 -= i; } + if (b5 > 0) { if (leftright) @@ -1330,11 +1378,16 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) b = pow5mult(b, j); } else - b = pow5mult(b, b5); + { + b = pow5mult(b, b5); + } } + S = i2b(1); if (s5 > 0) - S = pow5mult(S, s5); + { + S = pow5mult(S, s5); + } /* Check for special case that d is a normalized power of 2. */ @@ -1348,24 +1401,31 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) spec_case = 1; } else - spec_case = 0; + { + spec_case = 0; + } } - /* - * Arrange for convenient computation of quotients: shift left if + /* Arrange for convenient computation of quotients: shift left if * necessary so divisor has 4 leading 0 bits. * * Perhaps we should just compute leading 28 bits of S once and for all * and pass them and a shift to quorem, so it can do shifts and ors * to compute the numerator for q. */ + #ifdef Pack_32 if ((i = ((s5 ? 32 - hi0bits(S->x[S->wds - 1]) : 1) + s2) & 0x1f)) - i = 32 - i; + { + i = 32 - i; + } #else if ((i = ((s5 ? 32 - hi0bits(S->x[S->wds - 1]) : 1) + s2) & 0xf)) - i = 16 - i; + { + i = 16 - i; + } #endif + if (i > 4) { i -= 4; @@ -1380,10 +1440,17 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) m2 += i; s2 += i; } + if (b2 > 0) - b = lshift(b, b2); + { + b = lshift(b, b2); + } + if (s2 > 0) - S = lshift(S, s2); + { + S = lshift(S, s2); + } + if (k_check) { if (cmp(b, S) < 0) @@ -1391,10 +1458,14 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) k--; b = multadd(b, 10, 0); /* we botched the k estimate */ if (leftright) - mhi = multadd(mhi, 10, 0); + { + mhi = multadd(mhi, 10, 0); + } + ilim = ilim1; } } + if (ilim <= 0 && mode > 2) { if (ilim < 0 || cmp(b, S = multadd(S, 5, 0)) <= 0) @@ -1409,10 +1480,13 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) k++; goto ret; } + if (leftright) { if (m2 > 0) - mhi = lshift(mhi, m2); + { + mhi = lshift(mhi, m2); + } /* Compute mlo -- check for special case that d is a normalized power of * 2. */ @@ -1437,9 +1511,15 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) if (j_1 == 0 && !mode && !(word1(d) & 1)) { if (dig == '9') - goto round_9_up; + { + goto round_9_up; + } + if (j > 0) - dig++; + { + dig++; + } + *s++ = dig; goto ret; } @@ -1455,11 +1535,15 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) b = lshift(b, 1); j_1 = cmp(b, S); if ((j_1 > 0 || (j_1 == 0 && (dig & 1))) && dig++ == '9') - goto round_9_up; + { + goto round_9_up; + } } + *s++ = dig; goto ret; } + if (j_1 > 0) { if (dig == '9') @@ -1468,15 +1552,22 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) *s++ = '9'; goto roundoff; } + *s++ = dig + 1; goto ret; } + *s++ = dig; if (i == ilim) - break; + { + break; + } + b = multadd(b, 10, 0); if (mlo == mhi) - mlo = mhi = multadd(mhi, 10, 0); + { + mlo = mhi = multadd(mhi, 10, 0); + } else { mlo = multadd(mlo, 10, 0); @@ -1485,13 +1576,18 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) } } else - for (i = 1;; i++) - { - *s++ = dig = quorem(b, S) + '0'; - if (i >= ilim) - break; - b = multadd(b, 10, 0); - } + { + for (i = 1;; i++) + { + *s++ = dig = quorem(b, S) + '0'; + if (i >= ilim) + { + break; + } + + b = multadd(b, 10, 0); + } + } /* Round off last digit */ @@ -1514,12 +1610,16 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) while (*--s == '0'); s++; } + ret: Bfree(S); if (mhi) { if (mlo && mlo != mhi) - Bfree(mlo); + { + Bfree(mlo); + } + Bfree(mhi); } ret1: @@ -1529,9 +1629,13 @@ ret1: *s++ = '0'; k = 0; } + *s = 0; *decpt = k + 1; if (rve) - *rve = s; + { + *rve = s; + } + return s0; } diff --git a/nuttx/lib/stdio/lib_libdtoa.c b/nuttx/lib/stdio/lib_libdtoa.c index 3bfe70aeaf..b805d13a7e 100644 --- a/nuttx/lib/stdio/lib_libdtoa.c +++ b/nuttx/lib/stdio/lib_libdtoa.c @@ -136,7 +136,7 @@ static char* cvt(double value, int ndigits, int flags, char *sign, if (value == 0) { - /* kludge for __dtoa irregularity */ + /* kludge for __dtoa irregularity */ rve = bp; } @@ -333,7 +333,7 @@ static void lib_dtoa(FAR struct lib_outstream_s *obj, int ch, int prec, } else { - /* print the integer */ + /* Print the integer */ i = expt; while (i > 0) @@ -343,11 +343,11 @@ static void lib_dtoa(FAR struct lib_outstream_s *obj, int ch, int prec, cp++; } - /* print the decimal place */ + /* Print the decimal place */ obj->put(obj, '.'); - /* print the decimal */ + /* Print the decimal */ i = ndig - expt; while (i > 0) From 181f52600be57daf2fffec83303892123f3b351f Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 6 Aug 2012 02:14:36 +0000 Subject: [PATCH 04/13] Fix a floating point presentation error git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5012 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/ChangeLog | 5 + nuttx/TODO | 8 +- nuttx/lib/stdio/lib_libdtoa.c | 324 +++++++++++----------------------- 3 files changed, 111 insertions(+), 226 deletions(-) diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 6fd4979433..d57d9c4d87 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3125,3 +3125,8 @@ * lib/stdio/lib_libvsprintf.c: Fieldwidth and justification were not supported for the %s format. As a result, %s, %12s, and %-12s all produced the same output. + * lib/stdio/lib_libdtoa.c: Fix several issues with presenting floating + point numbers (conversions are fine, but presentation was bad). This + is a critical bug fix if you use printf or sprintf to deal with floating + point numbers. + diff --git a/nuttx/TODO b/nuttx/TODO index e2abce7f40..087977aee0 100644 --- a/nuttx/TODO +++ b/nuttx/TODO @@ -15,7 +15,7 @@ nuttx/ (5) Binary loaders (binfmt/) (17) Network (net/, drivers/net) (3) USB (drivers/usbdev, drivers/usbhost) - (9) Libraries (lib/) + (10) Libraries (lib/) (10) File system/Generic drivers (fs/, drivers/) (5) Graphics subystem (graphics/) (1) Pascal add-on (pcode/) @@ -685,6 +685,12 @@ o Libraries (lib/) Status: Open Priority: Low -- more of a roadmap + Title: FLOATING POINT FORMATS + Description: Only the %f floating point format is supported. Others are accepted + but treated like %f. + Status: Open + Priority: Medium (this might important to someone. + o File system / Generic drivers (fs/, drivers/) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/nuttx/lib/stdio/lib_libdtoa.c b/nuttx/lib/stdio/lib_libdtoa.c index b805d13a7e..2d4309abe5 100644 --- a/nuttx/lib/stdio/lib_libdtoa.c +++ b/nuttx/lib/stdio/lib_libdtoa.c @@ -48,7 +48,13 @@ * Pre-processor Definitions ****************************************************************************/ -#define MAXEXP 308 +#ifndef MIN +# define MIN(a,b) (a < b ? a : b) +#endif + +#ifndef MAX +# define MAX(a,b) (a > b ? a : b) +#endif /**************************************************************************** * Private Type Declarations @@ -58,10 +64,6 @@ * Private Function Prototypes ****************************************************************************/ -static char* cvt(double value, int ndigits, int flags, char *sign, - int *decpt, int ch, int *length); -static int exponent(char *p0, int exp, int fmtch); - /**************************************************************************** * Global Constant Data ****************************************************************************/ @@ -78,269 +80,123 @@ static int exponent(char *p0, int exp, int fmtch); * Private Variables ****************************************************************************/ +/**************************************************************************** + * Name: zeroes + * + * Description: + * Print the specified number of zeres + * + ****************************************************************************/ + +static void zeroes(FAR struct lib_outstream_s *obj, int nzeroes) +{ + int i; + + for (i = nzeroes; i > 0; i--) + { + obj->put(obj, '0'); + } +} + /**************************************************************************** * Private Functions ****************************************************************************/ -/**************************************************************************** - * Name: cvt - ****************************************************************************/ - -static char* cvt(double value, int ndigits, int flags, char *sign, - int *decpt, int ch, int *length) -{ - int mode, dsgn; - char *digits, *bp, *rve; - - if (ch == 'f') - { - mode = 3; /* ndigits after the decimal point */ - } - else - { - /* To obtain ndigits after the decimal point for the 'e' and 'E' - * formats, round to ndigits + 1 significant figures. - */ - - if (ch == 'e' || ch == 'E') - { - ndigits++; - } - mode = 2; /* ndigits significant digits */ - } - - if (value < 0) - { - value = -value; - *sign = '-'; - } - else - { - *sign = '\000'; - } - - digits = __dtoa(value, mode, ndigits, decpt, &dsgn, &rve); - if ((ch != 'g' && ch != 'G') || IS_ALTFORM(flags)) - { - /* Print trailing zeros */ - - bp = digits + ndigits; - if (ch == 'f') - { - if (*digits == '0' && value) - { - *decpt = -ndigits + 1; - } - bp += *decpt; - } - - if (value == 0) - { - /* kludge for __dtoa irregularity */ - - rve = bp; - } - - while (rve < bp) - { - *rve++ = '0'; - } - } - - *length = rve - digits; - return digits; -} - -/**************************************************************************** - * Name: exponent - ****************************************************************************/ - -static int exponent(FAR char *p0, int exp, int fmtch) -{ - FAR char *p; - FAR char *t; - char expbuf[MAXEXP]; - - p = p0; - *p++ = fmtch; - if (exp < 0) - { - exp = -exp; - *p++ = '-'; - } - else - { - *p++ = '+'; - } - - t = expbuf + MAXEXP; - if (exp > 9) - { - do - { - *--t = (exp % 10) + '0'; - } - while ((exp /= 10) > 9); - *--t = exp + '0'; - for (; t < expbuf + MAXEXP; *p++ = *t++); - } - else - { - *p++ = '0'; - *p++ = exp + '0'; - } - return (p - p0); -} - /**************************************************************************** * Name: lib_dtoa * * Description: * This is part of lib_vsprintf(). It handles the floating point formats. + * This version supports only the &f (with precision). * ****************************************************************************/ -static void lib_dtoa(FAR struct lib_outstream_s *obj, int ch, int prec, - uint8_t flags, double _double) +static void lib_dtoa(FAR struct lib_outstream_s *obj, int fmt, int prec, + uint8_t flags, double value) { - FAR char *cp; /* Handy char pointer (short term usage) */ - FAR char *cp_free = NULL; /* BIONIC: copy of cp to be freed after usage */ - char expstr[7]; /* Buffer for exponent string */ - char sign; /* Temporary negative sign for floats */ - int expt; /* Integer value of exponent */ - int expsize = 0; /* Character count for expstr */ - int ndig; /* Actual number of digits returned by cvt */ - int size; /* Size of converted field or string */ + FAR char *digits; /* String returned by __dtoa */ + FAR char *digalloc; /* Copy of digits to be freed after usage */ + FAR char *rve; /* Points to the end of the return value */ + char sign; /* Temporary negative sign for floats */ + int expt; /* Integer value of exponent */ + int numlen; /* Actual number of digits returned by cvt */ + int nchars; /* Number of characters to print */ + int dsgn; /* Unused sign indicator */ int i; - cp = cvt(_double, prec, flags, &sign, &expt, ch, &ndig); - cp_free = cp; + /* Non-zero... positive or negative */ - if (ch == 'g' || ch == 'G') + if (value < 0) { - /* 'g' or 'G' fmt */ - - if (expt <= -4 || expt > prec) - { - ch = (ch == 'g') ? 'e' : 'E'; - } - else - { - ch = 'g'; - } - } - - if (ch <= 'e') - { - /* 'e' or 'E' fmt */ - - --expt; - expsize = exponent(expstr, expt, ch); - size = expsize + ndig; - if (ndig > 1 || IS_ALTFORM(flags)) - { - ++size; - } - } - else if (ch == 'f') - { - /* f fmt */ - - if (expt > 0) - { - size = expt; - if (prec || IS_ALTFORM(flags)) - { - size += prec + 1; - } - } - else /* "0.X" */ - { - size = prec + 2; - } - } - else if (expt >= ndig) - { - /* fixed g fmt */ - - size = expt; - if (IS_ALTFORM(flags)) - { - ++size; - } + value = -value; + sign = '-'; } else { - size = ndig + (expt > 0 ? 1 : 2 - expt); + sign = '\0'; } + /* Perform the conversion */ + + digits = __dtoa(value, 3, prec, &expt, &dsgn, &rve); + digalloc = digits; + numlen = rve - digits; + if (sign) { obj->put(obj, '-'); } - if (_double == 0) + /* Always print at least one digit to the right of the decimal point. */ + + prec = MAX(1, prec); + + /* Special case exact zero or the case where the number is smaller than + * the print precision. + */ + + if (value == 0 || expt < -prec) { /* kludge for __dtoa irregularity */ obj->put(obj, '0'); - if (expt < ndig || IS_ALTFORM(flags)) - { - obj->put(obj, '.'); - - i = ndig - 1; - while (i > 0) - { - obj->put(obj, '0'); - i--; - } - } + obj->put(obj, '.'); } else if (expt <= 0) { obj->put(obj, '0'); obj->put(obj, '.'); - i = ndig; - while (i > 0) + /* Print leading zeros */ + + if (expt < 0) { - obj->put(obj, *cp); - i--; - cp++; + nchars = MIN(-expt, prec); + zeroes(obj, nchars); + prec -= nchars; } - } - else if (expt >= ndig) - { - i = ndig; - while (i > 0) + + /* Print the significant digits */ + + nchars = MIN(numlen, prec); + for (i = nchars; i > 0; i--) { - obj->put(obj, *cp); - i--; - cp++; + obj->put(obj, *digits); + digits++; } - i = expt - ndig; - while (i > 0) - { - obj->put(obj, '0'); - i--; - } + /* Decremnt to get the number of trailing zeroes to print */ - if (IS_ALTFORM(flags)) - { - obj->put(obj, '.'); - } + prec -= nchars; } else { - /* Print the integer */ + /* Print the integer part */ - i = expt; - while (i > 0) + for (i = expt; i > 0; i--) { - obj->put(obj, *cp); - i--; - cp++; + obj->put(obj, *digits); + digits++; } /* Print the decimal place */ @@ -349,14 +205,32 @@ static void lib_dtoa(FAR struct lib_outstream_s *obj, int ch, int prec, /* Print the decimal */ - i = ndig - expt; - while (i > 0) + numlen -= expt; + nchars = MIN(numlen, prec); + + for (i = nchars; i > 0; i--) { - obj->put(obj, *cp); - i--; - cp++; + obj->put(obj, *digits); + digits++; } + + /* Decremnt to get the number of trailing zeroes to print */ + + prec -= nchars; } + + /* Finally, print any trailing zeroes */ + + zeroes(obj, prec); + + /* Is this memory supposed to be freed or not? */ + +#if 0 + if (digalloc) + { + free(digalloc); + } +#endif } /**************************************************************************** From 722430d4d27063839de0be788c09c5068ce9070b Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 6 Aug 2012 14:38:47 +0000 Subject: [PATCH 05/13] Fix more floating point formatting bugs git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5013 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/ChangeLog | 2 + nuttx/lib/stdio/lib_libdtoa.c | 139 ++++++++++++++++++++++-------- nuttx/lib/stdio/lib_libvsprintf.c | 4 +- 3 files changed, 105 insertions(+), 40 deletions(-) diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index d57d9c4d87..603d2db97f 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3129,4 +3129,6 @@ point numbers (conversions are fine, but presentation was bad). This is a critical bug fix if you use printf or sprintf to deal with floating point numbers. + * lib/stdio/lib_libdtoa.c and lib_libvsprintf.c: Correct some floating + point options. diff --git a/nuttx/lib/stdio/lib_libdtoa.c b/nuttx/lib/stdio/lib_libdtoa.c index 2d4309abe5..77045d9b0b 100644 --- a/nuttx/lib/stdio/lib_libdtoa.c +++ b/nuttx/lib/stdio/lib_libdtoa.c @@ -48,6 +48,8 @@ * Pre-processor Definitions ****************************************************************************/ +#define MAX_PREC 16 + #ifndef MIN # define MIN(a,b) (a < b ? a : b) #endif @@ -107,7 +109,20 @@ static void zeroes(FAR struct lib_outstream_s *obj, int nzeroes) * * Description: * This is part of lib_vsprintf(). It handles the floating point formats. - * This version supports only the &f (with precision). + * This version supports only the %f (with precision). If no precision + * was provided in the format, this will use precision == 0 which is + * probably not what you want. + * + * Input Parameters: + * obj - The output stream object + * fmt - The format character. Not used 'f' is always assumed + * prec - The number of digits to the right of the decimal point. If no + * precision is provided in the format, this will be zero. And, + * unfortunately in this case, it will be treated literally as + * a precision of zero. + * flags - Only ALTFORM and SHOWPLUS flags are supported. ALTFORM only + * applies if prec == 0 which is not supported anyway. + * value - The floating point value to convert. * ****************************************************************************/ @@ -146,10 +161,10 @@ static void lib_dtoa(FAR struct lib_outstream_s *obj, int fmt, int prec, { obj->put(obj, '-'); } - - /* Always print at least one digit to the right of the decimal point. */ - - prec = MAX(1, prec); + else if (IS_SHOWPLUS(flags)) + { + obj->put(obj, '+'); + } /* Special case exact zero or the case where the number is smaller than * the print precision. @@ -160,53 +175,101 @@ static void lib_dtoa(FAR struct lib_outstream_s *obj, int fmt, int prec, /* kludge for __dtoa irregularity */ obj->put(obj, '0'); - obj->put(obj, '.'); - } - else if (expt <= 0) - { - obj->put(obj, '0'); - obj->put(obj, '.'); - /* Print leading zeros */ + /* A decimal point is printed only in the alternate form or if a + * particular precision is requested. + */ - if (expt < 0) + if (prec > 0 || IS_ALTFORM(flags)) { - nchars = MIN(-expt, prec); - zeroes(obj, nchars); - prec -= nchars; + obj->put(obj, '.'); + + /* Always print at least one digit to the right of the decimal point. */ + + prec = MAX(1, prec); } - - /* Print the significant digits */ - - nchars = MIN(numlen, prec); - for (i = nchars; i > 0; i--) - { - obj->put(obj, *digits); - digits++; - } - - /* Decremnt to get the number of trailing zeroes to print */ - - prec -= nchars; } + + /* A non-zero value will be printed */ + else { - /* Print the integer part */ - for (i = expt; i > 0; i--) + /* Handle the case where the value is less than 1.0 (in magnitude) and + * will need a leading zero. + */ + + if (expt <= 0) { - obj->put(obj, *digits); - digits++; + /* Print a single zero to the left of the decimal point */ + + obj->put(obj, '0'); + + /* Print the decimal point */ + + obj->put(obj, '.'); + + /* Print any leading zeros to the right of the decimal point */ + + if (expt < 0) + { + nchars = MIN(-expt, prec); + zeroes(obj, nchars); + prec -= nchars; + } } - /* Print the decimal place */ + /* Handle the general case where the value is greater than 1.0 (in + * magnitude). + */ - obj->put(obj, '.'); + else + { + /* Print the integer part to the left of the decimal point */ - /* Print the decimal */ + for (i = expt; i > 0; i--) + { + obj->put(obj, *digits); + digits++; + } - numlen -= expt; - nchars = MIN(numlen, prec); + /* Get the length of the fractional part */ + + numlen -= expt; + + /* If there is no fractional part, then a decimal point is printed + * only in the alternate form or if a particular precision is + * requested. + */ + + if (numlen > 0 || prec > 0 || IS_ALTFORM(flags)) + { + /* Print the decimal point */ + + obj->put(obj, '.'); + + /* Always print at least one digit to the right of the decimal + * point. + */ + + prec = MAX(1, prec); + } + } + + /* If a precision was specified, then limit the number digits to the + * right of the decimal point. + */ + + if (prec > 0) + { + nchars = MIN(numlen, prec); + } + else + { + nchars = numlen; + } + + /* Print the fractional part to the right of the decimal point */ for (i = nchars; i > 0; i--) { diff --git a/nuttx/lib/stdio/lib_libvsprintf.c b/nuttx/lib/stdio/lib_libvsprintf.c index 1fb0376a9a..2bf0958808 100644 --- a/nuttx/lib/stdio/lib_libvsprintf.c +++ b/nuttx/lib/stdio/lib_libvsprintf.c @@ -1587,7 +1587,7 @@ int lib_vsprintf(FAR struct lib_outstream_s *obj, FAR const char *src, va_list a /* Perform left field justification actions */ - prejustify(obj, fmt, flags, width, dblsize); + prejustify(obj, fmt, 0, width, dblsize); /* Output the number */ @@ -1595,7 +1595,7 @@ int lib_vsprintf(FAR struct lib_outstream_s *obj, FAR const char *src, va_list a /* Perform right field justification actions */ - postjustify(obj, fmt, flags, width, dblsize); + postjustify(obj, fmt, 0, width, dblsize); #else /* Output the number with a fixed precision */ From 756fc3f2db435855a76535c9863ad5d5d197b9dc Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 6 Aug 2012 17:59:41 +0000 Subject: [PATCH 06/13] Misc updates (minor) git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5014 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/Documentation/NXGraphicsSubsystem.html | 2 +- nuttx/Documentation/NuttXNxFlat.html | 3 ++- nuttx/TODO | 11 +++++++++-- nuttx/lib/stdio/lib_libdtoa.c | 9 ++------- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/nuttx/Documentation/NXGraphicsSubsystem.html b/nuttx/Documentation/NXGraphicsSubsystem.html index 4408de6cf2..6c72771bc5 100644 --- a/nuttx/Documentation/NXGraphicsSubsystem.html +++ b/nuttx/Documentation/NXGraphicsSubsystem.html @@ -255,7 +255,7 @@
  • Virtual Vertical Graphics Space. Windows that reside in a virtual, vertical space so that it makes - sense to talk about one window being on top of another and obcuring the + sense to talk about one window being on top of another and obscuring the window below it.
  • Client/Server Model. diff --git a/nuttx/Documentation/NuttXNxFlat.html b/nuttx/Documentation/NuttXNxFlat.html index 3a59397871..e6923a8bcb 100644 --- a/nuttx/Documentation/NuttXNxFlat.html +++ b/nuttx/Documentation/NuttXNxFlat.html @@ -143,7 +143,8 @@ This feature is especially attractive when combined with the NuttX ROMFS support: ROMFS allows you to execute programs in place (XIP) in flash without copying anything other than the .data section to RAM. - In fact, the initial NXFLAT release will work only on ROMFS. + In fact, the initial NXFLAT release only worked on ROMFS. + Later extensions also support execution NXFLAT binaries from an SRAM copy as well.

    This NuttX feature includes: diff --git a/nuttx/TODO b/nuttx/TODO index 087977aee0..2745452395 100644 --- a/nuttx/TODO +++ b/nuttx/TODO @@ -15,7 +15,7 @@ nuttx/ (5) Binary loaders (binfmt/) (17) Network (net/, drivers/net) (3) USB (drivers/usbdev, drivers/usbhost) - (10) Libraries (lib/) + (11) Libraries (lib/) (10) File system/Generic drivers (fs/, drivers/) (5) Graphics subystem (graphics/) (1) Pascal add-on (pcode/) @@ -689,7 +689,14 @@ o Libraries (lib/) Description: Only the %f floating point format is supported. Others are accepted but treated like %f. Status: Open - Priority: Medium (this might important to someone. + Priority: Medium (this might important to someone). + + Title: FLOATING POINT PRECISION + Description: A fieldwidth and precision is required with the %f format. If %f + is used with no format, than floating numbers will be printed with + a precision of 0 (effectively presented as integers). + Status: Open + Priority: Medium (this might important to someone). o File system / Generic drivers (fs/, drivers/) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/nuttx/lib/stdio/lib_libdtoa.c b/nuttx/lib/stdio/lib_libdtoa.c index 77045d9b0b..1e022a8ebe 100644 --- a/nuttx/lib/stdio/lib_libdtoa.c +++ b/nuttx/lib/stdio/lib_libdtoa.c @@ -132,7 +132,6 @@ static void lib_dtoa(FAR struct lib_outstream_s *obj, int fmt, int prec, FAR char *digits; /* String returned by __dtoa */ FAR char *digalloc; /* Copy of digits to be freed after usage */ FAR char *rve; /* Points to the end of the return value */ - char sign; /* Temporary negative sign for floats */ int expt; /* Integer value of exponent */ int numlen; /* Actual number of digits returned by cvt */ int nchars; /* Number of characters to print */ @@ -144,11 +143,7 @@ static void lib_dtoa(FAR struct lib_outstream_s *obj, int fmt, int prec, if (value < 0) { value = -value; - sign = '-'; - } - else - { - sign = '\0'; + SET_NEGATE(flags); } /* Perform the conversion */ @@ -157,7 +152,7 @@ static void lib_dtoa(FAR struct lib_outstream_s *obj, int fmt, int prec, digalloc = digits; numlen = rve - digits; - if (sign) + if (IS_NEGATE(flags)) { obj->put(obj, '-'); } From ed303232fa84efe26f95a86e671995cfb712f321 Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 7 Aug 2012 20:18:56 +0000 Subject: [PATCH 07/13] Update documentation to describe customization of NSH; Add the framework for a LPC43xx USB0 driver (not functional) git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5015 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/ChangeLog | 7 + nuttx/Documentation/NuttShell.html | 901 ++++++- nuttx/Documentation/NuttX.html | 14 +- nuttx/TODO | 25 +- nuttx/arch/arm/src/lpc43xx/Make.defs | 7 + nuttx/arch/arm/src/lpc43xx/lpc43_usb0dev.c | 2663 ++++++++++++++++++++ 6 files changed, 3599 insertions(+), 18 deletions(-) create mode 100644 nuttx/arch/arm/src/lpc43xx/lpc43_usb0dev.c diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 603d2db97f..614381c900 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3131,4 +3131,11 @@ point numbers. * lib/stdio/lib_libdtoa.c and lib_libvsprintf.c: Correct some floating point options. + * arch/arm/lpc43xx/lpc32_usb0dev.c: Add framework for development of + an USB0, device-side driver for the LPC43XX. The initial check-in, + however, is simply for the LPC31xx driver with name changes. The + LPC31xx has the same USB IP, but will require some additional initialization + (and lots of testing) before it can be used with the LPC43xx. + * nuttx/Documentation/NuttShell.html: Added a section covering ways to + customize the behavior or NSH. diff --git a/nuttx/Documentation/NuttShell.html b/nuttx/Documentation/NuttShell.html index 0413a46956..a92cbadd8e 100644 --- a/nuttx/Documentation/NuttShell.html +++ b/nuttx/Documentation/NuttShell.html @@ -332,6 +332,36 @@ 3.2 NSH-Specific Configuration Settings + + + + 4.0 Customimizing the NuttShell + + + +
    + + 4.1 The NSH Library and NSH Initialization + + + +
    + + 4.2 NSH Commands + + + +
    + + 4.3 NSH "Built-In" Applications + + + +
    + + 4.4 Customizing NSH Initialization + + @@ -655,6 +685,11 @@ mount -t vfat /dev/ram1 /tmp file system image.

    +

    + Further Information. + See the section on Customimizing the NuttShell for additional, more detailed information about the NSH start-up script and how to modify it. +

    +
    @@ -2644,6 +2679,816 @@ nsh>
    + + + + +
    +

    4.0 Customimizing the NuttShell

    +
    + +

    + Overview. + The NuttShell (NSH) is a simple shell application that may be used with NuttX. + It supports a variety of commands and is (very) loosely based on the bash shell and the common utilities used in Unix shell programming. + The paragraphs in this appendix will focus on customizing NSH: Adding new commands, changing the initialization sequence, etc. +

    + + + + + +
    +

    4.1 The NSH Library and NSH Initialization

    +
    + +

    + Overview. + NSH is implemented as a library that can be found at apps/nshlib. + As a library, it can be custom built into any application that follows the NSH initialization sequence described below. + As an example, the code at apps/examples/nsh/nsh_main.c illustrates how to start NSH and the logic there was intended to be incorporated into your own custom code. + Although code was generated simply as an example, in the end most people just use this example code as their application main() function. + That initialization performed by that example is discussed in the following paragraphs. +

    + +

    4.1.1 NSH Initialization sequence

    + +

    + The NSH start-up sequence is very simple. + As an example, the code at apps/examples/nsh/nsh_main.c illustrates how to start NSH. + It simple does the following: +

    + +
      +
    1. +

      + If you have C++ static initializers, it will call your implementation of up_cxxinitialize() which will, in turn, call those static initializers. + For the case of the STM3240G-EVAL board, the implementation of up_cxxinitialize() can be found at nuttx/configs/stm3240g-eval/src/up_cxxinitialize.c. +

      +
    2. +

      + This function then calls nsh_initialize() which initializes the NSH library. + nsh_initialize() is described in more detail below. +

      +
    3. +

      + If the Telnetconsole is enabled, it calls nsh_telnetstart() which resides in the NSH library. + nsh_telnetstart() will start the Telnet daemon that will listen for Telnet connections and start remote NSH sessions. +

      +
    4. +

      + If a local console is enabled (probably on a serial port), then nsh_consolemain() is called. + nsh_consolemain() also resides in the NSH library. + nsh_consolemain() does not return so that finished the entire NSH initialization sequence. +

      +
    + +

    4.1.2 nsh_initialize()

    + +

    + The NSH initialization function, nsh_initialize(), be found in apps/nshlib/nsh_init.c. + It does only three things: +

    + +
      +
    1. +

      + nsh_romfsetc(): + If so configured, it executes an NSH start-up script that can be found at /etc/init.d/rcS in the target file system. + The nsh_romfsetc() function can be found in apps/nshlib/nsh_romfsetc.c. + This function will (1) register a ROMFS file system, then (2) mount the ROMFS file system. + /etc is the default location where a read-only, ROMFS file system is mounted by nsh_romfsetc(). +

      +

      + The ROMFS image is, itself, just built into the firmware. + By default, this rcS start-up script contains the following logic: +

      +
        +# Create a RAMDISK and mount it at XXXRDMOUNTPOUNTXXX
        +
        +mkrd -m XXXMKRDMINORXXX -s XXMKRDSECTORSIZEXXX XXMKRDBLOCKSXXX
        +mkfatfs /dev/ramXXXMKRDMINORXXX
        +mount -t vfat /dev/ramXXXMKRDMINORXXX XXXRDMOUNTPOUNTXXX
        +
      + +

      + Where the XXXX*XXXX strings get replaced in the template when the ROMFS image is created: +

      +
        +
      • +

        + XXXMKRDMINORXXX will become the RAM device minor number. + Default: 0 +

        +
      • +

        + XXMKRDSECTORSIZEXXX will become the RAM device sector size +

        +
      • +

        + XXMKRDBLOCKSXXX will become the number of sectors in the device. +

        +
      • +

        + XXXRDMOUNTPOUNTXXX will become the configured mount point. + Default: /etc +

        +
      +

      + By default, the substituted values would yield an rcS file like: +

      +
        +# Create a RAMDISK and mount it at /tmp
        +
        +mkrd -m 1 -s 512 1024
        +mkfatfs /dev/ram1
        +mount -t vfat /dev/ram1 /tmp
        +
      +

      + This script will, then: +

      +
        +
      • +

        + Create a RAMDISK of size 512*1024 bytes at /dev/ram1, +

        +
      • +

        + Format a FAT file system on the RAM disk at /dev/ram1, and then +

        +
      • +

        + Mount the FAT filesystem at a configured mountpoint, /tmp. +

        +
      +

      + This rcS template file can be found at apps/nshlib/rcS.template. + The resulting ROMFS file system can be found in apps/nshlib/nsh_romfsimg.h. +

      +
    2. +

      + nsh_archinitialize(): + Next any architecture-specific NSH initialization will be performed (if any). + For the STM3240G-EVAL, this architecture specific initialization can be found at configs/stm3240g-eval/src/up_nsh.c. + This it does things like: (1) Initialize SPI devices, (2) Initialize SDIO, and (3) mount any SD cards that may be inserted. +

      +
    3. +

      + nsh_netinit(): + The nsh_netinit() function can be found in apps/nshlib/nsh_netinit.c. +

      +
    + + + + + +
    +

    4.2 NSH Commands

    +
    + +

    + Overview. + NSH supports a variety of commands as part of the NSH program. + All of the NSH commands are listed in the NSH documentation above. + Not all of these commands may be available at any time, however. + Many commands depend upon certain NuttX configuration options. + You can enter the help command at the NSH prompt to see the commands actual available: +

    +
      +nsh> help
      +
    +

    + For example, if network support is disabled, then all network-related commands will be missing from the list of commands presented by 'nsh> help'. + You can see the specific command dependencies in the table above. +

    + +

    4.2.1 Adding New NSH Commands

    + +

    + New commands can be added to the NSH very easily. + You simply need to add two things: +

    +
      +
    1. +

      + The implementation of your command, and +

      +
    2. +

      + A new entry in the NSH command table +

      +
    + +

    + Implementation of Your Command. + For example, if you want to add a new a new command called mycmd to NSH, you would first implement the mycmd code in a function with this prototype: +

    + +
      +int cmd_mycmd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +
    + +

    + The argc and argv are used to pass command line arguments to the NSH command. + Command line parameters are passed in a very standard way: argv[0] will be the name of the command, and argv[1] through argv[argc-1] are the additional arguments provided on the NSH command line. +

    +

    + The first parameter, vtbl, is special. + This is a pointer to session-specific state information. + You don't need to know the contents of the state information, but you do need to pass this vtbl argument when you interact with the NSH logic. + The only use you will need to make of the vtbl argument will be for outputting data to the console. + You don't use printf() within NSH commands. + Instead you would use: +

    +
      +void nsh_output(FAR struct nsh_vtbl_s *vtbl, const char *fmt, …);
      +
    +

    + So if you only wanted to output "Hello, World!" on the console, then your whole command implementation might be: +

    +
      +int cmd_mycmd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
      +{
      +  nsh_output(vtbl, "e;Hello, World!"e;);
      +  return 0;
      +}
      +
    +

    + The prototype for the new command should be placed in apps/examples/nshlib/nsh.h>. +

    + +

    + Adding You Command to the NSH Command Table. + All of the commands support by NSH appear in a single table called: +

    +
      +const struct cmdmap_s g_cmdmap[]
      +
    +

    + That table can be found in the file apps/examples/nshlib/nsh_parse.c. + The structure cmdmap_s is also defined in apps/nshlib/nsh_parse.c: +

    +
      +struct cmdmap_s
      +{
      +  const char *cmd;        /* Name of the command */
      +  cmd_t       handler;    /* Function that handles the command */
      +  uint8_t     minargs;    /* Minimum number of arguments (including command) */
      +  uint8_t     maxargs;    /* Maximum number of arguments (including command) */
      +  const char *usage;      /* Usage instructions for 'help' command */
      +};
      +
    +

    + This structure provides everything that you need to describe your command: + Its name (cmd), the function that handles the command (cmd_mycmd()), the minimum and maximum number of arguments needed by the command, + and a string describing the command line arguments. + That last string is what is printed when enter "nsh> help". +

    +

    + So, for you sample commnd, you would add the following the to the g_cmdmap[] table: +

    +
      +{ "mycmd", cmd_mycmd, 1, 1, NULL },
      +
    + +

    + This entry is particularly simply because mycmd is so simple. + Look at the other commands in g_cmdmap[] for more complex examples. +

    + + + + + +
    +

    4.3 NSH "Built-In" Applications

    +
    + +

    + Overview. + In addition to these commands that are a part of NSH, external programs can also be executed as NSH commands. + These external programs are called "Built-In" Applications for historic reasons. + That terminology is somewhat confusing because the actual NSH commands as described above are truly "built-into" NSH whereas these applications are really external to NuttX. +

    +

    + These applications are built-into NSH in the sense that they can be executed by simply typing the name of the application at the NSH prompt. + Built-in application support is enabled with the configuration option CONFIG_NSH_BUILTIN_APPS. + When this configuration option is set, you will also be able to see the built-in applications if you enter "nsh> help". + They will appear at the bottom of the list of NSH commands under: +

    + +
      +Builtin Apps:
      +
    +

    + Note that no detailed help information beyond the name of the built-in application is provided. +

    + +

    4.3.1 Named Applications

    + +

    + Overview. + The underlying logic that supports the NSH built-in applications is called "Named Applications". + The named application logic can be found at apps/namedapp. + This logic simply does the following: +

    + +
      +
    1. +

      + It supports registration mechanism so that named applications can dynamically register themselves at build time, and +

      +
    2. +

      + Utility functions to look up, list, and execute the named applications. +

      +
    + +

    + Named Application Utility Functions. + The utility functions exported by the named application logic are prototyped in apps/include/apps.h. + These utility functions include: +

    + +
      +
    • +

      + int namedapp_isavail(FAR const char *appname); + Checks for availability of application registered as appname during build time. +

      +
    • +

      + const char *namedapp_getname(int index); + Returns a pointer to a name of built-in application pointed by the index. + This is the utility function that is used by NSH in order to list the available built-in applications when "nsh> help" is entered. +

      +
    • +

      + int exec_namedapp(FAR const char *appname, FAR const char **argv); + Executes built-in named application registered during compile time. + This is the utility function used by NSH to execute the built-in application. +

      +
    + +

    + Autogenerated Header Files. + Application entry points with their requirements are gathered together in two files when NuttX is first built: +

    +
      +
    1. +

      + apps/namedapp/namedapp_proto.h: + Prototypes of application task entry points. +

      +
    2. +

      + apps/namedapp/namedapp_list.h: + Application specific information and start-up requirements +

      +
    + +

    + Registration of Named Applications. + The NuttX build occurs in several phases as different build targets are executed: + (1) context when the configuration is established, + (2) depend when target dependencies are generated, and + (3) default (all) when the normal compilation and link operations are performed. + Named application information is collected during the make context build phase. +

    + +

    + An example application that can be "built-in" is be found in the apps/examples/hello directory. + Let's walk through this specific cause to illustrate the general way that built-in applications are created and how they register themselves so that they can be used from NSH. +

    + +

    + apps/examples/hello. + The main routine for apps/examples/hello can be found in apps/examples/hello/main.c. + When CONFIG_EXAMPLES_HELLO_BUILTIN is defined, this main routine simplifies to: +

    +
      +int hello_main(int argc, char *argv[])
      +{
      +  printf("Hello, World!!\n");
      +  return 0;
      +}
      +
    + +

    + This is the built in function that will be registered during the context build phase of the NuttX build. + That registration is performed by logic in apps/examples/hello/Makefile. + But the build system gets to that logic through a rather tortuous path: +

    + +
      +
    1. +

      + The top-level context make target is in nuttx/Makefile. + All build targets depend upon the context build target. + For the apps/ directory, this build target will execute the context target in the apps/Makefile. +

      +
    2. +

      + The apps/Makefile will, in turn, execute the context targets in all of the configured sub-directories. + In our case will include the Makefile in apps/examples. +

      +
    3. +

      + And finally, the apps/examples/Makefilewill execute the context target in all configured examplesub-directores, getting us finally to apps/examples/Makefile (which is covered below).

      +
    4. +

      + At the conclusion of the context phase, the apps/Makefile will touch a file called .context in the apps/ directory, preventing any further configurations during any subsequent context phase build attempts. +

      +
    + +

    + NOTE: + Since this context build phase can only be executed one time, any subsequent configuration changes that you make will, then, not be reflected in the build sequence. + That is a common area of confusion. + Before you can instantiate the new configuration, you have to first get rid of the old configuration. + The most drastic way to this is: +

    +
      +make distclean
      +
    +

    + But then you will have to re-configuration NuttX from scratch. + But if you only want to re-build the configuration in the apps/ sub-directory, then there is a less labor-intensive way to do that. + The following NuttX make command will remove the configuration only from the apps/ directory and will let you continue without re-configuring everything: +

    +
      +make apps_distclean
      +
    + +

    + Logic for the context target in apps/examples/hello/Makefile registers the hello_main() application in the namedapp's namedapp_proto.hand namedapp_list.h files. + That logic that does that in apps/examples/hello/Makefile is abstracted below: +

    +
      +
    1. +

      + First, the Makefile includes apps/Make.defs: +

      +
        +include $(APPDIR)/Make.defs
        +
      +

      + This defines a macro called REGISTER that adds data to the namedapp header files: +

      +
        +define REGISTER
        +    @echo "Register: $1"
        +    @echo "{ \"$1\", $2, $3, $4 }," >> "$(APPDIR)/namedapp/namedapp_list.h"
        +    @echo "EXTERN int $4(int argc, char *argv[]);" >> "$(APPDIR)/namedapp/namedapp_proto.h"
        +endef
        +
      +

      + When this macro runs, you will see the output in the build "Register: hello", that is a sure sign that the registration was successful. +

      +
    2. +

      + The make file then defines the application name (hello), the task priority (default), and the stack size that will be allocated in the task runs (2Kb). +

      +
        +APPNAME         = hello
        +PRIORITY        = SCHED_PRIORITY_DEFAULT
        +STACKSIZE       = 2048
        +
      + +
    3. +

      + And finally, the Makefile invokes the REGISTER macro to added the hello_main() named application. + Then, when the system build completes, the hello command can be executed from the NSH command line. + When the hello command is executed, it will start the task with entry point hello_main() with the default priority and with a stack size of 2Kb. +

      +
        +.context:
        +ifeq ($(CONFIG_EXAMPLES_HELLO_BUILTIN),y)
        +  $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
        +  @touch $@
        +endif
        +
      +
    + +

    + Other Uses of Named Application. + The primary purpose of named applications is to support command line execution of applications from NSH. + However, there are two other uses of named applications that should be mentioned. +

    + +
      +
    1. +

      + Named Application Start-Up main() function. + A named application can even be used as the main, start-up entry point into your embedded software. + When the user defines this option in the NuttX configuration file: +

      +
        +CONFIG_BUILTIN_APP_START=<application name>
        +
      +

      + that application will be invoked immediately after system starts instead of the normal, default user_start() entry point. + Note that <application name> must be provided just as it would have been on the NSH command line. + For example, hello would result in hello_main() being started at power-up. +

      +

      + This option might be useful in some develop environments where you use NSH only during the debug phase, but want to eliminate NSH in the final product. + Setting CONFIG_BUILTIN_APP_START in this way will bypass NSH and execute your application just as if it were entered from the NSH command line. +

      + +
    2. +

      binfs. + binfs is a tiny file system located at apps/namedapp/binfs.c. + This provides an alternative what of visualizing installed named applications. + Without binfs, you can see the installed named applications using the NSH help command. + binfs will create a tiny pseudo-file system mounted at /bin. + Using binfs, you can see the available named applications by listing the contents of /bin directory. + This gives some superficial Unix compatibility, but does not really add any new functionality. +

      +
    + +

    4.3.2 Synchronous Built-In Applications

    + +

    + By default, built-in commands started from the NSH command line will run asynchronously with NSH. + If you want to force NSH to execute commands then wait for the command to execute, you can enable that feature by adding the following to the NuttX configuration file: +

    +
      +CONFIG_SCHED_WAITPID=y
      +
    +

    + This configuration option enables support for the standard waitpid() RTOS interface. + When that interface is enabled, NSH will use it to wait, sleeping until the built-in application executes to completion. +

    +

    + Of course, even with CONFIG_SCHED_WAITPID=y defined, specific applications can still be forced to run asynchronously by adding the ampersand (&) after the NSH command. +

    + +

    4.3.3 Application Configuration File

    + +

    + The appconfig File. + A special configuration file is used to configure which applications are to be included in the build. + The source for this file is saved at configs/<board>/<configuration>/appconfig. + The existence of the appconfig file in the board configuration directory is sufficient to enable building of applications. +

    + +

    + The appconfig file is copied into the apps/ directory as .config when NuttX is configured. + .config is included by the top-level apps/Makefile. + As a minimum, this configuration file must define files to add to the CONFIGURED_APPS list like: +

    +
      +CONFIGURED_APPS += examples/hello
      +
    + +

    + Changes in the Works. + There are changes in the works that will obsolete the appconfig file. + These changes will implement an automated configuration system for NuttX. + One consequence of this new configuration system is that the appconfig file will become obsolete and will be replaced by a new mechanism for selecting applications. + This new mechanism is not yet available, but is dicussed here: http://tech.groups.yahoo.com/group/nuttx/message/1604. +

    + + + + + +
    +

    4.4 Customizing NSH Initialization

    +
    + +

    + Ways to Customize NSH Initialization. + There are three ways to customize the NSH start-up behavior. + Here they are presented in order of increasing difficulty: +

    + +
      +
    1. +

      + You can extend the initialization logic in configs/stm3240g-eval/src/up_nsh.c. + The logic there is called each time that NSH is started and is good place in particular for any device-related initialization. +

      +
    2. +

      + You replace the sample code at apps/examples/nsh/nsh_main.c with whatever start-up logic that you want. + NSH is a library at apps/nshlib. + apps.examplex/nsh is just a tiny, example start-up function (user_start()) that that runs immediately and illustrates how to start NSH + If you want something else to run immediately then you can write your write your own custom user_start() function and then start other tasks from your custom user_start(). +

      +
    3. +

      + NSH also supports a start-up script that executed when NSH first runs. + This mechanism has the advantage that the start-up script can contain any NSH commands and so can do a lot of work with very little coding. + The disadvantage is that is is considerably more complex to create the start-up script. + It is sufficiently complex that is deserves its own paragraph +

      +
    + +

    4.4.1 NuttShell Start up Scripts

    + +

    + First of all you should look at NSH Start-Up Script paragraph. + Most everything you need to know can be found there. + That information will be repeated and extended here for completeness. +

    + +

    + NSH Start-Up Script. + NSH supports options to provide a start up script for NSH. + The start-up script contains any command support by NSH (i.e., that you see when you enter 'nsh> help'). + In general this capability is enabled with CONFIG_NSH_ROMFSETC=y, but has several other related configuration options as described with the NSH-specific configuration settings paragraph. + This capability also depends on: +

    + +
      +
    • +

      + CONFIG_DISABLE_MOUNTPOINT=n. + If mount point support is disabled, then you cannot mount any file systems. +

      +
    • +

      + CONFIG_NFILE_DESCRIPTORS > 4. + Of course you have to have file descriptions to use any thing in the file system. +

      +
    • +

      + CONFIG_FS_ROMFS enabled. + This option enables ROMFS file system support. +

      +
    + +

    + Default Start-Up Behavior. + The implementation that is provided is intended to provide great flexibility for the use of Start-Up files. + This paragraph will discuss the general behavior when all of the configuration options are set to the default values. +

    +

    + In this default case, enabling CONFIG_NSH_ROMFSETC will cause NSH to behave as follows at NSH start-up time: +

    +
      +
    • +

      + NSH will create a read-only RAM disk (a ROM disk), containing a tiny ROMFS filesystem containing the following: +

      +
        +`--init.d/
        +    `-- rcS
        +
      +

      + Where rcS is the NSH start-up script. +

      +
    • +

      + NSH will then mount the ROMFS filesystem at /etc, resulting in: +

      +
        +|--dev/
        +|   `-- ram0
        +`--etc/
        +    `--init.d/
        +        `-- rcS
        +
      +
    • +

      + By default, the contents of rcS script are: +

      +
        +# Create a RAMDISK and mount it at /tmp
        +
        +mkrd -m 1 -s 512 1024
        +mkfatfs /dev/ram1
        +mount -t vfat /dev/ram1 /tmp
        +
      +
    • +

      + NSH will execute the script at /etc/init.d/rcS at start-up (before the first NSH prompt). + After execution of the script, the root FS will look like: +

      +
        +|--dev/
        +|   |-- ram0
        +|   `-- ram1
        +|--etc/
        +|   `--init.d/
        +|       `-- rcS
        +`--tmp/
        +
      +
    + +

    + Example Configurations. + Here are some configurations that have CONFIG_NSH_ROMFSETC=y in the NuttX configuration file. + They might provide useful examples: +

    +
      + configs/hymini-stm32v/nsh2
      + configs/ntosd-dm320/nsh
      + configs/sim/nsh
      + configs/sim/nsh2
      + configs/sim/nx
      + configs/sim/nx11
      + configs/sim/touchscreen
      + configs/vsn/nsh
      +
    +

    + In most of these cases, the configuration sets up the default /etc/init.d/rcS script. + The default script is here: apps/nshlib/rcS.template. + (The funny values in the template like XXXMKRDMINORXXX get replaced via sed at build time). + This default configuration creates a ramdisk and mounts it at /tmp as discussed above. +

    +

    + If that default behavior is not what you want, then you can provide your own custom rcS script by defining CONFIG_NSH_ARCHROMFS=y in the configuration file. + The only example that uses a custom /etc/init.d/rcS file in the NuttX source tree is this one: configs/vsn/nsh. + The configs/vsn/nsh/defconfig file also has this definition: +

    +
      CONFIG_NSH_ARCHROMFS=y -- Support an architecture specific ROMFS file.
    + +

    + Modifying the ROMFS Image. + The contents of the /etc directory are retained in the file apps/nshlib/nsh_romfsimg.h OR, if CONFIG_NSH_ARCHROMFS is defined, include/arch/board/rcs.template. + In order to modify the start-up behavior, there are three things to study: +

    + +
      +
    1. +

      + Configuration Options. + The additional CONFIG_NSH_ROMFSETC configuration options discussed with the other NSH-specific configuration settings. +

      +
    2. +

      + tools/mkromfsimg.sh Script. + The script tools/mkromfsimg.sh creates nsh_romfsimg.h. + It is not automatically executed. + If you want to change the configuration settings associated with creating and mounting the /tmp directory, then it will be necessary to re-generate this header file using the tools/mkromfsimg.sh script. +

      +

      + The behavior of this script depends upon several things: +

      +
        +
      1. +

        + The configuration settings then installed configuration. +

        +
      2. +

        + The genromfs tool(available from http://romfs.sourceforge.net) or included within the NuttX buildroot toolchain. + There is a snapshot here: misc/tools/genromfs-0.5.2.tar.gz. +

        +
      3. +

        + The xxd tool that is used to generate the C header files (xxd is a normal part of a complete Linux or Cygwin installation, usually as part of the vi package). +

        +
      4. +

        + The file apps/nshlib/rcS.template (OR, if CONFIG_NSH_ARCHROMFS is defined include/arch/board/rcs.template. +

        +
      +
    3. +

      + rcS.template. + The file apps/nshlib/rcS.template contains the general form of the rcS file; configured values are plugged into this template file to produce the final rcS file. +

      +
    + +

    + rcS.template. + The default rcS.template, apps/nshlib/rcS.template, generates the standard, default apps/nshlib/nsh_romfsimg.h file. +

    + +

    + If CONFIG_NSH_ARCHROMFS is defined in the NuttX configuration file, then a custom, board-specific nsh_romfsimg.h file residing in configs/<board>/includewill be used. + NOTE when the OS is configured, include/arch/board will be linked to configs/<board>/include. +

    + +

    + As mention above, the only example that uses a custom /etc/init.d/rcS file in the NuttX source tree is this one: configs/vsn/nsh. + The custom script for the configs/vsn case is located at configs/vsn/include/rcS.template. +

    + +

    + All of the startup-behavior is contained in rcS.template. + The role of mkromfsimg.sh script is to (1) apply the specific configuration settings to rcS.template to create the final rcS, and (2) to generate the header file nsh_romfsimg.h containg the ROMFS file system image. + To do this, mkromfsimg.sh uses two tools that must be installed in your system: +

    +
      +
    1. +

      + The genromfs tool that is used to generate the ROMFS file system image. +

      +
    2. +

      + The xxd tool that is used to create the C header file. +

      +
    +

    + You can find the generated ROMFS file system for the configs/vsn case here: configs/vsn/include/rcS.template +

    + - +
    @@ -2657,15 +3502,28 @@ nsh>
  • echo
  • Environment Variables
  • /etc/init.d/rcS
  • exec
  • +
  • exec_namedapp()
  • +
  • exit
  • free
  • +
  • g_cmdmap
  • +
  • genromfs
  • get
  • Greeting
  • help
  • if-then[-else]-fi
  • ifconfig
  • +
  • Initialization sequence
  • kill
  • losetup
  • ls
  • @@ -2729,10 +3596,28 @@ nsh>
  • mkfatfs
  • mkfifo
  • mkrd
  • +
  • mkromfsimg.sh
  • mount
  • mv
  • +
  • Named application start-up main()
  • +
  • Named applications
  • +
  • namedapp_getname()
  • +
  • namedapp_isavail()
  • +
  • namedapp_list.h
  • +
  • namedapp_proto.h
  • nfsmount
  • nice
  • +
  • NSH library (nshlib)
  • +
  • nsh_archinitialize()
  • +
  • nsh_consolemain()
  • +
  • nsh_initialize()
  • +
  • nsh_main()
  • +
  • nsh_main.c
  • +
  • nsh_netinit()
  • +
  • nsh_output()
  • +
  • nsh_romfsetc()
  • +
  • nsh_telnetstart()
  • +
  • nshlib
  • OLDPWD
  • Overview
  • ping
  • @@ -2741,20 +3626,30 @@ nsh>
  • put
  • pwd
  • PWD
  • +
  • rcS.template
  • Re-directed commands
  • +
  • Registration of named applications
  • rm
  • rmdir
  • +
  • ROMFS, Modifying the ROMFS image
  • set
  • sh
  • Simple commands
  • sleep
  • -
  • start-up script +
  • Start-up, Default behavior
  • +
  • Start-up script +
  • Start-up script
  • +
  • Synchronous built-in applications
  • test
  • umount
  • unset
  • +
  • up_cxxinitialize()
  • +
  • up_nsh.c
  • usleep
  • +
  • waitpid()
  • wget
  • xd
  • +
  • xxd
  • diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html index 64f02f0812..ed994d69b9 100644 --- a/nuttx/Documentation/NuttX.html +++ b/nuttx/Documentation/NuttX.html @@ -256,14 +256,6 @@ - -
    - -

    -

  • Modular, micro-kernel
  • -

    - -
    @@ -365,7 +357,7 @@
    -

    System logging. +

  • System logging.
  • @@ -677,7 +669,7 @@

    -

  • USB device controller drivers available for the NXP LPC17xx, LPC214x, LPC313x, STMicro STM32 and TI DM320.
  • +
  • USB device controller drivers available for the PIC32, NXP LPC17xx, LPC214x, LPC313x, LPC43xx, STMicro STM32 and TI DM320.
  • @@ -776,7 +768,7 @@

    -

  • Support for Analog-to-Digital conversion (ADC) and Digital-to-Analog conversion (DAC).
  • +
  • Support for Analog-to-Digital conversion (ADC), Digital-to-Analog conversion (DAC), multiplexers, and amplifiers.
  • diff --git a/nuttx/TODO b/nuttx/TODO index 2745452395..7ffcb9ca80 100644 --- a/nuttx/TODO +++ b/nuttx/TODO @@ -1,4 +1,4 @@ -NuttX TODO List (Last updated August 3, 2012) +NuttX TODO List (Last updated August 7, 2012) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This file summarizes known NuttX bugs, limitations, inconsistencies with @@ -22,7 +22,7 @@ nuttx/ (1) Documentation (Documentation/) (6) Build system / Toolchains (5) Linux/Cywgin simulation (arch/sim) - (5) ARM (arch/arm/) + (6) ARM (arch/arm/) (1) ARM/C5471 (arch/arm/src/c5471/) (3) ARM/DM320 (arch/arm/src/dm320/) (2) ARM/i.MX (arch/arm/src/imx/) @@ -919,7 +919,7 @@ o Build system Status: Open Priority: Low. - Title: KERNEL BUILD MODE ISSUES + Title: KERNEL BUILD MODE ISSUES - GRAPHICS/NSH PARTITIONING. Description: In the kernel build mode (where NuttX is built as a monlithic kernel and user code must trap into the protected kernel via syscalls), the single user mode cannot be supported. In this @@ -928,6 +928,9 @@ o Build system this case, most of the user end functions in graphics/nxmu must be moved to lib/nx and those functions must be built into libuser.a to be linked with the user-space code. + A similar issue exists in NSH that uses some internal OS + interfaces that would not be available in a kernel build + (such as foreach_task, foreach_mountpoint, etc.). Status: Open Priority: Low -- the kernel build configuration is not fully fielded yet. @@ -1077,7 +1080,21 @@ o ARM (arch/arm/) Priority: Low. The conditions of continous interrupts is really the problem. If your design needs continous interrupts like this, please try the above change and, please, submit a patch with the working fix. - + + Title: KERNEL MODE ISSUES - HANDLERS + Description: The is a design flaw in the ARM/Cortex trap handlers. Currently, + they try to process the SYSCALL within the trap handler. That + cannot work. There are two possibilities to fix this. + 1) Just enable interrupts in the trap handler and make sure that + that sufficient protection is in place to handler the nested + interrupts, or + 3) Return from the exception via a trampoline (such as is + currently done for signal handlers). In the trampoline, + the trap would processed in supervisor mode with interrupts + enabled. + Status: Open + Priority: medium-high. + o ARM/C5471 (arch/arm/src/c5471/) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/nuttx/arch/arm/src/lpc43xx/Make.defs b/nuttx/arch/arm/src/lpc43xx/Make.defs index 4b75afffcc..cc8de3b321 100644 --- a/nuttx/arch/arm/src/lpc43xx/Make.defs +++ b/nuttx/arch/arm/src/lpc43xx/Make.defs @@ -117,3 +117,10 @@ ifeq ($(CONFIG_LPC43_DAC),y) CHIP_CSRCS += lpc43_adc.c endif endif + +ifeq ($(CONFIG_LPC43_USB0),y) +ifeq ($(CONFIG_USBDEV),y) +CHIP_CSRCS += lpc31_usb0dev.c +endif +endif + diff --git a/nuttx/arch/arm/src/lpc43xx/lpc43_usb0dev.c b/nuttx/arch/arm/src/lpc43xx/lpc43_usb0dev.c new file mode 100644 index 0000000000..40233ec0f6 --- /dev/null +++ b/nuttx/arch/arm/src/lpc43xx/lpc43_usb0dev.c @@ -0,0 +1,2663 @@ +/******************************************************************************* + * arch/arm/src/lpc43xx/lpc43_usbdev.c + * + * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Part of the NuttX OS and based, in part, on the LPC31xx USB driver: + * + * Authors: David Hewson + * Gregory Nutt + * + * Which, in turn, was based on the LPC2148 USB driver: + * + * Copyright (C) 2010-2012 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 +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include "chip.h" +#include "up_arch.h" +#include "up_internal.h" + +#include "lpc43_usbotg.h" +#include "lpc43_evntrtr.h" +#include "lpc43_syscreg.h" + +/******************************************************************************* + * Definitions + *******************************************************************************/ + +/* Configuration ***************************************************************/ + +#ifndef CONFIG_USBDEV_EP0_MAXSIZE +# define CONFIG_USBDEV_EP0_MAXSIZE 64 +#endif + +#ifndef CONFIG_USBDEV_MAXPOWER +# define CONFIG_USBDEV_MAXPOWER 100 /* mA */ +#endif + +/* Extremely detailed register debug that you would normally never want + * enabled. + */ + +#undef CONFIG_LPC43_USBDEV_REGDEBUG + +/* Enable reading SOF from interrupt handler vs. simply reading on demand. Probably + * a bad idea... Unless there is some issue with sampling the SOF from hardware + * asynchronously. + */ + +#ifdef CONFIG_LPC43_USBDEV_FRAME_INTERRUPT +# define USB_FRAME_INT USBDEV_USBINTR_SRE +#else +# define USB_FRAME_INT 0 +#endif + +#ifdef CONFIG_DEBUG +# define USB_ERROR_INT USBDEV_USBINTR_UEE +#else +# define USB_ERROR_INT 0 +#endif + +/* Debug ***********************************************************************/ + +/* Trace error codes */ + +#define LPC43_TRACEERR_ALLOCFAIL 0x0001 +#define LPC43_TRACEERR_BADCLEARFEATURE 0x0002 +#define LPC43_TRACEERR_BADDEVGETSTATUS 0x0003 +#define LPC43_TRACEERR_BADEPNO 0x0004 +#define LPC43_TRACEERR_BADEPGETSTATUS 0x0005 +#define LPC43_TRACEERR_BADEPTYPE 0x0006 +#define LPC43_TRACEERR_BADGETCONFIG 0x0007 +#define LPC43_TRACEERR_BADGETSETDESC 0x0008 +#define LPC43_TRACEERR_BADGETSTATUS 0x0009 +#define LPC43_TRACEERR_BADSETADDRESS 0x000a +#define LPC43_TRACEERR_BADSETCONFIG 0x000b +#define LPC43_TRACEERR_BADSETFEATURE 0x000c +#define LPC43_TRACEERR_BINDFAILED 0x000d +#define LPC43_TRACEERR_DISPATCHSTALL 0x000e +#define LPC43_TRACEERR_DRIVER 0x000f +#define LPC43_TRACEERR_DRIVERREGISTERED 0x0010 +#define LPC43_TRACEERR_EP0SETUPSTALLED 0x0011 +#define LPC43_TRACEERR_EPINNULLPACKET 0x0012 +#define LPC43_TRACEERR_EPOUTNULLPACKET 0x0013 +#define LPC43_TRACEERR_INVALIDCTRLREQ 0x0014 +#define LPC43_TRACEERR_INVALIDPARMS 0x0015 +#define LPC43_TRACEERR_IRQREGISTRATION 0x0016 +#define LPC43_TRACEERR_NOEP 0x0017 +#define LPC43_TRACEERR_NOTCONFIGURED 0x0018 +#define LPC43_TRACEERR_REQABORTED 0x0019 + +/* Trace interrupt codes */ + +#define LPC43_TRACEINTID_USB 0x0001 +#define LPC43_TRACEINTID_CLEARFEATURE 0x0002 +#define LPC43_TRACEINTID_DEVGETSTATUS 0x0003 +#define LPC43_TRACEINTID_DEVRESET 0x0004 +#define LPC43_TRACEINTID_DISPATCH 0x0005 +#define LPC43_TRACEINTID_EP0COMPLETE 0x0006 +#define LPC43_TRACEINTID_EP0NAK 0x0007 +#define LPC43_TRACEINTID_EP0SETUP 0x0008 +#define LPC43_TRACEINTID_EPGETSTATUS 0x0009 +#define LPC43_TRACEINTID_EPIN 0x000a +#define LPC43_TRACEINTID_EPINQEMPTY 0x000b +#define LPC43_TRACEINTID_EP0INSETADDRESS 0x000c +#define LPC43_TRACEINTID_EPOUT 0x000d +#define LPC43_TRACEINTID_EPOUTQEMPTY 0x000e +#define LPC43_TRACEINTID_EP0SETUPSETADDRESS 0x000f +#define LPC43_TRACEINTID_FRAME 0x0010 +#define LPC43_TRACEINTID_GETCONFIG 0x0011 +#define LPC43_TRACEINTID_GETSETDESC 0x0012 +#define LPC43_TRACEINTID_GETSETIF 0x0013 +#define LPC43_TRACEINTID_GETSTATUS 0x0014 +#define LPC43_TRACEINTID_IFGETSTATUS 0x0015 +#define LPC43_TRACEINTID_SETCONFIG 0x0016 +#define LPC43_TRACEINTID_SETFEATURE 0x0017 +#define LPC43_TRACEINTID_SUSPENDCHG 0x0018 +#define LPC43_TRACEINTID_SYNCHFRAME 0x0019 + +/* Hardware interface **********************************************************/ + +/* This represents a Endpoint Transfer Descriptor - note these must be 32 byte aligned */ +struct lpc43_dtd_s +{ + volatile uint32_t nextdesc; /* Address of the next DMA descripto in RAM */ + volatile uint32_t config; /* Misc. bit encoded configuration information */ + uint32_t buffer0; /* Buffer start address */ + uint32_t buffer1; /* Buffer start address */ + uint32_t buffer2; /* Buffer start address */ + uint32_t buffer3; /* Buffer start address */ + uint32_t buffer4; /* Buffer start address */ + uint32_t xfer_len; /* Software only - transfer len that was queued */ +}; + +/* DTD nextdesc field*/ +#define DTD_NEXTDESC_INVALID (1 << 0) /* Bit 0 : Next Descriptor Invalid */ + +/* DTD config field */ +#define DTD_CONFIG_LENGTH(n) ((n) << 16) /* Bits 16-31 : Total bytes to transfer */ +#define DTD_CONFIG_IOC (1 << 15) /* Bit 15 : Interrupt on Completion */ +#define DTD_CONFIG_MULT_VARIABLE (0 << 10) /* Bits 10-11 : Number of packets executed per transacation descriptor (override) */ +#define DTD_CONFIG_MULT_NUM(n) ((n) << 10) +#define DTD_CONFIG_ACTIVE (1 << 7) /* Bit 7 : Status Active */ +#define DTD_CONFIG_HALTED (1 << 6) /* Bit 6 : Status Halted */ +#define DTD_CONFIG_BUFFER_ERROR (1 << 5) /* Bit 6 : Status Buffer Error */ +#define DTD_CONFIG_TRANSACTION_ERROR (1 << 3) /* Bit 3 : Status Transaction Error */ + +/* This represents a queue head - not these must be aligned to a 2048 byte boundary */ +struct lpc43_dqh_s +{ + uint32_t capability; /* Endpoint capability */ + uint32_t currdesc; /* Current dTD pointer */ + struct lpc43_dtd_s overlay; /* DTD overlay */ + volatile uint32_t setup[2]; /* Set-up buffer */ + uint32_t gap[4]; /* align to 64 bytes */ +}; + +/* DQH capability field */ +#define DQH_CAPABILITY_MULT_VARIABLE (0 << 30) /* Bits 30-31 : Number of packets executed per transaction descriptor */ +#define DQH_CAPABILITY_MULT_NUM(n) ((n) << 30) +#define DQH_CAPABILITY_ZLT (1 << 29) /* Bit 29 : Zero Length Termination Select */ +#define DQH_CAPABILITY_MAX_PACKET(n) ((n) << 16) /* Bits 16-29 : Maximum packet size of associated endpoint (<1024) */ +#define DQH_CAPABILITY_IOS (1 << 15) /* Bit 15 : Interrupt on Setup */ + +/* Endpoints ******************************************************************/ + +/* Number of endpoints */ +#define LPC43_NLOGENDPOINTS (4) /* ep0-3 */ +#define LPC43_NPHYSENDPOINTS (8) /* x2 for IN and OUT */ + +/* Odd physical endpoint numbers are IN; even are OUT */ +#define LPC43_EPPHYIN(epphy) (((epphy)&1)!=0) +#define LPC43_EPPHYOUT(epphy) (((epphy)&1)==0) + +#define LPC43_EPPHYIN2LOG(epphy) (((uint8_t)(epphy)>>1)|USB_DIR_IN) +#define LPC43_EPPHYOUT2LOG(epphy) (((uint8_t)(epphy)>>1)|USB_DIR_OUT) + +/* Endpoint 0 is special... */ +#define LPC43_EP0_OUT (0) +#define LPC43_EP0_IN (1) + +/* Each endpoint has somewhat different characteristics */ +#define LPC43_EPALLSET (0xff) /* All endpoints */ +#define LPC43_EPOUTSET (0x55) /* Even phy endpoint numbers are OUT EPs */ +#define LPC43_EPINSET (0xaa) /* Odd endpoint numbers are IN EPs */ +#define LPC43_EPCTRLSET (0x03) /* EP0 IN/OUT are control endpoints */ +#define LPC43_EPINTRSET (0xa8) /* Interrupt endpoints */ +#define LPC43_EPBULKSET (0xfc) /* Bulk endpoints */ +#define LPC43_EPISOCSET (0xfc) /* Isochronous endpoints */ + +/* Maximum packet sizes for endpoints */ +#define LPC43_EP0MAXPACKET (64) /* EP0 max packet size (1-64) */ +#define LPC43_BULKMAXPACKET (512) /* Bulk endpoint max packet (8/16/32/64/512) */ +#define LPC43_INTRMAXPACKET (1024) /* Interrupt endpoint max packet (1 to 1024) */ +#define LPC43_ISOCMAXPACKET (512) /* Acutally 1..1023 */ + +/* The address of the endpoint control register */ +#define LPC43_USBDEV_ENDPTCTRL(epphy) (LPC43_USBDEV_ENDPTCTRL0 + ((epphy)>>1)*4) + +/* Endpoint bit position in SETUPSTAT, PRIME, FLUSH, STAT, COMPLETE registers */ +#define LPC43_ENDPTSHIFT(epphy) (LPC43_EPPHYIN(epphy) ? (16 + ((epphy) >> 1)) : ((epphy) >> 1)) +#define LPC43_ENDPTMASK(epphy) (1 << LPC43_ENDPTSHIFT(epphy)) +#define LPC43_ENDPTMASK_ALL 0x000f000f + +/* Request queue operations ****************************************************/ + +#define lpc43_rqempty(ep) ((ep)->head == NULL) +#define lpc43_rqpeek(ep) ((ep)->head) + +/******************************************************************************* + * Private Types + *******************************************************************************/ + +/* A container for a request so that the request may be retained in a list */ + +struct lpc43_req_s +{ + struct usbdev_req_s req; /* Standard USB request */ + struct lpc43_req_s *flink; /* Supports a singly linked list */ +}; + +/* This is the internal representation of an endpoint */ + +struct lpc43_ep_s +{ + /* Common endpoint fields. This must be the first thing defined in the + * structure so that it is possible to simply cast from struct usbdev_ep_s + * to struct lpc43_ep_s. + */ + + struct usbdev_ep_s ep; /* Standard endpoint structure */ + + /* LPC43XX-specific fields */ + + struct lpc43_usbdev_s *dev; /* Reference to private driver data */ + struct lpc43_req_s *head; /* Request list for this endpoint */ + struct lpc43_req_s *tail; + uint8_t epphy; /* Physical EP address */ + uint8_t stalled:1; /* 1: Endpoint is stalled */ +}; + +/* This structure retains the state of the USB device controller */ + +struct lpc43_usbdev_s +{ + /* Common device fields. This must be the first thing defined in the + * structure so that it is possible to simply cast from struct usbdev_s + * to struct lpc43_usbdev_s. + */ + + struct usbdev_s usbdev; + + /* The bound device class driver */ + + struct usbdevclass_driver_s *driver; + + /* LPC43XX-specific fields */ + + uint8_t ep0state; /* State of certain EP0 operations */ + uint8_t ep0buf[64]; /* buffer for EP0 short transfers */ + uint8_t paddr; /* Address assigned by SETADDRESS */ + uint8_t stalled:1; /* 1: Protocol stalled */ + uint8_t selfpowered:1; /* 1: Device is self powered */ + uint8_t paddrset:1; /* 1: Peripheral addr has been set */ + uint8_t attached:1; /* 1: Host attached */ + uint32_t softprio; /* Bitset of high priority interrupts */ + uint32_t epavail; /* Bitset of available endpoints */ +#ifdef CONFIG_LPC43_USBDEV_FRAME_INTERRUPT + uint32_t sof; /* Last start-of-frame */ +#endif + + /* The endpoint list */ + struct lpc43_ep_s eplist[LPC43_NPHYSENDPOINTS]; +}; + +#define EP0STATE_IDLE 0 /* Idle State, leave on receiving a setup packet or epsubmit */ +#define EP0STATE_SETUP_OUT 1 /* Setup Packet received - SET/CLEAR */ +#define EP0STATE_SETUP_IN 2 /* Setup Packet received - GET */ +#define EP0STATE_SHORTWRITE 3 /* Short write without a usb_request */ +#define EP0STATE_WAIT_NAK_OUT 4 /* Waiting for Host to illicit status phase (GET) */ +#define EP0STATE_WAIT_NAK_IN 5 /* Waiting for Host to illicit status phase (SET/CLEAR) */ +#define EP0STATE_WAIT_STATUS_OUT 6 /* Wait for status phase to complete */ +#define EP0STATE_WAIT_STATUS_IN 7 /* Wait for status phase to complete */ +#define EP0STATE_DATA_IN 8 +#define EP0STATE_DATA_OUT 9 + +/******************************************************************************* + * Private Function Prototypes + *******************************************************************************/ + +/* Register operations ********************************************************/ + +#if defined(CONFIG_LPC43_USBDEV_REGDEBUG) && defined(CONFIG_DEBUG) +static uint32_t lpc43_getreg(uint32_t addr); +static void lpc43_putreg(uint32_t val, uint32_t addr); +#else +# define lpc43_getreg(addr) getreg32(addr) +# define lpc43_putreg(val,addr) putreg32(val,addr) +#endif + +static inline void lpc43_clrbits(uint32_t mask, uint32_t addr); +static inline void lpc43_setbits(uint32_t mask, uint32_t addr); +static inline void lpc43_chgbits(uint32_t mask, uint32_t val, uint32_t addr); + +/* Request queue operations ****************************************************/ + +static FAR struct lpc43_req_s *lpc43_rqdequeue(FAR struct lpc43_ep_s *privep); +static bool lpc43_rqenqueue(FAR struct lpc43_ep_s *privep, + FAR struct lpc43_req_s *req); + +/* Low level data transfers and request operations *****************************/ + +static inline void lpc43_writedtd(struct lpc43_dtd_s *dtd, const uint8_t *data, + uint32_t nbytes); +static inline void lpc43_queuedtd(uint8_t epphy, struct lpc43_dtd_s *dtd); +static inline void lpc43_ep0xfer(uint8_t epphy, uint8_t *data, uint32_t nbytes); +static void lpc43_readsetup(uint8_t epphy, struct usb_ctrlreq_s *ctrl); + +static inline void lpc43_set_address(struct lpc43_usbdev_s *priv, uint16_t address); + +static void lpc43_flushep(struct lpc43_ep_s *privep); + +static int lpc43_progressep(struct lpc43_ep_s *privep); +static inline void lpc43_abortrequest(struct lpc43_ep_s *privep, + struct lpc43_req_s *privreq, int16_t result); +static void lpc43_reqcomplete(struct lpc43_ep_s *privep, + struct lpc43_req_s *privreq, int16_t result); + +static void lpc43_cancelrequests(struct lpc43_ep_s *privep, int16_t status); + +/* Interrupt handling **********************************************************/ +static struct lpc43_ep_s *lpc43_epfindbyaddr(struct lpc43_usbdev_s *priv, + uint16_t eplog); +static void lpc43_dispatchrequest(struct lpc43_usbdev_s *priv, + const struct usb_ctrlreq_s *ctrl); +static void lpc43_ep0configure(struct lpc43_usbdev_s *priv); +static void lpc43_usbreset(struct lpc43_usbdev_s *priv); + +static inline void lpc43_ep0state(struct lpc43_usbdev_s *priv, uint16_t state); +static void lpc43_ep0setup(struct lpc43_usbdev_s *priv); + +static void lpc43_ep0complete(struct lpc43_usbdev_s *priv, uint8_t epphy); +static void lpc43_ep0nak(struct lpc43_usbdev_s *priv, uint8_t epphy); +static bool lpc43_epcomplete(struct lpc43_usbdev_s *priv, uint8_t epphy); + +static int lpc43_usbinterrupt(int irq, FAR void *context); + +/* Endpoint operations *********************************************************/ + +/* USB device controller operations ********************************************/ + +static int lpc43_epconfigure(FAR struct usbdev_ep_s *ep, + const struct usb_epdesc_s *desc, bool last); +static int lpc43_epdisable(FAR struct usbdev_ep_s *ep); +static FAR struct usbdev_req_s *lpc43_epallocreq(FAR struct usbdev_ep_s *ep); +static void lpc43_epfreereq(FAR struct usbdev_ep_s *ep, + FAR struct usbdev_req_s *); +#ifdef CONFIG_ARCH_USBDEV_DMA +static void *lpc43_epallocbuffer(FAR struct usbdev_ep_s *ep, unsigned bytes); +static void lpc43_epfreebuffer(FAR struct usbdev_ep_s *ep, FAR void *buf); +#endif +static int lpc43_epsubmit(FAR struct usbdev_ep_s *ep, + struct usbdev_req_s *req); +static int lpc43_epcancel(FAR struct usbdev_ep_s *ep, + struct usbdev_req_s *req); +static int lpc43_epstall(FAR struct usbdev_ep_s *ep, bool resume); + +static FAR struct usbdev_ep_s *lpc43_allocep(FAR struct usbdev_s *dev, + uint8_t epno, bool in, uint8_t eptype); +static void lpc43_freeep(FAR struct usbdev_s *dev, FAR struct usbdev_ep_s *ep); +static int lpc43_getframe(struct usbdev_s *dev); +static int lpc43_wakeup(struct usbdev_s *dev); +static int lpc43_selfpowered(struct usbdev_s *dev, bool selfpowered); +static int lpc43_pullup(struct usbdev_s *dev, bool enable); + +/******************************************************************************* + * Private Data + *******************************************************************************/ + +/* Since there is only a single USB interface, all status information can be + * be simply retained in a single global instance. + */ + +static struct lpc43_usbdev_s g_usbdev; + +static struct lpc43_dqh_s __attribute__((aligned(2048))) g_qh[LPC43_NPHYSENDPOINTS]; +static struct lpc43_dtd_s __attribute__((aligned(32))) g_td[LPC43_NPHYSENDPOINTS]; + +static const struct usbdev_epops_s g_epops = +{ + .configure = lpc43_epconfigure, + .disable = lpc43_epdisable, + .allocreq = lpc43_epallocreq, + .freereq = lpc43_epfreereq, +#ifdef CONFIG_ARCH_USBDEV_DMA + .allocbuffer = lpc43_epallocbuffer, + .freebuffer = lpc43_epfreebuffer, +#endif + .submit = lpc43_epsubmit, + .cancel = lpc43_epcancel, + .stall = lpc43_epstall, +}; + +static const struct usbdev_ops_s g_devops = +{ + .allocep = lpc43_allocep, + .freeep = lpc43_freeep, + .getframe = lpc43_getframe, + .wakeup = lpc43_wakeup, + .selfpowered = lpc43_selfpowered, + .pullup = lpc43_pullup, +}; + +/******************************************************************************* + * Public Data + *******************************************************************************/ + +/******************************************************************************* + * Private Functions + *******************************************************************************/ + +/******************************************************************************* + * Name: lpc43_getreg + * + * Description: + * Get the contents of an LPC433x register + * + *******************************************************************************/ + +#if defined(CONFIG_LPC43_USBDEV_REGDEBUG) && defined(CONFIG_DEBUG) +static uint32_t lpc43_getreg(uint32_t addr) +{ + static uint32_t prevaddr = 0; + static uint32_t preval = 0; + static uint32_t count = 0; + + /* Read the value from the register */ + + uint32_t val = getreg32(addr); + + /* Is this the same value that we read from the same registe last time? Are + * we polling the register? If so, suppress some of the output. + */ + + if (addr == prevaddr && val == preval) + { + if (count == 0xffffffff || ++count > 3) + { + if (count == 4) + { + lldbg("...\n"); + } + return val; + } + } + + /* No this is a new address or value */ + + else + { + /* Did we print "..." for the previous value? */ + + if (count > 3) + { + /* Yes.. then show how many times the value repeated */ + + lldbg("[repeats %d more times]\n", count-3); + } + + /* Save the new address, value, and count */ + + prevaddr = addr; + preval = val; + count = 1; + } + + /* Show the register value read */ + + lldbg("%08x->%08x\n", addr, val); + return val; +} +#endif + +/******************************************************************************* + * Name: lpc43_putreg + * + * Description: + * Set the contents of an LPC433x register to a value + * + *******************************************************************************/ + +#if defined(CONFIG_LPC43_USBDEV_REGDEBUG) && defined(CONFIG_DEBUG) +static void lpc43_putreg(uint32_t val, uint32_t addr) +{ + /* Show the register value being written */ + + lldbg("%08x<-%08x\n", addr, val); + + /* Write the value */ + + putreg32(val, addr); +} +#endif + +/******************************************************************************* + * Name: lpc43_clrbits + * + * Description: + * Clear bits in a register + * + *******************************************************************************/ + +static inline void lpc43_clrbits(uint32_t mask, uint32_t addr) +{ + uint32_t reg = lpc43_getreg(addr); + reg &= ~mask; + lpc43_putreg(reg, addr); +} + +/******************************************************************************* + * Name: lpc43_setbits + * + * Description: + * Set bits in a register + * + *******************************************************************************/ + +static inline void lpc43_setbits(uint32_t mask, uint32_t addr) +{ + uint32_t reg = lpc43_getreg(addr); + reg |= mask; + lpc43_putreg(reg, addr); +} + +/******************************************************************************* + * Name: lpc43_chgbits + * + * Description: + * Change bits in a register + * + *******************************************************************************/ + +static inline void lpc43_chgbits(uint32_t mask, uint32_t val, uint32_t addr) +{ + uint32_t reg = lpc43_getreg(addr); + reg &= ~mask; + reg |= val; + lpc43_putreg(reg, addr); +} + +/******************************************************************************* + * Name: lpc43_rqdequeue + * + * Description: + * Remove a request from an endpoint request queue + * + *******************************************************************************/ + +static FAR struct lpc43_req_s *lpc43_rqdequeue(FAR struct lpc43_ep_s *privep) +{ + FAR struct lpc43_req_s *ret = privep->head; + + if (ret) + { + privep->head = ret->flink; + if (!privep->head) + { + privep->tail = NULL; + } + + ret->flink = NULL; + } + + return ret; +} + +/******************************************************************************* + * Name: lpc43_rqenqueue + * + * Description: + * Add a request from an endpoint request queue + * + *******************************************************************************/ + +static bool lpc43_rqenqueue(FAR struct lpc43_ep_s *privep, + FAR struct lpc43_req_s *req) +{ + bool is_empty = !privep->head; + + req->flink = NULL; + if (is_empty) + { + privep->head = req; + privep->tail = req; + } + else + { + privep->tail->flink = req; + privep->tail = req; + } + return is_empty; +} + +/******************************************************************************* + * Name: lpc43_writedtd + * + * Description: + * Initialise a DTD to transfer the data + * + *******************************************************************************/ + +static inline void lpc43_writedtd(struct lpc43_dtd_s *dtd, const uint8_t *data, uint32_t nbytes) +{ + dtd->nextdesc = DTD_NEXTDESC_INVALID; + dtd->config = DTD_CONFIG_LENGTH(nbytes) | DTD_CONFIG_IOC | DTD_CONFIG_ACTIVE; + dtd->buffer0 = ((uint32_t) data); + dtd->buffer1 = (((uint32_t) data) + 0x1000) & 0xfffff000; + dtd->buffer2 = (((uint32_t) data) + 0x2000) & 0xfffff000; + dtd->buffer3 = (((uint32_t) data) + 0x3000) & 0xfffff000; + dtd->buffer4 = (((uint32_t) data) + 0x4000) & 0xfffff000; + dtd->xfer_len = nbytes; +} + +/******************************************************************************* + * Name: lpc43_queuedtd + * + * Description: + * Add the DTD to the device list + * + *******************************************************************************/ + +static void lpc43_queuedtd(uint8_t epphy, struct lpc43_dtd_s *dtd) +{ + /* Queue the DTD onto the Endpoint */ + /* NOTE - this only works when no DTD is currently queued */ + + g_qh[epphy].overlay.nextdesc = (uint32_t) dtd; + g_qh[epphy].overlay.config &= ~(DTD_CONFIG_ACTIVE | DTD_CONFIG_HALTED); + + uint32_t bit = LPC43_ENDPTMASK(epphy); + + lpc43_setbits (bit, LPC43_USBDEV_ENDPTPRIME); + + while (lpc43_getreg (LPC43_USBDEV_ENDPTPRIME) & bit) + ; +} + +/******************************************************************************* + * Name: lpc43_ep0xfer + * + * Description: + * Schedule a short transfer for Endpoint 0 (IN or OUT) + * + *******************************************************************************/ + +static inline void lpc43_ep0xfer(uint8_t epphy, uint8_t *buf, uint32_t nbytes) +{ + struct lpc43_dtd_s *dtd = &g_td[epphy]; + + lpc43_writedtd(dtd, buf, nbytes); + + lpc43_queuedtd(epphy, dtd); +} + +/******************************************************************************* + * Name: lpc43_readsetup + * + * Description: + * Read a Setup packet from the DTD. + * + *******************************************************************************/ +static void lpc43_readsetup(uint8_t epphy, struct usb_ctrlreq_s *ctrl) +{ + struct lpc43_dqh_s *dqh = &g_qh[epphy]; + int i; + + do { + /* Set the trip wire */ + lpc43_setbits(USBDEV_USBCMD_SUTW, LPC43_USBDEV_USBCMD); + + /* copy the request... */ + for (i = 0; i < 8; i++) + ((uint8_t *) ctrl)[i] = ((uint8_t *) dqh->setup)[i]; + + } while (!(lpc43_getreg(LPC43_USBDEV_USBCMD) & USBDEV_USBCMD_SUTW)); + + /* Clear the trip wire */ + lpc43_clrbits(USBDEV_USBCMD_SUTW, LPC43_USBDEV_USBCMD); + + /* Clear the Setup Interrupt */ + lpc43_putreg (LPC43_ENDPTMASK(LPC43_EP0_OUT), LPC43_USBDEV_ENDPTSETUPSTAT); +} + +/******************************************************************************* + * Name: lpc43_set_address + * + * Description: + * Set the devices USB address + * + *******************************************************************************/ + +static inline void lpc43_set_address(struct lpc43_usbdev_s *priv, uint16_t address) +{ + priv->paddr = address; + priv->paddrset = address != 0; + + lpc43_chgbits(USBDEV_DEVICEADDR_MASK, priv->paddr << USBDEV_DEVICEADDR_SHIFT, + LPC43_USBDEV_DEVICEADDR); +} + +/******************************************************************************* + * Name: lpc43_flushep + * + * Description: + * Flush any primed descriptors from this ep + * + *******************************************************************************/ + +static void lpc43_flushep(struct lpc43_ep_s *privep) +{ + uint32_t mask = LPC43_ENDPTMASK(privep->epphy); + do + { + lpc43_putreg (mask, LPC43_USBDEV_ENDPTFLUSH); + while ((lpc43_getreg(LPC43_USBDEV_ENDPTFLUSH) & mask) != 0) + ; + } + while ((lpc43_getreg(LPC43_USBDEV_ENDPTSTATUS) & mask) != 0); +} + + +/******************************************************************************* + * Name: lpc43_progressep + * + * Description: + * Progress the Endpoint by priming the first request into the queue head + * + *******************************************************************************/ + +static int lpc43_progressep(struct lpc43_ep_s *privep) +{ + struct lpc43_dtd_s *dtd = &g_td[privep->epphy]; + struct lpc43_req_s *privreq; + + /* Check the request from the head of the endpoint request queue */ + + privreq = lpc43_rqpeek(privep); + if (!privreq) + { + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_EPINQEMPTY), 0); + return OK; + } + + /* Ignore any attempt to send a zero length packet */ + + if (privreq->req.len == 0) + { + /* If the class driver is responding to a setup packet, then wait for the + * host to illicit thr response */ + + if (privep->epphy == LPC43_EP0_IN && privep->dev->ep0state == EP0STATE_SETUP_OUT) + lpc43_ep0state (privep->dev, EP0STATE_WAIT_NAK_IN); + else + { + if (LPC43_EPPHYIN(privep->epphy)) + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_EPINNULLPACKET), 0); + else + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_EPOUTNULLPACKET), 0); + } + + lpc43_reqcomplete(privep, lpc43_rqdequeue(privep), OK); + return OK; + } + + if (privep->epphy == LPC43_EP0_IN) + lpc43_ep0state (privep->dev, EP0STATE_DATA_IN); + else if (privep->epphy == LPC43_EP0_OUT) + lpc43_ep0state (privep->dev, EP0STATE_DATA_OUT); + + int bytesleft = privreq->req.len - privreq->req.xfrd; + + if (LPC43_EPPHYIN(privep->epphy)) + usbtrace(TRACE_WRITE(privep->epphy), privreq->req.xfrd); + else + usbtrace(TRACE_READ(privep->epphy), privreq->req.xfrd); + + /* Initialise the DTD to transfer the next chunk */ + + lpc43_writedtd (dtd, privreq->req.buf + privreq->req.xfrd, bytesleft); + + /* then queue onto the DQH */ + lpc43_queuedtd(privep->epphy, dtd); + + return OK; +} + +/******************************************************************************* + * Name: lpc43_abortrequest + * + * Description: + * Discard a request + * + *******************************************************************************/ + +static inline void lpc43_abortrequest(struct lpc43_ep_s *privep, + struct lpc43_req_s *privreq, + int16_t result) +{ + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_REQABORTED), (uint16_t)privep->epphy); + + /* Save the result in the request structure */ + + privreq->req.result = result; + + /* Callback to the request completion handler */ + + privreq->req.callback(&privep->ep, &privreq->req); +} + +/******************************************************************************* + * Name: lpc43_reqcomplete + * + * Description: + * Handle termination of the request at the head of the endpoint request queue. + * + *******************************************************************************/ + +static void lpc43_reqcomplete(struct lpc43_ep_s *privep, + struct lpc43_req_s *privreq, int16_t result) +{ + /* If endpoint 0, temporarily reflect the state of protocol stalled + * in the callback. + */ + + bool stalled = privep->stalled; + if (privep->epphy == LPC43_EP0_IN) + privep->stalled = privep->dev->stalled; + + /* Save the result in the request structure */ + + privreq->req.result = result; + + /* Callback to the request completion handler */ + + privreq->req.callback(&privep->ep, &privreq->req); + + /* Restore the stalled indication */ + + privep->stalled = stalled; +} + +/******************************************************************************* + * Name: lpc43_cancelrequests + * + * Description: + * Cancel all pending requests for an endpoint + * + *******************************************************************************/ + +static void lpc43_cancelrequests(struct lpc43_ep_s *privep, int16_t status) +{ + if (!lpc43_rqempty(privep)) + lpc43_flushep(privep); + + while (!lpc43_rqempty(privep)) + { + // FIXME: the entry at the head should be sync'd with the DTD + // FIXME: only report the error status if the transfer hasn't completed + usbtrace(TRACE_COMPLETE(privep->epphy), + (lpc43_rqpeek(privep))->req.xfrd); + lpc43_reqcomplete(privep, lpc43_rqdequeue(privep), status); + } +} + +/******************************************************************************* + * Name: lpc43_epfindbyaddr + * + * Description: + * Find the physical endpoint structure corresponding to a logic endpoint + * address + * + *******************************************************************************/ + +static struct lpc43_ep_s *lpc43_epfindbyaddr(struct lpc43_usbdev_s *priv, + uint16_t eplog) +{ + struct lpc43_ep_s *privep; + int i; + + /* Endpoint zero is a special case */ + + if (USB_EPNO(eplog) == 0) + { + return &priv->eplist[0]; + } + + /* Handle the remaining */ + + for (i = 1; i < LPC43_NPHYSENDPOINTS; i++) + { + privep = &priv->eplist[i]; + + /* Same logical endpoint number? (includes direction bit) */ + + if (eplog == privep->ep.eplog) + { + /* Return endpoint found */ + + return privep; + } + } + + /* Return endpoint not found */ + + return NULL; +} + +/******************************************************************************* + * Name: lpc43_dispatchrequest + * + * Description: + * Provide unhandled setup actions to the class driver. This is logically part + * of the USB interrupt handler. + * + *******************************************************************************/ + +static void lpc43_dispatchrequest(struct lpc43_usbdev_s *priv, + const struct usb_ctrlreq_s *ctrl) +{ + int ret = -EIO; + + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_DISPATCH), 0); + if (priv->driver) + { + /* Forward to the control request to the class driver implementation */ + + ret = CLASS_SETUP(priv->driver, &priv->usbdev, ctrl, NULL, 0); + } + + if (ret < 0) + { + /* Stall on failure */ + + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_DISPATCHSTALL), 0); + priv->stalled = true; + } +} + +/******************************************************************************* + * Name: lpc43_ep0configure + * + * Description: + * Reset Usb engine + * + *******************************************************************************/ + +static void lpc43_ep0configure(struct lpc43_usbdev_s *priv) +{ + /* Enable ep0 IN and ep0 OUT */ + g_qh[LPC43_EP0_OUT].capability = (DQH_CAPABILITY_MAX_PACKET(CONFIG_USBDEV_EP0_MAXSIZE) | + DQH_CAPABILITY_IOS | + DQH_CAPABILITY_ZLT); + + g_qh[LPC43_EP0_IN ].capability = (DQH_CAPABILITY_MAX_PACKET(CONFIG_USBDEV_EP0_MAXSIZE) | + DQH_CAPABILITY_IOS | + DQH_CAPABILITY_ZLT); + + g_qh[LPC43_EP0_OUT].currdesc = DTD_NEXTDESC_INVALID; + g_qh[LPC43_EP0_IN ].currdesc = DTD_NEXTDESC_INVALID; + + /* Enable EP0 */ + lpc43_setbits (USBDEV_ENDPTCTRL0_RXE | USBDEV_ENDPTCTRL0_TXE, LPC43_USBDEV_ENDPTCTRL0); +} + +/******************************************************************************* + * Name: lpc43_usbreset + * + * Description: + * Reset Usb engine + * + *******************************************************************************/ + +static void lpc43_usbreset(struct lpc43_usbdev_s *priv) +{ + int epphy; + + /* Disable all endpoints */ + + lpc43_clrbits (USBDEV_ENDPTCTRL_RXE | USBDEV_ENDPTCTRL_TXE, LPC43_USBDEV_ENDPTCTRL0); + lpc43_clrbits (USBDEV_ENDPTCTRL_RXE | USBDEV_ENDPTCTRL_TXE, LPC43_USBDEV_ENDPTCTRL1); + lpc43_clrbits (USBDEV_ENDPTCTRL_RXE | USBDEV_ENDPTCTRL_TXE, LPC43_USBDEV_ENDPTCTRL2); + lpc43_clrbits (USBDEV_ENDPTCTRL_RXE | USBDEV_ENDPTCTRL_TXE, LPC43_USBDEV_ENDPTCTRL3); + + /* Clear all pending interrupts */ + + lpc43_putreg (lpc43_getreg(LPC43_USBDEV_ENDPTNAK), LPC43_USBDEV_ENDPTNAK); + lpc43_putreg (lpc43_getreg(LPC43_USBDEV_ENDPTSETUPSTAT), LPC43_USBDEV_ENDPTSETUPSTAT); + lpc43_putreg (lpc43_getreg(LPC43_USBDEV_ENDPTCOMPLETE), LPC43_USBDEV_ENDPTCOMPLETE); + + /* Wait for all prime operations to have completed and then flush all DTDs */ + while (lpc43_getreg (LPC43_USBDEV_ENDPTPRIME) != 0) + ; + lpc43_putreg (LPC43_ENDPTMASK_ALL, LPC43_USBDEV_ENDPTFLUSH); + while (lpc43_getreg (LPC43_USBDEV_ENDPTFLUSH)) + ; + + /* Reset endpoints */ + for (epphy = 0; epphy < LPC43_NPHYSENDPOINTS; epphy++) + { + struct lpc43_ep_s *privep = &priv->eplist[epphy]; + + lpc43_cancelrequests (privep, -ESHUTDOWN); + + /* Reset endpoint status */ + privep->stalled = false; + } + + /* Tell the class driver that we are disconnected. The class + * driver should then accept any new configurations. */ + + if (priv->driver) + CLASS_DISCONNECT(priv->driver, &priv->usbdev); + + /* Set the interrupt Threshold control interval to 0 */ + lpc43_chgbits(USBDEV_USBCMD_ITC_MASK, USBDEV_USBCMD_ITCIMME, LPC43_USBDEV_USBCMD); + + /* Zero out the Endpoint queue heads */ + memset ((void *) g_qh, 0, sizeof (g_qh)); + memset ((void *) g_td, 0, sizeof (g_td)); + + /* Set USB address to 0 */ + lpc43_set_address (priv, 0); + + /* Initialise the Enpoint List Address */ + lpc43_putreg ((uint32_t)g_qh, LPC43_USBDEV_ENDPOINTLIST); + + /* EndPoint 0 initialization */ + lpc43_ep0configure(priv); + + /* Enable Device interrupts */ + lpc43_putreg(USB_FRAME_INT | USB_ERROR_INT | + USBDEV_USBINTR_NAKE | USBDEV_USBINTR_SLE | USBDEV_USBINTR_URE | USBDEV_USBINTR_PCE | USBDEV_USBINTR_UE, + LPC43_USBDEV_USBINTR); +} + +/******************************************************************************* + * Name: lpc43_setstate + * + * Description: + * Sets the EP0 state and manages the NAK interrupts + * + *******************************************************************************/ + +static inline void lpc43_ep0state(struct lpc43_usbdev_s *priv, uint16_t state) +{ + priv->ep0state = state; + + switch (state) + { + case EP0STATE_WAIT_NAK_IN: + lpc43_putreg (LPC43_ENDPTMASK(LPC43_EP0_IN), LPC43_USBDEV_ENDPTNAKEN); + break; + case EP0STATE_WAIT_NAK_OUT: + lpc43_putreg (LPC43_ENDPTMASK(LPC43_EP0_OUT), LPC43_USBDEV_ENDPTNAKEN); + break; + default: + lpc43_putreg(0, LPC43_USBDEV_ENDPTNAKEN); + break; + } +} + +/******************************************************************************* + * Name: lpc43_ep0setup + * + * Description: + * USB Ctrl EP Setup Event. This is logically part of the USB interrupt + * handler. This event occurs when a setup packet is receive on EP0 OUT. + * + *******************************************************************************/ + +static inline void lpc43_ep0setup(struct lpc43_usbdev_s *priv) +{ + struct lpc43_ep_s *privep; + struct usb_ctrlreq_s ctrl; + uint16_t value; + uint16_t index; + uint16_t len; + + /* Terminate any pending requests - since all DTDs will have been retired + * because of the setup packet */ + + lpc43_cancelrequests(&priv->eplist[LPC43_EP0_OUT], -EPROTO); + lpc43_cancelrequests(&priv->eplist[LPC43_EP0_IN], -EPROTO); + + /* Assume NOT stalled */ + + priv->eplist[LPC43_EP0_OUT].stalled = false; + priv->eplist[LPC43_EP0_IN].stalled = false; + priv->stalled = false; + + /* Read EP0 setup data */ + lpc43_readsetup(LPC43_EP0_OUT, &ctrl); + + /* Starting a control request - update state */ + lpc43_ep0state (priv, (ctrl.type & USB_REQ_DIR_IN) ? EP0STATE_SETUP_IN : EP0STATE_SETUP_OUT); + + /* And extract the little-endian 16-bit values to host order */ + value = GETUINT16(ctrl.value); + index = GETUINT16(ctrl.index); + len = GETUINT16(ctrl.len); + + ullvdbg("type=%02x req=%02x value=%04x index=%04x len=%04x\n", + ctrl.type, ctrl.req, value, index, len); + + /* Dispatch any non-standard requests */ + if ((ctrl.type & USB_REQ_TYPE_MASK) != USB_REQ_TYPE_STANDARD) + lpc43_dispatchrequest(priv, &ctrl); + else + { + /* Handle standard request. Pick off the things of interest to the USB + * device controller driver; pass what is left to the class driver */ + switch (ctrl.req) + { + case USB_REQ_GETSTATUS: + { + /* type: device-to-host; recipient = device, interface, endpoint + * value: 0 + * index: zero interface endpoint + * len: 2; data = status + */ + + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_GETSTATUS), 0); + if (!priv->paddrset || len != 2 || + (ctrl.type & USB_REQ_DIR_IN) == 0 || value != 0) + { + priv->stalled = true; + } + else + { + switch (ctrl.type & USB_REQ_RECIPIENT_MASK) + { + case USB_REQ_RECIPIENT_ENDPOINT: + { + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_EPGETSTATUS), 0); + privep = lpc43_epfindbyaddr(priv, index); + if (!privep) + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_BADEPGETSTATUS), 0); + priv->stalled = true; + } + else + { + if (privep->stalled) + priv->ep0buf[0] = 1; /* Stalled */ + else + priv->ep0buf[0] = 0; /* Not stalled */ + priv->ep0buf[1] = 0; + + lpc43_ep0xfer (LPC43_EP0_IN, priv->ep0buf, 2); + lpc43_ep0state (priv, EP0STATE_SHORTWRITE); + } + } + break; + + case USB_REQ_RECIPIENT_DEVICE: + { + if (index == 0) + { + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_DEVGETSTATUS), 0); + + /* Features: Remote Wakeup=YES; selfpowered=? */ + + priv->ep0buf[0] = (priv->selfpowered << USB_FEATURE_SELFPOWERED) | + (1 << USB_FEATURE_REMOTEWAKEUP); + priv->ep0buf[1] = 0; + + lpc43_ep0xfer(LPC43_EP0_IN, priv->ep0buf, 2); + lpc43_ep0state (priv, EP0STATE_SHORTWRITE); + } + else + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_BADDEVGETSTATUS), 0); + priv->stalled = true; + } + } + break; + + case USB_REQ_RECIPIENT_INTERFACE: + { + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_IFGETSTATUS), 0); + priv->ep0buf[0] = 0; + priv->ep0buf[1] = 0; + + lpc43_ep0xfer(LPC43_EP0_IN, priv->ep0buf, 2); + lpc43_ep0state (priv, EP0STATE_SHORTWRITE); + } + break; + + default: + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_BADGETSTATUS), 0); + priv->stalled = true; + } + break; + } + } + } + break; + + case USB_REQ_CLEARFEATURE: + { + /* type: host-to-device; recipient = device, interface or endpoint + * value: feature selector + * index: zero interface endpoint; + * len: zero, data = none + */ + + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_CLEARFEATURE), 0); + if ((ctrl.type & USB_REQ_RECIPIENT_MASK) != USB_REQ_RECIPIENT_ENDPOINT) + { + lpc43_dispatchrequest(priv, &ctrl); + } + else if (priv->paddrset != 0 && value == USB_FEATURE_ENDPOINTHALT && len == 0 && + (privep = lpc43_epfindbyaddr(priv, index)) != NULL) + { + lpc43_epstall(&privep->ep, true); + lpc43_ep0state (priv, EP0STATE_WAIT_NAK_IN); + } + else + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_BADCLEARFEATURE), 0); + priv->stalled = true; + } + } + break; + + case USB_REQ_SETFEATURE: + { + /* type: host-to-device; recipient = device, interface, endpoint + * value: feature selector + * index: zero interface endpoint; + * len: 0; data = none + */ + + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_SETFEATURE), 0); + if (((ctrl.type & USB_REQ_RECIPIENT_MASK) == USB_REQ_RECIPIENT_DEVICE) && + value == USB_FEATURE_TESTMODE) + { + ullvdbg("test mode: %d\n", index); + } + else if ((ctrl.type & USB_REQ_RECIPIENT_MASK) != USB_REQ_RECIPIENT_ENDPOINT) + { + lpc43_dispatchrequest(priv, &ctrl); + } + else if (priv->paddrset != 0 && value == USB_FEATURE_ENDPOINTHALT && len == 0 && + (privep = lpc43_epfindbyaddr(priv, index)) != NULL) + { + lpc43_epstall(&privep->ep, false); + lpc43_ep0state (priv, EP0STATE_WAIT_NAK_IN); + } + else + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_BADSETFEATURE), 0); + priv->stalled = true; + } + } + break; + + case USB_REQ_SETADDRESS: + { + /* type: host-to-device; recipient = device + * value: device address + * index: 0 + * len: 0; data = none + */ + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_EP0SETUPSETADDRESS), value); + if ((ctrl.type & USB_REQ_RECIPIENT_MASK) == USB_REQ_RECIPIENT_DEVICE && + index == 0 && len == 0 && value < 128) + { + /* Save the address. We cannot actually change to the next address until + * the completion of the status phase. */ + + priv->paddr = ctrl.value[0]; + priv->paddrset = false; + lpc43_ep0state (priv, EP0STATE_WAIT_NAK_IN); + } + else + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_BADSETADDRESS), 0); + priv->stalled = true; + } + } + break; + + case USB_REQ_GETDESCRIPTOR: + /* type: device-to-host; recipient = device + * value: descriptor type and index + * index: 0 or language ID; + * len: descriptor len; data = descriptor + */ + case USB_REQ_SETDESCRIPTOR: + /* type: host-to-device; recipient = device + * value: descriptor type and index + * index: 0 or language ID; + * len: descriptor len; data = descriptor + */ + { + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_GETSETDESC), 0); + if ((ctrl.type & USB_REQ_RECIPIENT_MASK) == USB_REQ_RECIPIENT_DEVICE) + { + lpc43_dispatchrequest(priv, &ctrl); + } + else + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_BADGETSETDESC), 0); + priv->stalled = true; + } + } + break; + + case USB_REQ_GETCONFIGURATION: + /* type: device-to-host; recipient = device + * value: 0; + * index: 0; + * len: 1; data = configuration value + */ + { + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_GETCONFIG), 0); + if (priv->paddrset && (ctrl.type & USB_REQ_RECIPIENT_MASK) == USB_REQ_RECIPIENT_DEVICE && + value == 0 && index == 0 && len == 1) + { + lpc43_dispatchrequest(priv, &ctrl); + } + else + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_BADGETCONFIG), 0); + priv->stalled = true; + } + } + break; + + case USB_REQ_SETCONFIGURATION: + /* type: host-to-device; recipient = device + * value: configuration value + * index: 0; + * len: 0; data = none + */ + { + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_SETCONFIG), 0); + if ((ctrl.type & USB_REQ_RECIPIENT_MASK) == USB_REQ_RECIPIENT_DEVICE && + index == 0 && len == 0) + { + lpc43_dispatchrequest(priv, &ctrl); + } + else + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_BADSETCONFIG), 0); + priv->stalled = true; + } + } + break; + + case USB_REQ_GETINTERFACE: + /* type: device-to-host; recipient = interface + * value: 0 + * index: interface; + * len: 1; data = alt interface + */ + case USB_REQ_SETINTERFACE: + /* type: host-to-device; recipient = interface + * value: alternate setting + * index: interface; + * len: 0; data = none + */ + { + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_GETSETIF), 0); + lpc43_dispatchrequest(priv, &ctrl); + } + break; + + case USB_REQ_SYNCHFRAME: + /* type: device-to-host; recipient = endpoint + * value: 0 + * index: endpoint; + * len: 2; data = frame number + */ + { + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_SYNCHFRAME), 0); + } + break; + + default: + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_INVALIDCTRLREQ), 0); + priv->stalled = true; + } + break; + } + } + + if (priv->stalled) + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_EP0SETUPSTALLED), priv->ep0state); + lpc43_epstall(&priv->eplist[LPC43_EP0_IN].ep, false); + lpc43_epstall(&priv->eplist[LPC43_EP0_OUT].ep, false); + } +} + +/******************************************************************************* + * Name: lpc43_ep0complete + * + * Description: + * Transfer complete handler for Endpoint 0 + * + *******************************************************************************/ + +static void lpc43_ep0complete(struct lpc43_usbdev_s *priv, uint8_t epphy) +{ + struct lpc43_ep_s *privep = &priv->eplist[epphy]; + + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_EP0COMPLETE), (uint16_t)priv->ep0state); + + switch (priv->ep0state) + { + case EP0STATE_DATA_IN: + if (lpc43_rqempty(privep)) + return; + + if (lpc43_epcomplete (priv, epphy)) + lpc43_ep0state (priv, EP0STATE_WAIT_NAK_OUT); + break; + + case EP0STATE_DATA_OUT: + if (lpc43_rqempty(privep)) + return; + + if (lpc43_epcomplete (priv, epphy)) + lpc43_ep0state (priv, EP0STATE_WAIT_NAK_IN); + break; + + case EP0STATE_SHORTWRITE: + lpc43_ep0state (priv, EP0STATE_WAIT_NAK_OUT); + break; + + case EP0STATE_WAIT_STATUS_IN: + lpc43_ep0state (priv, EP0STATE_IDLE); + + /* If we've received a SETADDRESS packet, then we set the address + * now that the status phase has completed */ + if (! priv->paddrset && priv->paddr != 0) + { + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_EP0INSETADDRESS), (uint16_t)priv->paddr); + lpc43_set_address (priv, priv->paddr); + } + break; + + case EP0STATE_WAIT_STATUS_OUT: + lpc43_ep0state (priv, EP0STATE_IDLE); + break; + + default: +#ifdef CONFIG_DEBUG + DEBUGASSERT(priv->ep0state != EP0STATE_DATA_IN && + priv->ep0state != EP0STATE_DATA_OUT && + priv->ep0state != EP0STATE_SHORTWRITE && + priv->ep0state != EP0STATE_WAIT_STATUS_IN && + priv->ep0state != EP0STATE_WAIT_STATUS_OUT); +#endif + priv->stalled = true; + break; + } + + if (priv->stalled) + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_EP0SETUPSTALLED), priv->ep0state); + lpc43_epstall(&priv->eplist[LPC43_EP0_IN].ep, false); + lpc43_epstall(&priv->eplist[LPC43_EP0_OUT].ep, false); + } +} + +/******************************************************************************* + * Name: lpc43_ep0nak + * + * Description: + * Handle a NAK interrupt on EP0 + * + *******************************************************************************/ + +static void lpc43_ep0nak(struct lpc43_usbdev_s *priv, uint8_t epphy) +{ + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_EP0NAK), (uint16_t)priv->ep0state); + + switch (priv->ep0state) + { + case EP0STATE_WAIT_NAK_IN: + lpc43_ep0xfer (LPC43_EP0_IN, NULL, 0); + lpc43_ep0state (priv, EP0STATE_WAIT_STATUS_IN); + break; + case EP0STATE_WAIT_NAK_OUT: + lpc43_ep0xfer (LPC43_EP0_OUT, NULL, 0); + lpc43_ep0state (priv, EP0STATE_WAIT_STATUS_OUT); + break; + default: +#ifdef CONFIG_DEBUG + DEBUGASSERT(priv->ep0state != EP0STATE_WAIT_NAK_IN && + priv->ep0state != EP0STATE_WAIT_NAK_OUT); +#endif + priv->stalled = true; + break; + } + + if (priv->stalled) + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_EP0SETUPSTALLED), priv->ep0state); + lpc43_epstall(&priv->eplist[LPC43_EP0_IN].ep, false); + lpc43_epstall(&priv->eplist[LPC43_EP0_OUT].ep, false); + } +} + +/******************************************************************************* + * Name: lpc43_epcomplete + * + * Description: + * Transfer complete handler for Endpoints other than 0 + * returns whether the request at the head has completed + * + *******************************************************************************/ + +bool lpc43_epcomplete(struct lpc43_usbdev_s *priv, uint8_t epphy) +{ + struct lpc43_ep_s *privep = &priv->eplist[epphy]; + struct lpc43_req_s *privreq = privep->head; + struct lpc43_dtd_s *dtd = &g_td[epphy]; + + if (privreq == NULL) /* This shouldn't really happen */ + { + if (LPC43_EPPHYOUT(privep->epphy)) + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_EPINQEMPTY), 0); + else + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_EPOUTQEMPTY), 0); + return true; + } + + int xfrd = dtd->xfer_len - (dtd->config >> 16); + + privreq->req.xfrd += xfrd; + + bool complete = true; + if (LPC43_EPPHYOUT(privep->epphy)) + { + /* read(OUT) completes when request filled, or a short transfer is received */ + + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_EPIN), complete); + } + else + { + /* write(IN) completes when request finished, unless we need to terminate with a ZLP */ + + bool need_zlp = (xfrd == privep->ep.maxpacket) && ((privreq->req.flags & USBDEV_REQFLAGS_NULLPKT) != 0); + + complete = (privreq->req.xfrd >= privreq->req.len && !need_zlp); + + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_EPOUT), complete); + } + + /* If the transfer is complete, then dequeue and progress any further queued requests */ + + if (complete) + { + privreq = lpc43_rqdequeue (privep); + } + + if (!lpc43_rqempty(privep)) + { + lpc43_progressep(privep); + } + + /* Now it's safe to call the completion callback as it may well submit a new request */ + + if (complete) + { + usbtrace(TRACE_COMPLETE(privep->epphy), privreq->req.xfrd); + lpc43_reqcomplete(privep, privreq, OK); + } + + return complete; +} + + +/******************************************************************************* + * Name: lpc43_usbinterrupt + * + * Description: + * USB interrupt handler + * + *******************************************************************************/ + +static int lpc43_usbinterrupt(int irq, FAR void *context) +{ + struct lpc43_usbdev_s *priv = &g_usbdev; + uint32_t disr, portsc1, n; + + usbtrace(TRACE_INTENTRY(LPC43_TRACEINTID_USB), 0); + + /* Read the interrupts and then clear them */ + disr = lpc43_getreg(LPC43_USBDEV_USBSTS); + lpc43_putreg(disr, LPC43_USBDEV_USBSTS); + + if (disr & USBDEV_USBSTS_URI) + { + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_DEVRESET),0); + + lpc43_usbreset(priv); + + usbtrace(TRACE_INTEXIT(LPC43_TRACEINTID_USB), 0); + return OK; + } + + if (disr & USBDEV_USBSTS_SLI) + { + // FIXME: what do we need to do here... + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_SUSPENDCHG),0); + } + + if (disr & USBDEV_USBSTS_PCI) + { + portsc1 = lpc43_getreg(LPC43_USBDEV_PORTSC1); + + if (portsc1 & USBDEV_PRTSC1_HSP) + priv->usbdev.speed = USB_SPEED_HIGH; + else + priv->usbdev.speed = USB_SPEED_FULL; + + if (portsc1 & USBDEV_PRTSC1_FPR) + { + /* FIXME: this occurs because of a J-to-K transition detected + * while the port is in SUSPEND state - presumambly this + * is where the host is resuming the device? + * + * - but do we need to "ack" the interrupt + */ + } + } + +#ifdef CONFIG_LPC43_USBDEV_FRAME_INTERRUPT + if (disr & USBDEV_USBSTT_SRI) + { + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_FRAME), 0); + + priv->sof = (int)lpc43_getreg(LPC43_USBDEV_FRINDEX_OFFSET); + } +#endif + + if (disr & USBDEV_USBSTS_UEI) + { + /* FIXME: these occur when a transfer results in an error condition + * it is set alongside USBINT if the DTD also had its IOC + * bit set. */ + } + + if (disr & USBDEV_USBSTS_UI) + { + /* Handle completion interrupts */ + uint32_t mask = lpc43_getreg (LPC43_USBDEV_ENDPTCOMPLETE); + + if (mask) + { + /* Clear any NAK interrupt and completion interrupts */ + lpc43_putreg (mask, LPC43_USBDEV_ENDPTNAK); + lpc43_putreg (mask, LPC43_USBDEV_ENDPTCOMPLETE); + + if (mask & LPC43_ENDPTMASK(0)) + lpc43_ep0complete(priv, 0); + if (mask & LPC43_ENDPTMASK(1)) + lpc43_ep0complete(priv, 1); + + for (n = 1; n < LPC43_NLOGENDPOINTS; n++) + { + if (mask & LPC43_ENDPTMASK((n<<1))) + lpc43_epcomplete (priv, (n<<1)); + if (mask & LPC43_ENDPTMASK((n<<1)+1)) + lpc43_epcomplete(priv, (n<<1)+1); + } + } + + /* Handle setup interrupts */ + uint32_t setupstat = lpc43_getreg(LPC43_USBDEV_ENDPTSETUPSTAT); + if (setupstat) + { + /* Clear the endpoint complete CTRL OUT and IN when a Setup is received */ + lpc43_putreg(LPC43_ENDPTMASK(LPC43_EP0_IN) | LPC43_ENDPTMASK(LPC43_EP0_OUT), + LPC43_USBDEV_ENDPTCOMPLETE); + + if (setupstat & LPC43_ENDPTMASK(LPC43_EP0_OUT)) + { + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_EP0SETUP), setupstat); + lpc43_ep0setup(priv); + } + } + } + + if (disr & USBDEV_USBSTS_NAKI) + { + uint32_t pending = lpc43_getreg(LPC43_USBDEV_ENDPTNAK) & lpc43_getreg(LPC43_USBDEV_ENDPTNAKEN); + if (pending) + { + /* We shouldn't see NAK interrupts except on Endpoint 0 */ + if (pending & LPC43_ENDPTMASK(0)) + lpc43_ep0nak(priv, 0); + if (pending & LPC43_ENDPTMASK(1)) + lpc43_ep0nak(priv, 1); + } + + /* Clear the interrupts */ + lpc43_putreg(pending, LPC43_USBDEV_ENDPTNAK); + } + + usbtrace(TRACE_INTEXIT(LPC43_TRACEINTID_USB), 0); + return OK; +} + +/******************************************************************************* + * Endpoint operations + *******************************************************************************/ + +/******************************************************************************* + * Name: lpc43_epconfigure + * + * Description: + * Configure endpoint, making it usable + * + * Input Parameters: + * ep - the struct usbdev_ep_s instance obtained from allocep() + * desc - A struct usb_epdesc_s instance describing the endpoint + * last - true if this this last endpoint to be configured. Some hardware + * needs to take special action when all of the endpoints have been + * configured. + * + *******************************************************************************/ + +static int lpc43_epconfigure(FAR struct usbdev_ep_s *ep, + FAR const struct usb_epdesc_s *desc, + bool last) +{ + FAR struct lpc43_ep_s *privep = (FAR struct lpc43_ep_s *)ep; + + usbtrace(TRACE_EPCONFIGURE, privep->epphy); + DEBUGASSERT(desc->addr == ep->eplog); + + /* Initialise EP capabilities */ + + uint16_t maxsize = GETUINT16(desc->mxpacketsize); + if ((desc->attr & USB_EP_ATTR_XFERTYPE_MASK) == USB_EP_ATTR_XFER_ISOC) + { + g_qh[privep->epphy].capability = (DQH_CAPABILITY_MAX_PACKET(maxsize) | + DQH_CAPABILITY_IOS | + DQH_CAPABILITY_ZLT); + } + else + { + g_qh[privep->epphy].capability = (DQH_CAPABILITY_MAX_PACKET(maxsize) | + DQH_CAPABILITY_ZLT); + } + + /* Setup Endpoint Control Register */ + + if (LPC43_EPPHYIN(privep->epphy)) + { + /* Reset the data toggles */ + uint32_t cfg = USBDEV_ENDPTCTRL_TXR; + + /* Set the endpoint type */ + switch (desc->attr & USB_EP_ATTR_XFERTYPE_MASK) + { + case USB_EP_ATTR_XFER_CONTROL: cfg |= USBDEV_ENDPTCTRL_TXT_CTRL; break; + case USB_EP_ATTR_XFER_ISOC: cfg |= USBDEV_ENDPTCTRL_TXT_ISOC; break; + case USB_EP_ATTR_XFER_BULK: cfg |= USBDEV_ENDPTCTRL_TXT_BULK; break; + case USB_EP_ATTR_XFER_INT: cfg |= USBDEV_ENDPTCTRL_TXT_INTR; break; + } + lpc43_chgbits (0xFFFF0000, cfg, LPC43_USBDEV_ENDPTCTRL(privep->epphy)); + } + else + { + /* Reset the data toggles */ + uint32_t cfg = USBDEV_ENDPTCTRL_RXR; + + /* Set the endpoint type */ + switch (desc->attr & USB_EP_ATTR_XFERTYPE_MASK) + { + case USB_EP_ATTR_XFER_CONTROL: cfg |= USBDEV_ENDPTCTRL_RXT_CTRL; break; + case USB_EP_ATTR_XFER_ISOC: cfg |= USBDEV_ENDPTCTRL_RXT_ISOC; break; + case USB_EP_ATTR_XFER_BULK: cfg |= USBDEV_ENDPTCTRL_RXT_BULK; break; + } + lpc43_chgbits (0x0000FFFF, cfg, LPC43_USBDEV_ENDPTCTRL(privep->epphy)); + } + + /* Reset endpoint status */ + privep->stalled = false; + + /* Enable the endpoint */ + if (LPC43_EPPHYIN(privep->epphy)) + lpc43_setbits (USBDEV_ENDPTCTRL_TXE, LPC43_USBDEV_ENDPTCTRL(privep->epphy)); + else + lpc43_setbits (USBDEV_ENDPTCTRL_RXE, LPC43_USBDEV_ENDPTCTRL(privep->epphy)); + + return OK; +} + +/******************************************************************************* + * Name: lpc43_epdisable + * + * Description: + * The endpoint will no longer be used + * + *******************************************************************************/ + +static int lpc43_epdisable(FAR struct usbdev_ep_s *ep) +{ + FAR struct lpc43_ep_s *privep = (FAR struct lpc43_ep_s *)ep; + irqstate_t flags; + +#ifdef CONFIG_DEBUG + if (!ep) + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_INVALIDPARMS), 0); + return -EINVAL; + } +#endif + usbtrace(TRACE_EPDISABLE, privep->epphy); + + flags = irqsave(); + + /* Disable Endpoint */ + if (LPC43_EPPHYIN(privep->epphy)) + lpc43_clrbits (USBDEV_ENDPTCTRL_TXE, LPC43_USBDEV_ENDPTCTRL(privep->epphy)); + else + lpc43_clrbits (USBDEV_ENDPTCTRL_RXE, LPC43_USBDEV_ENDPTCTRL(privep->epphy)); + + privep->stalled = true; + + /* Cancel any ongoing activity */ + lpc43_cancelrequests(privep, -ESHUTDOWN); + + irqrestore(flags); + return OK; +} + +/******************************************************************************* + * Name: lpc43_epallocreq + * + * Description: + * Allocate an I/O request + * + *******************************************************************************/ + +static FAR struct usbdev_req_s *lpc43_epallocreq(FAR struct usbdev_ep_s *ep) +{ + FAR struct lpc43_req_s *privreq; + +#ifdef CONFIG_DEBUG + if (!ep) + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_INVALIDPARMS), 0); + return NULL; + } +#endif + usbtrace(TRACE_EPALLOCREQ, ((FAR struct lpc43_ep_s *)ep)->epphy); + + privreq = (FAR struct lpc43_req_s *)malloc(sizeof(struct lpc43_req_s)); + if (!privreq) + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_ALLOCFAIL), 0); + return NULL; + } + + memset(privreq, 0, sizeof(struct lpc43_req_s)); + return &privreq->req; +} + +/******************************************************************************* + * Name: lpc43_epfreereq + * + * Description: + * Free an I/O request + * + *******************************************************************************/ + +static void lpc43_epfreereq(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req) +{ + FAR struct lpc43_req_s *privreq = (FAR struct lpc43_req_s *)req; + +#ifdef CONFIG_DEBUG + if (!ep || !req) + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_INVALIDPARMS), 0); + return; + } +#endif + + usbtrace(TRACE_EPFREEREQ, ((FAR struct lpc43_ep_s *)ep)->epphy); + free(privreq); +} + +/******************************************************************************* + * Name: lpc43_epallocbuffer + * + * Description: + * Allocate an I/O buffer + * + *******************************************************************************/ + +#ifdef CONFIG_ARCH_USBDEV_DMA +static void *lpc43_epallocbuffer(FAR struct usbdev_ep_s *ep, unsigned bytes) +{ + usbtrace(TRACE_EPALLOCBUFFER, privep->epphy); + return malloc(bytes) +} +#endif + +/******************************************************************************* + * Name: lpc43_epfreebuffer + * + * Description: + * Free an I/O buffer + * + *******************************************************************************/ + +#ifdef CONFIG_LPC433x_USBDEV_DMA +static void lpc43_epfreebuffer(FAR struct usbdev_ep_s *ep, FAR void *buf) +{ + usbtrace(TRACE_EPFREEBUFFER, privep->epphy); + free(buf); +} +#endif + +/******************************************************************************* + * Name: lpc43_epsubmit + * + * Description: + * Submit an I/O request to the endpoint + * + *******************************************************************************/ + +static int lpc43_epsubmit(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req) +{ + FAR struct lpc43_req_s *privreq = (FAR struct lpc43_req_s *)req; + FAR struct lpc43_ep_s *privep = (FAR struct lpc43_ep_s *)ep; + FAR struct lpc43_usbdev_s *priv; + irqstate_t flags; + int ret = OK; + +#ifdef CONFIG_DEBUG + if (!req || !req->callback || !req->buf || !ep) + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_INVALIDPARMS), 0); + ullvdbg("req=%p callback=%p buf=%p ep=%p\n", req, req->callback, req->buf, ep); + return -EINVAL; + } +#endif + + usbtrace(TRACE_EPSUBMIT, privep->epphy); + priv = privep->dev; + + if (!priv->driver || priv->usbdev.speed == USB_SPEED_UNKNOWN) + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_NOTCONFIGURED), priv->usbdev.speed); + return -ESHUTDOWN; + } + + /* Handle the request from the class driver */ + + req->result = -EINPROGRESS; + req->xfrd = 0; + + /* Disable Interrupts */ + + flags = irqsave(); + + /* If we are stalled, then drop all requests on the floor */ + + if (privep->stalled) + { + ret = -EBUSY; + } + else + { + /* Add the new request to the request queue for the endpoint */ + + if (LPC43_EPPHYIN(privep->epphy)) + usbtrace(TRACE_INREQQUEUED(privep->epphy), privreq->req.len); + else + usbtrace(TRACE_OUTREQQUEUED(privep->epphy), privreq->req.len); + + if (lpc43_rqenqueue(privep, privreq)) + { + lpc43_progressep(privep); + } + } + + irqrestore(flags); + return ret; +} + +/******************************************************************************* + * Name: lpc43_epcancel + * + * Description: + * Cancel an I/O request previously sent to an endpoint + * + *******************************************************************************/ + +static int lpc43_epcancel(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req) +{ + FAR struct lpc43_ep_s *privep = (FAR struct lpc43_ep_s *)ep; + FAR struct lpc43_usbdev_s *priv; + irqstate_t flags; + +#ifdef CONFIG_DEBUG + if (!ep || !req) + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_INVALIDPARMS), 0); + return -EINVAL; + } +#endif + + usbtrace(TRACE_EPCANCEL, privep->epphy); + priv = privep->dev; + + flags = irqsave(); + + /* FIXME: if the request is the first, then we need to flush the EP + * otherwise just remove it from the list + * + * but ... all other implementations cancel all requests ... + */ + + lpc43_cancelrequests(privep, -ESHUTDOWN); + irqrestore(flags); + return OK; +} + +/******************************************************************************* + * Name: lpc43_epstall + * + * Description: + * Stall or resume and endpoint + * + *******************************************************************************/ + +static int lpc43_epstall(FAR struct usbdev_ep_s *ep, bool resume) +{ + FAR struct lpc43_ep_s *privep = (FAR struct lpc43_ep_s *)ep; + irqstate_t flags; + + /* STALL or RESUME the endpoint */ + + flags = irqsave(); + usbtrace(resume ? TRACE_EPRESUME : TRACE_EPSTALL, privep->epphy); + + uint32_t addr = LPC43_USBDEV_ENDPTCTRL(privep->epphy); + uint32_t ctrl_xs = LPC43_EPPHYIN(privep->epphy) ? USBDEV_ENDPTCTRL_TXS : USBDEV_ENDPTCTRL_RXS; + uint32_t ctrl_xr = LPC43_EPPHYIN(privep->epphy) ? USBDEV_ENDPTCTRL_TXR : USBDEV_ENDPTCTRL_RXR; + + if (resume) + { + privep->stalled = false; + + /* Clear stall and reset the data toggle */ + + lpc43_chgbits (ctrl_xs | ctrl_xr, ctrl_xr, addr); + } + else + { + privep->stalled = true; + + lpc43_setbits (ctrl_xs, addr); + } + + irqrestore(flags); + return OK; +} + +/******************************************************************************* + * Device operations + *******************************************************************************/ + +/******************************************************************************* + * Name: lpc43_allocep + * + * Description: + * Allocate an endpoint matching the parameters. + * + * Input Parameters: + * eplog - 7-bit logical endpoint number (direction bit ignored). Zero means + * that any endpoint matching the other requirements will suffice. The + * assigned endpoint can be found in the eplog field. + * in - true: IN (device-to-host) endpoint requested + * eptype - Endpoint type. One of {USB_EP_ATTR_XFER_ISOC, USB_EP_ATTR_XFER_BULK, + * USB_EP_ATTR_XFER_INT} + * + *******************************************************************************/ + +static FAR struct usbdev_ep_s *lpc43_allocep(FAR struct usbdev_s *dev, uint8_t eplog, + bool in, uint8_t eptype) +{ + FAR struct lpc43_usbdev_s *priv = (FAR struct lpc43_usbdev_s *)dev; + uint32_t epset = LPC43_EPALLSET & ~LPC43_EPCTRLSET; + irqstate_t flags; + int epndx = 0; + + usbtrace(TRACE_DEVALLOCEP, (uint16_t)eplog); + + /* Ignore any direction bits in the logical address */ + + eplog = USB_EPNO(eplog); + + /* A logical address of 0 means that any endpoint will do */ + + if (eplog > 0) + { + /* Otherwise, we will return the endpoint structure only for the requested + * 'logical' endpoint. All of the other checks will still be performed. + * + * First, verify that the logical endpoint is in the range supported by + * by the hardware. + */ + + if (eplog >= LPC43_NLOGENDPOINTS) + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_BADEPNO), (uint16_t)eplog); + return NULL; + } + + /* Convert the logical address to a physical OUT endpoint address and + * remove all of the candidate endpoints from the bitset except for the + * the IN/OUT pair for this logical address. + */ + + epset &= 3 << (eplog << 1); + } + + /* Get the subset matching the requested direction */ + + if (in) + { + epset &= LPC43_EPINSET; + } + else + { + epset &= LPC43_EPOUTSET; + } + + /* Get the subset matching the requested type */ + + switch (eptype) + { + case USB_EP_ATTR_XFER_INT: /* Interrupt endpoint */ + epset &= LPC43_EPINTRSET; + break; + + case USB_EP_ATTR_XFER_BULK: /* Bulk endpoint */ + epset &= LPC43_EPBULKSET; + break; + + case USB_EP_ATTR_XFER_ISOC: /* Isochronous endpoint */ + epset &= LPC43_EPISOCSET; + break; + + case USB_EP_ATTR_XFER_CONTROL: /* Control endpoint -- not a valid choice */ + default: + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_BADEPTYPE), (uint16_t)eptype); + return NULL; + } + + /* Is the resulting endpoint supported by the LPC433x? */ + + if (epset) + { + /* Yes.. now see if any of the request endpoints are available */ + + flags = irqsave(); + epset &= priv->epavail; + if (epset) + { + /* Select the lowest bit in the set of matching, available endpoints */ + + for (epndx = 2; epndx < LPC43_NPHYSENDPOINTS; epndx++) + { + uint32_t bit = 1 << epndx; + if ((epset & bit) != 0) + { + /* Mark the IN/OUT endpoint no longer available */ + + priv->epavail &= ~(3 << (bit & ~1)); + irqrestore(flags); + + /* And return the pointer to the standard endpoint structure */ + + return &priv->eplist[epndx].ep; + } + } + /* Shouldn't get here */ + } + irqrestore(flags); + } + + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_NOEP), (uint16_t)eplog); + return NULL; +} + +/******************************************************************************* + * Name: lpc43_freeep + * + * Description: + * Free the previously allocated endpoint + * + *******************************************************************************/ + +static void lpc43_freeep(FAR struct usbdev_s *dev, FAR struct usbdev_ep_s *ep) +{ + FAR struct lpc43_usbdev_s *priv = (FAR struct lpc43_usbdev_s *)dev; + FAR struct lpc43_ep_s *privep = (FAR struct lpc43_ep_s *)ep; + irqstate_t flags; + + usbtrace(TRACE_DEVFREEEP, (uint16_t)privep->epphy); + + if (priv && privep) + { + /* Mark the endpoint as available */ + + flags = irqsave(); + priv->epavail |= (1 << privep->epphy); + irqrestore(flags); + } +} + +/******************************************************************************* + * Name: lpc43_getframe + * + * Description: + * Returns the current frame number + * + *******************************************************************************/ + +static int lpc43_getframe(struct usbdev_s *dev) +{ +#ifdef CONFIG_LPC43_USBDEV_FRAME_INTERRUPT + FAR struct lpc43_usbdev_s *priv = (FAR struct lpc43_usbdev_s *)dev; + + /* Return last valid value of SOF read by the interrupt handler */ + + usbtrace(TRACE_DEVGETFRAME, (uint16_t)priv->sof); + return priv->sof; +#else + /* Return the last frame number detected by the hardware */ + + usbtrace(TRACE_DEVGETFRAME, 0); + + /* FIXME: this actually returns the micro frame number! */ + return (int)lpc43_getreg(LPC43_USBDEV_FRINDEX_OFFSET); +#endif +} + +/******************************************************************************* + * Name: lpc43_wakeup + * + * Description: + * Tries to wake up the host connected to this device + * + *******************************************************************************/ + +static int lpc43_wakeup(struct usbdev_s *dev) +{ + irqstate_t flags; + + usbtrace(TRACE_DEVWAKEUP, 0); + + flags = irqsave(); + lpc43_setbits(USBDEV_PRTSC1_FPR, LPC43_USBDEV_PORTSC1); + irqrestore(flags); + return OK; +} + +/******************************************************************************* + * Name: lpc43_selfpowered + * + * Description: + * Sets/clears the device selfpowered feature + * + *******************************************************************************/ + +static int lpc43_selfpowered(struct usbdev_s *dev, bool selfpowered) +{ + FAR struct lpc43_usbdev_s *priv = (FAR struct lpc43_usbdev_s *)dev; + + usbtrace(TRACE_DEVSELFPOWERED, (uint16_t)selfpowered); + +#ifdef CONFIG_DEBUG + if (!dev) + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_INVALIDPARMS), 0); + return -ENODEV; + } +#endif + + priv->selfpowered = selfpowered; + return OK; +} + +/******************************************************************************* + * Name: lpc43_pullup + * + * Description: + * Software-controlled connect to/disconnect from USB host + * + *******************************************************************************/ + +static int lpc43_pullup(struct usbdev_s *dev, bool enable) +{ + usbtrace(TRACE_DEVPULLUP, (uint16_t)enable); + + irqstate_t flags = irqsave(); + if (enable) + lpc43_setbits (USBDEV_USBCMD_RS, LPC43_USBDEV_USBCMD); + else + lpc43_clrbits (USBDEV_USBCMD_RS, LPC43_USBDEV_USBCMD); + irqrestore(flags); + return OK; +} + +/******************************************************************************* + * Public Functions + *******************************************************************************/ + +/******************************************************************************* + * Name: up_usbinitialize + * + * Description: + * Initialize USB hardware. + * + * Assumptions: + * - This function is called very early in the initialization sequence + * - PLL and GIO pin initialization is not performed here but should been in + * the low-level boot logic: PLL1 must be configured for operation at 48MHz + * and P0.23 and PO.31 in PINSEL1 must be configured for Vbus and USB connect + * LED. + * + *******************************************************************************/ + +void up_usbinitialize(void) +{ + struct lpc43_usbdev_s *priv = &g_usbdev; + int i; + + usbtrace(TRACE_DEVINIT, 0); + + /* Disable USB interrupts */ + + lpc43_putreg(0, LPC43_USBDEV_USBINTR); + + /* Initialize the device state structure */ + + memset(priv, 0, sizeof(struct lpc43_usbdev_s)); + priv->usbdev.ops = &g_devops; + priv->usbdev.ep0 = &priv->eplist[LPC43_EP0_IN].ep; + priv->epavail = LPC43_EPALLSET; + + /* Initialize the endpoint list */ + + for (i = 0; i < LPC43_NPHYSENDPOINTS; i++) + { + uint32_t bit = 1 << i; + + /* Set endpoint operations, reference to driver structure (not + * really necessary because there is only one controller), and + * the physical endpoint number (which is just the index to the + * endpoint). + */ + priv->eplist[i].ep.ops = &g_epops; + priv->eplist[i].dev = priv; + + /* The index, i, is the physical endpoint address; Map this + * to a logical endpoint address usable by the class driver. + */ + + priv->eplist[i].epphy = i; + if (LPC43_EPPHYIN(i)) + { + priv->eplist[i].ep.eplog = LPC43_EPPHYIN2LOG(i); + } + else + { + priv->eplist[i].ep.eplog = LPC43_EPPHYOUT2LOG(i); + } + + /* The maximum packet size may depend on the type of endpoint */ + + if ((LPC43_EPCTRLSET & bit) != 0) + { + priv->eplist[i].ep.maxpacket = LPC43_EP0MAXPACKET; + } + else if ((LPC43_EPINTRSET & bit) != 0) + { + priv->eplist[i].ep.maxpacket = LPC43_INTRMAXPACKET; + } + else if ((LPC43_EPBULKSET & bit) != 0) + { + priv->eplist[i].ep.maxpacket = LPC43_BULKMAXPACKET; + } + else /* if ((LPC43_EPISOCSET & bit) != 0) */ + { + priv->eplist[i].ep.maxpacket = LPC43_ISOCMAXPACKET; + } + } + + /* Enable USB to AHB clock and to Event router*/ + + lpc43_enableclock (CLKID_USBOTGAHBCLK); + lpc43_enableclock (CLKID_EVENTROUTERPCLK); + + /* Reset USB block */ + + lpc43_softreset (RESETID_USBOTGAHBRST); + + /* Enable USB OTG PLL and wait for lock */ + + lpc43_putreg (0, LPC43_SYSCREG_USB_ATXPLLPDREG); + + uint32_t bank = EVNTRTR_BANK(EVENTRTR_USBATXPLLLOCK); + uint32_t bit = EVNTRTR_BIT(EVENTRTR_USBATXPLLLOCK); + + while (! (lpc43_getreg(LPC43_EVNTRTR_RSR(bank)) & (1 << bit))) + ; + + /* Enable USB AHB clock */ + + lpc43_enableclock (CLKID_USBOTGAHBCLK); + + /* Reset the controller */ + + lpc43_putreg (USBDEV_USBCMD_RST, LPC43_USBDEV_USBCMD); + while (lpc43_getreg (LPC43_USBDEV_USBCMD) & USBDEV_USBCMD_RST) + ; + + /* Attach USB controller interrupt handler */ + + if (irq_attach(LPC43_IRQ_USBOTG, lpc43_usbinterrupt) != 0) + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_IRQREGISTRATION), + (uint16_t)LPC43_IRQ_USBOTG); + goto errout; + } + + + /* Program the controller to be the USB device controller */ + + lpc43_putreg (USBDEV_USBMODE_SDIS | USBDEV_USBMODE_SLOM | USBDEV_USBMODE_CMDEVICE, + LPC43_USBDEV_USBMODE); + + /* Disconnect device */ + + lpc43_pullup(&priv->usbdev, false); + + /* Reset/Re-initialize the USB hardware */ + + lpc43_usbreset(priv); + + return; + +errout: + up_usbuninitialize(); +} + +/******************************************************************************* + * Name: up_usbuninitialize + *******************************************************************************/ + +void up_usbuninitialize(void) +{ + struct lpc43_usbdev_s *priv = &g_usbdev; + irqstate_t flags; + + usbtrace(TRACE_DEVUNINIT, 0); + + if (priv->driver) + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_DRIVERREGISTERED), 0); + usbdev_unregister(priv->driver); + } + + /* Disconnect device */ + + flags = irqsave(); + lpc43_pullup(&priv->usbdev, false); + priv->usbdev.speed = USB_SPEED_UNKNOWN; + + /* Disable and detach IRQs */ + + up_disable_irq(LPC43_IRQ_USBOTG); + irq_detach(LPC43_IRQ_USBOTG); + + /* Reset the controller */ + + lpc43_putreg (USBDEV_USBCMD_RST, LPC43_USBDEV_USBCMD); + while (lpc43_getreg (LPC43_USBDEV_USBCMD) & USBDEV_USBCMD_RST) + ; + + /* Turn off USB power and clocking */ + + lpc43_disableclock (CLKID_USBOTGAHBCLK); + lpc43_disableclock (CLKID_EVENTROUTERPCLK); + + + irqrestore(flags); +} + +/******************************************************************************* + * Name: usbdev_register + * + * Description: + * Register a USB device class driver. The class driver's bind() method will be + * called to bind it to a USB device driver. + * + *******************************************************************************/ + +int usbdev_register(struct usbdevclass_driver_s *driver) +{ + int ret; + + usbtrace(TRACE_DEVREGISTER, 0); + +#ifdef CONFIG_DEBUG + if (!driver || !driver->ops->bind || !driver->ops->unbind || + !driver->ops->disconnect || !driver->ops->setup) + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_INVALIDPARMS), 0); + return -EINVAL; + } + + if (g_usbdev.driver) + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_DRIVER), 0); + return -EBUSY; + } +#endif + + /* First hook up the driver */ + + g_usbdev.driver = driver; + + /* Then bind the class driver */ + + ret = CLASS_BIND(driver, &g_usbdev.usbdev); + if (ret) + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_BINDFAILED), (uint16_t)-ret); + g_usbdev.driver = NULL; + } + else + { + /* Enable USB controller interrupts */ + + up_enable_irq(LPC43_IRQ_USBOTG); + + /* FIXME: nothing seems to call DEV_CONNECT(), but we need to set + * the RS bit to enable the controller. It kind of makes sense + * to do this after the class has bound to us... + * GEN: This bug is really in the class driver. It should make the + * soft connect when it is ready to be enumerated. I have added + * that logic to the class drivers but left this logic here. + */ + + lpc43_pullup(&g_usbdev.usbdev, true); + } + return ret; +} + +/******************************************************************************* + * Name: usbdev_unregister + * + * Description: + * Un-register usbdev class driver.If the USB device is connected to a USB host, + * it will first disconnect(). The driver is also requested to unbind() and clean + * up any device state, before this procedure finally returns. + * + *******************************************************************************/ + +int usbdev_unregister(struct usbdevclass_driver_s *driver) +{ + usbtrace(TRACE_DEVUNREGISTER, 0); + +#ifdef CONFIG_DEBUG + if (driver != g_usbdev.driver) + { + usbtrace(TRACE_DEVERROR(LPC43_TRACEERR_INVALIDPARMS), 0); + return -EINVAL; + } +#endif + + /* Unbind the class driver */ + + CLASS_UNBIND(driver, &g_usbdev.usbdev); + + /* Disable USB controller interrupts */ + + up_disable_irq(LPC43_IRQ_USBOTG); + + /* Unhook the driver */ + + g_usbdev.driver = NULL; + return OK; +} From 62cfd38241000dfb6fbfa8deaaf940fcf400ac31 Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 7 Aug 2012 23:51:47 +0000 Subject: [PATCH 08/13] Add a USB0 device header file for LPC43 git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5016 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/ChangeLog | 10 +- nuttx/Documentation/NuttShell.html | 8 +- nuttx/Documentation/NuttX.html | 14 +- nuttx/Documentation/NuttXDemandPaging.html | 1350 ++++++++++---------- nuttx/Documentation/NuttxPortingGuide.html | 4 +- nuttx/Documentation/NxWidgets.html | 2 +- nuttx/ReleaseNotes | 14 +- nuttx/TODO | 2 +- nuttx/arch/arm/src/lpc43xx/lpc43_usb0dev.c | 4 +- nuttx/arch/arm/src/lpc43xx/lpc43_usb0dev.h | 98 ++ 10 files changed, 801 insertions(+), 705 deletions(-) create mode 100644 nuttx/arch/arm/src/lpc43xx/lpc43_usb0dev.h diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 614381c900..107a426d6f 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -816,7 +816,7 @@ and (2) it requires symbol table arguments. * lib/: Add fileno() * examples/ostest: Several of the tests used a big, hard-coded stack size - when creating test threads (16Kb stacksize). The stack size should + when creating test threads (16K stacksize). The stack size should be controlled by the .config file or the OSTest won't work on platforms with memory constraints. * netutils/thttpd: An initial port of Jeff Poskanzer's THTTPD HTTP server. @@ -1369,10 +1369,10 @@ out instead. This improves behavior, for example, on the first GET request from a browser. * arch/arm/src/lpc17xx/lpc17_emacram.h and lpc17_allocateheap.c: The Ethernet - logic was using all of AHB SRAM Bank0 for Ethernet packet buffers (16Kb). An + logic was using all of AHB SRAM Bank0 for Ethernet packet buffers (16K). An option was added to limit the amount of SRAM used for packet buffering and to re-use any extra Bank0 memory for heap. configs/olimex-lpc1766stk/nettest - now uses only 8Kb at the beginning of Bank0; the 8Kb at the end of Bank0 is + now uses only 8K at the beginning of Bank0; the 8K at the end of Bank0 is included in the heap * arch/arm/src/lpc17xx/lpc17_ssp.c: Fix compilation errors when SSP1 is selected. @@ -1785,7 +1785,7 @@ that support 16-bit addressability have smaller overhead than devices that support 32-bit addressability. However, there are many MCUs that support 32-bit addressability *but* have internal SRAM of size - less than or equal to 64Kb. In this case, CONFIG_MM_SMALL can be + less than or equal to 64K. In this case, CONFIG_MM_SMALL can be defined so that those MCUs will also benefit from the smaller, 16- bit-based allocation overhead. * lib/string/lib_strndup.c: Add standard strndup() library function. @@ -1846,7 +1846,7 @@ * arch/sim/src/up_romgetc.c: Used to test the basic logic to access strings without directly de-referencing a string pointer. * arch/avr/src/avr/up_romget.c: Used to access strings that lie in the first - 64Kb of FLASH (But I still haven't figured out how to get strings to reside in + 64K of FLASH (But I still haven't figured out how to get strings to reside in FLASH without using the PROGMEM attribute). * configs/teensy/src/up_spi.c: Correct reading of SD CD and WP pins (was reading the wrong register. AVR SPI now appears to be functional. diff --git a/nuttx/Documentation/NuttShell.html b/nuttx/Documentation/NuttShell.html index a92cbadd8e..ca7e826279 100644 --- a/nuttx/Documentation/NuttShell.html +++ b/nuttx/Documentation/NuttShell.html @@ -8,7 +8,7 @@

    NuttShell (NSH)

    -

    Last Updated: August 3, 2012

    +

    Last Updated: August 7, 2012

    @@ -1210,7 +1210,7 @@ losetup [-o ] [-r] <dev-path> <file-path>

    Synopsis. Setup the loop device at <dev-path> to access the file at <file-path> as a block device. - In the following example a 256Kb file is created (dd) and losetup is + In the following example a 256K file is created (dd) and losetup is used to make the file accessible as a block device. A FAT file system is created (mkfatfs) and mounted (mount). Files can then be managed on the loop-mounted file. @@ -3148,7 +3148,7 @@ endef

  • - The make file then defines the application name (hello), the task priority (default), and the stack size that will be allocated in the task runs (2Kb). + The make file then defines the application name (hello), the task priority (default), and the stack size that will be allocated in the task runs (2K).

       APPNAME         = hello
      @@ -3160,7 +3160,7 @@ STACKSIZE       = 2048
           

      And finally, the Makefile invokes the REGISTER macro to added the hello_main() named application. Then, when the system build completes, the hello command can be executed from the NSH command line. - When the hello command is executed, it will start the task with entry point hello_main() with the default priority and with a stack size of 2Kb. + When the hello command is executed, it will start the task with entry point hello_main() with the default priority and with a stack size of 2K.

         .context:
        diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html
        index ed994d69b9..b7026f8965 100644
        --- a/nuttx/Documentation/NuttX.html
        +++ b/nuttx/Documentation/NuttX.html
        @@ -858,9 +858,9 @@
             

        Using a variety of technologies, NuttX can scale from the very tiny to the moderate-size system. I have executed NuttX with some simple applications - in as little as 32Kb total memory (code and data). - On the other hand, typical, richly featured NuttX builds require more like 64Kb - (and if all of the features are used, this can push 100Kb). + in as little as 32K total memory (code and data). + On the other hand, typical, richly featured NuttX builds require more like 64K + (and if all of the features are used, this can push 100K).

        @@ -2028,8 +2028,8 @@ Micropendous 3 AT9USB64x and AT9USB6128x. This port of NuttX to the Opendous Micropendous 3 board. The Micropendous3 is may be populated with an AT90USB646, 647, 1286, or 1287. I have only the AT90USB647 - version for testing. This version have very limited memory resources: 64Kb of - FLASH and 4Kb of SRAM. + version for testing. This version have very limited memory resources: 64K of + FLASH and 4K of SRAM.

          @@ -2085,7 +2085,7 @@

          Most NuttX test applications are console-oriented with lots of strings used for printf and debug output. - These strings are all stored in SRAM now due to these data accessing issues and even the smallest console-oriented applications can quickly fill a 4-8Kb memory. + These strings are all stored in SRAM now due to these data accessing issues and even the smallest console-oriented applications can quickly fill a 4-8K memory. So, in order for the AVR port to be useful, one of two things would need to be done:

            @@ -2917,7 +2917,7 @@ if [ -x "$WINELOADER" ]; then exec "$WINELOADER" "$appname" "$@"; fi

        87C52 A reduced functionality OS test for the 8052 target requires only - about 18-19Kb: + about 18-19K:

         Stack starts at: 0x21 (sp set to 0x20) with 223 bytes available.
        diff --git a/nuttx/Documentation/NuttXDemandPaging.html b/nuttx/Documentation/NuttXDemandPaging.html
        index 3246e070d0..c238161a82 100644
        --- a/nuttx/Documentation/NuttXDemandPaging.html
        +++ b/nuttx/Documentation/NuttXDemandPaging.html
        @@ -1,675 +1,675 @@
        -
        -
        -On-Demand Paging
        -
        -
        -

        - - - - -
        -

        On-Demand Paging

        -

        >>> Under Construction <<<

        -

        Last Updated: August 12, 2010

        -
        -

        - - - - - -
        -

        Table of Contents

        -
        - -
        - - - - - - - - - - -
        - - - - - - - - - - - - - -
        - Introduction -
          - Overview -
          - Terminology -
        -
        - - - - - - - - - - - - - - - - - - - - - - - - - -
        - NuttX Common Logic Design Description -
          - Initialization -
          - Page Faults -
          - Fill Initiation -
          - Fill Complete -
          - Task Resumption -
        -
        - - - - - - - - - - - - - -
        - Architecture-Specific Support Requirements -
          - Memory Organization -
          - Architecture-Specific Functions -
        -
        - - - - - -
        -

        Introduction

        -
        -

        Overview

        - -

        - This document summarizes the design of NuttX on-demand paging. - This feature permits embedded MCUs with some limited RAM space to execute large programs from some non-random access media. - This feature was first discussed in this email thread: - http://tech.groups.yahoo.com/group/nuttx/message/213. -

        -

        - What kind of platforms can support NuttX on-demang paging? -

          -
        1. - The MCU should have some large, probably low-cost non-volatile storage such as serial FLASH or an SD card. - This storage probably does not support non-random access (otherwise, why not just execute the program directly on the storage media). - SD and serial FLASH are inexpensive and do not require very many pins and SPI support is prevalent in just about all MCUs. - This large serial FLASH would contain a big program. Perhaps a program of several megabytes in size. -
        2. -
        3. - The MCU must have a (relatively) small block of fast SRAM from which it can execute code. - A size of, say 256Kb (or 192Kb as in the NXP LPC3131) would be sufficient for many applications. -
        4. -
        5. - The MCU has an MMU (again like the NXP LPC3131). -
        6. -
        -

        -

        - If the platform meets these requirement, then NuttX can provide on-demand paging: - It can copy .text from the large program in non-volatile media into RAM as needed to execute a huge program from the small RAM. -

        - -

        Terminology

        - -
        -
        g_waitingforfill
        -
        An OS list that is used to hold the TCBs of tasks that are waiting for a page fill.
        -
        g_pftcb
        -
        A variable that holds a reference to the TCB of the thread that is currently be re-filled.
        -
        g_pgworker
        -
        The process ID of of the thread that will perform the page fills.
        -
        pg_callback()
        -
        The callback function that is invoked from a driver when the fill is complete.
        -
        pg_miss()
        -
        The function that is called from architecture-specific code to handle a page fault.
        -
        TCB
        -
        Task Control Block
        -
        - - - - - -
        -

        NuttX Common Logic Design Description

        -
        - - -

        Initialization

        - -

        - The following declarations will be added. -

          -
        • - g_waitingforfill. - A doubly linked list that will be used to implement a prioritized list of the TCBs of tasks that are waiting for a page fill. -
        • -
        • - g_pgworker. - The process ID of of the thread that will perform the page fills -
        • -
        -

        -

        - During OS initialization in sched/os_start.c, the following steps - will be performed: -

          -
        • - The g_waitingforfill queue will be initialized. -
        • -
        • - The special, page fill worker thread, will be started. - The pid of the page will worker thread will be saved in g_pgworker. - Note that we need a special worker thread to perform fills; - we cannot use the "generic" worker thread facility because we cannot be - assured that all actions called by that worker thread will always be resident in memory. -
        • -
        -

        -

        - Declarations for g_waitingforfill, g_pgworker, and other - internal, private definitions will be provided in sched/pg_internal.h. - All public definitions that should be used by the architecture-specific code will be available - in include/nuttx/page.h. - Most architecture-specific functions are declared in include/nuttx/arch.h, - but for the case of this paging logic, those architecture specific functions are instead declared in include/nuttx/page.h. -

        - -

        Page Faults

        - -

        - Page fault exception handling. - Page fault handling is performed by the function pg_miss(). - This function is called from architecture-specific memory segmentation - fault handling logic. This function will perform the following - operations: -

          -
        1. - Sanity checking. - This function will ASSERT if the currently executing task is the page fill worker thread. - The page fill worker thread is how the the page fault is resolved and all logic associated with the page fill worker - must be "locked" and always present in memory. -
        2. -
        3. - Block the currently executing task. - This function will call up_block_task() to block the task at the head of the ready-to-run list. - This should cause an interrupt level context switch to the next highest priority task. - The blocked task will be marked with state TSTATE_WAIT_PAGEFILL and will be retained in the g_waitingforfill prioritized task list. -
        4. -
        5. - Boost the page fill worker thread priority. - Check the priority of the task at the head of the g_waitingforfill list. - If the priority of that task is higher than the current priority of the page fill worker thread, then boost the priority of the page fill worker thread to that priority. - Thus, the page fill worker thread will always run at the priority of the highest priority task that is waiting for a fill. -
        6. -
        7. - Signal the page fill worker thread. - Is there a page already being filled? - If not then signal the page fill worker thread to start working on the queued page fill requests. -
        8. -
        -

        -

        - When signaled from pg_miss(), the page fill worker thread will be awakenend and will initiate the fill operation. -

        -

        - Input Parameters. - None -- The head of the ready-to-run list is assumed to be that task that caused the exception. - The current task context should already be saved in the TCB of that task. - No additional inputs are required. -

        -

        - Assumptions. -

          -
        • - It is assumed that this function is called from the level of an exception handler and that all interrupts are disabled. -
        • -
        • - The pg_miss() must be "locked" in memory. - Calling pg_miss() cannot cause a nested page fault. -
        • -
        • - It is assumed that currently executing task (the one at the head of the ready-to-run list) is the one that cause the fault. - This will always be true unless the page fault occurred in an interrupt handler. - Interrupt handling logic must always be available and "locked" into memory so that page faults never come from interrupt handling. -
        • -
        • - The architecture-specific page fault exception handling has already verified that the exception did not occur from interrupt/exception handling logic. -
        • -
        • - As mentioned above, the task causing the page fault must not be the page fill worker thread because that is the only way to complete the page fill. -
        • -
        -

        - -

        Fill Initiation

        - -

        - The page fill worker thread will be awakened on one of three conditions: -

          -
        • - When signaled by pg_miss(), the page fill worker thread will be awakenend (see above), -
        • -
        • - From pg_callback() after completing last fill (when CONFIG_PAGING_BLOCKINGFILL is defined... see below), or -
        • -
        • - A configurable timeout expires with no activity. - This timeout can be used to detect failure conditions such things as fills that never complete. -
        • -
        -

        - -

        - The page fill worker thread will maintain a static variable called _TCB *g_pftcb. - If no fill is in progress, g_pftcb will be NULL. - Otherwise, it will point to the TCB of the task which is receiving the fill that is in progess. -

        -
          - NOTE: - I think that this is the only state in which a TCB does not reside in some list. - Here is it in limbo, outside of the normally queuing while the page file is in progress. - While here, it will be marked with TSTATE_TASK_INVALID. -
        - -

        - When awakened from pg_miss(), no fill will be in progress and g_pftcb will be NULL. - In this case, the page fill worker thread will call pg_startfill(). - That function will perform the following operations: -

          -
        • - Call the architecture-specific function up_checkmapping() to see if the page fill - still needs to be performed. - In certain conditions, the page fault may occur on several threads and be queued multiple times. - In this corner case, the blocked task will simply be restarted (see the logic below for the - case of normal completion of the fill operation). -
        • -
        • - Call up_allocpage(tcb, &vpage). - This architecture-specific function will set aside page in memory and map to virtual address (vpage). - If all available pages are in-use (the typical case), - this function will select a page in-use, un-map it, and make it available. -
        • -
        • - Call the architecture-specific function up_fillpage(). - Two versions of the up_fillpage function are supported -- a blocking and a non-blocking version based upon the configuratin setting CONFIG_PAGING_BLOCKINGFILL. -
            -
          • - If CONFIG_PAGING_BLOCKINGFILL is defined, then up_fillpage is blocking call. - In this case, up_fillpage() will accept only (1) a reference to the TCB that requires the fill. - Architecture-specific context information within the TCB will be sufficient to perform the fill. - And (2) the (virtual) address of the allocated page to be filled. - The resulting status of the fill will be provided by return value from up_fillpage(). -
          • -
          • - If CONFIG_PAGING_BLOCKINGFILL is defined, then up_fillpage is non-blocking call. - In this case up_fillpage() will accept an additional argument: - The page fill worker thread will provide a callback function, pg_callback. - This function is non-blocking, it will start an asynchronous page fill. - After calling the non-blocking up_fillpage(), the page fill worker thread will wait to be signaled for the next event -- the fill completion event. - The callback function will be called when the page fill is finished (or an error occurs). - The resulting status of the fill will be providing as an argument to the callback functions. - This callback will probably occur from interrupt level. -
          -
        • -
        -

        -

        - In any case, while the fill is in progress, other tasks may execute. - If another page fault occurs during this time, the faulting task will be blocked, its TCB will be added (in priority order) to g_waitingforfill, and the priority of the page worker task may be boosted. - But no action will be taken until the current page fill completes. - NOTE: The IDLE task must also be fully locked in memory. - The IDLE task cannot be blocked. - It the case where all tasks are blocked waiting for a page fill, the IDLE task must still be available to run. -

        - The architecture-specific functions, up_checkmapping(), up_allocpage(tcb, &vpage) and up_fillpage(page, pg_callback) - will be prototyped in include/nuttx/arch.h -

        - -

        Fill Complete

        - -

        - For the blocking up_fillpage(), the result of the fill will be returned directly from the call to up_fillpage. -

        -

        - For the non-blocking up_fillpage(), the architecture-specific driver call the pg_callback() that was provided to up_fillpage() when the fill completes. - In this case, the pg_callback() will probably be called from driver interrupt-level logic. - The driver will provide the result of the fill as an argument to the callback function. - NOTE: pg_callback() must also be locked in memory. -

        -

        - In this non-blocking case, the callback pg_callback() will perform the following operations when it is notified that the fill has completed: -

          -
        • - Verify that g_pftcb is non-NULL. -
        • -
        • - Find the higher priority between the task waiting for the fill to complete in g_pftcb and the task waiting at the head of the g_waitingforfill list. - That will be the priority of he highest priority task waiting for a fill. -
        • -
        • - If this higher priority is higher than current page fill worker thread, then boost worker thread's priority to that level. - Thus, the page fill worker thread will always run at the priority of the highest priority task that is waiting for a fill. -
        • -
        • - Save the result of the fill operation. -
        • -
        • - Signal the page fill worker thread. -
        • -
        -

        - -

        Task Resumption

        - -

        - For the non-blocking up_fillpage(), the page fill worker thread will detect that the page fill is complete when it is awakened with g_pftcb non-NULL and fill completion status from pg_callback. - In the non-blocking case, the page fill worker thread will know that the page fill is complete when up_fillpage() returns. -

        -

        - In this either, the page fill worker thread will: -

          -
        • - Verify consistency of state information and g_pftcb. -
        • -
        • - Verify that the page fill completed successfully, and if so, -
        • -
        • - Call up_unblocktask(g_pftcb) to make the task that just received the fill ready-to-run. -
        • -
        • - Check if the g_waitingforfill list is empty. - If not: -
            -
          • - Remove the highest priority task waiting for a page fill from g_waitingforfill, -
          • -
          • - Save the task's TCB in g_pftcb, -
          • -
          • - If the priority of the thread in g_pftcb, is higher in priority than the default priority of the page fill worker thread, then set the priority of the page fill worker thread to that priority. -
          • -
          • - Call pg_startfill() which will start the next fill (as described above). -
          • -
          -
        • -
        • - Otherwise, -
            -
          • - Set g_pftcb to NULL. -
          • -
          • - Restore the default priority of the page fill worker thread. -
          • -
          • - Wait for the next fill related event (a new page fault). -
          • -
          -
        • -
        -

        - - - - - -
        -

        Architecture-Specific Support Requirements

        -
        - -

        Memory Organization

        - -

        - Memory Regions. - Chip specific logic will map the virtual and physical address spaces into three general regions: -

          -
        1. - A .text region containing "locked-in-memory" code that is always avaialable and will never cause a page fault. - This locked memory is loaded at boot time and remains resident for all time. - This memory regions must include: -
            -
          • - All logic for all interrupt pathes. - All interrupt logic must be locked in memory because the design present here will not support page faults from interrupt handlers. - This includes the page fault handling logic and pg_miss() that is called from the page fault handler. - It also includes the pg_callback() function that wakes up the page fill worker thread - and whatever architecture-specific logic that calls pg_callback(). -
          • -
          • - All logic for the IDLE thread. - The IDLE thread must always be ready to run and cannot be blocked for any reason. -
          • -
          • - All of the page fill worker thread must be locked in memory. - This thread must execute in order to unblock any thread waiting for a fill. - It this thread were to block, there would be no way to complete the fills! -
          -
        2. -
        3. - A .text region containing pages that can be assigned allocated, mapped to various virtual addresses, and filled from some mass storage medium. -
        4. -
        5. - And a fixed RAM space for .bss, .text, and .heap. -
        6. -
        -

        -

        - This memory organization is illustrated in the following table. - Notice that: -

          -
        • - There is a one-to-one relationship between pages in the virtual address space and between pages of .text in the non-volatile mass storage device. -
        • -
        • - There are, however, far fewer physical pages available than virtual pages. - Only a subset of physical pages will be mapped to virtual pages at any given time. - This mapping will be performed on-demand as needed for program execution. -
        -

        - -
        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        SRAMVirtual Address SpaceNon-Volatile Storage
         DATA 
         Virtual Page n (n > m)Stored Page n
         Virtual Page n-1Stored Page n-1
        DATA......
        Physical Page m (m < n)......
        Physical Page m-1......
        .........
        Physical Page 1Virtual Page 1Stored Page 1
        Locked MemoryLocked MemoryMemory Resident
        - -

        - Example. - As an example, suppose that the size of the SRAM is 192Kb (as in the NXP LPC3131). And suppose further that: -

          -
        • - The size of the locked, memory resident .text area is 32Kb, and -
        • -
        • - The size of the DATA area is 64Kb. -
        • -
        • - The size of one, managed page is 1Kb. -
        • -
        • - The size of the whole .text image on the non-volatile, mass storage device is 1024Kb. -
        • -
        -

        - Then, the size of the locked, memory resident code is 32Kb (m=32 pages). - The size of the physical page region is 96Kb (96 pages), and the - size of the data region is 64 pages. - And the size of the virtual paged region must then be greater than or equal to (1024-32) or 992 pages (n). -

        - -

        - Building the Locked, In-Memory Image. - One way to accomplish this would be a two phase link: -

          -
        • - In the first phase, create a partially linked objected containing all interrupt/exception handling logic, the page fill worker thread plus all parts of the IDLE thread (which must always be available for execution). -
        • -
        • - All of the .text and .rodata sections of this partial link should be collected into a single section. -
        • -
        • - The second link would link the partially linked object along with the remaining object to produce the final binary. - The linker script should position the "special" section so that it lies in a reserved, "non-swappable" region. -
        -

        - -

        Architecture-Specific Functions

        - -

        - Most standard, architecture-specific functions are declared in include/nuttx/arch.h. - However, for the case of this paging logic, the architecture specific functions are declared in include/nuttx/page.h. - Standard, architecture-specific functions that should already be provided in the architecture port. - The following are used by the common paging logic: -

        -
          -
          - void up_block_task(FAR _TCB *tcb, tstate_t task_state); -
          -
          - The currently executing task at the head of the ready to run list must be stopped. - Save its context and move it to the inactive list specified by task_state. - This function is called by the on-demand paging logic in order to block the task that requires the - page fill, and to -
          -
          - void up_unblock_task(FAR _TCB *tcb); -
          -
          - A task is currently in an inactive task list but has been prepped to execute. - Move the TCB to the ready-to-run list, restore its context, and start execution. - This function will be called -
          -
        - -

        - New, additional functions that must be implemented just for on-demand paging support: -

        - -
          -
          - int up_checkmapping(FAR _TCB *tcb); -
          -
          - The function up_checkmapping() returns an indication if the page fill still needs to performed or not. - In certain conditions, the page fault may occur on several threads and be queued multiple times. - This function will prevent the same page from be filled multiple times. -
          -
          - int up_allocpage(FAR _TCB *tcb, FAR void *vpage); -
          -
          - This architecture-specific function will set aside page in memory and map to its correct virtual address. - Architecture-specific context information saved within the TCB will provide the function with the information needed to identify the virtual miss address. - This function will return the allocated physical page address in vpage. - The size of the underlying physical page is determined by the configuration setting CONFIG_PAGING_PAGESIZE. - NOTE: This function must always return a page allocation. - If all available pages are in-use (the typical case), then this function will select a page in-use, un-map it, and make it available. -
          -
          int up_fillpage(FAR _TCB *tcb, FAR const void *vpage, void (*pg_callback)(FAR _TCB *tcb, int result)); -
          - The actual filling of the page with data from the non-volatile, must be performed by a separate call to the architecture-specific function, up_fillpage(). - This will start asynchronous page fill. - The common paging logic will provide a callback function, pg_callback, that will be called when the page fill is finished (or an error occurs). - This callback is assumed to occur from an interrupt level when the device driver completes the fill operation. - -
        - - - + + +On-Demand Paging + + +

        + + + + +
        +

        On-Demand Paging

        +

        >>> Under Construction <<<

        +

        Last Updated: August 12, 2010

        +
        +

        + + + + + +
        +

        Table of Contents

        +
        + +
        + + + + + + + + + + +
        + + + + + + + + + + + + + +
        + Introduction +
          + Overview +
          + Terminology +
        +
        + + + + + + + + + + + + + + + + + + + + + + + + + +
        + NuttX Common Logic Design Description +
          + Initialization +
          + Page Faults +
          + Fill Initiation +
          + Fill Complete +
          + Task Resumption +
        +
        + + + + + + + + + + + + + +
        + Architecture-Specific Support Requirements +
          + Memory Organization +
          + Architecture-Specific Functions +
        +
        + + + + + +
        +

        Introduction

        +
        +

        Overview

        + +

        + This document summarizes the design of NuttX on-demand paging. + This feature permits embedded MCUs with some limited RAM space to execute large programs from some non-random access media. + This feature was first discussed in this email thread: + http://tech.groups.yahoo.com/group/nuttx/message/213. +

        +

        + What kind of platforms can support NuttX on-demang paging? +

          +
        1. + The MCU should have some large, probably low-cost non-volatile storage such as serial FLASH or an SD card. + This storage probably does not support non-random access (otherwise, why not just execute the program directly on the storage media). + SD and serial FLASH are inexpensive and do not require very many pins and SPI support is prevalent in just about all MCUs. + This large serial FLASH would contain a big program. Perhaps a program of several megabytes in size. +
        2. +
        3. + The MCU must have a (relatively) small block of fast SRAM from which it can execute code. + A size of, say 256K (or 192K as in the NXP LPC3131) would be sufficient for many applications. +
        4. +
        5. + The MCU has an MMU (again like the NXP LPC3131). +
        6. +
        +

        +

        + If the platform meets these requirement, then NuttX can provide on-demand paging: + It can copy .text from the large program in non-volatile media into RAM as needed to execute a huge program from the small RAM. +

        + +

        Terminology

        + +
        +
        g_waitingforfill
        +
        An OS list that is used to hold the TCBs of tasks that are waiting for a page fill.
        +
        g_pftcb
        +
        A variable that holds a reference to the TCB of the thread that is currently be re-filled.
        +
        g_pgworker
        +
        The process ID of of the thread that will perform the page fills.
        +
        pg_callback()
        +
        The callback function that is invoked from a driver when the fill is complete.
        +
        pg_miss()
        +
        The function that is called from architecture-specific code to handle a page fault.
        +
        TCB
        +
        Task Control Block
        +
        + + + + + +
        +

        NuttX Common Logic Design Description

        +
        + + +

        Initialization

        + +

        + The following declarations will be added. +

          +
        • + g_waitingforfill. + A doubly linked list that will be used to implement a prioritized list of the TCBs of tasks that are waiting for a page fill. +
        • +
        • + g_pgworker. + The process ID of of the thread that will perform the page fills +
        • +
        +

        +

        + During OS initialization in sched/os_start.c, the following steps + will be performed: +

          +
        • + The g_waitingforfill queue will be initialized. +
        • +
        • + The special, page fill worker thread, will be started. + The pid of the page will worker thread will be saved in g_pgworker. + Note that we need a special worker thread to perform fills; + we cannot use the "generic" worker thread facility because we cannot be + assured that all actions called by that worker thread will always be resident in memory. +
        • +
        +

        +

        + Declarations for g_waitingforfill, g_pgworker, and other + internal, private definitions will be provided in sched/pg_internal.h. + All public definitions that should be used by the architecture-specific code will be available + in include/nuttx/page.h. + Most architecture-specific functions are declared in include/nuttx/arch.h, + but for the case of this paging logic, those architecture specific functions are instead declared in include/nuttx/page.h. +

        + +

        Page Faults

        + +

        + Page fault exception handling. + Page fault handling is performed by the function pg_miss(). + This function is called from architecture-specific memory segmentation + fault handling logic. This function will perform the following + operations: +

          +
        1. + Sanity checking. + This function will ASSERT if the currently executing task is the page fill worker thread. + The page fill worker thread is how the the page fault is resolved and all logic associated with the page fill worker + must be "locked" and always present in memory. +
        2. +
        3. + Block the currently executing task. + This function will call up_block_task() to block the task at the head of the ready-to-run list. + This should cause an interrupt level context switch to the next highest priority task. + The blocked task will be marked with state TSTATE_WAIT_PAGEFILL and will be retained in the g_waitingforfill prioritized task list. +
        4. +
        5. + Boost the page fill worker thread priority. + Check the priority of the task at the head of the g_waitingforfill list. + If the priority of that task is higher than the current priority of the page fill worker thread, then boost the priority of the page fill worker thread to that priority. + Thus, the page fill worker thread will always run at the priority of the highest priority task that is waiting for a fill. +
        6. +
        7. + Signal the page fill worker thread. + Is there a page already being filled? + If not then signal the page fill worker thread to start working on the queued page fill requests. +
        8. +
        +

        +

        + When signaled from pg_miss(), the page fill worker thread will be awakenend and will initiate the fill operation. +

        +

        + Input Parameters. + None -- The head of the ready-to-run list is assumed to be that task that caused the exception. + The current task context should already be saved in the TCB of that task. + No additional inputs are required. +

        +

        + Assumptions. +

          +
        • + It is assumed that this function is called from the level of an exception handler and that all interrupts are disabled. +
        • +
        • + The pg_miss() must be "locked" in memory. + Calling pg_miss() cannot cause a nested page fault. +
        • +
        • + It is assumed that currently executing task (the one at the head of the ready-to-run list) is the one that cause the fault. + This will always be true unless the page fault occurred in an interrupt handler. + Interrupt handling logic must always be available and "locked" into memory so that page faults never come from interrupt handling. +
        • +
        • + The architecture-specific page fault exception handling has already verified that the exception did not occur from interrupt/exception handling logic. +
        • +
        • + As mentioned above, the task causing the page fault must not be the page fill worker thread because that is the only way to complete the page fill. +
        • +
        +

        + +

        Fill Initiation

        + +

        + The page fill worker thread will be awakened on one of three conditions: +

          +
        • + When signaled by pg_miss(), the page fill worker thread will be awakenend (see above), +
        • +
        • + From pg_callback() after completing last fill (when CONFIG_PAGING_BLOCKINGFILL is defined... see below), or +
        • +
        • + A configurable timeout expires with no activity. + This timeout can be used to detect failure conditions such things as fills that never complete. +
        • +
        +

        + +

        + The page fill worker thread will maintain a static variable called _TCB *g_pftcb. + If no fill is in progress, g_pftcb will be NULL. + Otherwise, it will point to the TCB of the task which is receiving the fill that is in progess. +

        +
          + NOTE: + I think that this is the only state in which a TCB does not reside in some list. + Here is it in limbo, outside of the normally queuing while the page file is in progress. + While here, it will be marked with TSTATE_TASK_INVALID. +
        + +

        + When awakened from pg_miss(), no fill will be in progress and g_pftcb will be NULL. + In this case, the page fill worker thread will call pg_startfill(). + That function will perform the following operations: +

          +
        • + Call the architecture-specific function up_checkmapping() to see if the page fill + still needs to be performed. + In certain conditions, the page fault may occur on several threads and be queued multiple times. + In this corner case, the blocked task will simply be restarted (see the logic below for the + case of normal completion of the fill operation). +
        • +
        • + Call up_allocpage(tcb, &vpage). + This architecture-specific function will set aside page in memory and map to virtual address (vpage). + If all available pages are in-use (the typical case), + this function will select a page in-use, un-map it, and make it available. +
        • +
        • + Call the architecture-specific function up_fillpage(). + Two versions of the up_fillpage function are supported -- a blocking and a non-blocking version based upon the configuratin setting CONFIG_PAGING_BLOCKINGFILL. +
            +
          • + If CONFIG_PAGING_BLOCKINGFILL is defined, then up_fillpage is blocking call. + In this case, up_fillpage() will accept only (1) a reference to the TCB that requires the fill. + Architecture-specific context information within the TCB will be sufficient to perform the fill. + And (2) the (virtual) address of the allocated page to be filled. + The resulting status of the fill will be provided by return value from up_fillpage(). +
          • +
          • + If CONFIG_PAGING_BLOCKINGFILL is defined, then up_fillpage is non-blocking call. + In this case up_fillpage() will accept an additional argument: + The page fill worker thread will provide a callback function, pg_callback. + This function is non-blocking, it will start an asynchronous page fill. + After calling the non-blocking up_fillpage(), the page fill worker thread will wait to be signaled for the next event -- the fill completion event. + The callback function will be called when the page fill is finished (or an error occurs). + The resulting status of the fill will be providing as an argument to the callback functions. + This callback will probably occur from interrupt level. +
          +
        • +
        +

        +

        + In any case, while the fill is in progress, other tasks may execute. + If another page fault occurs during this time, the faulting task will be blocked, its TCB will be added (in priority order) to g_waitingforfill, and the priority of the page worker task may be boosted. + But no action will be taken until the current page fill completes. + NOTE: The IDLE task must also be fully locked in memory. + The IDLE task cannot be blocked. + It the case where all tasks are blocked waiting for a page fill, the IDLE task must still be available to run. +

        + The architecture-specific functions, up_checkmapping(), up_allocpage(tcb, &vpage) and up_fillpage(page, pg_callback) + will be prototyped in include/nuttx/arch.h +

        + +

        Fill Complete

        + +

        + For the blocking up_fillpage(), the result of the fill will be returned directly from the call to up_fillpage. +

        +

        + For the non-blocking up_fillpage(), the architecture-specific driver call the pg_callback() that was provided to up_fillpage() when the fill completes. + In this case, the pg_callback() will probably be called from driver interrupt-level logic. + The driver will provide the result of the fill as an argument to the callback function. + NOTE: pg_callback() must also be locked in memory. +

        +

        + In this non-blocking case, the callback pg_callback() will perform the following operations when it is notified that the fill has completed: +

          +
        • + Verify that g_pftcb is non-NULL. +
        • +
        • + Find the higher priority between the task waiting for the fill to complete in g_pftcb and the task waiting at the head of the g_waitingforfill list. + That will be the priority of he highest priority task waiting for a fill. +
        • +
        • + If this higher priority is higher than current page fill worker thread, then boost worker thread's priority to that level. + Thus, the page fill worker thread will always run at the priority of the highest priority task that is waiting for a fill. +
        • +
        • + Save the result of the fill operation. +
        • +
        • + Signal the page fill worker thread. +
        • +
        +

        + +

        Task Resumption

        + +

        + For the non-blocking up_fillpage(), the page fill worker thread will detect that the page fill is complete when it is awakened with g_pftcb non-NULL and fill completion status from pg_callback. + In the non-blocking case, the page fill worker thread will know that the page fill is complete when up_fillpage() returns. +

        +

        + In this either, the page fill worker thread will: +

          +
        • + Verify consistency of state information and g_pftcb. +
        • +
        • + Verify that the page fill completed successfully, and if so, +
        • +
        • + Call up_unblocktask(g_pftcb) to make the task that just received the fill ready-to-run. +
        • +
        • + Check if the g_waitingforfill list is empty. + If not: +
            +
          • + Remove the highest priority task waiting for a page fill from g_waitingforfill, +
          • +
          • + Save the task's TCB in g_pftcb, +
          • +
          • + If the priority of the thread in g_pftcb, is higher in priority than the default priority of the page fill worker thread, then set the priority of the page fill worker thread to that priority. +
          • +
          • + Call pg_startfill() which will start the next fill (as described above). +
          • +
          +
        • +
        • + Otherwise, +
            +
          • + Set g_pftcb to NULL. +
          • +
          • + Restore the default priority of the page fill worker thread. +
          • +
          • + Wait for the next fill related event (a new page fault). +
          • +
          +
        • +
        +

        + + + + + +
        +

        Architecture-Specific Support Requirements

        +
        + +

        Memory Organization

        + +

        + Memory Regions. + Chip specific logic will map the virtual and physical address spaces into three general regions: +

          +
        1. + A .text region containing "locked-in-memory" code that is always avaialable and will never cause a page fault. + This locked memory is loaded at boot time and remains resident for all time. + This memory regions must include: +
            +
          • + All logic for all interrupt paths. + All interrupt logic must be locked in memory because the design present here will not support page faults from interrupt handlers. + This includes the page fault handling logic and pg_miss() that is called from the page fault handler. + It also includes the pg_callback() function that wakes up the page fill worker thread + and whatever architecture-specific logic that calls pg_callback(). +
          • +
          • + All logic for the IDLE thread. + The IDLE thread must always be ready to run and cannot be blocked for any reason. +
          • +
          • + All of the page fill worker thread must be locked in memory. + This thread must execute in order to unblock any thread waiting for a fill. + It this thread were to block, there would be no way to complete the fills! +
          +
        2. +
        3. + A .text region containing pages that can be assigned allocated, mapped to various virtual addresses, and filled from some mass storage medium. +
        4. +
        5. + And a fixed RAM space for .bss, .text, and .heap. +
        6. +
        +

        +

        + This memory organization is illustrated in the following table. + Notice that: +

          +
        • + There is a one-to-one relationship between pages in the virtual address space and between pages of .text in the non-volatile mass storage device. +
        • +
        • + There are, however, far fewer physical pages available than virtual pages. + Only a subset of physical pages will be mapped to virtual pages at any given time. + This mapping will be performed on-demand as needed for program execution. +
        +

        + +
        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        SRAMVirtual Address SpaceNon-Volatile Storage
         DATA 
         Virtual Page n (n > m)Stored Page n
         Virtual Page n-1Stored Page n-1
        DATA......
        Physical Page m (m < n)......
        Physical Page m-1......
        .........
        Physical Page 1Virtual Page 1Stored Page 1
        Locked MemoryLocked MemoryMemory Resident
        + +

        + Example. + As an example, suppose that the size of the SRAM is 192K (as in the NXP LPC3131). And suppose further that: +

          +
        • + The size of the locked, memory resident .text area is 32K, and +
        • +
        • + The size of the DATA area is 64K. +
        • +
        • + The size of one, managed page is 1K. +
        • +
        • + The size of the whole .text image on the non-volatile, mass storage device is 1024K. +
        • +
        +

        + Then, the size of the locked, memory resident code is 32K (m=32 pages). + The size of the physical page region is 96K (96 pages), and the + size of the data region is 64 pages. + And the size of the virtual paged region must then be greater than or equal to (1024-32) or 992 pages (n). +

        + +

        + Building the Locked, In-Memory Image. + One way to accomplish this would be a two phase link: +

          +
        • + In the first phase, create a partially linked objected containing all interrupt/exception handling logic, the page fill worker thread plus all parts of the IDLE thread (which must always be available for execution). +
        • +
        • + All of the .text and .rodata sections of this partial link should be collected into a single section. +
        • +
        • + The second link would link the partially linked object along with the remaining object to produce the final binary. + The linker script should position the "special" section so that it lies in a reserved, "non-swappable" region. +
        +

        + +

        Architecture-Specific Functions

        + +

        + Most standard, architecture-specific functions are declared in include/nuttx/arch.h. + However, for the case of this paging logic, the architecture specific functions are declared in include/nuttx/page.h. + Standard, architecture-specific functions that should already be provided in the architecture port. + The following are used by the common paging logic: +

        +
          +
          + void up_block_task(FAR _TCB *tcb, tstate_t task_state); +
          +
          + The currently executing task at the head of the ready to run list must be stopped. + Save its context and move it to the inactive list specified by task_state. + This function is called by the on-demand paging logic in order to block the task that requires the + page fill, and to +
          +
          + void up_unblock_task(FAR _TCB *tcb); +
          +
          + A task is currently in an inactive task list but has been prepped to execute. + Move the TCB to the ready-to-run list, restore its context, and start execution. + This function will be called +
          +
        + +

        + New, additional functions that must be implemented just for on-demand paging support: +

        + +
          +
          + int up_checkmapping(FAR _TCB *tcb); +
          +
          + The function up_checkmapping() returns an indication if the page fill still needs to performed or not. + In certain conditions, the page fault may occur on several threads and be queued multiple times. + This function will prevent the same page from be filled multiple times. +
          +
          + int up_allocpage(FAR _TCB *tcb, FAR void *vpage); +
          +
          + This architecture-specific function will set aside page in memory and map to its correct virtual address. + Architecture-specific context information saved within the TCB will provide the function with the information needed to identify the virtual miss address. + This function will return the allocated physical page address in vpage. + The size of the underlying physical page is determined by the configuration setting CONFIG_PAGING_PAGESIZE. + NOTE: This function must always return a page allocation. + If all available pages are in-use (the typical case), then this function will select a page in-use, un-map it, and make it available. +
          +
          int up_fillpage(FAR _TCB *tcb, FAR const void *vpage, void (*pg_callback)(FAR _TCB *tcb, int result)); +
          + The actual filling of the page with data from the non-volatile, must be performed by a separate call to the architecture-specific function, up_fillpage(). + This will start asynchronous page fill. + The common paging logic will provide a callback function, pg_callback, that will be called when the page fill is finished (or an error occurs). + This callback is assumed to occur from an interrupt level when the device driver completes the fill operation. + +
        + + + diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html index e605dd109d..a339b3a990 100644 --- a/nuttx/Documentation/NuttxPortingGuide.html +++ b/nuttx/Documentation/NuttxPortingGuide.html @@ -3935,7 +3935,7 @@ build 16-bit addressability have smaller overhead than devices that support 32-bit addressability. However, there are many MCUs that support 32-bit addressability but have internal SRAM - of size less than or equal to 64Kb. In this case, CONFIG_MM_SMALL + of size less than or equal to 64K. In this case, CONFIG_MM_SMALL can be defined so that those MCUs will also benefit from the smaller, 16-bit-based allocation overhead. @@ -4740,7 +4740,7 @@ build
      • CONFIG_P14201_FRAMEBUFFER: If defined, accesses will be performed using an in-memory copy of the OLEDs GDDRAM. - This cost of this buffer is 128 * 96 / 2 = 6Kb. + This cost of this buffer is 128 * 96 / 2 = 6K. If this is defined, then the driver will be fully functional. If not, then it will have the following limitations:
          diff --git a/nuttx/Documentation/NxWidgets.html b/nuttx/Documentation/NxWidgets.html index cef99d4943..1678d9ebe7 100755 --- a/nuttx/Documentation/NxWidgets.html +++ b/nuttx/Documentation/NxWidgets.html @@ -33,7 +33,7 @@
        • Small Footprint. NXWidgets is tailored for use MCUs in embedded applications. It is ideally suited for mid- and upper-range of most MCU families. - A complete NXWidgets is possible in as little as 40Kb of FLASH and maybe 4Kb of SRAM. + A complete NXWidgets is possible in as little as 40K of FLASH and maybe 4K of SRAM.
        • Output Devices. NXWidgets will work on the high-end frame buffer devices as well as on LCDs connected via serial or parallel ports to a small MCU. diff --git a/nuttx/ReleaseNotes b/nuttx/ReleaseNotes index 8c6ae0ccb8..26af0e38d4 100644 --- a/nuttx/ReleaseNotes +++ b/nuttx/ReleaseNotes @@ -1668,7 +1668,7 @@ Important bugfixes included: And feature enhancements: * The LPC176x Ethernet driver was using all of AHB SRAM Bank0 for - Ethernet packet buffers (16Kb). An option was added to limit + Ethernet packet buffers (16K). An option was added to limit the amount of SRAM used for packet buffering and to re-use any extra Bank0 memory for heap. @@ -2022,7 +2022,7 @@ and is available for download from the SourceForge website. The * A PCI-based E1000 Ethernet driver (contributed by Yu Qiang) * New C library functions: inet_addr() (contributed by Yu Qiang), strndup(), asprintf() - * Reduced memory allocation overhead for MCUs with small heaps (<64Kb). + * Reduced memory allocation overhead for MCUs with small heaps (<64K). * fdopen() now works with socket descriptors allowing standard buffered C functions to be used for network communications. * The NSH ifconfig command can now be used to set or change the @@ -2062,7 +2062,7 @@ they are, ordered from the least to the most complete: This port of NuttX to the Amber Web Server from SoC Robotics (http://www.soc-robotics.com/index.htm). Is only partially in place. The Amber Web Server is based on an Atmel ATMega128 - (128Kb FLASH but only 4Kb of SRAM). + (128K FLASH but only 4K of SRAM). STATUS: Work on this port has stalled due to toolchain issues. It is complete, but untested. @@ -2073,7 +2073,7 @@ they are, ordered from the least to the most complete: Micropendous3 may be populated with an AT90USB646, 647, 1286, or 1287. See http://code.google.com/p/opendous/. I have only the AT90USB647 version for testing. This version has very - limited memory resources: 64Kb of FLASH and 4Kb of SRAM. + limited memory resources: 64K of FLASH and 4K of SRAM. STATUS: The basic port was released in NuttX-6.5. This basic port consists only of a "Hello, World!!" example that demonstrates @@ -2085,8 +2085,8 @@ they are, ordered from the least to the most complete: This is a port of NuttX to the PJRC Teensy++ 2.0 board. This board was developed by PJRC (http://pjrc.com/teensy/). The - Teensy++ 2.0 is based on an Atmel AT90USB1286 MCU with 128Kb - of FLASH and 8Kb of SRAM; a little more room to move than the + Teensy++ 2.0 is based on an Atmel AT90USB1286 MCU with 128K + of FLASH and 8K of SRAM; a little more room to move than the AT90USB647. STATUS: The basic port was released in NuttX-6.5. This basic @@ -2109,7 +2109,7 @@ integrated into the normal, general purpose OS. Most NuttX test applications are console-oriented with lots of strings used for printf and debug output. These strings are all stored in SRAM now due to these data accessing issues and even the -smallest console-oriented applications can quickly fill a 4-8Kb +smallest console-oriented applications can quickly fill a 4-8K memory. So, in order for the AVR port to be useful, one of two things would need to be done: diff --git a/nuttx/TODO b/nuttx/TODO index 7ffcb9ca80..f9fc558eab 100644 --- a/nuttx/TODO +++ b/nuttx/TODO @@ -1819,7 +1819,7 @@ o mc68hc1x (arch/hc) Description: There is no script for building in banked mode (more correctly, there is a script, but logic inside the script has not yet been implemented). It would be necessary to implement banked mode to able to access more - the 48Kb of FLASH. + the 48K of FLASH. Status: Open. Priority: Medium/Low diff --git a/nuttx/arch/arm/src/lpc43xx/lpc43_usb0dev.c b/nuttx/arch/arm/src/lpc43xx/lpc43_usb0dev.c index 40233ec0f6..2ce19a3250 100644 --- a/nuttx/arch/arm/src/lpc43xx/lpc43_usb0dev.c +++ b/nuttx/arch/arm/src/lpc43xx/lpc43_usb0dev.c @@ -69,9 +69,7 @@ #include "up_arch.h" #include "up_internal.h" -#include "lpc43_usbotg.h" -#include "lpc43_evntrtr.h" -#include "lpc43_syscreg.h" +#include "lpc43_usb0dev.h" /******************************************************************************* * Definitions diff --git a/nuttx/arch/arm/src/lpc43xx/lpc43_usb0dev.h b/nuttx/arch/arm/src/lpc43xx/lpc43_usb0dev.h new file mode 100644 index 0000000000..97076cd802 --- /dev/null +++ b/nuttx/arch/arm/src/lpc43xx/lpc43_usb0dev.h @@ -0,0 +1,98 @@ +/************************************************************************************ + * arch/arm/src/lpc43xx/lpc43_usbdev.h + * + * Copyright (C) 2009, 2011 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. + * + ************************************************************************************/ + +#ifndef __ARCH_ARM_SRC_LPC43XX_LPC32_USB0DEV_H +#define __ARCH_ARM_SRC_LPC43XX_LPC32_USB0DEV_H + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include +#include +#include + +#include "chip.h" +#include "chip/lpc43_usb0.h" + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +#ifndef __ASSEMBLY__ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +/************************************************************************************ + * Name: lpc43_usbpullup + * + * Description: + * If USB is supported and the board supports a pullup via GPIO (for USB software + * connect and disconnect), then the board software must provide lpc43_pullup. + * See include/nuttx/usb/usbdev.h for additional description of this method. + * Alternatively, if no pull-up GPIO the following EXTERN can be redefined to be + * NULL. + * + ************************************************************************************/ + +EXTERN int lpc43_usbpullup(FAR struct usbdev_s *dev, bool enable); + +/************************************************************************************ + * Name: lpc43_usbsuspend + * + * Description: + * Board logic must provide the lpc43_usbsuspend logic if the USBDEV driver is + * used. This function is called whenever the USB enters or leaves suspend mode. + * This is an opportunity for the board logic to shutdown clocks, power, etc. + * while the USB is suspended. + * + ************************************************************************************/ + +EXTERN void lpc43_usbsuspend(FAR struct usbdev_s *dev, bool resume); + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __ARCH_ARM_SRC_LPC43XX_LPC32_USB0DEV_H */ + From ddaa72597bd52d1d592ab7dca1405b7a9a6ba6b8 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 8 Aug 2012 23:23:15 +0000 Subject: [PATCH 09/13] STM32 CAN TX/RX pins reversed; inconsistent conditional compilation git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5017 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/ChangeLog | 3 ++- .../arm/src/stm32/chip/stm32f103re_pinmap.h | 12 +++++----- .../arm/src/stm32/chip/stm32f103vc_pinmap.h | 16 ++++++------- .../arm/src/stm32/chip/stm32f103ze_pinmap.h | 6 ++--- .../arm/src/stm32/chip/stm32f105vb_pinmap.h | 24 +++++++++---------- .../arm/src/stm32/chip/stm32f107vc_pinmap.h | 24 +++++++++---------- nuttx/configs/hymini-stm32v/README.txt | 4 ++-- nuttx/configs/stm3210e-eval/README.txt | 4 ++-- 8 files changed, 47 insertions(+), 46 deletions(-) diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 107a426d6f..0b0fccd39e 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3138,4 +3138,5 @@ (and lots of testing) before it can be used with the LPC43xx. * nuttx/Documentation/NuttShell.html: Added a section covering ways to customize the behavior or NSH. - + * arch/arm/src/stm32/chip/stm32f1*_pinmap.h: STM32 CAN TX/RX pins reversed; + inconsistent conditional compilation. Reported by Max Holtzberg. diff --git a/nuttx/arch/arm/src/stm32/chip/stm32f103re_pinmap.h b/nuttx/arch/arm/src/stm32/chip/stm32f103re_pinmap.h index 7c33da449a..d0b5a6386b 100644 --- a/nuttx/arch/arm/src/stm32/chip/stm32f103re_pinmap.h +++ b/nuttx/arch/arm/src/stm32/chip/stm32f103re_pinmap.h @@ -301,14 +301,14 @@ /* CAN */ #if defined(CONFIG_STM32_CAN1_REMAP1) -# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN8) -# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN9) +# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN8) +# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN9) #elif defined(CONFIG_STM32_CAN1_REMAP2) -# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN0) -# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTD|GPIO_PIN1) +# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTD|GPIO_PIN0) +# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN1) #else -# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN11) -# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN12) +# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN11) +# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN12) #endif diff --git a/nuttx/arch/arm/src/stm32/chip/stm32f103vc_pinmap.h b/nuttx/arch/arm/src/stm32/chip/stm32f103vc_pinmap.h index c8f33321a0..1606768025 100644 --- a/nuttx/arch/arm/src/stm32/chip/stm32f103vc_pinmap.h +++ b/nuttx/arch/arm/src/stm32/chip/stm32f103vc_pinmap.h @@ -66,15 +66,15 @@ #define GPIO_ADC12_IN8 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN0) #define GPIO_ADC12_IN9 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN1) -#if defined(CONFIG_STM32_CAN1_FULL_REMAP) -# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN0) -# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTD|GPIO_PIN1) -#elif defined(CONFIG_STM32_CAN1_PARTIAL_REMAP) -# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN8) -# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN9) +#if defined(CONFIG_STM32_CAN1_REMAP1) +# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN8) +# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN9) +#elif defined(CONFIG_STM32_CAN1_REMAP2) +# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTD|GPIO_PIN0) +# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN1) #else -# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN11) -# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN12) +# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN11) +# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN12) #endif /* SDIO */ diff --git a/nuttx/arch/arm/src/stm32/chip/stm32f103ze_pinmap.h b/nuttx/arch/arm/src/stm32/chip/stm32f103ze_pinmap.h index 4a320e1fda..9bcee49f57 100644 --- a/nuttx/arch/arm/src/stm32/chip/stm32f103ze_pinmap.h +++ b/nuttx/arch/arm/src/stm32/chip/stm32f103ze_pinmap.h @@ -356,14 +356,14 @@ /* CAN */ #if defined(CONFIG_STM32_CAN1_REMAP1) -# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN9) # define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN8) +# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN9) #elif defined(CONFIG_STM32_CAN1_REMAP2) -# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN1) # define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTD|GPIO_PIN0) +# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN1) #else -# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN12) # define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN11) +# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN12) #endif /* FSMC: CF */ diff --git a/nuttx/arch/arm/src/stm32/chip/stm32f105vb_pinmap.h b/nuttx/arch/arm/src/stm32/chip/stm32f105vb_pinmap.h index 81f621dd9f..fde8dd9358 100644 --- a/nuttx/arch/arm/src/stm32/chip/stm32f105vb_pinmap.h +++ b/nuttx/arch/arm/src/stm32/chip/stm32f105vb_pinmap.h @@ -65,23 +65,23 @@ #define GPIO_ADC12_IN8 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN0) #define GPIO_ADC12_IN9 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN1) -#if defined(CONFIG_STM32_CAN1_FULL_REMAP) -# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN0) -# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTD|GPIO_PIN1) -#elif defined(CONFIG_STM32_CAN1_PARTIAL_REMAP) -# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN8) -# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN9) +#if defined(CONFIG_STM32_CAN1_REMAP1) +# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN8) +# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN9) +#elif defined(CONFIG_STM32_CAN1_REMAP2) +# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTD|GPIO_PIN0) +# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN1) #else -# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN11) -# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN12) +# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN11) +# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN12) #endif #if defined(CONFIG_STM32_CAN2_REMAP) -# define GPIO_CAN2_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN5) -# define GPIO_CAN2_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN6) +# define GPIO_CAN2_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN5) +# define GPIO_CAN2_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN6) #else -# define GPIO_CAN2_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN12) -# define GPIO_CAN2_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN13) +# define GPIO_CAN2_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN12) +# define GPIO_CAN2_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN13) #endif #if 0 /* Needs further investigation */ diff --git a/nuttx/arch/arm/src/stm32/chip/stm32f107vc_pinmap.h b/nuttx/arch/arm/src/stm32/chip/stm32f107vc_pinmap.h index 0b46d79fa9..b9f30b0ed5 100644 --- a/nuttx/arch/arm/src/stm32/chip/stm32f107vc_pinmap.h +++ b/nuttx/arch/arm/src/stm32/chip/stm32f107vc_pinmap.h @@ -65,23 +65,23 @@ #define GPIO_ADC12_IN8 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN0) #define GPIO_ADC12_IN9 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN1) -#if defined(CONFIG_STM32_CAN1_FULL_REMAP) -# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN0) -# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTD|GPIO_PIN1) -#elif defined(CONFIG_STM32_CAN1_PARTIAL_REMAP) -# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN8) -# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN9) +#if defined(CONFIG_STM32_CAN1_REMAP1) +# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN8) +# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN9) +#elif defined(CONFIG_STM32_CAN1_REMAP2) +# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTD|GPIO_PIN0) +# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN1) #else -# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN11) -# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN12) +# define GPIO_CAN1_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN11) +# define GPIO_CAN1_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN12) #endif #if defined(CONFIG_STM32_CAN2_REMAP) -# define GPIO_CAN2_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN5) -# define GPIO_CAN2_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN6) +# define GPIO_CAN2_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN5) +# define GPIO_CAN2_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN6) #else -# define GPIO_CAN2_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN12) -# define GPIO_CAN2_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN13) +# define GPIO_CAN2_RX (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|GPIO_PORTB|GPIO_PIN12) +# define GPIO_CAN2_TX (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN13) #endif #if 0 /* Needs further investigation */ diff --git a/nuttx/configs/hymini-stm32v/README.txt b/nuttx/configs/hymini-stm32v/README.txt index cadd41acf5..43a4127964 100755 --- a/nuttx/configs/hymini-stm32v/README.txt +++ b/nuttx/configs/hymini-stm32v/README.txt @@ -432,8 +432,8 @@ HY-Mini specific Configuration Options CONFIG_STM32_SPI1_REMAP CONFIG_STM32_SPI3_REMAP CONFIG_STM32_I2C1_REMAP - CONFIG_STM32_CAN1_FULL_REMAP - CONFIG_STM32_CAN1_PARTIAL_REMAP + CONFIG_STM32_CAN1_REMAP1 + CONFIG_STM32_CAN1_REMAP2 CONFIG_STM32_CAN2_REMAP STM32F103V specific device driver settings diff --git a/nuttx/configs/stm3210e-eval/README.txt b/nuttx/configs/stm3210e-eval/README.txt index d7df1ef9bd..975e85ceda 100755 --- a/nuttx/configs/stm3210e-eval/README.txt +++ b/nuttx/configs/stm3210e-eval/README.txt @@ -540,8 +540,8 @@ STM3210E-EVAL-specific Configuration Options CONFIG_STM32_SPI1_REMAP CONFIG_STM32_SPI3_REMAP CONFIG_STM32_I2C1_REMAP - CONFIG_STM32_CAN1_FULL_REMAP - CONFIG_STM32_CAN1_PARTIAL_REMAP + CONFIG_STM32_CAN1_REMAP1 + CONFIG_STM32_CAN1_REMAP2 CONFIG_STM32_CAN2_REMAP JTAG Enable settings (by default JTAG-DP and SW-DP are disabled): From 35451abdd787f4ae8b2803095b2ae678b48be184 Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 10 Aug 2012 17:07:02 +0000 Subject: [PATCH 10/13] Add support for Olimex STM32-P107 board (contributed by Max Holtzberg) git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5018 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/ChangeLog | 4 + nuttx/Documentation/NuttX.html | 73 +- .../arch/arm/include/stm32/stm32f10xxx_irq.h | 8 +- .../arm/src/stm32/chip/stm32f107vc_pinmap.h | 58 +- .../arm/src/stm32/chip/stm32f10xxx_gpio.h | 5 +- .../arch/arm/src/stm32/chip/stm32f10xxx_rcc.h | 140 ++- .../arm/src/stm32/chip/stm32f10xxx_vectors.h | 10 +- nuttx/arch/arm/src/stm32/stm32_eth.c | 24 +- nuttx/arch/arm/src/stm32/stm32_rcc.h | 33 + nuttx/arch/arm/src/stm32/stm32_sdio.c | 2 +- nuttx/arch/arm/src/stm32/stm32_vectors.S | 6 + nuttx/arch/arm/src/stm32/stm32f10xxx_rcc.c | 6 + nuttx/configs/README.txt | 6 + nuttx/configs/lpc4330-xplorer/README.txt | 84 +- .../configs/olimex-stm32-p107/include/board.h | 141 +++ nuttx/configs/olimex-stm32-p107/nsh/Make.defs | 174 +++ nuttx/configs/olimex-stm32-p107/nsh/appconfig | 54 + nuttx/configs/olimex-stm32-p107/nsh/defconfig | 1059 +++++++++++++++++ nuttx/configs/olimex-stm32-p107/nsh/setenv.sh | 75 ++ .../olimex-stm32-p107/ostest/Make.defs | 174 +++ .../olimex-stm32-p107/ostest/appconfig | 38 + .../olimex-stm32-p107/ostest/defconfig | 978 +++++++++++++++ .../olimex-stm32-p107/ostest/setenv.sh | 75 ++ .../olimex-stm32-p107/scripts/ld.script | 106 ++ .../olimex-stm32-p107/scripts/ld.script.dfu | 106 ++ nuttx/configs/olimex-stm32-p107/src/Makefile | 89 ++ nuttx/configs/olimex-stm32-p107/src/up_boot.c | 181 +++ nuttx/configs/olimex-stm32-p107/src/up_can.c | 132 ++ nuttx/configs/vsn/include/board.h | 26 +- 29 files changed, 3730 insertions(+), 137 deletions(-) create mode 100644 nuttx/configs/olimex-stm32-p107/include/board.h create mode 100644 nuttx/configs/olimex-stm32-p107/nsh/Make.defs create mode 100644 nuttx/configs/olimex-stm32-p107/nsh/appconfig create mode 100644 nuttx/configs/olimex-stm32-p107/nsh/defconfig create mode 100755 nuttx/configs/olimex-stm32-p107/nsh/setenv.sh create mode 100644 nuttx/configs/olimex-stm32-p107/ostest/Make.defs create mode 100644 nuttx/configs/olimex-stm32-p107/ostest/appconfig create mode 100644 nuttx/configs/olimex-stm32-p107/ostest/defconfig create mode 100755 nuttx/configs/olimex-stm32-p107/ostest/setenv.sh create mode 100644 nuttx/configs/olimex-stm32-p107/scripts/ld.script create mode 100644 nuttx/configs/olimex-stm32-p107/scripts/ld.script.dfu create mode 100644 nuttx/configs/olimex-stm32-p107/src/Makefile create mode 100644 nuttx/configs/olimex-stm32-p107/src/up_boot.c create mode 100644 nuttx/configs/olimex-stm32-p107/src/up_can.c diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 0b0fccd39e..c6ce0f1307 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3140,3 +3140,7 @@ customize the behavior or NSH. * arch/arm/src/stm32/chip/stm32f1*_pinmap.h: STM32 CAN TX/RX pins reversed; inconsistent conditional compilation. Reported by Max Holtzberg. + * arch/arm/*/stm32: Add support for STM32 F107 "Connectivity Line" + Ethernet (contributed by Max Holtzberg). + * configs/olimex-stm32-p107: Add board support for the Olimiex STM32-P107 + board (contributed by Max Holtzberg). \ No newline at end of file diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html index b7026f8965..042042890e 100644 --- a/nuttx/Documentation/NuttX.html +++ b/nuttx/Documentation/NuttX.html @@ -8,7 +8,7 @@

          NuttX RTOS

          -

          Last Updated: July 25, 2012

          +

          Last Updated: August 10, 2012

          @@ -120,7 +120,7 @@

          Goals. - Nuttx is a real timed embedded operating system (RTOS). + NuttX is a real timed embedded operating system (RTOS). Its goals are:

          @@ -286,7 +286,7 @@

        • Easily extensible to new processor architectures, SoC architecture, or board architectures. - A Porting Guide is available. + A Porting Guide is available.
        • @@ -373,7 +373,7 @@ @@ -503,7 +503,7 @@ @@ -922,7 +922,7 @@ This configuration file contains a long list of settings that control what is built into NuttX and what is not. There are hundreds of such settings - (see the NuttX Porting Guide + (see the NuttX Porting Guide for a partial list that excludes platform specific settings). These many, many configuration options allow NuttX to be highly tuned to meet size requirements. @@ -954,7 +954,7 @@

          -

        • Well documented in the NuttX User Guide.
        • +
        • Well documented in the NuttX User Guide.

        • -

        • Power management sub-system.
        • +
        • Power management sub-system.
        • - Most Nuttx-related discussion occurs on the Yahoo! NuttX group. + Most NuttX-related discussion occurs on the Yahoo! NuttX group. You are cordially invited to join. I make a special effort to answer any questions and provide any help that I can.

          @@ -1554,13 +1554,26 @@

          + +
          + +

          + STMicro STM32F100x. + Chip support for these STM32 "Value Line" family was contributed by Mike Smith and users have reported that they have successful brought up NuttX on there proprietary boards using this logic. + However, there is no specific board support for this chip families in the NuttX source tree. +

          + + +
          +
          +

          STMicro STM32F103x. Support for four MCUs and three board configurations are available. - MCU support includes: STM32F103ZET6, STM32F103RET6, STM32F103VCT, and STM32F107VC. + MCU support includes: STM32F103ZET6, STM32F103RET6, and STM32F103VCT. Boards supported include:

            @@ -1623,10 +1636,13 @@

            - STMicro STM32F00x and STM32F107x. - Chip support for these STM32 F1 families are present in NuttX and users have reported that they have successful brought up NuttX on there proprietary boards using this logic. - However, there is specific board support for these chip families. -

            + STMicro STM32F107x. + Chip support for the STM32 F1 "Connectivity Line" family has been present in NuttX and users have reported that they have successful brought up NuttX on there proprietary boards using this logic. + Support for the Olimex STM32-P107 was contributed by Max Holtzberg and first appeared in NuttX-6.21. +
              + STATUS: + Configurations for the basic OS test and NSH are available and verified. +
            @@ -1833,7 +1849,7 @@

            - FreeScale Kinetics K40. + FreeScale Kinetis K40. This port uses the Freescale Kinetis KwikStik K40. Refer to the Freescale web site for further information about this board. The Kwikstik is used with the FreeScale Tower System (mostly just to provide a simple UART connection) @@ -1860,7 +1876,7 @@

            - FreeScale Kinetics K60. + FreeScale Kinetis K60. This port uses the Freescale Kinetis TWR-K60N512 tower system. Refer to the Freescale web site for further information about this board. The TWR-K60N51 includes with the FreeScale Tower System which provides (among other things) a DBP UART connection. @@ -1890,7 +1906,7 @@

            STMicro STM3240G-EVAL. - This port uses the Freescale STMicro STM3240G-EVAL board featuring the STM32F407IGH6 MCU. + This port uses the STMicro STM3240G-EVAL board featuring the STM32F407IGH6 MCU. Refer to the STMicro web site for further information about this board.

              @@ -1927,7 +1943,7 @@

                STATUS: - The basic port for the STM32F-Discovery was contributed by Mike Smith and was first released in NuttX-6.14. + The basic port for the STM32F4-Discovery was contributed by Mike Smith and was first released in NuttX-6.14.

              @@ -1952,7 +1968,7 @@ This includes verified support for: SYSTICK system time, pin and GPIO configuration, and a serial console.

              - Several drivers have been coped from the related LPC17xx port but require integration into the LPC43xx: ADC, DAC, GPDMA, I2C, SPI, and SSP. + Several drivers have been copied from the related LPC17xx port but require integration into the LPC43xx: ADC, DAC, GPDMA, I2C, SPI, and SSP. The registers for these blocks are the same in both the LPC43xx and the LPC17xx and they should integrate into the LPC43xx very easily by simply adapting the clocking and pin configuration logic.

              @@ -1965,8 +1981,9 @@ Some of these can be leveraged from other MCUs that appear to support the same peripheral IP:

              • - USB0 appears to be the same as the USB OTG peripheral for the LPC31xx. - It should be possible to drop in the LPC31xx driver with a small porting effort. + The LPC43xx USB0 peripheral appears to be the same as the USB OTG peripheral for the LPC31xx. + The LPC31xx USB0 device-side driver has been copied from the LPC31xx port but also integration into the LPC43xx (clocking and pin configuration). + It should be possible to complete poriting of this LPC31xx driver with a small porting effort.
              • The Ethernet block looks to be based on the same IP as the STM32 Ethernet and, as a result, it should be possible to leverage the NuttX STM32 Ethernet driver with a little more effort. @@ -2025,7 +2042,7 @@

                - Micropendous 3 AT9USB64x and AT9USB6128x. + Micropendous 3 AT90USB64x and AT90USB6128x. This port of NuttX to the Opendous Micropendous 3 board. The Micropendous3 is may be populated with an AT90USB646, 647, 1286, or 1287. I have only the AT90USB647 version for testing. This version have very limited memory resources: 64K of @@ -2049,7 +2066,7 @@

                - PJRC Teensy++ 2.0 AT9USB1286. + PJRC Teensy++ 2.0 AT90USB1286. This is a port of NuttX to the PJRC Teensy++ 2.0 board. This board was developed by PJRC. The Teensy++ 2.0 is based on an Atmel AT90USB1286 MCU. @@ -2105,7 +2122,7 @@

                Development Environments: 1) Linux with native Linux GNU toolchain, 2) Cygwin with Cygwin GNU toolchain, or 3) Cygwin with Windows native toolchain. - All testing, however, has been performed using the Nuttx DIY toolchain for Linux or Cygwin is provided by the NuttX + All testing, however, has been performed using the NuttX DIY toolchain for Linux or Cygwin is provided by the NuttX buildroot package. As a result, that toolchain is recommended.

                @@ -2399,7 +2416,7 @@

                STATUS: Two verified configurations are available: - (1) The basic OS test configuration that verfies the correctness port of Nuttx, and (2) an extensive NuttShell (NSH) configuration. + (1) The basic OS test configuration that verfies the correctness port of NuttX, and (2) an extensive NuttShell (NSH) configuration. The NSH configuration includes: (1) Full network support, (2) Verified SPI driver, @@ -2447,7 +2464,7 @@

                SH-1 SH7032. This port uses the Hitachi SH-1 Low-Cost Evaluation Board (SH1_LCEVB1), US7032EVB, - with a GNU arm-elf toolchain* under Linux or Cygwin. + with a GNU ELF toolchain* under Linux or Cygwin.

                  @@ -2813,9 +2830,9 @@ avr, m68k, m68hc11, m68hc12, m9s12, blackfin, m32c, h8, and SuperH ports.

                  - "I've installed ZDS-II 5.1.1 (IDE for ez80-based boards) on wine (windows emulator for UNIX) and to my surprise, not many changes were needed to make SVN snapshot of Nuttx buildable... + "I've installed ZDS-II 5.1.1 (IDE for ez80-based boards) on wine (windows emulator for UNIX) and to my surprise, not many changes were needed to make SVN snapshot of NuttX buildable... I've tried nsh profile and build process completed successfully. - One remark is necessary: Nuttx makefiles for ez80 are referencing cygpath utility. + One remark is necessary: NuttX makefiles for ez80 are referencing cygpath utility. Wine provides similar thing called winepath which is compatible and offers compatible syntax. To use that, winepath (which itself is a shell script) has to be copied as cygpath somewhere in $PATH, and edited as in following patch:

                  @@ -3210,11 +3227,11 @@ buildroot-1.10 2011-05-06 <gnutt@nuttx.org> - User Guide + User Guide - Porting Guide + Porting Guide diff --git a/nuttx/arch/arm/include/stm32/stm32f10xxx_irq.h b/nuttx/arch/arm/include/stm32/stm32f10xxx_irq.h index e9c495b782..67f4ba436b 100644 --- a/nuttx/arch/arm/include/stm32/stm32f10xxx_irq.h +++ b/nuttx/arch/arm/include/stm32/stm32f10xxx_irq.h @@ -167,7 +167,13 @@ # define STM32_IRQ_EXTI1510 (56) /* 40: EXTI Line[15:10] interrupts */ # define STM32_IRQ_RTCALRM (57) /* 41: RTC alarm through EXTI line interrupt */ # define STM32_IRQ_OTGFSWKUP (58) /* 42: USB On-The-Go FS Wakeup through EXTI line interrupt */ - /* 43-49: Reserved */ +# define STM32_IRQ_RESERVED0 (59) /* 43: Reserved 0 */ +# define STM32_IRQ_RESERVED1 (60) /* 44: Reserved 1 */ +# define STM32_IRQ_RESERVED2 (61) /* 45: Reserved 2 */ +# define STM32_IRQ_RESERVED3 (62) /* 46: Reserved 3 */ +# define STM32_IRQ_RESERVED4 (63) /* 47: Reserved 4 */ +# define STM32_IRQ_RESERVED5 (64) /* 48: Reserved 5 */ +# define STM32_IRQ_RESERVED6 (65) /* 49: Reserved 6 */ # define STM32_IRQ_TIM5 (66) /* 50: TIM5 global interrupt */ # define STM32_IRQ_SPI3 (67) /* 51: SPI3 global interrupt */ # define STM32_IRQ_UART4 (68) /* 52: UART4 global interrupt */ diff --git a/nuttx/arch/arm/src/stm32/chip/stm32f107vc_pinmap.h b/nuttx/arch/arm/src/stm32/chip/stm32f107vc_pinmap.h index b9f30b0ed5..82f1fa5e78 100644 --- a/nuttx/arch/arm/src/stm32/chip/stm32f107vc_pinmap.h +++ b/nuttx/arch/arm/src/stm32/chip/stm32f107vc_pinmap.h @@ -89,43 +89,49 @@ #define GPIO_DAC_OUT2 (GPIO_INPUT|GPIO_CNF_ANALOGIN|GPIO_MODE_INPUT|GPIO_PORTA|GPIO_PIN5) #endif -#if 0 /* Needs further investigation */ +/* Section 29.3 in the stm32 datasheet (Doc ID 13902 Rev 14) */ + #define GPIO_ETH_MDC (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN1) #define GPIO_ETH_MDIO (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN2) -#define GPIO_ETH_MIICOL (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN3) -#define GPIO_ETH_MIICRSWKUP (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN0) -#define GPIO_ETH_MIIRXCLK (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN1) - +#define GPIO_ETH_MIICOL (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN3) +#define GPIO_ETH_MIICRSWKUP (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN0) +#define GPIO_ETH_MIIRXCLK (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN1) #if defined(CONFIG_STM32_ETH_REMAP) -# define GPIO_ETH_MIIRXD0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN9) -# define GPIO_ETH_MIIRXD1 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN10) -# define GPIO_ETH_MIIRXD2 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN11) -# define GPIO_ETH_MIIRXD3 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN12) -# define GPIO_ETH_MIIRXDV (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN8) +# define GPIO_ETH_MIIRXD0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN9) +# define GPIO_ETH_MIIRXD1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN10) +# define GPIO_ETH_MIIRXD2 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN11) +# define GPIO_ETH_MIIRXD3 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN12) +# define GPIO_ETH_MIIRXDV (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN8) #else -# define GPIO_ETH_MIIRXD0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN4) -# define GPIO_ETH_MIIRXD1 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN5) -# define GPIO_ETH_MIIRXD2 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN0) -# define GPIO_ETH_MIIRXD3 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN1) -# define GPIO_ETH_MIIRXDV (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN7) +# define GPIO_ETH_MIIRXD0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN4) +# define GPIO_ETH_MIIRXD1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN5) +# define GPIO_ETH_MIIRXD2 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN0) +# define GPIO_ETH_MIIRXD3 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN1) +# define GPIO_ETH_MIIRXDV (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN7) #endif -#define GPIO_ETH_MIIRXER (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN10) -#define GPIO_ETH_MIITXCLK (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN3) +#define GPIO_ETH_MIIRXER (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN10) +#define GPIO_ETH_MIITXCLK (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN3) #define GPIO_ETH_MIITXD0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN12) #define GPIO_ETH_MIITXD1 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN13) #define GPIO_ETH_MIITXD2 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN2) #define GPIO_ETH_MIITXD3 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN8) #define GPIO_ETH_MIITXEN (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN11) -#define GPIO_ETH_PPSOUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN5) -#define GPIO_ETH_RMIICRSDV (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN7) -#define GPIO_ETH_RMIIREFCLK (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN1) -#define GPIO_ETH_RMIIRXD0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN4) -#define GPIO_ETH_RMIIRXD1 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN5) -#define GPIO_ETH_RMIITXD0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN12) -#define GPIO_ETH_RMIITXD1 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN13) -#define GPIO_ETH_RMIITXEN (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN11) +#define GPIO_ETH_PPS_OUT (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN5) + +#define GPIO_ETH_RMII_REF_CLK (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN1) +#if defined(CONFIG_STM32_ETH_REMAP) +# define GPIO_ETH_RMII_CRS_DV (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN8) +# define GPIO_ETH_RMII_RXD0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN9) +# define GPIO_ETH_RMII_RXD1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTD|GPIO_PIN10) +#else +# define GPIO_ETH_RMII_CRS_DV (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN7) +# define GPIO_ETH_RMII_RXD0 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN4) +# define GPIO_ETH_RMII_RXD1 (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_50MHz|GPIO_PORTC|GPIO_PIN5) #endif +#define GPIO_ETH_RMII_TXD0 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN12) +#define GPIO_ETH_RMII_TXD1 (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN13) +#define GPIO_ETH_RMII_TX_EN (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN11) #if defined(CONFIG_STM32_I2C1_REMAP) # define GPIO_I2C1_SCL (GPIO_ALT|GPIO_CNF_AFOD|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN8) @@ -148,9 +154,7 @@ #define GPIO_I2S3_SD (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTB|GPIO_PIN5) #define GPIO_I2S3_WS (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN15) -#if 0 /* Needs further investigation */ #define GPIO_MCO (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN8) -#endif #if 0 /* Needs further investigation */ #define GPIO_OTG_FSDM (GPIO_ALT|GPIO_CNF_AFPP|GPIO_MODE_50MHz|GPIO_PORTA|GPIO_PIN11) diff --git a/nuttx/arch/arm/src/stm32/chip/stm32f10xxx_gpio.h b/nuttx/arch/arm/src/stm32/chip/stm32f10xxx_gpio.h index e3b0241290..feeeda6dd2 100644 --- a/nuttx/arch/arm/src/stm32/chip/stm32f10xxx_gpio.h +++ b/nuttx/arch/arm/src/stm32/chip/stm32f10xxx_gpio.h @@ -271,6 +271,9 @@ # define AFIO_MAPR_SWJ (1 << AFIO_MAPR_SWJ_CFG_SHIFT) /* 001: Full SWJ (JTAG-DP + SW-DP) but without JNTRST */ # define AFIO_MAPR_SWDP (2 << AFIO_MAPR_SWJ_CFG_SHIFT) /* 010: JTAG-DP Disabled and SW-DP Enabled */ # define AFIO_MAPR_DISAB (4 << AFIO_MAPR_SWJ_CFG_SHIFT) /* 100: JTAG-DP Disabled and SW-DP Disabled */ +#ifdef CONFIG_STM32_CONNECTIVITYLINE +# define AFIO_MAPR_MII_RMII_SEL (1 << 23) /* MII or RMII selection */ +#endif #define AFIO_MAPR_PD01_REMAP (1 << 15) /* Bit 15 : Port D0/Port D1 mapping on OSC_IN/OSC_OUT */ #define AFIO_MAPR_CAN_REMAP_SHIFT (13) /* Bits 14-13: CAN Alternate function remapping */ #define AFIO_MAPR_CAN_REMAP_MASK (3 << AFIO_MAPR_CAN_REMAP_SHIFT) @@ -278,7 +281,7 @@ # define AFIO_MAPR_PB89 (2 << AFIO_MAPR_CAN_REMAP_SHIFT) /* 10: CANRX mapped to PB8, CANTX mapped to PB9 */ # define AFIO_MAPR_PD01 (3 << AFIO_MAPR_CAN_REMAP_SHIFT) /* 11: CANRX mapped to PD0, CANTX mapped to PD1 */ #define AFIO_MAPR_TIM4_REMAP (1 << 12) /* Bit 12: TIM4 remapping */ -#define AFIO_MAPR_TIM3_REMAP_SHIFT (10) /* Bits 11-10: TIM3 remapping */ +#define AFIO_MAPR_TIM3_REMAP_SHIFT (10) /* Bits 11-10: TIM3 remapping */ #define AFIO_MAPR_TIM3_REMAP_MASK (3 << AFIO_MAPR_TIM3_REMAP_SHIFT) # define AFIO_MAPR_TIM3_NOREMAP (0 << AFIO_MAPR_TIM3_REMAP_SHIFT) /* 00: No remap (CH1/PA6, CH2/PA7, CH3/PB0, CH4/PB1) */ # define AFIO_MAPR_TIM3_PARTREMAP (2 << AFIO_MAPR_TIM3_REMAP_SHIFT) /* 10: Partial remap (CH1/PB4, CH2/PB5, CH3/PB0, CH4/PB1) */ diff --git a/nuttx/arch/arm/src/stm32/chip/stm32f10xxx_rcc.h b/nuttx/arch/arm/src/stm32/chip/stm32f10xxx_rcc.h index 31544c99f3..60365b9218 100644 --- a/nuttx/arch/arm/src/stm32/chip/stm32f10xxx_rcc.h +++ b/nuttx/arch/arm/src/stm32/chip/stm32f10xxx_rcc.h @@ -52,7 +52,10 @@ #define STM32_RCC_APB1ENR_OFFSET 0x001c /* APB1 Peripheral Clock enable register */ #define STM32_RCC_BDCR_OFFSET 0x0020 /* Backup domain control register */ #define STM32_RCC_CSR_OFFSET 0x0024 /* Control/status register */ -#ifdef CONFIG_STM32_VALUELINE +#ifdef CONFIG_STM32_CONNECTIVITYLINE +# define STM32_RCC_AHBRSTR_OFFSET 0x0028 /* AHB Reset register */ +#endif +#if defined(CONFIG_STM32_VALUELINE) || defined(CONFIG_STM32_CONNECTIVITYLINE) # define STM32_RCC_CFGR2_OFFSET 0x002c /* Clock configuration register 2 */ #endif @@ -68,7 +71,10 @@ #define STM32_RCC_APB1ENR (STM32_RCC_BASE+STM32_RCC_APB1ENR_OFFSET) #define STM32_RCC_BDCR (STM32_RCC_BASE+STM32_RCC_BDCR_OFFSET) #define STM32_RCC_CSR (STM32_RCC_BASE+STM32_RCC_CSR_OFFSET) -#ifdef CONFIG_STM32_VALUELINE +#ifdef CONFIG_STM32_CONNECTIVITYLINE +# define STM32_RCC_AHBRSTR (STM32_RCC_BASE+STM32_RCC_AHBRSTR_OFFSET) +#endif +#if defined(CONFIG_STM32_VALUELINE) || defined(CONFIG_STM32_CONNECTIVITYLINE) # define STM32_RCC_CFGR2 (STM32_RCC_BASE+STM32_RCC_CFGR2_OFFSET) #endif @@ -88,6 +94,12 @@ #define RCC_CR_CSSON (1 << 19) /* Bit 19: Clock Security System enable */ #define RCC_CR_PLLON (1 << 24) /* Bit 24: PLL enable */ #define RCC_CR_PLLRDY (1 << 25) /* Bit 25: PLL clock ready flag */ +#ifdef CONFIG_STM32_CONNECTIVITYLINE +# define RCC_CR_PLL2ON (1 << 26) /* Bit 26: PLL2 enable */ +# define RCC_CR_PLL2RDY (1 << 27) /* Bit 27: PLL2 clock ready flag */ +# define RCC_CR_PLL3ON (1 << 28) /* Bit 28: PLL3 enable */ +# define RCC_CR_PLL3RDY (1 << 29) /* Bit 29: PLL3 ready flag */ +#endif /* Clock configuration register */ @@ -153,12 +165,16 @@ # define RCC_CFGR_PLLMUL_CLKx16 (14 << RCC_CFGR_PLLMUL_SHIFT) /* 111x: PLL input clock x 16 */ #define RCC_CFGR_USBPRE (1 << 22) /* Bit 22: USB prescaler */ #define RCC_CFGR_MCO_SHIFT (24) /* Bits 26-24: Microcontroller Clock Output */ -#define RCC_CFGR_MCO_MASK (7 << RCC_CFGR_MCO_SHIFT) -# define RCC_CFGR_NOCLK (0 << RCC_CFGR_MCO_SHIFT) /* 0xx: No clock */ -# define RCC_CFGR_SYSCLK (4 << RCC_CFGR_MCO_SHIFT) /* 100: System clock selected */ -# define RCC_CFGR_INTCLK (5 << RCC_CFGR_MCO_SHIFT) /* 101: Internal 8 MHz RC oscillator clock selected */ -# define RCC_CFGR_EXTCLK (6 << RCC_CFGR_MCO_SHIFT) /* 110: External 1-25 MHz oscillator clock selected */ -# define RCC_CFGR_PLLCLKd2 (7 << RCC_CFGR_MCO_SHIFT) /* 111: PLL clock divided by 2 selected */ +#define RCC_CFGR_MCO_MASK (0x0f << RCC_CFGR_MCO_SHIFT) +# define RCC_CFGR_NOCLK (0 << RCC_CFGR_MCO_SHIFT) /* 0xx: No clock */ +# define RCC_CFGR_SYSCLK (4 << RCC_CFGR_MCO_SHIFT) /* 100: System clock selected */ +# define RCC_CFGR_INTCLK (5 << RCC_CFGR_MCO_SHIFT) /* 101: Internal 8 MHz RC oscillator clock selected */ +# define RCC_CFGR_EXTCLK (6 << RCC_CFGR_MCO_SHIFT) /* 110: External 1-25 MHz oscillator clock selected */ +# define RCC_CFGR_PLLCLKd2 (7 << RCC_CFGR_MCO_SHIFT) /* 111: PLL clock divided by 2 selected */ +# define RCC_CFGR_PLL2CLK (8 << RCC_CFGR_MCO_SHIFT) /* 1000: PLL2 clock selected */ +# define RCC_CFGR_PLL3CLKd2 (9 << RCC_CFGR_MCO_SHIFT) /* 1001: PLL3 clock devided by 2 selected */ +# define RCC_CFGR_XT1 (10 << RCC_CFGR_MCO_SHIFT) /* 1010: external 3-25 MHz oscillator clock selected (for Ethernet) */ +# define RCC_CFGR_PLL3CLK (11 << RCC_CFGR_MCO_SHIFT) /* 1011: PLL3 clock selected (for Ethernet) */ /* Clock interrupt register */ @@ -231,6 +247,18 @@ #define RCC_AHBENR_CRCEN (1 << 6) /* Bit 6: CRC clock enable */ #define RCC_AHBENR_FSMCEN (1 << 8) /* Bit 8: FSMC clock enable */ #define RCC_AHBENR_SDIOEN (1 << 10) /* Bit 10: SDIO clock enable */ +#ifdef CONFIG_STM32_CONNECTIVITYLINE +# define RCC_AHBENR_ETHMACEN (1 << 14) /* Bit 14: Ethernet MAC clock enable */ +# define RCC_AHBENR_ETHMACTXEN (1 << 15) /* Bit 15: Ethernet MAC TX clock enable */ +# define RCC_AHBENR_ETHMACRXEN (1 << 16) /* Bit 16: Ethernet MAC RX clock enable */ +#endif + +/* AHB peripheral clock reset register (RCC_AHBRSTR) */ + +#ifdef CONFIG_STM32_CONNECTIVITYLINE +# define RCC_AHBRSTR_OTGFSRST (1 << 12) /* USB OTG FS reset */ +# define RCC_AHBRSTR_ETHMACRST (1 << 14) /* Ethernet MAC reset */ +#endif /* APB2 Peripheral Clock enable register */ @@ -301,26 +329,86 @@ #define RCC_CSR_WWDGRSTF (1 << 30) /* Bit 30: Window watchdog reset flag */ #define RCC_CSR_LPWRRSTF (1 << 31) /* Bit 31: Low-Power reset flag */ -#ifdef CONFIG_STM32_VALUELINE +#if defined(CONFIG_STM32_VALUELINE) || defined(CONFIG_STM32_CONNECTIVITYLINE) -/* Clock configuration register 2 */ +/* Clock configuration register 2 (For connectivity line only) */ -# define RCC_CFGR2_PREDIV1d1 0 /* HSE input not divided */ -# define RCC_CFGR2_PREDIV1d2 1 /* HSE input divided by 2 */ -# define RCC_CFGR2_PREDIV1d3 2 /* HSE input divided by 3 */ -# define RCC_CFGR2_PREDIV1d4 3 /* HSE input divided by 4 */ -# define RCC_CFGR2_PREDIV1d5 4 /* HSE input divided by 5 */ -# define RCC_CFGR2_PREDIV1d6 5 /* HSE input divided by 6 */ -# define RCC_CFGR2_PREDIV1d7 6 /* HSE input divided by 7 */ -# define RCC_CFGR2_PREDIV1d8 7 /* HSE input divided by 8 */ -# define RCC_CFGR2_PREDIV1d9 8 /* HSE input divided by 9 */ -# define RCC_CFGR2_PREDIV1d10 9 /* HSE input divided by 10 */ -# define RCC_CFGR2_PREDIV1d11 10 /* HSE input divided by 11 */ -# define RCC_CFGR2_PREDIV1d12 11 /* HSE input divided by 12 */ -# define RCC_CFGR2_PREDIV1d13 12 /* HSE input divided by 13 */ -# define RCC_CFGR2_PREDIV1d14 13 /* HSE input divided by 14 */ -# define RCC_CFGR2_PREDIV1d15 14 /* HSE input divided by 15 */ -# define RCC_CFGR2_PREDIV1d16 15 /* HSE input divided by 16 */ +#define RCC_CFGR2_PREDIV1_SHIFT (0) +#define RCC_CFGR2_PREDIV1_MASK (0x0f << RCC_CFGR2_PREDIV1_SHIFT) +# define RCC_CFGR2_PREDIV1d1 (0 << RCC_CFGR2_PREDIV1_SHIFT) +# define RCC_CFGR2_PREDIV1d2 (1 << RCC_CFGR2_PREDIV1_SHIFT) +# define RCC_CFGR2_PREDIV1d3 (2 << RCC_CFGR2_PREDIV1_SHIFT) +# define RCC_CFGR2_PREDIV1d4 (3 << RCC_CFGR2_PREDIV1_SHIFT) +# define RCC_CFGR2_PREDIV1d5 (4 << RCC_CFGR2_PREDIV1_SHIFT) +# define RCC_CFGR2_PREDIV1d6 (5 << RCC_CFGR2_PREDIV1_SHIFT) +# define RCC_CFGR2_PREDIV1d7 (6 << RCC_CFGR2_PREDIV1_SHIFT) +# define RCC_CFGR2_PREDIV1d8 (7 << RCC_CFGR2_PREDIV1_SHIFT) +# define RCC_CFGR2_PREDIV1d9 (8 << RCC_CFGR2_PREDIV1_SHIFT) +# define RCC_CFGR2_PREDIV1d10 (9 << RCC_CFGR2_PREDIV1_SHIFT) +# define RCC_CFGR2_PREDIV1d11 (10 << RCC_CFGR2_PREDIV1_SHIFT) +# define RCC_CFGR2_PREDIV1d12 (11 << RCC_CFGR2_PREDIV1_SHIFT) +# define RCC_CFGR2_PREDIV1d13 (12 << RCC_CFGR2_PREDIV1_SHIFT) +# define RCC_CFGR2_PREDIV1d14 (13 << RCC_CFGR2_PREDIV1_SHIFT) +# define RCC_CFGR2_PREDIV1d15 (14 << RCC_CFGR2_PREDIV1_SHIFT) +# define RCC_CFGR2_PREDIV1d16 (15 << RCC_CFGR2_PREDIV1_SHIFT) + +#define RCC_CFGR2_PREDIV2_SHIFT (4) +#define RCC_CFGR2_PREDIV2_MASK (0x0f << RCC_CFGR2_PREDIV2_SHIFT) +# define RCC_CFGR2_PREDIV2d1 (0 << RCC_CFGR2_PREDIV2_SHIFT) +# define RCC_CFGR2_PREDIV2d2 (1 << RCC_CFGR2_PREDIV2_SHIFT) +# define RCC_CFGR2_PREDIV2d3 (2 << RCC_CFGR2_PREDIV2_SHIFT) +# define RCC_CFGR2_PREDIV2d4 (3 << RCC_CFGR2_PREDIV2_SHIFT) +# define RCC_CFGR2_PREDIV2d5 (4 << RCC_CFGR2_PREDIV2_SHIFT) +# define RCC_CFGR2_PREDIV2d6 (5 << RCC_CFGR2_PREDIV2_SHIFT) +# define RCC_CFGR2_PREDIV2d7 (6 << RCC_CFGR2_PREDIV2_SHIFT) +# define RCC_CFGR2_PREDIV2d8 (7 << RCC_CFGR2_PREDIV2_SHIFT) +# define RCC_CFGR2_PREDIV2d9 (8 << RCC_CFGR2_PREDIV2_SHIFT) +# define RCC_CFGR2_PREDIV2d10 (9 << RCC_CFGR2_PREDIV2_SHIFT) +# define RCC_CFGR2_PREDIV2d11 (10 << RCC_CFGR2_PREDIV2_SHIFT) +# define RCC_CFGR2_PREDIV2d12 (11 << RCC_CFGR2_PREDIV2_SHIFT) +# define RCC_CFGR2_PREDIV2d13 (12 << RCC_CFGR2_PREDIV2_SHIFT) +# define RCC_CFGR2_PREDIV2d14 (13 << RCC_CFGR2_PREDIV2_SHIFT) +# define RCC_CFGR2_PREDIV2d15 (14 << RCC_CFGR2_PREDIV2_SHIFT) +# define RCC_CFGR2_PREDIV2d16 (15 << RCC_CFGR2_PREDIV2_SHIFT) + +#define RCC_CFGR2_PLL2MUL_SHIFT (8) +#define RCC_CFGR2_PLL2MUL_MASK (0x0f << RCC_CFGR2_PLL2MUL_SHIFT) +# define RCC_CFGR2_PLL2MULx8 (6 << RCC_CFGR2_PLL2MUL_SHIFT) +# define RCC_CFGR2_PLL2MULx9 (7 << RCC_CFGR2_PLL2MUL_SHIFT) +# define RCC_CFGR2_PLL2MULx10 (8 << RCC_CFGR2_PLL2MUL_SHIFT) +# define RCC_CFGR2_PLL2MULx11 (9 << RCC_CFGR2_PLL2MUL_SHIFT) +# define RCC_CFGR2_PLL2MULx12 (10 << RCC_CFGR2_PLL2MUL_SHIFT) +# define RCC_CFGR2_PLL2MULx13 (11 << RCC_CFGR2_PLL2MUL_SHIFT) +# define RCC_CFGR2_PLL2MULx14 (12 << RCC_CFGR2_PLL2MUL_SHIFT) +# define RCC_CFGR2_PLL2MULx16 (14 << RCC_CFGR2_PLL2MUL_SHIFT) +# define RCC_CFGR2_PLL2MULx20 (15 << RCC_CFGR2_PLL2MUL_SHIFT) + +#define RCC_CFGR2_PLL3MUL_SHIFT (12) +#define RCC_CFGR2_PLL3MUL_MASK (0x0f << RCC_CFGR2_PLL3MUL_SHIFT) +# define RCC_CFGR2_PLL3MULx8 (6 << RCC_CFGR2_PLL3MUL_SHIFT) +# define RCC_CFGR2_PLL3MULx9 (7 << RCC_CFGR2_PLL3MUL_SHIFT) +# define RCC_CFGR2_PLL3MULx10 (8 << RCC_CFGR2_PLL3MUL_SHIFT) +# define RCC_CFGR2_PLL3MULx11 (9 << RCC_CFGR2_PLL3MUL_SHIFT) +# define RCC_CFGR2_PLL3MULx12 (10 << RCC_CFGR2_PLL3MUL_SHIFT) +# define RCC_CFGR2_PLL3MULx13 (11 << RCC_CFGR2_PLL3MUL_SHIFT) +# define RCC_CFGR2_PLL3MULx14 (12 << RCC_CFGR2_PLL3MUL_SHIFT) +# define RCC_CFGR2_PLL3MULx16 (14 << RCC_CFGR2_PLL3MUL_SHIFT) +# define RCC_CFGR2_PLL3MULx20 (15 << RCC_CFGR2_PLL3MUL_SHIFT) + +#define RCC_CFGR2_PREDIV1SRC_SHIFT (16) +#define RCC_CFGR2_PREDIV1SRC_MASK (0x01 << RCC_CFGR2_PREDIV1SRC_SHIFT) +# define RCC_CFGR2_PREDIV1SRC_HSE (0 << RCC_CFGR2_PREDIV1SRC_SHIFT) +# define RCC_CFGR2_PREDIV1SRC_PLL2 (1 << RCC_CFGR2_PREDIV1SRC_SHIFT) + +#define RCC_CFGR2_I2S2SRC_SHIFT (17) +#define RCC_CFGR2_I2S2SRC_MASK (0x01 << RCC_CFGR2_I2S2SRC_SHIFT) +# define RCC_CFGR2_I2S2SRC_SYSCLK (0 << RCC_CFGR2_I2S2SRC_SHIFT) +# define RCC_CFGR2_I2S2SRC_PLL3 (1 << RCC_CFGR2_I2S2SRC_SHIFT) + +#define RCC_CFGR2_I2S3SRC_SHIFT (17) +#define RCC_CFGR2_I2S3SRC_MASK (0x01 << RCC_CFGR2_I2S3SRC_SHIFT) +# define RCC_CFGR2_I2S3SRC_SYSCLK (0 << RCC_CFGR2_I2S3SRC_SHIFT) +# define RCC_CFGR2_I2S3SRC_PLL3 (1 << RCC_CFGR2_I2S3SRC_SHIFT) #endif diff --git a/nuttx/arch/arm/src/stm32/chip/stm32f10xxx_vectors.h b/nuttx/arch/arm/src/stm32/chip/stm32f10xxx_vectors.h index d18c7e7898..b8d71799fe 100644 --- a/nuttx/arch/arm/src/stm32/chip/stm32f10xxx_vectors.h +++ b/nuttx/arch/arm/src/stm32/chip/stm32f10xxx_vectors.h @@ -89,7 +89,8 @@ VECTOR(stm32_dma1ch2, STM32_IRQ_DMA1CH2) /* Vector 16+12: DMA1 Channel 2 VECTOR(stm32_dma1ch3, STM32_IRQ_DMA1CH3) /* Vector 16+13: DMA1 Channel 3 global interrupt */ VECTOR(stm32_dma1ch4, STM32_IRQ_DMA1CH4) /* Vector 16+14: DMA1 Channel 4 global interrupt */ VECTOR(stm32_dma1ch5, STM32_IRQ_DMA1CH5) /* Vector 16+15: DMA1 Channel 5 global interrupt */ -VECTOR(stm32_dma1ch6, STM32_IRQ_DMA1CH6) /* Vector 16+16: DMA1 Channel 7 global interrupt */ +VECTOR(stm32_dma1ch6, STM32_IRQ_DMA1CH6) /* Vector 16+16: DMA1 Channel 6 global interrupt */ +VECTOR(stm32_dma1ch7, STM32_IRQ_DMA1CH7) /* Vector 16+17: DMA1 Channel 7 global interrupt */ VECTOR(stm32_adc12, STM32_IRQ_ADC12) /* Vector 16+18: ADC1 and ADC2 global interrupt */ VECTOR(stm32_can1tx, STM32_IRQ_CAN1TX) /* Vector 16+19: CAN1 TX interrupts */ VECTOR(stm32_can1rx0, STM32_IRQ_CAN1RX0) /* Vector 16+20: CAN1 RX0 interrupts */ @@ -115,6 +116,13 @@ VECTOR(stm32_usart3, STM32_IRQ_USART3) /* Vector 16+39: USART3 global VECTOR(stm32_exti1510, STM32_IRQ_EXTI1510) /* Vector 16+40: EXTI Line[15:10] interrupts */ VECTOR(stm32_rtcalr, STM32_IRQ_RTCALRM) /* Vector 16+41: RTC alarm through EXTI line interrupt */ VECTOR(stm32_otgfswkup, STM32_IRQ_OTGFSWKUP) /* Vector 16+42: USB On-The-Go FS Wakeup through EXTI line interrupt */ +UNUSED(STM32_IRQ_RESERVED0) /* Vector 16+43: Reserved 0 */ +UNUSED(STM32_IRQ_RESERVED1) /* Vector 16+44: Reserved 1 */ +UNUSED(STM32_IRQ_RESERVED2) /* Vector 16+55: Reserved 2 */ +UNUSED(STM32_IRQ_RESERVED3) /* Vector 16+46: Reserved 3 */ +UNUSED(STM32_IRQ_RESERVED4) /* Vector 16+47: Reserved 4 */ +UNUSED(STM32_IRQ_RESERVED5) /* Vector 16+48: Reserved 5 */ +UNUSED(STM32_IRQ_RESERVED6) /* Vector 16+49: Reserved 6 */ VECTOR(stm32_tim5, STM32_IRQ_TIM5) /* Vector 16+50: TIM5 global interrupt */ VECTOR(stm32_spi3, STM32_IRQ_SPI3 ) /* Vector 16+51: SPI3 global interrupt */ VECTOR(stm32_uart4 , STM32_IRQ_UART4) /* Vector 16+52: UART4 global interrupt */ diff --git a/nuttx/arch/arm/src/stm32/stm32_eth.c b/nuttx/arch/arm/src/stm32/stm32_eth.c index 68ee78fd5f..57d4cc2d33 100644 --- a/nuttx/arch/arm/src/stm32/stm32_eth.c +++ b/nuttx/arch/arm/src/stm32/stm32_eth.c @@ -85,7 +85,7 @@ # error "Logic to support multiple Ethernet interfaces is incomplete" #endif -#ifndef CONFIG_STM32_SYSCFG +#if !defined(CONFIG_STM32_SYSCFG) && !defined(CONFIG_STM32_CONNECTIVITYLINE) # error "CONFIG_STM32_SYSCFG must be defined in the NuttX configuration" #endif @@ -2657,6 +2657,13 @@ static inline void stm32_ethgpioconfig(FAR struct stm32_ethmac_s *priv) #elif defined(CONFIG_STM32_RMII) + /* Setup MCO pin for alternative usage */ + +#if defined(CONFIG_STM32_RMII_MCO) + stm32_configgpio(GPIO_MCO); + stm32_mcoconfig(BOARD_CFGR_MCO_SOURCE); +#endif + /* Select the RMII interface */ stm32_selectrmii(); @@ -2673,7 +2680,7 @@ static inline void stm32_ethgpioconfig(FAR struct stm32_ethmac_s *priv) stm32_configgpio(GPIO_ETH_RMII_RXD1); stm32_configgpio(GPIO_ETH_RMII_TXD0); stm32_configgpio(GPIO_ETH_RMII_TXD1); - stm32_configgpio(GPIO_ETH_RMII_TX_CLK); + /* stm32_configgpio(GPIO_ETH_RMII_TX_CLK); not needed? */ stm32_configgpio(GPIO_ETH_RMII_TX_EN); #endif @@ -2704,14 +2711,25 @@ static void stm32_ethreset(FAR struct stm32_ethmac_s *priv) { uint32_t regval; - /* Reset the Ethernet on the AHB1 bus */ + /* Reset the Ethernet on the AHB bus (F1 Connectivity Line) or AHB1 bus (F2 + * and F4) + */ +#if defined(CONFIG_STM32_CONNECTIVITYLINE) + regval = stm32_getreg(STM32_RCC_AHBRSTR); + regval |= RCC_AHBRSTR_ETHMACRST; + stm32_putreg(regval, STM32_RCC_AHBRSTR); + + regval &= ~RCC_AHBRSTR_ETHMACRST; + stm32_putreg(regval, STM32_RCC_AHBRSTR); +#else regval = stm32_getreg(STM32_RCC_AHB1RSTR); regval |= RCC_AHB1RSTR_ETHMACRST; stm32_putreg(regval, STM32_RCC_AHB1RSTR); regval &= ~RCC_AHB1RSTR_ETHMACRST; stm32_putreg(regval, STM32_RCC_AHB1RSTR); +#endif /* Perform a software reset by setting the SR bit in the DMABMR register. * This Resets all MAC subsystem internal registers and logic. After this diff --git a/nuttx/arch/arm/src/stm32/stm32_rcc.h b/nuttx/arch/arm/src/stm32/stm32_rcc.h index c4d43db3a7..292eade73b 100644 --- a/nuttx/arch/arm/src/stm32/stm32_rcc.h +++ b/nuttx/arch/arm/src/stm32/stm32_rcc.h @@ -116,6 +116,39 @@ static inline void stm32_mco1config(uint32_t source, uint32_t div) } #endif +/************************************************************************************ + * Name: stm32_mcoconfig + * + * Description: + * Selects the clock source to output on MC pin (PA8) for stm32f10xxx. + * PA8 should be configured in alternate function mode. + * + * Input Parameters: + * source - One of the definitions for the RCC_CFGR_MCO definitions from + * chip/stm32f10xxx_rcc.h {RCC_CFGR_SYSCLK, RCC_CFGR_INTCLK, RCC_CFGR_EXTCLK, + * RCC_CFGR_PLLCLKd2, RCC_CFGR_PLL2CLK, RCC_CFGR_PLL3CLKd2, RCC_CFGR_XT1, + * RCC_CFGR_PLL3CLK} + * + * Returned Value: + * None + * + ************************************************************************************/ + +#if defined(CONFIG_STM32_CONNECTIVITYLINE) +static inline void stm32_mcoconfig(uint32_t source) +{ + uint32_t regval; + + /* Set MCO source */ + + regval = getreg32(STM32_RCC_CFGR); + regval &= ~(RCC_CFGR_MCO_MASK); + regval |= (source & RCC_CFGR_MCO_MASK); + putreg32(regval, STM32_RCC_CFGR); +} +#endif + + /************************************************************************************ * Name: stm32_mco2config * diff --git a/nuttx/arch/arm/src/stm32/stm32_sdio.c b/nuttx/arch/arm/src/stm32/stm32_sdio.c index b109160a17..57d5f80d96 100644 --- a/nuttx/arch/arm/src/stm32/stm32_sdio.c +++ b/nuttx/arch/arm/src/stm32/stm32_sdio.c @@ -1615,7 +1615,7 @@ static void stm32_clock(FAR struct sdio_dev_s *dev, enum sdio_clock_e rate) /* SD normal operation clocking (narrow 1-bit mode) */ case CLOCK_SD_TRANSFER_1BIT: - clckr = (SDIO_CLCKR_SDXFR | SDIO_CLKCR_CLKEN) + clckr = (SDIO_CLCKR_SDXFR | SDIO_CLKCR_CLKEN); break; } diff --git a/nuttx/arch/arm/src/stm32/stm32_vectors.S b/nuttx/arch/arm/src/stm32/stm32_vectors.S index b75237e40f..ab4dadb779 100644 --- a/nuttx/arch/arm/src/stm32/stm32_vectors.S +++ b/nuttx/arch/arm/src/stm32/stm32_vectors.S @@ -143,6 +143,9 @@ stm32_vectors: #undef VECTOR #define VECTOR(l,i) .word l +#undef UNUSED +#define UNUSED(i) .word stm32_reserved + #if defined(CONFIG_STM32_STM32F10XX) # include "chip/chip/stm32f10xxx_vectors.h" #elif defined(CONFIG_STM32_STM32F20XX) @@ -176,6 +179,9 @@ handlers: #undef VECTOR #define VECTOR(l,i) HANDLER l, i +#undef UNUSED +#define UNUSED(i) + #if defined(CONFIG_STM32_STM32F10XX) # include "chip/chip/stm32f10xxx_vectors.h" #elif defined(CONFIG_STM32_STM32F20XX) diff --git a/nuttx/arch/arm/src/stm32/stm32f10xxx_rcc.c b/nuttx/arch/arm/src/stm32/stm32f10xxx_rcc.c index 516b026fb0..10b8572cf0 100644 --- a/nuttx/arch/arm/src/stm32/stm32f10xxx_rcc.c +++ b/nuttx/arch/arm/src/stm32/stm32f10xxx_rcc.c @@ -144,6 +144,12 @@ static inline void rcc_enableahb(void) regval |= RCC_AHBENR_SDIOEN; #endif +#if defined(CONFIG_STM32_ETHMAC) && defined(CONFIG_STM32_CONNECTIVITYLINE) + /* Ethernet clock enable */ + + regval |= (RCC_AHBENR_ETHMACEN | RCC_AHBENR_ETHMACTXEN | RCC_AHBENR_ETHMACRXEN); +#endif + putreg32(regval, STM32_RCC_AHBENR); /* Enable peripherals */ } diff --git a/nuttx/configs/README.txt b/nuttx/configs/README.txt index db341dfe3b..87725bf58f 100644 --- a/nuttx/configs/README.txt +++ b/nuttx/configs/README.txt @@ -1603,6 +1603,12 @@ configs/olimex-lpc2378 Linux or Cygwin. STATUS: ostest and NSH configurations available. This port for the NXP LPC2378 was contributed by Rommel Marcelo. +configs/olimex-stm32-p107 + This port uses the Olimex STM32-P107 board (STM32F107VC) and a GNU arm-elf + toolchain* under Linux or Cygwin. See the https://www.olimex.com/dev/stm32-p107.html + for further information. Contributed by Max Holtzberg. STATUS: Configurations + for the basic OS test and NSH are available and verified. + configs/olimex-strp711 This port uses the Olimex STR-P711 board and a GNU arm-elf toolchain* under Linux or Cygwin. See the http://www.olimex.com/dev/str-p711.html" for diff --git a/nuttx/configs/lpc4330-xplorer/README.txt b/nuttx/configs/lpc4330-xplorer/README.txt index 4ebe89d9ed..4cd867c32b 100644 --- a/nuttx/configs/lpc4330-xplorer/README.txt +++ b/nuttx/configs/lpc4330-xplorer/README.txt @@ -12,11 +12,17 @@ Contents - Development Environment - GNU Toolchain Options - IDEs + - Code Red IDE/Tools + Booting the LPCLink + Using GDB + Troubleshooting + Command Line Flash Programming + Executing from SPIFI + USB DFU Booting - NuttX buildroot Toolchain - Serial Console - FPU - LPC4330-Xplorer Configuration Options - - USB Host Configuration - Configurations LPC4330-Xplorer board @@ -263,8 +269,8 @@ IDEs Startup files will probably cause you some headaches. The NuttX startup file is arch/arm/src/common/up_vectors.S. -Code Red IDE -^^^^^^^^^^^^ +Code Red IDE/Tools +^^^^^^^^^^^^^^^^^^ Booting the LPCLink ------------------- @@ -418,6 +424,39 @@ Code Red IDE found in the configs/lpc4330-xplorer/scripts directory can do that with a single command line command. + Executing from SPIFI + -------------------- + + By default, the configurations here assume that you are executing directly + from SRAM. + + CONFIG_BOOT_SRAM=y : Executing in SRAM + CONFIG_LPC32_CODEREDW=y : Code Red under Windows + + To execute from SPIFI, you would need to set: + + CONFIG_BOOT_SPIFI=y : Executing from SPIFI + CONFIG_DRAM_SIZE=(128*1024) : SRAM Bank0 size + CONFIG_DRAM_START=0x10000000 : SRAM Bank0 base address + CONFIG_SPIFI_OFFSET=(512*1024) : SPIFI file system offset + + To boot the LPC4330-Xplorer from SPIFI the DIP switches should be 1-OFF, + 2-ON, 3-ON, 4-ON (LOW LOW LOW HIGH in Table 19, MSB to LSB). + + If the code in flash hard faults after reset and crt_emu_lpc18_43_nxp + can't reset the MCU, an alternative is to temporarily change switch 1 + to ON and press the reset button so it enters UART boot mode. Then + change it back to OFF and reset to boot again from flash. + + # Use -wire to specify the debug probe in use: + # (empty) Red Probe+ + # -wire=winusb LPC-Link on Windows XP + # -wire=hid LPC-Link on Windows Vista/ Windows 7 + # Add -g -4 for verbose output + + crt_emu_lpc18_43_nxp -wire=hid -pLPC4330 -load-base=0x14000000 + -flash-load-exec=nuttx.bin -flash-driver=LPC1850A_4350A_SPIFI.cfx + USB DFU Booting --------------- @@ -804,41 +843,6 @@ LPC4330-Xplorer Configuration Options application can guarantee that all end-user I/O buffers reside in AHB SRAM. -USB Host Configuration -====================== - -The LPC4330-Xplorer board supports a USB host interface. The hidkbd -example can be used to test this interface. - -The NuttShell (NSH) lpc4330-xplorer can also be modified in order to support USB -host operations. To make these modifications, do the following: - -1. First configure to build the NSH configuration from the top-level - NuttX directory: - - cd tools - ./configure lpc4330-xplorer/nsh - cd .. - -2. Then edit the top-level .config file to enable USB host. Make the - following changes: - - CONFIG_LPC43_USBHOST=n - CONFIG_USBHOST=n - CONFIG_SCHED_WORKQUEUE=y - -When this change is made, NSH should be extended to support USB flash -devices. When a FLASH device is inserted, you should see a device -appear in the /dev (pseudo) directory. The device name should be -like /dev/sda, /dev/sdb, etc. The USB mass storage device, is present -it can be mounted from the NSH command line like: - - ls /dev - mount -t vfat /dev/sda /mnt/flash - -Files on the connect USB flash device should then be accessible under -the mountpoint /mnt/flash. - Configurations ============== @@ -901,12 +905,12 @@ Where is one of the following: CONFIG_BOOT_SRAM=y : Executing in SRAM CONFIG_LPC32_CODEREDW=y : Code Red under Windows - To execute from SRAM, you would need to set: + To execute from SPIFI, you would need to set: CONFIG_BOOT_SPIFI=y : Executing from SPIFI CONFIG_DRAM_SIZE=(128*1024) : SRAM Bank0 size CONFIG_DRAM_START=0x10000000 : SRAM Bank0 base address - CONFIG_SPIFI_OFFSET=(128*1024) : SPIFI file system offset + CONFIG_SPIFI_OFFSET=(512*1024) : SPIFI file system offset CONFIG_MM_REGIONS should also be increased if you want to other SRAM banks to the memory pool. diff --git a/nuttx/configs/olimex-stm32-p107/include/board.h b/nuttx/configs/olimex-stm32-p107/include/board.h new file mode 100644 index 0000000000..71b7f0a593 --- /dev/null +++ b/nuttx/configs/olimex-stm32-p107/include/board.h @@ -0,0 +1,141 @@ +/************************************************************************************ + * configs/olimex-stm32-p107/include/board.h + * + * Copyright (C) 2009, 2012 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 + +#ifndef __ASSEMBLY__ +# include +#endif +#include "stm32_rcc.h" +#include "stm32_sdio.h" +#include "stm32_internal.h" + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ + +#define BOARD_CFGR_MCO_SOURCE RCC_CFGR_PLL3CLK + +/* Clocking *************************************************************************/ + +/* On-board crystal frequency is 25MHz (HSE) */ + +#define STM32_BOARD_XTAL 25000000ul +#define STM32_PLL_FREQUENCY (72000000) +#define STM32_SYSCLK_FREQUENCY STM32_PLL_FREQUENCY + +#define STM32_HCLK_FREQUENCY STM32_PLL_FREQUENCY +#define STM32_BOARD_HCLK STM32_HCLK_FREQUENCY /* same as above, to satisfy compiler */ + +/* APB2 clock (PCLK2) is HCLK (72MHz) */ + +#define STM32_RCC_CFGR_PPRE2 RCC_CFGR_PPRE2_HCLK +#define STM32_PCLK2_FREQUENCY STM32_HCLK_FREQUENCY +#define STM32_APB2_CLKIN (STM32_PCLK2_FREQUENCY) /* Timers 2-7, 12-14 */ + +/* APB2 timers 1 and 8 will receive PCLK2. */ + +#define STM32_APB2_TIM1_CLKIN (STM32_PCLK2_FREQUENCY) +#define STM32_APB2_TIM8_CLKIN (STM32_PCLK2_FREQUENCY) + +/* APB1 clock (PCLK1) is HCLK/2 (36MHz) */ + +#define STM32_RCC_CFGR_PPRE1 RCC_CFGR_PPRE1_HCLKd2 +#define STM32_PCLK1_FREQUENCY (STM32_HCLK_FREQUENCY/2) + +/* APB1 timers 2-4 will be twice PCLK1 (I presume the remaining will receive PCLK1) */ + +#define STM32_APB1_TIM2_CLKIN (2*STM32_PCLK1_FREQUENCY) +#define STM32_APB1_TIM3_CLKIN (2*STM32_PCLK1_FREQUENCY) +#define STM32_APB1_TIM4_CLKIN (2*STM32_PCLK1_FREQUENCY) +#define STM32_APB1_TIM5_CLKIN (STM32_PCLK1_FREQUENCY) +#define STM32_APB1_TIM6_CLKIN (STM32_PCLK1_FREQUENCY) +#define STM32_APB1_TIM7_CLKIN (STM32_PCLK1_FREQUENCY) + +/************************************************************************************ + * Public Function Prototypes + ************************************************************************************/ +/************************************************************************************ + * Name: stm32_boardinitialize + * + * Description: + * All STM32 architectures must provide the following entry point. This entry point + * is called early in the intitialization -- after all memory has been configured + * and mapped but before any devices have been initialized. + * + ************************************************************************************/ + +void stm32_boardinitialize(void); + +/************************************************************************************ + * Name: stm32_board_clockconfig + * + * Description: + * Any STM32 board may replace the "standard" board clock configuration logic with + * its own, custom clock cofiguration logic. + * + ************************************************************************************/ + +#ifdef CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG +void stm32_board_clockconfig(void); +#endif + +/************************************************************************************ + * Name: stm32_selectrmii + * + * Description: + * Selects the RMII inteface. + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ************************************************************************************/ + +static inline void stm32_selectrmii(void) +{ + uint32_t regval; + + regval = getreg32(STM32_AFIO_MAPR); + regval |= AFIO_MAPR_MII_RMII_SEL; + putreg32(regval, STM32_AFIO_MAPR); +} + diff --git a/nuttx/configs/olimex-stm32-p107/nsh/Make.defs b/nuttx/configs/olimex-stm32-p107/nsh/Make.defs new file mode 100644 index 0000000000..3f1f87431d --- /dev/null +++ b/nuttx/configs/olimex-stm32-p107/nsh/Make.defs @@ -0,0 +1,174 @@ +############################################################################ +# configs/olimex-stm32-p107/nsh/Make.defs +# +# Copyright (C) 2009, 2012 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. +# +############################################################################ + +include ${TOPDIR}/.config + +# Setup for the selected toolchain + +ifeq ($(CONFIG_STM32_DFU),y) + LDSCRIPT = ld.script.dfu +else + LDSCRIPT = ld.script +endif + +ifeq ($(CONFIG_STM32_CODESOURCERYW),y) + # CodeSourcery under Windows + CROSSDEV = arm-none-eabi- + WINTOOL = y + ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft +endif +ifeq ($(CONFIG_STM32_CODESOURCERYL),y) + # CodeSourcery under Linux + CROSSDEV = arm-none-eabi- + ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft + MAXOPTIMIZATION = -O2 +endif +ifeq ($(CONFIG_STM32_DEVKITARM),y) + # devkitARM under Windows + CROSSDEV = arm-eabi- + WINTOOL = y + ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft +endif +ifeq ($(CONFIG_STM32_RAISONANCE),y) + # Raisonance RIDE7 under Windows + CROSSDEV = arm-none-eabi- + WINTOOL = y + ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft +endif +ifeq ($(CONFIG_STM32_BUILDROOT),y) + # NuttX buildroot under Linux or Cygwin + CROSSDEV = arm-elf- + ARCHCPUFLAGS = -mtune=cortex-m3 -march=armv7-m -mfloat-abi=soft + MAXOPTIMIZATION = -Os +endif + +ifeq ($(WINTOOL),y) + # Windows-native toolchains + DIRLINK = $(TOPDIR)/tools/winlink.sh + DIRUNLINK = $(TOPDIR)/tools/unlink.sh + MKDEP = $(TOPDIR)/tools/mknulldeps.sh + ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" + ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}" + ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}" + MAXOPTIMIZATION = -O2 +else + # Linux/Cygwin-native toolchain + MKDEP = $(TOPDIR)/tools/mkdeps.sh + ARCHINCLUDES = -I. -isystem $(TOPDIR)/include + ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx + ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) +endif + +CC = $(CROSSDEV)gcc +CXX = $(CROSSDEV)g++ +CPP = $(CROSSDEV)gcc -E +LD = $(CROSSDEV)ld +AR = $(CROSSDEV)ar rcs +NM = $(CROSSDEV)nm +OBJCOPY = $(CROSSDEV)objcopy +OBJDUMP = $(CROSSDEV)objdump + +ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'} +ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1} + +ifeq ("${CONFIG_DEBUG_SYMBOLS}","y") + ARCHOPTIMIZATION = -g +else + ARCHOPTIMIZATION = $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer +endif + +ARCHCFLAGS = -fno-builtin +ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fno-rtti +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow +ARCHWARNINGSXX = -Wall -Wshadow +ARCHDEFINES = +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) +AFLAGS = $(CFLAGS) -D__ASSEMBLY__ + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 + +OBJEXT = .o +LIBEXT = .a +EXEEXT = + +ifneq ($(CROSSDEV),arm-elf-) + LDFLAGS += -nostartfiles -nodefaultlibs +endif +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g +endif + +define PREPROCESS + @echo "CPP: $1->$2" + @$(CPP) $(CPPFLAGS) $1 -o $2 +endef + +define COMPILE + @echo "CC: $1" + @$(CC) -c $(CFLAGS) $1 -o $2 +endef + +define COMPILEXX + @echo "CXX: $1" + @$(CXX) -c $(CXXFLAGS) $1 -o $2 +endef + +define ASSEMBLE + @echo "AS: $1" + @$(CC) -c $(AFLAGS) $1 -o $2 +endef + +define ARCHIVE + echo "AR: $2"; \ + $(AR) $1 $2 || { echo "$(AR) $1 $2 FAILED!" ; exit 1 ; } +endef + +define CLEAN + @rm -f *.o *.a +endef + +HOSTCC = gcc +HOSTINCLUDES = -I. +HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe +HOSTLDFLAGS = + diff --git a/nuttx/configs/olimex-stm32-p107/nsh/appconfig b/nuttx/configs/olimex-stm32-p107/nsh/appconfig new file mode 100644 index 0000000000..56daadc529 --- /dev/null +++ b/nuttx/configs/olimex-stm32-p107/nsh/appconfig @@ -0,0 +1,54 @@ +############################################################################ +# configs/olimex-stm32-p107/nsh/appconfig +# +# Copyright (C) 2011 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. +# +############################################################################ + +# Path to example in apps/examples containing the user_start entry point + +CONFIGURED_APPS += system/readline +CONFIGURED_APPS += nshlib + +CONFIGURED_APPS += examples/nsh + +ifeq ($(CONFIG_NET),y) +CONFIGURED_APPS += netutils/uiplib +# CONFIGURED_APPS += netutils/resolv +# CONFIGURED_APPS += netutils/webclient +# CONFIGURED_APPS += netutils/tftpc +# CONFIGURED_APPS += netutils/ftpc +# CONFIGURED_APPS += netutils/ftpd +ifeq ($(CONFIG_NSH_TELNET),y) +CONFIGURED_APPS += netutils/telnetd +endif +endif + diff --git a/nuttx/configs/olimex-stm32-p107/nsh/defconfig b/nuttx/configs/olimex-stm32-p107/nsh/defconfig new file mode 100644 index 0000000000..e89cda44df --- /dev/null +++ b/nuttx/configs/olimex-stm32-p107/nsh/defconfig @@ -0,0 +1,1059 @@ +############################################################################ +# configs/olimex-stm32-p107/nsh/defconfig +# +# Copyright (C) 2012 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. +# +############################################################################ +# +# architecture selection +# +# CONFIG_ARCH - identifies the arch subdirectory and, hence, the +# processor architecture. +# CONFIG_ARCH_family - for use in C code. This identifies the +# particular chip family that the architecture is implemented +# in. +# CONFIG_ARCH_architecture - for use in C code. This identifies the +# specific architecture within the chip familyl. +# CONFIG_ARCH_CHIP - Identifies the arch/*/chip subdirectory +# CONFIG_ARCH_CHIP_name - For use in C code +# CONFIG_ARCH_BOARD - identifies the configs subdirectory and, hence, +# the board that supports the particular chip or SoC. +# CONFIG_ARCH_BOARD_name - for use in C code +# CONFIG_ENDIAN_BIG - define if big endian (default is little endian) +# CONFIG_BOARD_LOOPSPERMSEC - for delay loops +# CONFIG_DRAM_SIZE - Describes the installed DRAM. +# CONFIG_DRAM_START - The start address of DRAM (physical) +# CONFIG_DRAM_END - Last address+1 of installed RAM +# CONFIG_ARCH_IRQPRIO - The STM3220xxx supports interrupt prioritization +# CONFIG_ARCH_INTERRUPTSTACK - This architecture supports an interrupt +# stack. If defined, this symbol is the size of the interrupt +# stack in bytes. If not defined, the user task stacks will be +# used during interrupt handling. +# CONFIG_ARCH_STACKDUMP - Do stack dumps after assertions +# CONFIG_ARCH_BOOTLOADER - Set if you are using a bootloader. +# CONFIG_ARCH_LEDS - Use LEDs to show state. Unique to board architecture. +# CONFIG_ARCH_BUTTONS - Enable support for buttons. Unique to board architecture. +# CONFIG_ARCH_CALIBRATION - Enables some build in instrumentation that +# cause a 100 second delay during boot-up. This 100 second delay +# serves no purpose other than it allows you to calibrate +# CONFIG_BOARD_LOOPSPERMSEC. You simply use a stop watch to measure +# the 100 second delay then adjust CONFIG_BOARD_LOOPSPERMSEC until +# the delay actually is 100 seconds. +# CONFIG_ARCH_DMA - Support DMA initialization +# +CONFIG_ARCH=arm +CONFIG_ARCH_ARM=y +CONFIG_ARCH_CORTEXM3=y +CONFIG_ARCH_CHIP=stm32 +CONFIG_ARCH_CHIP_STM32F107VC=y +CONFIG_ARCH_BOARD=olimex-stm32-p107 +CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG=y +CONFIG_BOARD_LOOPSPERMSEC=5483 +CONFIG_DRAM_SIZE=0x00010000 +CONFIG_DRAM_START=0x20000000 +CONFIG_DRAM_END=(CONFIG_DRAM_START+CONFIG_DRAM_SIZE) +CONFIG_ARCH_IRQPRIO=y +CONFIG_ARCH_INTERRUPTSTACK=n +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_BOOTLOADER=n +CONFIG_ARCH_LEDS=n +CONFIG_ARCH_BUTTONS=n +CONFIG_ARCH_CALIBRATION=n +CONFIG_ARCH_DMA=n + +# +# Identify toolchain and linker options +# +CONFIG_STM32_CODESOURCERYW=n +CONFIG_STM32_CODESOURCERYL=y +CONFIG_STM32_DEVKITARM=n +CONFIG_STM32_RAISONANCE=n +CONFIG_STM32_BUILDROOT=n + +# +# Alternate pin mappings +# +CONFIG_STM32_TIM1_FULL_REMAP=n +CONFIG_STM32_TIM1_PARTIAL_REMAP=n +CONFIG_STM32_TIM2_FULL_REMAP=n +CONFIG_STM32_TIM2_PARTIAL_REMAP_1=n +CONFIG_STM32_TIM2_PARTIAL_REMAP_2=n +CONFIG_STM32_TIM3_FULL_REMAP=n +CONFIG_STM32_TIM3_PARTIAL_REMAP=n +CONFIG_STM32_TIM4_REMAP=n +CONFIG_STM32_USART1_REMAP=n +CONFIG_STM32_USART2_REMAP=y +CONFIG_STM32_USART3_FULL_REMAP=n +CONFIG_STM32_USART3_PARTIAL_REMAP=n +CONFIG_STM32_SPI1_REMAP=n +CONFIG_STM32_SPI3_REMAP=n +CONFIG_STM32_I2C1_REMAP=n +CONFIG_STM32_CAN1_REMAP1=y +CONFIG_STM32_CAN1_REMAP2=n + + +# +# JTAG Enable settings (by default JTAG-DP and SW-DP are disabled): +# +# CONFIG_STM32_DFU - Use the DFU bootloader, not JTAG +# +# JTAG Enable options: +# +# CONFIG_STM32_JTAG_FULL_ENABLE - Enables full SWJ (JTAG-DP + SW-DP) +# CONFIG_STM32_JTAG_NOJNTRST_ENABLE - Enables full SWJ (JTAG-DP + SW-DP) +# but without JNTRST. +# CONFIG_STM32_JTAG_SW_ENABLE - Set JTAG-DP disabled and SW-DP enabled +# +CONFIG_STM32_DFU=n +CONFIG_STM32_JTAG_FULL_ENABLE=y +CONFIG_STM32_JTAG_NOJNTRST_ENABLE=n +CONFIG_STM32_JTAG_SW_ENABLE=n + +# +# Individual subsystems can be enabled: +# AHB: +CONFIG_STM32_DMA1=n +CONFIG_STM32_DMA2=n +CONFIG_STM32_CRC=n +CONFIG_STM32_ETHMAC=y +CONFIG_STM32_SDIO=n +# APB1: +CONFIG_STM32_TIM2=n +CONFIG_STM32_TIM3=n +CONFIG_STM32_TIM4=n +CONFIG_STM32_TIM5=n +CONFIG_STM32_TIM6=n +CONFIG_STM32_TIM7=n +CONFIG_STM32_WWDG=n +CONFIG_STM32_IWDG=n +CONFIG_STM32_SPI2=n +CONFIG_STM32_SPI4=n +CONFIG_STM32_USART2=y +CONFIG_STM32_USART3=n +CONFIG_STM32_UART4=n +CONFIG_STM32_UART5=n +CONFIG_STM32_I2C1=n +CONFIG_STM32_I2C2=n +CONFIG_STM32_USB=n +CONFIG_STM32_CAN1=n +CONFIG_STM32_BKP=n +CONFIG_STM32_PWR=n +CONFIG_STM32_DAC=n +# APB2: +CONFIG_STM32_ADC1=n +CONFIG_STM32_ADC2=n +CONFIG_STM32_TIM1=n +CONFIG_STM32_SPI1=n +CONFIG_STM32_TIM8=n +CONFIG_STM32_USART1=n +CONFIG_STM32_ADC3=n + +# +# Timer and I2C devices may need to the following to force power to be applied: +# +#CONFIG_STM32_FORCEPOWER=y + +# +# STM32F103Z specific serial device driver settings +# +# CONFIG_USARTn_SERIAL_CONSOLE - selects the USARTn for the +# console and ttys0 (default is the USART1). +# CONFIG_USARTn_RXBUFSIZE - Characters are buffered as received. +# This specific the size of the receive buffer +# CONFIG_USARTn_TXBUFSIZE - Characters are buffered before +# being sent. This specific the size of the transmit buffer +# CONFIG_USARTn_BAUD - The configure BAUD of the UART. Must be +# CONFIG_USARTn_BITS - The number of bits. Must be either 7 or 8. +# CONFIG_USARTn_PARTIY - 0=no parity, 1=odd parity, 2=even parity +# CONFIG_USARTn_2STOP - Two stop bits +# +CONFIG_USART1_SERIAL_CONSOLE=n +CONFIG_USART2_SERIAL_CONSOLE=y +CONFIG_USART3_SERIAL_CONSOLE=n +CONFIG_USART4_SERIAL_CONSOLE=n +CONFIG_USART5_SERIAL_CONSOLE=n + +CONFIG_USART1_TXBUFSIZE=256 +CONFIG_USART2_TXBUFSIZE=256 +CONFIG_USART3_TXBUFSIZE=256 +CONFIG_USART4_TXBUFSIZE=256 +CONFIG_USART5_TXBUFSIZE=256 + +CONFIG_USART1_RXBUFSIZE=256 +CONFIG_USART2_RXBUFSIZE=256 +CONFIG_USART3_RXBUFSIZE=256 +CONFIG_USART4_RXBUFSIZE=256 +CONFIG_USART5_RXBUFSIZE=256 + +CONFIG_USART1_BAUD=115200 +CONFIG_USART2_BAUD=115200 +CONFIG_USART3_BAUD=115200 +CONFIG_USART4_BAUD=115200 +CONFIG_USART5_BAUD=115200 + +CONFIG_USART1_BITS=8 +CONFIG_USART2_BITS=8 +CONFIG_USART3_BITS=8 +CONFIG_USART4_BITS=8 +CONFIG_USART5_BITS=8 + +CONFIG_USART1_PARITY=0 +CONFIG_USART2_PARITY=0 +CONFIG_USART3_PARITY=0 +CONFIG_USART4_PARITY=0 +CONFIG_USART5_PARITY=0 + +CONFIG_USART1_2STOP=0 +CONFIG_USART2_2STOP=0 +CONFIG_USART3_2STOP=0 +CONFIG_USART4_2STOP=0 +CONFIG_USART5_2STOP=0 + +# +# STM32F103Z specific SSI device driver settings +# +# CONFIG_SSIn_DISABLE - select to disable all support for +# the SSI +# CONFIG_SSI_POLLWAIT - Select to disable interrupt driven SSI support +# Poll-waiting is recommended if the interrupt rate would be to +# high in the interrupt driven case. +# CONFIG_SSI_TXLIMIT - Write this many words to the Tx FIFO before +# emptying the Rx FIFO. If the SPI frequency is high and this +# value is large, then larger values of this setting may cause +# Rx FIFO overrun errors. Default: half of the Tx FIFO size (4). +# +CONFIG_SSI0_DISABLE=n +CONFIG_SSI1_DISABLE=y +CONFIG_SSI_POLLWAIT=y +#CONFIG_SSI_TXLIMIT=4 + +# +# STM3210E-EVAL specific LCD settings +# +CONFIG_STM32_AM240320_DISABLE=n +CONFIG_STM32_SPFD5408B_DISABLE=n +CONFIG_STM32_R61580_DISABLE=y + +# +# General build options +# +# CONFIG_RRLOAD_BINARY - make the rrload binary format used with +# BSPs from www.ridgerun.com using the tools/mkimage.sh script +# CONFIG_INTELHEX_BINARY - make the Intel HEX binary format +# used with many different loaders using the GNU objcopy program +# Should not be selected if you are not using the GNU toolchain. +# CONFIG_MOTOROLA_SREC - make the Motorola S-Record binary format +# used with many different loaders using the GNU objcopy program +# Should not be selected if you are not using the GNU toolchain. +# CONFIG_RAW_BINARY - make a raw binary format file used with many +# different loaders using the GNU objcopy program. This option +# should not be selected if you are not using the GNU toolchain. +# CONFIG_HAVE_LIBM - toolchain supports libm.a +# +CONFIG_RRLOAD_BINARY=n +CONFIG_INTELHEX_BINARY=y +CONFIG_MOTOROLA_SREC=n +CONFIG_RAW_BINARY=n +CONFIG_HAVE_LIBM=n + +# +# General OS setup +# +# CONFIG_APPS_DIR - Identifies the relative path to the directory +# that builds the application to link with NuttX. Default: ../apps +# CONFIG_DEBUG - enables built-in debug options +# CONFIG_DEBUG_VERBOSE - enables verbose debug output +# CONFIG_DEBUG_SYMBOLS - build without optimization and with +# debug symbols (needed for use with a debugger). +# CONFIG_HAVE_CXX - Enable support for C++ +# CONFIG_HAVE_CXXINITIALIZE - The platform-specific logic includes support +# for initialization of static C++ instances for this architecture +# and for the selected toolchain (via up_cxxinitialize()). +# CONFIG_MM_REGIONS - If the architecture includes multiple +# regions of memory to allocate from, this specifies the +# number of memory regions that the memory manager must +# handle and enables the API mm_addregion(start, end); +# CONFIG_ARCH_LOWPUTC - architecture supports low-level, boot +# time console output +# CONFIG_MSEC_PER_TICK - The default system timer is 100Hz +# or MSEC_PER_TICK=10. This setting may be defined to +# inform NuttX that the processor hardware is providing +# system timer interrupts at some interrupt interval other +# than 10 msec. +# CONFIG_RR_INTERVAL - The round robin timeslice will be set +# this number of milliseconds; Round robin scheduling can +# be disabled by setting this value to zero. +# CONFIG_SCHED_INSTRUMENTATION - enables instrumentation in +# scheduler to monitor system performance +# CONFIG_TASK_NAME_SIZE - Spcifies that maximum size of a +# task name to save in the TCB. Useful if scheduler +# instrumentation is selected. Set to zero to disable. +# CONFIG_START_YEAR, CONFIG_START_MONTH, CONFIG_START_DAY - +# Used to initialize the internal time logic. +# CONFIG_GREGORIAN_TIME - Enables Gregorian time conversions. +# You would only need this if you are concerned about accurate +# time conversions in the past or in the distant future. +# CONFIG_JULIAN_TIME - Enables Julian time conversions. You +# would only need this if you are concerned about accurate +# time conversion in the distand past. You must also define +# CONFIG_GREGORIAN_TIME in order to use Julian time. +# CONFIG_DEV_CONSOLE - Set if architecture-specific logic +# provides /dev/console. Enables stdout, stderr, stdin. +# CONFIG_DEV_LOWCONSOLE - Use the simple, low-level serial console +# driver (minimul support) +# CONFIG_MUTEX_TYPES: Set to enable support for recursive and +# errorcheck mutexes. Enables pthread_mutexattr_settype(). +# CONFIG_PRIORITY_INHERITANCE : Set to enable support for priority +# inheritance on mutexes and semaphores. +# CONFIG_SEM_PREALLOCHOLDERS: This setting is only used if priority +# inheritance is enabled. It defines the maximum number of +# different threads (minus one) that can take counts on a +# semaphore with priority inheritance support. This may be +# set to zero if priority inheritance is disabled OR if you +# are only using semaphores as mutexes (only one holder) OR +# if no more than two threads participate using a counting +# semaphore. +# CONFIG_SEM_NNESTPRIO. If priority inheritance is enabled, +# then this setting is the maximum number of higher priority +# threads (minus 1) than can be waiting for another thread +# to release a count on a semaphore. This value may be set +# to zero if no more than one thread is expected to wait for +# a semaphore. +# CONFIG_FDCLONE_DISABLE. Disable cloning of all file descriptors +# by task_create() when a new task is started. If set, all +# files/drivers will appear to be closed in the new task. +# CONFIG_FDCLONE_STDIO. Disable cloning of all but the first +# three file descriptors (stdin, stdout, stderr) by task_create() +# when a new task is started. If set, all files/drivers will +# appear to be closed in the new task except for stdin, stdout, +# and stderr. +# CONFIG_SDCLONE_DISABLE. Disable cloning of all socket +# desciptors by task_create() when a new task is started. If +# set, all sockets will appear to be closed in the new task. +# CONFIG_NXFLAT. Enable support for the NXFLAT binary format. +# This format will support execution of NuttX binaries located +# in a ROMFS filesystem (see examples/nxflat). +# CONFIG_SCHED_WORKQUEUE. Create a dedicated "worker" thread to +# handle delayed processing from interrupt handlers. This feature +# is required for some drivers but, if there are not complaints, +# can be safely disabled. The worker thread also performs +# garbage collection -- completing any delayed memory deallocations +# from interrupt handlers. If the worker thread is disabled, +# then that clean will be performed by the IDLE thread instead +# (which runs at the lowest of priority and may not be appropriate +# if memory reclamation is of high priority). If CONFIG_SCHED_WORKQUEUE +# is enabled, then the following options can also be used: +# CONFIG_SCHED_WORKPRIORITY - The execution priority of the worker +# thread. Default: 50 +# CONFIG_SCHED_WORKPERIOD - How often the worker thread checks for +# work in units of microseconds. Default: 50*1000 (50 MS). +# CONFIG_SCHED_WORKSTACKSIZE - The stack size allocated for the worker +# thread. Default: CONFIG_IDLETHREAD_STACKSIZE. +# CONFIG_SIG_SIGWORK - The signal number that will be used to wake-up +# the worker thread. Default: 4 +# +#CONFIG_APPS_DIR= +CONFIG_DEBUG=y +CONFIG_DEBUG_VERBOSE=y +CONFIG_DEBUG_SYMBOLS=n +CONFIG_DEBUG_CAN=n +CONFIG_DEBUG_NET=y +CONFIG_HAVE_CXX=n +CONFIG_HAVE_CXXINITIALIZE=n +CONFIG_MM_REGIONS=1 +CONFIG_ARCH_LOWPUTC=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_INSTRUMENTATION=n +CONFIG_TASK_NAME_SIZE=0 +CONFIG_START_YEAR=2009 +CONFIG_START_MONTH=9 +CONFIG_START_DAY=21 +CONFIG_GREGORIAN_TIME=n +CONFIG_JULIAN_TIME=n +CONFIG_DEV_CONSOLE=y +ONFIG_DEV_LOWCONSOLE=n +CONFIG_MUTEX_TYPES=n +CONFIG_PRIORITY_INHERITANCE=n +CONFIG_SEM_PREALLOCHOLDERS=0 +CONFIG_SEM_NNESTPRIO=0 +CONFIG_FDCLONE_DISABLE=n +CONFIG_FDCLONE_STDIO=n +CONFIG_SDCLONE_DISABLE=y +CONFIG_NXFLAT=n +CONFIG_SCHED_WORKQUEUE=y +CONFIG_SCHED_WORKPRIORITY=50 +CONFIG_SCHED_WORKPERIOD=(50*1000) +CONFIG_SCHED_WORKSTACKSIZE=1024 +CONFIG_SIG_SIGWORK=4 + +# +# The following can be used to disable categories of +# APIs supported by the OS. If the compiler supports +# weak functions, then it should not be necessary to +# disable functions unless you want to restrict usage +# of those APIs. +# +# There are certain dependency relationships in these +# features. +# +# o mq_notify logic depends on signals to awaken tasks +# waiting for queues to become full or empty. +# o pthread_condtimedwait() depends on signals to wake +# up waiting tasks. +# +CONFIG_DISABLE_CLOCK=n +CONFIG_DISABLE_POSIX_TIMERS=n +CONFIG_DISABLE_PTHREAD=n +CONFIG_DISABLE_SIGNALS=n +CONFIG_DISABLE_MQUEUE=n +CONFIG_DISABLE_MOUNTPOINT=n +CONFIG_DISABLE_ENVIRON=n +CONFIG_DISABLE_POLL=y + +# +# Misc libc settings +# +# CONFIG_NOPRINTF_FIELDWIDTH - sprintf-related logic is a +# little smaller if we do not support fieldwidthes +# +CONFIG_NOPRINTF_FIELDWIDTH=n + +# +# Allow for architecture optimized implementations +# +# The architecture can provide optimized versions of the +# following to improve system performance +# +CONFIG_ARCH_MEMCPY=n +CONFIG_ARCH_MEMCMP=n +CONFIG_ARCH_MEMMOVE=n +CONFIG_ARCH_MEMSET=n +CONFIG_ARCH_STRCMP=n +CONFIG_ARCH_STRCPY=n +CONFIG_ARCH_STRNCPY=n +CONFIG_ARCH_STRLEN=n +CONFIG_ARCH_STRNLEN=n +CONFIG_ARCH_BZERO=n + +# +# Sizes of configurable things (0 disables) +# +# CONFIG_MAX_TASKS - The maximum number of simultaneously +# active tasks. This value must be a power of two. +# CONFIG_MAX_TASK_ARGS - This controls the maximum number of +# of parameters that a task may receive (i.e., maxmum value +# of 'argc') +# CONFIG_NPTHREAD_KEYS - The number of items of thread- +# specific data that can be retained +# CONFIG_NFILE_DESCRIPTORS - The maximum number of file +# descriptors (one for each open) +# CONFIG_NFILE_STREAMS - The maximum number of streams that +# can be fopen'ed +# CONFIG_NAME_MAX - The maximum size of a file name. +# CONFIG_STDIO_BUFFER_SIZE - Size of the buffer to allocate +# on fopen. (Only if CONFIG_NFILE_STREAMS > 0) +# CONFIG_NUNGET_CHARS - Number of characters that can be +# buffered by ungetc() (Only if CONFIG_NFILE_STREAMS > 0) +# CONFIG_PREALLOC_MQ_MSGS - The number of pre-allocated message +# structures. The system manages a pool of preallocated +# message structures to minimize dynamic allocations +# CONFIG_MQ_MAXMSGSIZE - Message structures are allocated with +# a fixed payload size given by this settin (does not include +# other message structure overhead. +# CONFIG_MAX_WDOGPARMS - Maximum number of parameters that +# can be passed to a watchdog handler +# CONFIG_PREALLOC_WDOGS - The number of pre-allocated watchdog +# structures. The system manages a pool of preallocated +# watchdog structures to minimize dynamic allocations +# CONFIG_PREALLOC_TIMERS - The number of pre-allocated POSIX +# timer structures. The system manages a pool of preallocated +# timer structures to minimize dynamic allocations. Set to +# zero for all dynamic allocations. +# +CONFIG_MAX_TASKS=16 +CONFIG_MAX_TASK_ARGS=4 +CONFIG_NPTHREAD_KEYS=4 +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NAME_MAX=32 +CONFIG_STDIO_BUFFER_SIZE=256 +CONFIG_NUNGET_CHARS=2 +CONFIG_PREALLOC_MQ_MSGS=4 +CONFIG_MQ_MAXMSGSIZE=32 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_PREALLOC_WDOGS=4 +CONFIG_PREALLOC_TIMERS=4 + +# +# Filesystem configuration +# +# CONFIG_FS_FAT - Enable FAT filesystem support +# CONFIG_FAT_SECTORSIZE - Max supported sector size +# CONFIG_FAT_LCNAMES - Enable use of the NT-style upper/lower case 8.3 +# file name support. +# CONFIG_FAT_LFN - Enable FAT long file names. NOTE: Microsoft claims +# patents on FAT long file name technology. Please read the +# disclaimer in the top-level COPYING file and only enable this +# feature if you understand these issues. +# CONFIG_FAT_MAXFNAME - If CONFIG_FAT_LFN is defined, then the +# default, maximum long file name is 255 bytes. This can eat up +# a lot of memory (especially stack space). If you are willing +# to live with some non-standard, short long file names, then +# define this value. A good choice would be the same value as +# selected for CONFIG_NAME_MAX which will limit the visibility +# of longer file names anyway. +# CONFIG_FS_NXFFS: Enable NuttX FLASH file system (NXFF) support. +# CONFIG_NXFFS_ERASEDSTATE: The erased state of FLASH. +# This must have one of the values of 0xff or 0x00. +# Default: 0xff. +# CONFIG_NXFFS_PACKTHRESHOLD: When packing flash file data, +# don't both with file chunks smaller than this number of data bytes. +# CONFIG_NXFFS_MAXNAMLEN: The maximum size of an NXFFS file name. +# Default: 255. +# CONFIG_NXFFS_PACKTHRESHOLD: When packing flash file data, +# don't both with file chunks smaller than this number of data bytes. +# Default: 32. +# CONFIG_NXFFS_TAILTHRESHOLD: clean-up can either mean +# packing files together toward the end of the file or, if file are +# deleted at the end of the file, clean up can simply mean erasing +# the end of FLASH memory so that it can be re-used again. However, +# doing this can also harm the life of the FLASH part because it can +# mean that the tail end of the FLASH is re-used too often. This +# threshold determines if/when it is worth erased the tail end of FLASH +# and making it available for re-use (and possible over-wear). +# Default: 8192. +# CONFIG_FS_ROMFS - Enable ROMFS filesystem support +# CONFIG_FS_RAMMAP - For file systems that do not support XIP, this +# option will enable a limited form of memory mapping that is +# implemented by copying whole files into memory. +# +CONFIG_FS_FAT=n +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=n +CONFIG_FAT_MAXFNAME=32 +CONFIG_FS_NXFFS=n +CONFIG_FS_ROMFS=n + +# +# SPI-based MMC/SD driver +# +# CONFIG_MMCSD_NSLOTS +# Number of MMC/SD slots supported by the driver +# CONFIG_MMCSD_READONLY +# Provide read-only access (default is read/write) +# CONFIG_MMCSD_SPICLOCK - Maximum SPI clock to drive MMC/SD card. +# Default is 20MHz. +# +CONFIG_MMCSD_NSLOTS=1 +CONFIG_MMCSD_READONLY=n +CONFIG_MMCSD_SPICLOCK=12500000 + +# +# Block driver buffering +# +# CONFIG_FS_READAHEAD +# Enable read-ahead buffering +# CONFIG_FS_WRITEBUFFER +# Enable write buffering +# +CONFIG_FS_READAHEAD=n +CONFIG_FS_WRITEBUFFER=n + +# +# STM32 SDIO-based MMC/SD driver +# +# CONFIG_SDIO_DMA - Support DMA data transfers. Requires CONFIG_STM32_SDIO +# and CONFIG_STM32_DMA2. +# CONFIG_SDIO_PRI - Select SDIO interrupt prority. Default: 128 +# CONFIG_SDIO_DMAPRIO - Select SDIO DMA interrupt priority. +# Default: Medium +# CONFIG_SDIO_WIDTH_D1_ONLY - Select 1-bit transfer mode. Default: +# 4-bit transfer mode. +# CONFIG_MMCSD_MMCSUPPORT +# Enable support for MMC cards +# CONFIG_MMCSD_HAVECARDDETECT +# SDIO driver card detection is 100% accurate +# +CONFIG_SDIO_DMA=y +#CONFIG_SDIO_PRI=128 +#CONFIG_SDIO_DMAPRIO +#CONFIG_SDIO_WIDTH_D1_ONLY +CONFIG_MMCSD_MMCSUPPORT=n +CONFIG_MMCSD_HAVECARDDETECT=n + +# +# TCP/IP and UDP support via uIP +# +# CONFIG_NET - Enable or disable all network features +# CONFIG_NET_NOINTS - uIP not called from interrupt level. +# CONFIG_NET_MULTIBUFFER - Use multiple input/output buffers (probably no) +# CONFIG_NET_IPv6 - Build in support for IPv6 +# CONFIG_NSOCKET_DESCRIPTORS - Maximum number of socket descriptors per task/thread. +# CONFIG_NET_SOCKOPTS - Enable or disable support for socket options +# CONFIG_NET_BUFSIZE - uIP buffer size +# CONFIG_NET_TCP - TCP support on or off +# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks) +# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers +# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero) +# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until +# accept() is called. The size of the backlog is selected when listen() is called. +# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks) +# CONFIG_NET_UDP - UDP support on or off +# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off +# CONFIG_NET_UDP_CONNS - The maximum amount of concurrent UDP connections +# CONFIG_NET_ICMP - ICMP ping response support on or off +# CONFIG_NET_ICMP_PING - ICMP ping request support on or off +# CONFIG_NET_PINGADDRCONF - Use "ping" packet for setting IP address +# CONFIG_NET_STATISTICS - uIP statistics on or off +# CONFIG_NET_RECEIVE_WINDOW - The size of the advertised receiver's window +# CONFIG_NET_BROADCAST - Broadcast support +# CONFIG_NET_ARPTAB_SIZE - The size of the ARP table +# CONFIG_NET_ARP_IPIN - Harvest IP/MAC address mappings from the ARP table +# from incoming IP packets. +# CONFIG_NET_MULTICAST - Outgoing multi-cast address support +# CONFIG_NET_FWCACHE_SIZE - number of packets to remember when +# looking for duplicates +# +CONFIG_NET=y +CONFIG_NET_NOINTS=n +CONFIG_NET_MULTIBUFFER=y +CONFIG_NET_IPv6=n +CONFIG_NSOCKET_DESCRIPTORS=10 +CONFIG_NET_SOCKOPTS=y +CONFIG_NET_BUFSIZE=1020 +CONFIG_NET_TCP=y +CONFIG_NET_TCP_CONNS=40 +# CONFIG_NET_TCP_READAHEAD_BUFSIZE +CONFIG_NET_NTCP_READAHEAD_BUFFERS=8 +CONFIG_NET_TCPBACKLOG=n +CONFIG_NET_MAX_LISTENPORTS=40 +CONFIG_NET_UDP=n +CONFIG_NET_UDP_CHECKSUMS=n +# CONFIG_NET_UDP_CONNS=10 +CONFIG_NET_ICMP=y +CONFIG_NET_ICMP_PING=y +# CONFIG_NET_PINGADDRCONF=0 +CONFIG_NET_STATISTICS=n +# CONFIG_NET_RECEIVE_WINDOW= +CONFIG_NET_BROADCAST=n +# CONFIG_NET_ARPTAB_SIZE=8 +CONFIG_NET_ARP_IPIN=n +CONFIG_NET_MULTICAST=n +# CONFIG_NET_FWCACHE_SIZE=2 + +# +# STM32F107vc Ethernet device driver settings +# +# CONFIG_STM32_PHYADDR - The 5-bit address of the PHY on the board +# CONFIG_STM32_MII - Support Ethernet MII interface +# CONFIG_STM32_MII_MCO1 - Use MCO1 to clock the MII interface +# CONFIG_STM32_MII_MCO2 - Use MCO2 to clock the MII interface +# CONFIG_STM32_RMII - Support Ethernet RMII interface +# CONFIG_STM32_AUTONEG - Use PHY autonegotion to determine speed and mode +# CONFIG_STM32_ETHFD - If CONFIG_STM32_AUTONEG is not defined, then this +# may be defined to select full duplex mode. Default: half-duplex +# CONFIG_STM32_ETH100MBPS - If CONFIG_STM32_AUTONEG is not defined, then this +# may be defined to select 100 MBps speed. Default: 10 Mbps +# CONFIG_STM32_PHYSR - This must be provided if CONFIG_STM32_AUTONEG is +# defined. The PHY status register address may diff from PHY to PHY. This +# configuration sets the address of the PHY status register. +# CONFIG_STM32_PHYSR_SPEED - This must be provided if CONFIG_STM32_AUTONEG is +# defined. This provides bit mask indicating 10 or 100MBps speed. +# CONFIG_STM32_PHYSR_100MBPS - This must be provided if CONFIG_STM32_AUTONEG is +# defined. This provides the value of the speed bit(s) indicating 100MBps speed. +# CONFIG_STM32_PHYSR_MODE - This must be provided if CONFIG_STM32_AUTONEG is +# defined. This provide bit mask indicating full or half duplex modes. +# CONFIG_STM32_PHYSR_FULLDUPLEX - This must be provided if CONFIG_STM32_AUTONEG is +# defined. This provides the value of the mode bits indicating full duplex mode. +# CONFIG_STM32_ETH_PTP - Precision Time Protocol (PTP). Not supported +# but some hooks are indicated with this condition. +# CONFIG_STM32_ETHMAC_REGDEBUG - If CONFIG_DEBUG is also enabled, this will +# generate far more debug output than you could ever care to see unless you +# are debugging low-level Ethernet driver features. +# +CONFIG_STM32_PHYADDR=0x01 +CONFIG_STM32_MII=n +CONFIG_STM32_RMII=y +CONFIG_STM32_RMII_MCO=y +CONFIG_STM32_AUTONEG=y +#CONFIG_STM32_ETHFD +#CONFIG_STM32_ETH100MB +CONFIG_STM32_PHYSR=16 +CONFIG_STM32_PHYSR_SPEED=0x0002 +CONFIG_STM32_PHYSR_100MBPS=0x0000 +CONFIG_STM32_PHYSR_MODE=0x0004 +CONFIG_STM32_PHYSR_FULLDUPLEX=0x0004 +CONFIG_STM32_ETH_PTP=n +CONFIG_STM32_ETHMAC_REGDEBUG=n + + + +# +# UIP Network Utilities +# CONFIG_NET_DHCP_LIGHT - Reduces size of DHCP +# CONFIG_NET_RESOLV_ENTRIES - Number of resolver entries +# +CONFIG_NET_DHCP_LIGHT=n +CONFIG_NET_RESOLV_ENTRIES=4 + +# +# USB Device Configuration +# +# CONFIG_USBDEV +# Enables USB device support +# CONFIG_USBDEV_ISOCHRONOUS +# Build in extra support for isochronous endpoints +# CONFIG_USBDEV_DUALSPEED +# Hardware handles high and full speed operation (USB 2.0) +# CONFIG_USBDEV_SELFPOWERED +# Will cause USB features to indicate that the device is +# self-powered +# CONFIG_USBDEV_MAXPOWER +# Maximum power consumption in mA +# CONFIG_USBDEV_TRACE +# Enables USB tracing for debug +# CONFIG_USBDEV_TRACE_NRECORDS +# Number of trace entries to remember +# +CONFIG_USBDEV=n +CONFIG_USBDEV_ISOCHRONOUS=n +CONFIG_USBDEV_DUALSPEED=n +CONFIG_USBDEV_SELFPOWERED=y +CONFIG_USBDEV_REMOTEWAKEUP=n +CONFIG_USBDEV_MAXPOWER=100 +CONFIG_USBDEV_TRACE=n +CONFIG_USBDEV_TRACE_NRECORDS=128 + +# +# USB Serial Device Configuration +# +# CONFIG_PL2303 +# Enable compilation of the USB serial driver +# CONFIG_PL2303_EPINTIN +# The logical 7-bit address of a hardware endpoint that supports +# interrupt IN operation +# CONFIG_PL2303_EPBULKOUT +# The logical 7-bit address of a hardware endpoint that supports +# bulk OUT operation +# CONFIG_PL2303_EPBULKIN +# The logical 7-bit address of a hardware endpoint that supports +# bulk IN operation +# # CONFIG_PL2303_NWRREQS and CONFIG_PL2303_NRDREQS +# The number of write/read requests that can be in flight +# CONFIG_PL2303_VENDORID and CONFIG_PL2303_VENDORSTR +# The vendor ID code/string +# CONFIG_PL2303_PRODUCTID and CONFIG_PL2303_PRODUCTSTR +# The product ID code/string +# CONFIG_PL2303_RXBUFSIZE and CONFIG_PL2303_TXBUFSIZE +# Size of the serial receive/transmit buffers +# +CONFIG_PL2303=n +CONFIG_PL2303_EPINTIN=1 +CONFIG_PL2303_EPBULKOUT=2 +CONFIG_PL2303_EPBULKIN=3 +CONFIG_PL2303_NWRREQS=4 +CONFIG_PL2303_NRDREQS=4 +CONFIG_PL2303_VENDORID=0x067b +CONFIG_PL2303_PRODUCTID=0x2303 +CONFIG_PL2303_VENDORSTR="Nuttx" +CONFIG_PL2303_PRODUCTSTR="USBdev Serial" +CONFIG_PL2303_RXBUFSIZE=512 +CONFIG_PL2303_TXBUFSIZE=512 + +# +# USB Storage Device Configuration +# +# CONFIG_USBMSC +# Enable compilation of the USB storage driver +# CONFIG_USBMSC_EP0MAXPACKET +# Max packet size for endpoint 0 +# CONFIG_USBMSC_EPBULKOUT and CONFIG_USBMSC_EPBULKIN +# The logical 7-bit address of a hardware endpoints that support +# bulk OUT and IN operations +# CONFIG_USBMSC_NWRREQS and CONFIG_USBMSC_NRDREQS +# The number of write/read requests that can be in flight +# CONFIG_USBMSC_BULKINREQLEN and CONFIG_USBMSC_BULKOUTREQLEN +# The size of the buffer in each write/read request. This +# value needs to be at least as large as the endpoint +# maxpacket and ideally as large as a block device sector. +# CONFIG_USBMSC_VENDORID and CONFIG_USBMSC_VENDORSTR +# The vendor ID code/string +# CONFIG_USBMSC_PRODUCTID and CONFIG_USBMSC_PRODUCTSTR +# The product ID code/string +# CONFIG_USBMSC_REMOVABLE +# Select if the media is removable +# +CONFIG_USBMSC=n +CONFIG_USBMSC_EP0MAXPACKET=64 +CONFIG_USBMSC_EPBULKOUT=2 +CONFIG_USBMSC_EPBULKIN=5 +CONFIG_USBMSC_NRDREQS=2 +CONFIG_USBMSC_NWRREQS=2 +CONFIG_USBMSC_BULKINREQLEN=256 +CONFIG_USBMSC_BULKOUTREQLEN=256 +CONFIG_USBMSC_VENDORID=0x584e +CONFIG_USBMSC_VENDORSTR="NuttX" +CONFIG_USBMSC_PRODUCTID=0x5342 +CONFIG_USBMSC_PRODUCTSTR="USBdev Storage" +CONFIG_USBMSC_VERSIONNO=0x0399 +CONFIG_USBMSC_REMOVABLE=y + +# +# Watchdog timer configuration +# +# CONFIG_WATCHDOG - Enable overall watchdog timer driver support. +# +# The STM32 also needs one of the following enabled: +# +# CONFIG_STM32_WWDG=y, OR +# CONFIG_STM32_IWDG=y (but not both) +# +CONFIG_WATCHDOG=n + +# +# Settings for examples/uip +# +CONFIG_EXAMPLE_UIP_IPADDR=(10<<24|0<<16|0<<8|2) +CONFIG_EXAMPLE_UIP_DRIPADDR=(10<<24|0<<16|0<<8|1) +CONFIG_EXAMPLE_UIP_NETMASK=(255<<24|255<<16|255<<8|0) +CONFIG_EXAMPLE_UIP_DHCPC=n + +# +# Settings for examples/nettest +CONFIG_EXAMPLE_NETTEST_SERVER=n +CONFIG_EXAMPLE_NETTEST_PERFORMANCE=n +CONFIG_EXAMPLE_NETTEST_NOMAC=n +CONFIG_EXAMPLE_NETTEST_IPADDR=(10<<24|0<<16|0<<8|2) +CONFIG_EXAMPLE_NETTEST_DRIPADDR=(10<<24|0<<16|0<<8|1) +CONFIG_EXAMPLE_NETTEST_NETMASK=(255<<24|255<<16|255<<8|0) +CONFIG_EXAMPLE_NETTEST_CLIENTIP=(10<<24|0<<16|0<<8|1) + +# +# Settings for examples/ostest +# +CONFIG_EXAMPLES_OSTEST_LOOPS=1 +CONFIG_EXAMPLES_OSTEST_STACKSIZE=2048 +CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 + +# +# Settings for apps/nshlib +# +# CONFIG_NSH_BUILTIN_APPS - Support external registered, +# "named" applications that can be executed from the NSH +# command line (see apps/README.txt for more information). +# CONFIG_NSH_FILEIOSIZE - Size of a static I/O buffer +# CONFIG_NSH_STRERROR - Use strerror(errno) +# CONFIG_NSH_LINELEN - Maximum length of one command line +# CONFIG_NSH_NESTDEPTH - Max number of nested if-then[-else]-fi +# CONFIG_NSH_DISABLESCRIPT - Disable scripting support +# CONFIG_NSH_DISABLEBG - Disable background commands +# CONFIG_NSH_ROMFSETC - Use startup script in /etc +# CONFIG_NSH_CONSOLE - Use serial console front end +# CONFIG_NSH_TELNET - Use telnetd console front end +# CONFIG_NSH_ARCHINIT - Platform provides architecture +# specific initialization (nsh_archinitialize()). +# +# If CONFIG_NSH_TELNET is selected: +# CONFIG_NSH_IOBUFFER_SIZE -- Telnetd I/O buffer size +# CONFIG_NSH_DHCPC - Obtain address using DHCP +# CONFIG_NSH_IPADDR - Provides static IP address +# CONFIG_NSH_DRIPADDR - Provides static router IP address +# CONFIG_NSH_NETMASK - Provides static network mask +# CONFIG_NSH_NOMAC - Use a bogus MAC address +# +# If CONFIG_NSH_ROMFSETC is selected: +# CONFIG_NSH_ROMFSMOUNTPT - ROMFS mountpoint +# CONFIG_NSH_INITSCRIPT - Relative path to init script +# CONFIG_NSH_ROMFSDEVNO - ROMFS RAM device minor +# CONFIG_NSH_ROMFSSECTSIZE - ROMF sector size +# CONFIG_NSH_FATDEVNO - FAT FS RAM device minor +# CONFIG_NSH_FATSECTSIZE - FAT FS sector size +# CONFIG_NSH_FATNSECTORS - FAT FS number of sectors +# CONFIG_NSH_FATMOUNTPT - FAT FS mountpoint +# +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_STRERROR=n +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_NESTDEPTH=3 +CONFIG_NSH_DISABLESCRIPT=y +CONFIG_NSH_DISABLEBG=y +CONFIG_NSH_ROMFSETC=n +CONFIG_NSH_CONSOLE=y +CONFIG_NSH_TELNET=y +CONFIG_NSH_ARCHINIT=n +CONFIG_NSH_IOBUFFER_SIZE=512 +CONFIG_NSH_DHCPC=n +CONFIG_NSH_NOMAC=y +CONFIG_NSH_IPADDR=(192<<24|168<<16|2<<8|50) +CONFIG_NSH_DRIPADDR=(192<<24|168<<16|2<<8|1) +CONFIG_NSH_NETMASK=(255<<24|255<<16|255<<8|0) +CONFIG_NSH_ROMFSMOUNTPT="/etc" +CONFIG_NSH_INITSCRIPT="init.d/rcS" +CONFIG_NSH_ROMFSDEVNO=0 +CONFIG_NSH_ROMFSSECTSIZE=64 +CONFIG_NSH_FATDEVNO=1 +CONFIG_NSH_FATSECTSIZE=512 +CONFIG_NSH_FATNSECTORS=1024 +CONFIG_NSH_FATMOUNTPT=/tmp +CONFIG_NSH_DISABLE_GET=y +CONFIG_NSH_DISABLE_PUT=y +CONFIG_NSH_DISABLE_WGET=y + +# +# Architecture-specific NSH options +# +CONFIG_NSH_MMCSDSPIPORTNO=0 +CONFIG_NSH_MMCSDSLOTNO=0 +CONFIG_NSH_MMCSDMINOR=0 + +# +# Settings for examples/usbserial +# +# CONFIG_EXAMPLES_USBSERIAL_INONLY +# Only verify IN (device-to-host) data transfers. Default: both +# CONFIG_EXAMPLES_USBSERIAL_OUTONLY +# Only verify OUT (host-to-device) data transfers. Default: both +# CONFIG_EXAMPLES_USBSERIAL_ONLYSMALL +# Send only small, single packet messages. Default: Send large and small. +# CONFIG_EXAMPLES_USBSERIAL_ONLYBIG +# Send only large, multi-packet messages. Default: Send large and small. +# +CONFIG_EXAMPLES_USBSERIAL_INONLY=n +CONFIG_EXAMPLES_USBSERIAL_OUTONLY=n +CONFIG_EXAMPLES_USBSERIAL_ONLYSMALL=n +CONFIG_EXAMPLES_USBSERIAL_ONLYBIG=n + +CONFIG_EXAMPLES_USBSERIAL_TRACEINIT=n +CONFIG_EXAMPLES_USBSERIAL_TRACECLASS=n +CONFIG_EXAMPLES_USBSERIAL_TRACETRANSFERS=n +CONFIG_EXAMPLES_USBSERIAL_TRACECONTROLLER=n +CONFIG_EXAMPLES_USBSERIAL_TRACEINTERRUPTS=n + +# +# Settings for examples/watchdog +# +# This test depends on these specific Watchdog/NSH configurations settings (your +# specific watchdog hardware settings might require additional settings). +# +# CONFIG_WATCHDOG- Enables watchdog timer support support. +# CONFIG_NSH_BUILTIN_APPS - Build the watchdog time test as an NSH +# built-in function. Default: Not built! The example can only be used +# as an NSH built-in application +# +# The STM32 also needs one of the following enabled: +# +# CONFIG_STM32_WWDG=y, OR +# CONFIG_STM32_IWDG=y (but not both) +# +# Specific configuration options for this example include: +# +# CONFIG_EXAMPLES_WATCHDOG_DEVPATH - The path to the Watchdog device. +# Default: /dev/watchdog0 +# CONFIG_EXAMPLES_WATCHDOG_PINGTIME - Time in milliseconds that the example +# will ping the watchdog before letting the watchdog expire. Default: 5000 +# milliseconds +# CONFIG_EXAMPLES_WATCHDOG_PINGDELAY - Time delay between pings in +# milliseconds. Default: 500 milliseconds. +# CONFIG_EXAMPLES_WATCHDOG_TIMEOUT - The watchdog timeout value in +# milliseconds before the watchdog timer expires. Default: 2000 +# milliseconds. +# +# CONFIG_EXAMPLES_WATCHDOG_DEVPATH +# CONFIG_EXAMPLES_WATCHDOG_PINGTIME +# CONFIG_EXAMPLES_WATCHDOG_PINGDELAY +# CONFIG_EXAMPLES_WATCHDOG_TIMEOUT + + +# +# STM32F10xxx specific CAN device driver settings +# +# CONFIG_CAN - Enables CAN support (CONFIG_STM32_CAN1 must also be defined) +# CONFIG_CAN_EXTID - Enables support for the 29-bit extended ID. Default +# Standard 11-bit IDs. +# CONFIG_CAN_FIFOSIZE - The size of the circular buffer of CAN messages. +# Default: 8 +# CONFIG_CAN_NPENDINGRTR - The size of the list of pending RTR requests. +# Default: 4 +# CONFIG_CAN_LOOPBACK - A CAN driver may or may not support a loopback +# mode for testing. The STM32 CAN driver does support loopback mode. +# CONFIG_CAN1_BAUD - CAN1 BAUD rate. Required if CONFIG_STM32_CAN1 is defined. +# CONFIG_CAN_TSEG1 - The number of CAN time quanta in segment 1. Default: 6 +# CONFIG_CAN_TSEG2 - the number of CAN time quanta in segment 2. Default: 7 +# +CONFIG_CAN=y +CONFIG_CAN_EXTID=n +#CONFIG_CAN_FIFOSIZE +#CONFIG_CAN_NPENDINGRTR +CONFIG_CAN_LOOPBACK=n +# ISO-11783 requires the baud to be set to 250K +CONFIG_CAN1_BAUD=700000 +# ISO-11783 requires the sample point to be within 75 to 80% +CONFIG_CAN_TSEG1=12 +CONFIG_CAN_TSEG2=3 + +CONFIG_EXAMPLES_CAN_READONLY=y +CONFIG_EXAMPLES_CAN_WRITEONLY=n +CONFIG_EXAMPLES_CAN_NMSGS=4 + +# +# Stack and heap information +# +# CONFIG_BOOT_RUNFROMFLASH - Some configurations support XIP +# operation from FLASH but must copy initialized .data sections to RAM. +# (should also be =n for the STM3210E-EVAL which always runs from flash) +# CONFIG_BOOT_COPYTORAM - Some configurations boot in FLASH +# but copy themselves entirely into RAM for better performance. +# CONFIG_CUSTOM_STACK - The up_ implementation will handle +# all stack operations outside of the nuttx model. +# CONFIG_STACK_POINTER - The initial stack pointer (arm7tdmi only) +# CONFIG_IDLETHREAD_STACKSIZE - The size of the initial stack. +# This is the thread that (1) performs the inital boot of the system up +# to the point where user_start() is spawned, and (2) there after is the +# IDLE thread that executes only when there is no other thread ready to +# run. +# CONFIG_USERMAIN_STACKSIZE - The size of the stack to allocate +# for the main user thread that begins at the user_start() entry point. +# CONFIG_PTHREAD_STACK_MIN - Minimum pthread stack size +# CONFIG_PTHREAD_STACK_DEFAULT - Default pthread stack size +# CONFIG_HEAP_BASE - The beginning of the heap +# CONFIG_HEAP_SIZE - The size of the heap +# +CONFIG_BOOT_RUNFROMFLASH=n +CONFIG_BOOT_COPYTORAM=n +CONFIG_CUSTOM_STACK=n +#CONFIG_STACK_POINTER +CONFIG_IDLETHREAD_STACKSIZE=1024 +CONFIG_USERMAIN_STACKSIZE=2048 +CONFIG_PTHREAD_STACK_MIN=256 +CONFIG_PTHREAD_STACK_DEFAULT=2048 +CONFIG_HEAP_BASE= +CONFIG_HEAP_SIZE= diff --git a/nuttx/configs/olimex-stm32-p107/nsh/setenv.sh b/nuttx/configs/olimex-stm32-p107/nsh/setenv.sh new file mode 100755 index 0000000000..6884313cda --- /dev/null +++ b/nuttx/configs/olimex-stm32-p107/nsh/setenv.sh @@ -0,0 +1,75 @@ +#!/bin/bash +# configs/olimex-stm32-p107/nsh/setenv.sh +# +# Copyright (C) 2009 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. +# + +if [ "$_" = "$0" ] ; then + echo "You must source this script, not run it!" 1>&2 + exit 1 +fi + +WD=`pwd` +if [ ! -x "setenv.sh" ]; then + echo "This script must be executed from the top-level NuttX build directory" + exit 1 +fi + +if [ -z "${PATH_ORIG}" ]; then + export PATH_ORIG="${PATH}" +fi + +# This the Cygwin path to the location where I installed the RIDE +# toolchain under windows. You will also have to edit this if you install +# the RIDE toolchain in any other location +#export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/Raisonance/Ride/arm-gcc/bin" + +# This the Cygwin path to the location where I installed the CodeSourcery +# toolchain under windows. You will also have to edit this if you install +# the CodeSourcery toolchain in any other location +export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/CodeSourcery/Sourcery G++ Lite/bin" + +# These are the Cygwin paths to the locations where I installed the Atollic +# toolchain under windows. You will also have to edit this if you install +# the Atollic toolchain in any other location. /usr/bin is added before +# the Atollic bin path because there is are binaries named gcc.exe and g++.exe +# at those locations as well. +#export TOOLCHAIN_BIN="/usr/bin:/cygdrive/c/Program Files (x86)/Atollic/TrueSTUDIO for ARM Pro 2.3.0/ARMTools/bin" +#export TOOLCHAIN_BIN="/usr/bin:/cygdrive/c/Program Files (x86)/Atollic/TrueSTUDIO for STMicroelectronics STM32 Lite 2.3.0/ARMTools/bin" + +# This the Cygwin path to the location where I build the buildroot +# toolchain. +#export TOOLCHAIN_BIN="${WD}/../misc/buildroot/build_arm_nofpu/staging_dir/bin" + +# Add the path to the toolchain to the PATH varialble +export PATH="${TOOLCHAIN_BIN}:/sbin:/usr/sbin:${PATH_ORIG}" + +echo "PATH : ${PATH}" diff --git a/nuttx/configs/olimex-stm32-p107/ostest/Make.defs b/nuttx/configs/olimex-stm32-p107/ostest/Make.defs new file mode 100644 index 0000000000..0c3f7461d6 --- /dev/null +++ b/nuttx/configs/olimex-stm32-p107/ostest/Make.defs @@ -0,0 +1,174 @@ +############################################################################ +# configs/olimex-stm32-p107/ostest/Make.defs +# +# Copyright (C) 2009, 2012 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. +# +############################################################################ + +include ${TOPDIR}/.config + +# Setup for the selected toolchain + +ifeq ($(CONFIG_STM32_DFU),y) + LDSCRIPT = ld.script.dfu +else + LDSCRIPT = ld.script +endif + +ifeq ($(CONFIG_STM32_CODESOURCERYW),y) + # CodeSourcery under Windows + CROSSDEV = arm-none-eabi- + WINTOOL = y + ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft +endif +ifeq ($(CONFIG_STM32_CODESOURCERYL),y) + # CodeSourcery under Linux + CROSSDEV = arm-none-eabi- + ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft + MAXOPTIMIZATION = -O2 +endif +ifeq ($(CONFIG_STM32_DEVKITARM),y) + # devkitARM under Windows + CROSSDEV = arm-eabi- + WINTOOL = y + ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft +endif +ifeq ($(CONFIG_STM32_RAISONANCE),y) + # Raisonance RIDE7 under Windows + CROSSDEV = arm-none-eabi- + WINTOOL = y + ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft +endif +ifeq ($(CONFIG_STM32_BUILDROOT),y) + # NuttX buildroot under Linux or Cygwin + CROSSDEV = arm-elf- + ARCHCPUFLAGS = -mtune=cortex-m3 -march=armv7-m -mfloat-abi=soft + MAXOPTIMIZATION = -Os +endif + +ifeq ($(WINTOOL),y) + # Windows-native toolchains + DIRLINK = $(TOPDIR)/tools/winlink.sh + DIRUNLINK = $(TOPDIR)/tools/unlink.sh + MKDEP = $(TOPDIR)/tools/mknulldeps.sh + ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" + ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}" + ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}" + MAXOPTIMIZATION = -O2 +else + # Linux/Cygwin-native toolchain + MKDEP = $(TOPDIR)/tools/mkdeps.sh + ARCHINCLUDES = -I. -isystem $(TOPDIR)/include + ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx + ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) +endif + +CC = $(CROSSDEV)gcc +CXX = $(CROSSDEV)g++ +CPP = $(CROSSDEV)gcc -E +LD = $(CROSSDEV)ld +AR = $(CROSSDEV)ar rcs +NM = $(CROSSDEV)nm +OBJCOPY = $(CROSSDEV)objcopy +OBJDUMP = $(CROSSDEV)objdump + +ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'} +ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1} + +ifeq ("${CONFIG_DEBUG_SYMBOLS}","y") + ARCHOPTIMIZATION = -g +else + ARCHOPTIMIZATION = $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer +endif + +ARCHCFLAGS = -fno-builtin +ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fno-rtti +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow +ARCHWARNINGSXX = -Wall -Wshadow +ARCHDEFINES = +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) +AFLAGS = $(CFLAGS) -D__ASSEMBLY__ + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 + +OBJEXT = .o +LIBEXT = .a +EXEEXT = + +ifneq ($(CROSSDEV),arm-elf-) + LDFLAGS += -nostartfiles -nodefaultlibs +endif +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g +endif + +define PREPROCESS + @echo "CPP: $1->$2" + @$(CPP) $(CPPFLAGS) $1 -o $2 +endef + +define COMPILE + @echo "CC: $1" + @$(CC) -c $(CFLAGS) $1 -o $2 +endef + +define COMPILEXX + @echo "CXX: $1" + @$(CXX) -c $(CXXFLAGS) $1 -o $2 +endef + +define ASSEMBLE + @echo "AS: $1" + @$(CC) -c $(AFLAGS) $1 -o $2 +endef + +define ARCHIVE + echo "AR: $2"; \ + $(AR) $1 $2 || { echo "$(AR) $1 $2 FAILED!" ; exit 1 ; } +endef + +define CLEAN + @rm -f *.o *.a +endef + +HOSTCC = gcc +HOSTINCLUDES = -I. +HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe +HOSTLDFLAGS = + diff --git a/nuttx/configs/olimex-stm32-p107/ostest/appconfig b/nuttx/configs/olimex-stm32-p107/ostest/appconfig new file mode 100644 index 0000000000..18d8040abe --- /dev/null +++ b/nuttx/configs/olimex-stm32-p107/ostest/appconfig @@ -0,0 +1,38 @@ +############################################################################ +# configs/olimex-stm32-p107/ostest/appconfig +# +# Copyright (C) 2011 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. +# +############################################################################ + +# Path to example in apps/examples containing the user_start entry point + +CONFIGURED_APPS += examples/ostest diff --git a/nuttx/configs/olimex-stm32-p107/ostest/defconfig b/nuttx/configs/olimex-stm32-p107/ostest/defconfig new file mode 100644 index 0000000000..246f35665f --- /dev/null +++ b/nuttx/configs/olimex-stm32-p107/ostest/defconfig @@ -0,0 +1,978 @@ +############################################################################ +# configs/olimex-stm32-p107/ostest/defconfig +# +# Copyright (C) 2012 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. +# +############################################################################ +# +# architecture selection +# +# CONFIG_ARCH - identifies the arch subdirectory and, hence, the +# processor architecture. +# CONFIG_ARCH_family - for use in C code. This identifies the +# particular chip family that the architecture is implemented +# in. +# CONFIG_ARCH_architecture - for use in C code. This identifies the +# specific architecture within the chip familyl. +# CONFIG_ARCH_CHIP - Identifies the arch/*/chip subdirectory +# CONFIG_ARCH_CHIP_name - For use in C code +# CONFIG_ARCH_BOARD - identifies the configs subdirectory and, hence, +# the board that supports the particular chip or SoC. +# CONFIG_ARCH_BOARD_name - for use in C code +# CONFIG_ENDIAN_BIG - define if big endian (default is little endian) +# CONFIG_BOARD_LOOPSPERMSEC - for delay loops +# CONFIG_DRAM_SIZE - Describes the installed DRAM. +# CONFIG_DRAM_START - The start address of DRAM (physical) +# CONFIG_DRAM_END - Last address+1 of installed RAM +# CONFIG_ARCH_IRQPRIO - The STM3220xxx supports interrupt prioritization +# CONFIG_ARCH_INTERRUPTSTACK - This architecture supports an interrupt +# stack. If defined, this symbol is the size of the interrupt +# stack in bytes. If not defined, the user task stacks will be +# used during interrupt handling. +# CONFIG_ARCH_STACKDUMP - Do stack dumps after assertions +# CONFIG_ARCH_BOOTLOADER - Set if you are using a bootloader. +# CONFIG_ARCH_LEDS - Use LEDs to show state. Unique to board architecture. +# CONFIG_ARCH_BUTTONS - Enable support for buttons. Unique to board architecture. +# CONFIG_ARCH_CALIBRATION - Enables some build in instrumentation that +# cause a 100 second delay during boot-up. This 100 second delay +# serves no purpose other than it allows you to calibrate +# CONFIG_BOARD_LOOPSPERMSEC. You simply use a stop watch to measure +# the 100 second delay then adjust CONFIG_BOARD_LOOPSPERMSEC until +# the delay actually is 100 seconds. +# CONFIG_ARCH_DMA - Support DMA initialization +# +CONFIG_ARCH=arm +CONFIG_ARCH_ARM=y +CONFIG_ARCH_CORTEXM3=y +CONFIG_ARCH_CHIP=stm32 +CONFIG_ARCH_CHIP_STM32F107VC=y +CONFIG_ARCH_BOARD=olimex-stm32-p107 +CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG=y +CONFIG_BOARD_LOOPSPERMSEC=5483 +CONFIG_DRAM_SIZE=0x00010000 +CONFIG_DRAM_START=0x20000000 +CONFIG_DRAM_END=(CONFIG_DRAM_START+CONFIG_DRAM_SIZE) +CONFIG_ARCH_IRQPRIO=y +CONFIG_ARCH_INTERRUPTSTACK=n +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_BOOTLOADER=n +CONFIG_ARCH_LEDS=n +CONFIG_ARCH_BUTTONS=n +CONFIG_ARCH_CALIBRATION=n +CONFIG_ARCH_DMA=n + + +# +# Identify toolchain and linker options +# +CONFIG_STM32_CODESOURCERYW=n +CONFIG_STM32_CODESOURCERYL=y +CONFIG_STM32_DEVKITARM=n +CONFIG_STM32_RAISONANCE=n +CONFIG_STM32_BUILDROOT=n + +# +# JTAG Enable settings (by default JTAG-DP and SW-DP are disabled): +# +# CONFIG_STM32_DFU - Use the DFU bootloader, not JTAG +# +# JTAG Enable options: +# +# CONFIG_STM32_JTAG_FULL_ENABLE - Enables full SWJ (JTAG-DP + SW-DP) +# CONFIG_STM32_JTAG_NOJNTRST_ENABLE - Enables full SWJ (JTAG-DP + SW-DP) +# but without JNTRST. +# CONFIG_STM32_JTAG_SW_ENABLE - Set JTAG-DP disabled and SW-DP enabled +# +CONFIG_STM32_DFU=n +CONFIG_STM32_JTAG_FULL_ENABLE=y +CONFIG_STM32_JTAG_NOJNTRST_ENABLE=n +CONFIG_STM32_JTAG_SW_ENABLE=n + +# +# Alternate pin mappings +# +CONFIG_STM32_TIM1_FULL_REMAP=n +CONFIG_STM32_TIM1_PARTIAL_REMAP=n +CONFIG_STM32_TIM2_FULL_REMAP=n +CONFIG_STM32_TIM2_PARTIAL_REMAP_1=n +CONFIG_STM32_TIM2_PARTIAL_REMAP_2=n +CONFIG_STM32_TIM3_FULL_REMAP=n +CONFIG_STM32_TIM3_PARTIAL_REMAP=n +CONFIG_STM32_TIM4_REMAP=n +CONFIG_STM32_USART1_REMAP=n +CONFIG_STM32_USART2_REMAP=y +CONFIG_STM32_USART3_FULL_REMAP=n +CONFIG_STM32_USART3_PARTIAL_REMAP=n +CONFIG_STM32_SPI1_REMAP=n +CONFIG_STM32_SPI3_REMAP=n +CONFIG_STM32_I2C1_REMAP=n +CONFIG_STM32_CAN1_REMAP1=y +CONFIG_STM32_CAN1_REMAP2=n + + +# +# Individual subsystems can be enabled: +# +# Individual subsystems can be enabled: +# AHB: +CONFIG_STM32_DMA1=n +CONFIG_STM32_DMA2=n +CONFIG_STM32_CRC=n +CONFIG_STM32_FSMC=n +CONFIG_STM32_SDIO=n +# APB1: +CONFIG_STM32_TIM2=n +CONFIG_STM32_TIM3=n +CONFIG_STM32_TIM4=n +CONFIG_STM32_TIM5=n +CONFIG_STM32_TIM6=n +CONFIG_STM32_TIM7=n +CONFIG_STM32_WWDG=n +CONFIG_STM32_IWDG=n +CONFIG_STM32_SPI2=n +CONFIG_STM32_SPI4=n +CONFIG_STM32_USART2=y +CONFIG_STM32_USART3=n +CONFIG_STM32_UART4=n +CONFIG_STM32_UART5=n +CONFIG_STM32_I2C1=n +CONFIG_STM32_I2C2=n +CONFIG_STM32_USB=n +CONFIG_STM32_CAN1=n +CONFIG_STM32_BKP=n +CONFIG_STM32_PWR=n +CONFIG_STM32_DAC=n +# APB2: +CONFIG_STM32_ADC1=n +CONFIG_STM32_ADC2=n +CONFIG_STM32_TIM1=n +CONFIG_STM32_SPI1=n +CONFIG_STM32_TIM8=n +CONFIG_STM32_USART1=n +CONFIG_STM32_ADC3=n + +# +# Timer and I2C devices may need to the following to force power to be applied: +# +#CONFIG_STM32_FORCEPOWER=y + +# +# STM32F103Z specific serial device driver settings +# +# CONFIG_USARTn_SERIAL_CONSOLE - selects the USARTn for the +# console and ttys0 (default is the USART1). +# CONFIG_USARTn_RXBUFSIZE - Characters are buffered as received. +# This specific the size of the receive buffer +# CONFIG_USARTn_TXBUFSIZE - Characters are buffered before +# being sent. This specific the size of the transmit buffer +# CONFIG_USARTn_BAUD - The configure BAUD of the UART. Must be +# CONFIG_USARTn_BITS - The number of bits. Must be either 7 or 8. +# CONFIG_USARTn_PARTIY - 0=no parity, 1=odd parity, 2=even parity +# CONFIG_USARTn_2STOP - Two stop bits +# +CONFIG_USART1_SERIAL_CONSOLE=n +CONFIG_USART2_SERIAL_CONSOLE=y +CONFIG_USART3_SERIAL_CONSOLE=n +CONFIG_USART4_SERIAL_CONSOLE=n +CONFIG_USART5_SERIAL_CONSOLE=n + +CONFIG_USART1_TXBUFSIZE=256 +CONFIG_USART2_TXBUFSIZE=256 +CONFIG_USART3_TXBUFSIZE=256 +CONFIG_USART4_TXBUFSIZE=256 +CONFIG_USART5_TXBUFSIZE=256 + +CONFIG_USART1_RXBUFSIZE=256 +CONFIG_USART2_RXBUFSIZE=256 +CONFIG_USART3_RXBUFSIZE=256 +CONFIG_USART4_RXBUFSIZE=256 +CONFIG_USART5_RXBUFSIZE=256 + +CONFIG_USART1_BAUD=115200 +CONFIG_USART2_BAUD=115200 +CONFIG_USART3_BAUD=115200 +CONFIG_USART4_BAUD=115200 +CONFIG_USART5_BAUD=115200 + +CONFIG_USART1_BITS=8 +CONFIG_USART2_BITS=8 +CONFIG_USART3_BITS=8 +CONFIG_USART4_BITS=8 +CONFIG_USART5_BITS=8 + +CONFIG_USART1_PARITY=0 +CONFIG_USART2_PARITY=0 +CONFIG_USART3_PARITY=0 +CONFIG_USART4_PARITY=0 +CONFIG_USART5_PARITY=0 + +CONFIG_USART1_2STOP=0 +CONFIG_USART2_2STOP=0 +CONFIG_USART3_2STOP=0 +CONFIG_USART4_2STOP=0 +CONFIG_USART5_2STOP=0 + +# +# STM32F103Z specific SSI device driver settings +# +# CONFIG_SSIn_DISABLE - select to disable all support for +# the SSI +# CONFIG_SSI_POLLWAIT - Select to disable interrupt driven SSI support +# Poll-waiting is recommended if the interrupt rate would be to +# high in the interrupt driven case. +# CONFIG_SSI_TXLIMIT - Write this many words to the Tx FIFO before +# emptying the Rx FIFO. If the SPI frequency is high and this +# value is large, then larger values of this setting may cause +# Rx FIFO overrun errors. Default: half of the Tx FIFO size (4). +# +CONFIG_SSI0_DISABLE=y +CONFIG_SSI1_DISABLE=y +CONFIG_SSI_POLLWAIT=y +#CONFIG_SSI_TXLIMIT=4 + +# +# STM3210E-EVAL specific LCD settings +# +CONFIG_STM32_AM240320_DISABLE=y +CONFIG_STM32_SPFD5408B_DISABLE=y +CONFIG_STM32_R61580_DISABLE=y + +# +# STM32F103Z specific CAN device driver settings +# +# CONFIG_CAN - Enables CAN support (one or both of CONFIG_STM32_CAN1 or +# CONFIG_STM32_CAN2 must also be defined) +# CONFIG_CAN_EXTID - Enables support for the 29-bit extended ID. Default +# Standard 11-bit IDs. +# CONFIG_CAN_FIFOSIZE - The size of the circular buffer of CAN messages. +# Default: 8 +# CONFIG_CAN_NPENDINGRTR - The size of the list of pending RTR requests. +# Default: 4 +# CONFIG_CAN_LOOPBACK - A CAN driver may or may not support a loopback +# mode for testing. The STM32 CAN driver does support loopback mode. +# CONFIG_CAN1_BAUD - CAN1 BAUD rate. Required if CONFIG_STM32_CAN1 is defined. +# CONFIG_CAN2_BAUD - CAN1 BAUD rate. Required if CONFIG_STM32_CAN2 is defined. +# CONFIG_CAN_TSEG1 - The number of CAN time quanta in segment 1. Default: 6 +# CONFIG_CAN_TSEG2 - the number of CAN time quanta in segment 2. Default: 7 +# +CONFIG_CAN=n +CONFIG_CAN_EXTID=n +#CONFIG_CAN_FIFOSIZE +#CONFIG_CAN_NPENDINGRTR +CONFIG_CAN_LOOPBACK=n +CONFIG_CAN1_BAUD=700000 +CONFIG_CAN2_BAUD=700000 + +# +# General build options +# +# CONFIG_RRLOAD_BINARY - make the rrload binary format used with +# BSPs from www.ridgerun.com using the tools/mkimage.sh script +# CONFIG_INTELHEX_BINARY - make the Intel HEX binary format +# used with many different loaders using the GNU objcopy program +# Should not be selected if you are not using the GNU toolchain. +# CONFIG_MOTOROLA_SREC - make the Motorola S-Record binary format +# used with many different loaders using the GNU objcopy program +# Should not be selected if you are not using the GNU toolchain. +# CONFIG_RAW_BINARY - make a raw binary format file used with many +# different loaders using the GNU objcopy program. This option +# should not be selected if you are not using the GNU toolchain. +# CONFIG_HAVE_LIBM - toolchain supports libm.a +# +CONFIG_RRLOAD_BINARY=n +CONFIG_INTELHEX_BINARY=y +CONFIG_MOTOROLA_SREC=n +CONFIG_RAW_BINARY=n +CONFIG_HAVE_LIBM=n + +# +# General OS setup +# +# CONFIG_APPS_DIR - Identifies the relative path to the directory +# that builds the application to link with NuttX. Default: ../apps +# CONFIG_DEBUG - enables built-in debug options +# CONFIG_DEBUG_VERBOSE - enables verbose debug output +# CONFIG_DEBUG_SYMBOLS - build without optimization and with +# debug symbols (needed for use with a debugger). +# CONFIG_HAVE_CXX - Enable support for C++ +# CONFIG_HAVE_CXXINITIALIZE - The platform-specific logic includes support +# for initialization of static C++ instances for this architecture +# and for the selected toolchain (via up_cxxinitialize()). +# CONFIG_MM_REGIONS - If the architecture includes multiple +# regions of memory to allocate from, this specifies the +# number of memory regions that the memory manager must +# handle and enables the API mm_addregion(start, end); +# CONFIG_ARCH_LOWPUTC - architecture supports low-level, boot +# time console output +# CONFIG_MSEC_PER_TICK - The default system timer is 100Hz +# or MSEC_PER_TICK=10. This setting may be defined to +# inform NuttX that the processor hardware is providing +# system timer interrupts at some interrupt interval other +# than 10 msec. +# CONFIG_RR_INTERVAL - The round robin timeslice will be set +# this number of milliseconds; Round robin scheduling can +# be disabled by setting this value to zero. +# CONFIG_SCHED_INSTRUMENTATION - enables instrumentation in +# scheduler to monitor system performance +# CONFIG_TASK_NAME_SIZE - Spcifies that maximum size of a +# task name to save in the TCB. Useful if scheduler +# instrumentation is selected. Set to zero to disable. +# CONFIG_START_YEAR, CONFIG_START_MONTH, CONFIG_START_DAY - +# Used to initialize the internal time logic. +# CONFIG_GREGORIAN_TIME - Enables Gregorian time conversions. +# You would only need this if you are concerned about accurate +# time conversions in the past or in the distant future. +# CONFIG_JULIAN_TIME - Enables Julian time conversions. You +# would only need this if you are concerned about accurate +# time conversion in the distand past. You must also define +# CONFIG_GREGORIAN_TIME in order to use Julian time. +# CONFIG_DEV_CONSOLE - Set if architecture-specific logic +# provides /dev/console. Enables stdout, stderr, stdin. +# CONFIG_DEV_LOWCONSOLE - Use the simple, low-level serial console +# driver (minimul support) +# CONFIG_MUTEX_TYPES: Set to enable support for recursive and +# errorcheck mutexes. Enables pthread_mutexattr_settype(). +# CONFIG_PRIORITY_INHERITANCE : Set to enable support for priority +# inheritance on mutexes and semaphores. +# CONFIG_SEM_PREALLOCHOLDERS: This setting is only used if priority +# inheritance is enabled. It defines the maximum number of +# different threads (minus one) that can take counts on a +# semaphore with priority inheritance support. This may be +# set to zero if priority inheritance is disabled OR if you +# are only using semaphores as mutexes (only one holder) OR +# if no more than two threads participate using a counting +# semaphore. +# CONFIG_SEM_NNESTPRIO. If priority inheritance is enabled, +# then this setting is the maximum number of higher priority +# threads (minus 1) than can be waiting for another thread +# to release a count on a semaphore. This value may be set +# to zero if no more than one thread is expected to wait for +# a semaphore. +# CONFIG_FDCLONE_DISABLE. Disable cloning of all file descriptors +# by task_create() when a new task is started. If set, all +# files/drivers will appear to be closed in the new task. +# CONFIG_FDCLONE_STDIO. Disable cloning of all but the first +# three file descriptors (stdin, stdout, stderr) by task_create() +# when a new task is started. If set, all files/drivers will +# appear to be closed in the new task except for stdin, stdout, +# and stderr. +# CONFIG_SDCLONE_DISABLE. Disable cloning of all socket +# desciptors by task_create() when a new task is started. If +# set, all sockets will appear to be closed in the new task. +# CONFIG_NXFLAT. Enable support for the NXFLAT binary format. +# This format will support execution of NuttX binaries located +# in a ROMFS filesystem (see examples/nxflat). +# CONFIG_SCHED_WORKQUEUE. Create a dedicated "worker" thread to +# handle delayed processing from interrupt handlers. This feature +# is required for some drivers but, if there are not complaints, +# can be safely disabled. The worker thread also performs +# garbage collection -- completing any delayed memory deallocations +# from interrupt handlers. If the worker thread is disabled, +# then that clean will be performed by the IDLE thread instead +# (which runs at the lowest of priority and may not be appropriate +# if memory reclamation is of high priority). If CONFIG_SCHED_WORKQUEUE +# is enabled, then the following options can also be used: +# CONFIG_SCHED_WORKPRIORITY - The execution priority of the worker +# thread. Default: 50 +# CONFIG_SCHED_WORKPERIOD - How often the worker thread checks for +# work in units of microseconds. Default: 50*1000 (50 MS). +# CONFIG_SCHED_WORKSTACKSIZE - The stack size allocated for the worker +# thread. Default: CONFIG_IDLETHREAD_STACKSIZE. +# CONFIG_SIG_SIGWORK - The signal number that will be used to wake-up +# the worker thread. Default: 4 +# +#CONFIG_APPS_DIR= +CONFIG_DEBUG=y +CONFIG_DEBUG_VERBOSE=y +CONFIG_DEBUG_SYMBOLS=n +CONFIG_HAVE_CXX=n +CONFIG_HAVE_CXXINITIALIZE=n +CONFIG_MM_REGIONS=1 +CONFIG_ARCH_LOWPUTC=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_INSTRUMENTATION=n +CONFIG_TASK_NAME_SIZE=0 +CONFIG_START_YEAR=2009 +CONFIG_START_MONTH=9 +CONFIG_START_DAY=21 +CONFIG_GREGORIAN_TIME=n +CONFIG_JULIAN_TIME=n +CONFIG_DEV_CONSOLE=y +CONFIG_DEV_LOWCONSOLE=y +CONFIG_MUTEX_TYPES=n +CONFIG_PRIORITY_INHERITANCE=n +CONFIG_SEM_PREALLOCHOLDERS=0 +CONFIG_SEM_NNESTPRIO=0 +CONFIG_FDCLONE_DISABLE=n +CONFIG_FDCLONE_STDIO=n +CONFIG_SDCLONE_DISABLE=y +CONFIG_NXFLAT=n +CONFIG_SCHED_WORKQUEUE=n +CONFIG_SCHED_WORKPRIORITY=50 +CONFIG_SCHED_WORKPERIOD=(50*1000) +CONFIG_SCHED_WORKSTACKSIZE=1024 +CONFIG_SIG_SIGWORK=4 + +# +# The following can be used to disable categories of +# APIs supported by the OS. If the compiler supports +# weak functions, then it should not be necessary to +# disable functions unless you want to restrict usage +# of those APIs. +# +# There are certain dependency relationships in these +# features. +# +# o mq_notify logic depends on signals to awaken tasks +# waiting for queues to become full or empty. +# o pthread_condtimedwait() depends on signals to wake +# up waiting tasks. +# +CONFIG_DISABLE_CLOCK=n +CONFIG_DISABLE_POSIX_TIMERS=n +CONFIG_DISABLE_PTHREAD=n +CONFIG_DISABLE_SIGNALS=n +CONFIG_DISABLE_MQUEUE=n +CONFIG_DISABLE_MOUNTPOINT=n +CONFIG_DISABLE_ENVIRON=n +CONFIG_DISABLE_POLL=n + +# +# Misc libc settings +# +# CONFIG_NOPRINTF_FIELDWIDTH - sprintf-related logic is a +# little smaller if we do not support fieldwidthes +# +CONFIG_NOPRINTF_FIELDWIDTH=n + +# +# Allow for architecture optimized implementations +# +# The architecture can provide optimized versions of the +# following to improve system performance +# +CONFIG_ARCH_MEMCPY=n +CONFIG_ARCH_MEMCMP=n +CONFIG_ARCH_MEMMOVE=n +CONFIG_ARCH_MEMSET=n +CONFIG_ARCH_STRCMP=n +CONFIG_ARCH_STRCPY=n +CONFIG_ARCH_STRNCPY=n +CONFIG_ARCH_STRLEN=n +CONFIG_ARCH_STRNLEN=n +CONFIG_ARCH_BZERO=n + +# +# Sizes of configurable things (0 disables) +# +# CONFIG_MAX_TASKS - The maximum number of simultaneously +# active tasks. This value must be a power of two. +# CONFIG_MAX_TASK_ARGS - This controls the maximum number of +# of parameters that a task may receive (i.e., maxmum value +# of 'argc') +# CONFIG_NPTHREAD_KEYS - The number of items of thread- +# specific data that can be retained +# CONFIG_NFILE_DESCRIPTORS - The maximum number of file +# descriptors (one for each open) +# CONFIG_NFILE_STREAMS - The maximum number of streams that +# can be fopen'ed +# CONFIG_NAME_MAX - The maximum size of a file name. +# CONFIG_STDIO_BUFFER_SIZE - Size of the buffer to allocate +# on fopen. (Only if CONFIG_NFILE_STREAMS > 0) +# CONFIG_NUNGET_CHARS - Number of characters that can be +# buffered by ungetc() (Only if CONFIG_NFILE_STREAMS > 0) +# CONFIG_PREALLOC_MQ_MSGS - The number of pre-allocated message +# structures. The system manages a pool of preallocated +# message structures to minimize dynamic allocations +# CONFIG_MQ_MAXMSGSIZE - Message structures are allocated with +# a fixed payload size given by this settin (does not include +# other message structure overhead. +# CONFIG_MAX_WDOGPARMS - Maximum number of parameters that +# can be passed to a watchdog handler +# CONFIG_PREALLOC_WDOGS - The number of pre-allocated watchdog +# structures. The system manages a pool of preallocated +# watchdog structures to minimize dynamic allocations +# CONFIG_PREALLOC_TIMERS - The number of pre-allocated POSIX +# timer structures. The system manages a pool of preallocated +# timer structures to minimize dynamic allocations. Set to +# zero for all dynamic allocations. +# +CONFIG_MAX_TASKS=16 +CONFIG_MAX_TASK_ARGS=4 +CONFIG_NPTHREAD_KEYS=4 +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NAME_MAX=32 +CONFIG_STDIO_BUFFER_SIZE=256 +CONFIG_NUNGET_CHARS=2 +CONFIG_PREALLOC_MQ_MSGS=4 +CONFIG_MQ_MAXMSGSIZE=32 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_PREALLOC_WDOGS=4 +CONFIG_PREALLOC_TIMERS=4 + +# +# Filesystem configuration +# +# CONFIG_FS_FAT - Enable FAT filesystem support +# CONFIG_FAT_SECTORSIZE - Max supported sector size +# CONFIG_FAT_LCNAMES - Enable use of the NT-style upper/lower case 8.3 +# file name support. +# CONFIG_FAT_LFN - Enable FAT long file names. NOTE: Microsoft claims +# patents on FAT long file name technology. Please read the +# disclaimer in the top-level COPYING file and only enable this +# feature if you understand these issues. +# CONFIG_FAT_MAXFNAME - If CONFIG_FAT_LFN is defined, then the +# default, maximum long file name is 255 bytes. This can eat up +# a lot of memory (especially stack space). If you are willing +# to live with some non-standard, short long file names, then +# define this value. A good choice would be the same value as +# selected for CONFIG_NAME_MAX which will limit the visibility +# of longer file names anyway. +# CONFIG_FS_NXFFS: Enable NuttX FLASH file system (NXFF) support. +# CONFIG_NXFFS_ERASEDSTATE: The erased state of FLASH. +# This must have one of the values of 0xff or 0x00. +# Default: 0xff. +# CONFIG_NXFFS_PACKTHRESHOLD: When packing flash file data, +# don't both with file chunks smaller than this number of data bytes. +# CONFIG_NXFFS_MAXNAMLEN: The maximum size of an NXFFS file name. +# Default: 255. +# CONFIG_NXFFS_PACKTHRESHOLD: When packing flash file data, +# don't both with file chunks smaller than this number of data bytes. +# Default: 32. +# CONFIG_NXFFS_TAILTHRESHOLD: clean-up can either mean +# packing files together toward the end of the file or, if file are +# deleted at the end of the file, clean up can simply mean erasing +# the end of FLASH memory so that it can be re-used again. However, +# doing this can also harm the life of the FLASH part because it can +# mean that the tail end of the FLASH is re-used too often. This +# threshold determines if/when it is worth erased the tail end of FLASH +# and making it available for re-use (and possible over-wear). +# Default: 8192. +# CONFIG_FS_ROMFS - Enable ROMFS filesystem support +# CONFIG_FS_RAMMAP - For file systems that do not support XIP, this +# option will enable a limited form of memory mapping that is +# implemented by copying whole files into memory. +# +CONFIG_FS_FAT=n +CONFIG_FAT_LCNAMES=n +CONFIG_FAT_LFN=n +CONFIG_FAT_MAXFNAME=32 +CONFIG_FS_NXFFS=n +CONFIG_FS_ROMFS=n + +# +# SPI-based MMC/SD driver +# +# CONFIG_MMCSD_NSLOTS +# Number of MMC/SD slots supported by the driver +# CONFIG_MMCSD_READONLY +# Provide read-only access (default is read/write) +# CONFIG_MMCSD_SPICLOCK - Maximum SPI clock to drive MMC/SD card. +# Default is 20MHz. +# +CONFIG_MMCSD_NSLOTS=1 +CONFIG_MMCSD_READONLY=n +CONFIG_MMCSD_SPICLOCK=12500000 + +# +# Block driver buffering +# +# CONFIG_FS_READAHEAD +# Enable read-ahead buffering +# CONFIG_FS_WRITEBUFFER +# Enable write buffering +# +CONFIG_FS_READAHEAD=n +CONFIG_FS_WRITEBUFFER=n + +# +# SDIO-based MMC/SD driver +# +# CONFIG_SDIO_DMA +# SDIO driver supports DMA +# CONFIG_MMCSD_MMCSUPPORT +# Enable support for MMC cards +# CONFIG_MMCSD_HAVECARDDETECT +# SDIO driver card detection is 100% accurate +# +CONFIG_SDIO_DMA=n +CONFIG_MMCSD_MMCSUPPORT=n +CONFIG_MMCSD_HAVECARDDETECT=n + +# +# TCP/IP and UDP support via uIP +# CONFIG_NET - Enable or disable all network features +# CONFIG_NET_IPv6 - Build in support for IPv6 +# CONFIG_NSOCKET_DESCRIPTORS - Maximum number of socket descriptors per task/thread. +# CONFIG_NET_SOCKOPTS - Enable or disable support for socket options +# CONFIG_NET_BUFSIZE - uIP buffer size +# CONFIG_NET_TCP - TCP support on or off +# CONFIG_NET_TCP_CONNS - Maximum number of TCP connections (all tasks) +# CONFIG_NET_TCP_READAHEAD_BUFSIZE - Size of TCP read-ahead buffers +# CONFIG_NET_NTCP_READAHEAD_BUFFERS - Number of TCP read-ahead buffers (may be zero) +# CONFIG_NET_TCPBACKLOG - Incoming connections pend in a backlog until +# accept() is called. The size of the backlog is selected when listen() is called. +# CONFIG_NET_MAX_LISTENPORTS - Maximum number of listening TCP ports (all tasks) +# CONFIG_NET_UDP - UDP support on or off +# CONFIG_NET_UDP_CHECKSUMS - UDP checksums on or off +# CONFIG_NET_UDP_CONNS - The maximum amount of concurrent UDP connections +# CONFIG_NET_ICMP - ICMP ping response support on or off +# CONFIG_NET_ICMP_PING - ICMP ping request support on or off +# CONFIG_NET_PINGADDRCONF - Use "ping" packet for setting IP address +# CONFIG_NET_STATISTICS - uIP statistics on or off +# CONFIG_NET_RECEIVE_WINDOW - The size of the advertised receiver's window +# CONFIG_NET_ARPTAB_SIZE - The size of the ARP table +# CONFIG_NET_BROADCAST - Broadcast support +# CONFIG_NET_FWCACHE_SIZE - number of packets to remember when looking for duplicates +# +CONFIG_NET=n +CONFIG_NET_IPv6=n +CONFIG_NSOCKET_DESCRIPTORS=0 +CONFIG_NET_SOCKOPTS=y +CONFIG_NET_BUFSIZE=420 +CONFIG_NET_TCP=n +CONFIG_NET_TCP_CONNS=40 +CONFIG_NET_MAX_LISTENPORTS=40 +CONFIG_NET_UDP=n +CONFIG_NET_UDP_CHECKSUMS=y +#CONFIG_NET_UDP_CONNS=10 +CONFIG_NET_ICMP=n +CONFIG_NET_ICMP_PING=n +#CONFIG_NET_PINGADDRCONF=0 +CONFIG_NET_STATISTICS=y +#CONFIG_NET_RECEIVE_WINDOW= +#CONFIG_NET_ARPTAB_SIZE=8 +CONFIG_NET_BROADCAST=n +#CONFIG_NET_FWCACHE_SIZE=2 + +# +# UIP Network Utilities +# CONFIG_NET_DHCP_LIGHT - Reduces size of DHCP +# CONFIG_NET_RESOLV_ENTRIES - Number of resolver entries +# +CONFIG_NET_DHCP_LIGHT=n +CONFIG_NET_RESOLV_ENTRIES=4 + +# +# USB Device Configuration +# +# CONFIG_USBDEV +# Enables USB device support +# CONFIG_USBDEV_ISOCHRONOUS +# Build in extra support for isochronous endpoints +# CONFIG_USBDEV_DUALSPEED +# Hardware handles high and full speed operation (USB 2.0) +# CONFIG_USBDEV_SELFPOWERED +# Will cause USB features to indicate that the device is +# self-powered +# CONFIG_USBDEV_MAXPOWER +# Maximum power consumption in mA +# CONFIG_USBDEV_TRACE +# Enables USB tracing for debug +# CONFIG_USBDEV_TRACE_NRECORDS +# Number of trace entries to remember +# +CONFIG_USBDEV=n +CONFIG_USBDEV_ISOCHRONOUS=n +CONFIG_USBDEV_DUALSPEED=n +CONFIG_USBDEV_SELFPOWERED=y +CONFIG_USBDEV_REMOTEWAKEUP=n +CONFIG_USBDEV_MAXPOWER=100 +CONFIG_USBDEV_TRACE=n +CONFIG_USBDEV_TRACE_NRECORDS=128 + +# +# USB Serial Device Configuration +# +# CONFIG_PL2303 +# Enable compilation of the USB serial driver +# CONFIG_PL2303_EPINTIN +# The logical 7-bit address of a hardware endpoint that supports +# interrupt IN operation +# CONFIG_PL2303_EPBULKOUT +# The logical 7-bit address of a hardware endpoint that supports +# bulk OUT operation +# CONFIG_PL2303_EPBULKIN +# The logical 7-bit address of a hardware endpoint that supports +# bulk IN operation +# # CONFIG_PL2303_NWRREQS and CONFIG_PL2303_NRDREQS +# The number of write/read requests that can be in flight +# CONFIG_PL2303_VENDORID and CONFIG_PL2303_VENDORSTR +# The vendor ID code/string +# CONFIG_PL2303_PRODUCTID and CONFIG_PL2303_PRODUCTSTR +# The product ID code/string +# CONFIG_PL2303_RXBUFSIZE and CONFIG_PL2303_TXBUFSIZE +# Size of the serial receive/transmit buffers +# +CONFIG_PL2303=n +CONFIG_PL2303_EPINTIN=1 +CONFIG_PL2303_EPBULKOUT=2 +CONFIG_PL2303_EPBULKIN=3 +CONFIG_PL2303_NWRREQS=4 +CONFIG_PL2303_NRDREQS=4 +CONFIG_PL2303_VENDORID=0x067b +CONFIG_PL2303_PRODUCTID=0x2303 +CONFIG_PL2303_VENDORSTR="Nuttx" +CONFIG_PL2303_PRODUCTSTR="USBdev Serial" +CONFIG_PL2303_RXBUFSIZE=512 +CONFIG_PL2303_TXBUFSIZE=512 + +# +# USB Storage Device Configuration +# +# CONFIG_USBMSC +# Enable compilation of the USB storage driver +# CONFIG_USBMSC_EP0MAXPACKET +# Max packet size for endpoint 0 +# CONFIG_USBMSC_EPBULKOUT and CONFIG_USBMSC_EPBULKIN +# The logical 7-bit address of a hardware endpoints that support +# bulk OUT and IN operations +# CONFIG_USBMSC_NWRREQS and CONFIG_USBMSC_NRDREQS +# The number of write/read requests that can be in flight +# CONFIG_USBMSC_BULKINREQLEN and CONFIG_USBMSC_BULKOUTREQLEN +# The size of the buffer in each write/read request. This +# value needs to be at least as large as the endpoint +# maxpacket and ideally as large as a block device sector. +# CONFIG_USBMSC_VENDORID and CONFIG_USBMSC_VENDORSTR +# The vendor ID code/string +# CONFIG_USBMSC_PRODUCTID and CONFIG_USBMSC_PRODUCTSTR +# The product ID code/string +# CONFIG_USBMSC_REMOVABLE +# Select if the media is removable +# +CONFIG_USBMSC=n +CONFIG_USBMSC_EP0MAXPACKET=64 +CONFIG_USBMSC_EPBULKOUT=2 +CONFIG_USBMSC_EPBULKIN=5 +CONFIG_USBMSC_NRDREQS=2 +CONFIG_USBMSC_NWRREQS=2 +CONFIG_USBMSC_BULKINREQLEN=256 +CONFIG_USBMSC_BULKOUTREQLEN=256 +CONFIG_USBMSC_VENDORID=0x584e +CONFIG_USBMSC_VENDORSTR="NuttX" +CONFIG_USBMSC_PRODUCTID=0x5342 +CONFIG_USBMSC_PRODUCTSTR="USBdev Storage" +CONFIG_USBMSC_VERSIONNO=0x0399 +CONFIG_USBMSC_REMOVABLE=y + +# +# Watchdog timer configuration +# +# CONFIG_WATCHDOG - Enable overall watchdog timer driver support. +# +# The STM32 also needs one of the following enabled: +# +# CONFIG_STM32_WWDG=y, OR +# CONFIG_STM32_IWDG=y (but not both) +# +CONFIG_WATCHDOG=n + +# +# Settings for examples/uip +# +CONFIG_EXAMPLE_UIP_IPADDR=(10<<24|0<<16|0<<8|2) +CONFIG_EXAMPLE_UIP_DRIPADDR=(10<<24|0<<16|0<<8|1) +CONFIG_EXAMPLE_UIP_NETMASK=(255<<24|255<<16|255<<8|0) +CONFIG_EXAMPLE_UIP_DHCPC=n + +# +# Settings for examples/nettest +CONFIG_EXAMPLE_NETTEST_SERVER=n +CONFIG_EXAMPLE_NETTEST_PERFORMANCE=n +CONFIG_EXAMPLE_NETTEST_NOMAC=n +CONFIG_EXAMPLE_NETTEST_IPADDR=(10<<24|0<<16|0<<8|2) +CONFIG_EXAMPLE_NETTEST_DRIPADDR=(10<<24|0<<16|0<<8|1) +CONFIG_EXAMPLE_NETTEST_NETMASK=(255<<24|255<<16|255<<8|0) +CONFIG_EXAMPLE_NETTEST_CLIENTIP=(10<<24|0<<16|0<<8|1) + +# +# Settings for examples/ostest +# +CONFIG_EXAMPLES_OSTEST_LOOPS=1 +CONFIG_EXAMPLES_OSTEST_STACKSIZE=2048 +CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=1 + +# +# Settings for apps/nshlib +# +# CONFIG_NSH_FILEIOSIZE - Size of a static I/O buffer +# CONFIG_NSH_STRERROR - Use strerror(errno) +# CONFIG_NSH_LINELEN - Maximum length of one command line +# CONFIG_NSH_NESTDEPTH - Max number of nested if-then[-else]-fi +# CONFIG_NSH_DISABLESCRIPT - Disable scripting support +# CONFIG_NSH_DISABLEBG - Disable background commands +# CONFIG_NSH_ROMFSETC - Use startup script in /etc +# CONFIG_NSH_CONSOLE - Use serial console front end +# CONFIG_NSH_TELNET - Use telnetd console front end +# CONFIG_NSH_ARCHINIT - Platform provides architecture +# specific initialization (nsh_archinitialize()). +# +# If CONFIG_NSH_TELNET is selected: +# CONFIG_NSH_IOBUFFER_SIZE -- Telnetd I/O buffer size +# CONFIG_NSH_DHCPC - Obtain address using DHCP +# CONFIG_NSH_IPADDR - Provides static IP address +# CONFIG_NSH_DRIPADDR - Provides static router IP address +# CONFIG_NSH_NETMASK - Provides static network mask +# CONFIG_NSH_NOMAC - Use a bogus MAC address +# +# If CONFIG_NSH_ROMFSETC is selected: +# CONFIG_NSH_ROMFSMOUNTPT - ROMFS mountpoint +# CONFIG_NSH_INITSCRIPT - Relative path to init script +# CONFIG_NSH_ROMFSDEVNO - ROMFS RAM device minor +# CONFIG_NSH_ROMFSSECTSIZE - ROMF sector size +# CONFIG_NSH_FATDEVNO - FAT FS RAM device minor +# CONFIG_NSH_FATSECTSIZE - FAT FS sector size +# CONFIG_NSH_FATNSECTORS - FAT FS number of sectors +# CONFIG_NSH_FATMOUNTPT - FAT FS mountpoint +# +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_STRERROR=n +CONFIG_NSH_LINELEN=64 +CONFIG_NSH_NESTDEPTH=3 +CONFIG_NSH_DISABLESCRIPT=n +CONFIG_NSH_DISABLEBG=n +CONFIG_NSH_ROMFSETC=n +CONFIG_NSH_CONSOLE=y +CONFIG_NSH_TELNET=n +CONFIG_NSH_ARCHINIT=n +CONFIG_NSH_IOBUFFER_SIZE=512 +CONFIG_NSH_DHCPC=n +CONFIG_NSH_NOMAC=n +CONFIG_NSH_IPADDR=(10<<24|0<<16|0<<8|2) +CONFIG_NSH_DRIPADDR=(10<<24|0<<16|0<<8|1) +CONFIG_NSH_NETMASK=(255<<24|255<<16|255<<8|0) +CONFIG_NSH_ROMFSMOUNTPT="/etc" +CONFIG_NSH_INITSCRIPT="init.d/rcS" +CONFIG_NSH_ROMFSDEVNO=0 +CONFIG_NSH_ROMFSSECTSIZE=64 +CONFIG_NSH_FATDEVNO=1 +CONFIG_NSH_FATSECTSIZE=512 +CONFIG_NSH_FATNSECTORS=1024 +CONFIG_NSH_FATMOUNTPT=/tmp + +# +# Architecture-specific NSH options +# +CONFIG_NSH_MMCSDSPIPORTNO=0 +CONFIG_NSH_MMCSDSLOTNO=0 +CONFIG_NSH_MMCSDMINOR=0 + +# +# Settings for examples/usbserial +# +# CONFIG_EXAMPLES_USBSERIAL_INONLY +# Only verify IN (device-to-host) data transfers. Default: both +# CONFIG_EXAMPLES_USBSERIAL_OUTONLY +# Only verify OUT (host-to-device) data transfers. Default: both +# CONFIG_EXAMPLES_USBSERIAL_ONLYSMALL +# Send only small, single packet messages. Default: Send large and small. +# CONFIG_EXAMPLES_USBSERIAL_ONLYBIG +# Send only large, multi-packet messages. Default: Send large and small. +# +CONFIG_EXAMPLES_USBSERIAL_INONLY=n +CONFIG_EXAMPLES_USBSERIAL_OUTONLY=n +CONFIG_EXAMPLES_USBSERIAL_ONLYSMALL=n +CONFIG_EXAMPLES_USBSERIAL_ONLYBIG=n + +CONFIG_EXAMPLES_USBSERIAL_TRACEINIT=n +CONFIG_EXAMPLES_USBSERIAL_TRACECLASS=n +CONFIG_EXAMPLES_USBSERIAL_TRACETRANSFERS=n +CONFIG_EXAMPLES_USBSERIAL_TRACECONTROLLER=n +CONFIG_EXAMPLES_USBSERIAL_TRACEINTERRUPTS=n + +# +# Settings for examples/watchdog +# +# This test depends on these specific Watchdog/NSH configurations settings (your +# specific watchdog hardware settings might require additional settings). +# +# CONFIG_WATCHDOG- Enables watchdog timer support support. +# CONFIG_NSH_BUILTIN_APPS - Build the watchdog time test as an NSH +# built-in function. Default: Not built! The example can only be used +# as an NSH built-in application +# +# The STM32 also needs one of the following enabled: +# +# CONFIG_STM32_WWDG=y, OR +# CONFIG_STM32_IWDG=y (but not both) +# +# Specific configuration options for this example include: +# +# CONFIG_EXAMPLES_WATCHDOG_DEVPATH - The path to the Watchdog device. +# Default: /dev/watchdog0 +# CONFIG_EXAMPLES_WATCHDOG_PINGTIME - Time in milliseconds that the example +# will ping the watchdog before letting the watchdog expire. Default: 5000 +# milliseconds +# CONFIG_EXAMPLES_WATCHDOG_PINGDELAY - Time delay between pings in +# milliseconds. Default: 500 milliseconds. +# CONFIG_EXAMPLES_WATCHDOG_TIMEOUT - The watchdog timeout value in +# milliseconds before the watchdog timer expires. Default: 2000 +# milliseconds. +# +# CONFIG_EXAMPLES_WATCHDOG_DEVPATH +# CONFIG_EXAMPLES_WATCHDOG_PINGTIME +# CONFIG_EXAMPLES_WATCHDOG_PINGDELAY +# CONFIG_EXAMPLES_WATCHDOG_TIMEOUT + +# +# Stack and heap information +# +# CONFIG_BOOT_RUNFROMFLASH - Some configurations support XIP +# operation from FLASH but must copy initialized .data sections to RAM. +# (should also be =n for the STM3210E-EVAL which always runs from flash) +# CONFIG_BOOT_COPYTORAM - Some configurations boot in FLASH +# but copy themselves entirely into RAM for better performance. +# CONFIG_CUSTOM_STACK - The up_ implementation will handle +# all stack operations outside of the nuttx model. +# CONFIG_STACK_POINTER - The initial stack pointer (arm7tdmi only) +# CONFIG_IDLETHREAD_STACKSIZE - The size of the initial stack. +# This is the thread that (1) performs the inital boot of the system up +# to the point where user_start() is spawned, and (2) there after is the +# IDLE thread that executes only when there is no other thread ready to +# run. +# CONFIG_USERMAIN_STACKSIZE - The size of the stack to allocate +# for the main user thread that begins at the user_start() entry point. +# CONFIG_PTHREAD_STACK_MIN - Minimum pthread stack size +# CONFIG_PTHREAD_STACK_DEFAULT - Default pthread stack size +# CONFIG_HEAP_BASE - The beginning of the heap +# CONFIG_HEAP_SIZE - The size of the heap +# +CONFIG_BOOT_RUNFROMFLASH=n +CONFIG_BOOT_COPYTORAM=n +CONFIG_CUSTOM_STACK=n +#CONFIG_STACK_POINTER +CONFIG_IDLETHREAD_STACKSIZE=1024 +CONFIG_USERMAIN_STACKSIZE=2048 +CONFIG_PTHREAD_STACK_MIN=256 +CONFIG_PTHREAD_STACK_DEFAULT=2048 +CONFIG_HEAP_BASE= +CONFIG_HEAP_SIZE= diff --git a/nuttx/configs/olimex-stm32-p107/ostest/setenv.sh b/nuttx/configs/olimex-stm32-p107/ostest/setenv.sh new file mode 100755 index 0000000000..009c5ce22f --- /dev/null +++ b/nuttx/configs/olimex-stm32-p107/ostest/setenv.sh @@ -0,0 +1,75 @@ +#!/bin/bash +# configs/olimex-stm32-p107/ostest/setenv.sh +# +# Copyright (C) 2009 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. +# + +if [ "$_" = "$0" ] ; then + echo "You must source this script, not run it!" 1>&2 + exit 1 +fi + +WD=`pwd` +if [ ! -x "setenv.sh" ]; then + echo "This script must be executed from the top-level NuttX build directory" + exit 1 +fi + +if [ -z "${PATH_ORIG}" ]; then + export PATH_ORIG="${PATH}" +fi + +# This the Cygwin path to the location where I installed the RIDE +# toolchain under windows. You will also have to edit this if you install +# the RIDE toolchain in any other location +#export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/Raisonance/Ride/arm-gcc/bin" + +# This the Cygwin path to the location where I installed the CodeSourcery +# toolchain under windows. You will also have to edit this if you install +# the CodeSourcery toolchain in any other location +export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/CodeSourcery/Sourcery G++ Lite/bin" + +# These are the Cygwin paths to the locations where I installed the Atollic +# toolchain under windows. You will also have to edit this if you install +# the Atollic toolchain in any other location. /usr/bin is added before +# the Atollic bin path because there is are binaries named gcc.exe and g++.exe +# at those locations as well. +#export TOOLCHAIN_BIN="/usr/bin:/cygdrive/c/Program Files (x86)/Atollic/TrueSTUDIO for ARM Pro 2.3.0/ARMTools/bin" +#export TOOLCHAIN_BIN="/usr/bin:/cygdrive/c/Program Files (x86)/Atollic/TrueSTUDIO for STMicroelectronics STM32 Lite 2.3.0/ARMTools/bin" + +# This the Cygwin path to the location where I build the buildroot +# toolchain. +#export TOOLCHAIN_BIN="${WD}/../misc/buildroot/build_arm_nofpu/staging_dir/bin" + +# Add the path to the toolchain to the PATH varialble +export PATH="${TOOLCHAIN_BIN}:/sbin:/usr/sbin:${PATH_ORIG}" + +echo "PATH : ${PATH}" diff --git a/nuttx/configs/olimex-stm32-p107/scripts/ld.script b/nuttx/configs/olimex-stm32-p107/scripts/ld.script new file mode 100644 index 0000000000..5037954bae --- /dev/null +++ b/nuttx/configs/olimex-stm32-p107/scripts/ld.script @@ -0,0 +1,106 @@ +/**************************************************************************** + * configs/olimex-stm32-p107/scripts/ld.script + * + * Copyright (C) 2009, 2011-2012 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. + * + ****************************************************************************/ + +MEMORY +{ + flash (rx) : ORIGIN = 0x08000000, LENGTH = 256K + sram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K + +} + +OUTPUT_ARCH(arm) +ENTRY(_stext) +SECTIONS +{ + .text : { + _stext = ABSOLUTE(.); + *(.vectors) + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > flash + + _eronly = ABSOLUTE(.); + + /* The STM32F107VC has 64Kb of SRAM beginning at the following address */ + + .data : { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + _edata = ABSOLUTE(.); + } > sram AT > flash + + .ARM.extab : { + *(.ARM.extab*) + } >sram + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : { + *(.ARM.exidx*) + } >sram + __exidx_end = ABSOLUTE(.); + + .bss : { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + _ebss = ABSOLUTE(.); + } > sram + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/nuttx/configs/olimex-stm32-p107/scripts/ld.script.dfu b/nuttx/configs/olimex-stm32-p107/scripts/ld.script.dfu new file mode 100644 index 0000000000..87acb12f90 --- /dev/null +++ b/nuttx/configs/olimex-stm32-p107/scripts/ld.script.dfu @@ -0,0 +1,106 @@ +/**************************************************************************** + * configs/olimex-stm32-p107/scripts/ld.script.dfu + * + * Copyright (C) 2009, 2011-2012 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. + * + ****************************************************************************/ + +/* Don't know if this is correct. Just 256K-48K (not testet) */ +MEMORY +{ + flash (rx) : ORIGIN = 0x08003000, LENGTH = 208K + sram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K +} + +OUTPUT_ARCH(arm) +ENTRY(_stext) +SECTIONS +{ + .text : { + _stext = ABSOLUTE(.); + *(.vectors) + *(.text .text.*) + *(.fixup) + *(.gnu.warning) + *(.rodata .rodata.*) + *(.gnu.linkonce.t.*) + *(.glue_7) + *(.glue_7t) + *(.got) + *(.gcc_except_table) + *(.gnu.linkonce.r.*) + _etext = ABSOLUTE(.); + } > flash + + _eronly = ABSOLUTE(.); + + /* The STM32F103Z has 64Kb of SRAM beginning at the following address */ + + .data : { + _sdata = ABSOLUTE(.); + *(.data .data.*) + *(.gnu.linkonce.d.*) + CONSTRUCTORS + _edata = ABSOLUTE(.); + } > sram AT > flash + + .ARM.extab : { + *(.ARM.extab*) + } >sram + + __exidx_start = ABSOLUTE(.); + .ARM.exidx : { + *(.ARM.exidx*) + } >sram + __exidx_end = ABSOLUTE(.); + + .bss : { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + _ebss = ABSOLUTE(.); + } > sram + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_info 0 : { *(.debug_info) } + .debug_line 0 : { *(.debug_line) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_aranges 0 : { *(.debug_aranges) } +} diff --git a/nuttx/configs/olimex-stm32-p107/src/Makefile b/nuttx/configs/olimex-stm32-p107/src/Makefile new file mode 100644 index 0000000000..85a0722f36 --- /dev/null +++ b/nuttx/configs/olimex-stm32-p107/src/Makefile @@ -0,0 +1,89 @@ +############################################################################ +# configs/olimex-stm32-p107/src/Makefile +# +# Copyright (C) 2009-2010, 2012 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. +# +############################################################################ + +-include $(TOPDIR)/Make.defs + +CFLAGS += -I$(TOPDIR)/sched + +ASRCS = +AOBJS = $(ASRCS:.S=$(OBJEXT)) + +CSRCS = up_boot.c + +ifeq ($(CONFIG_CAN),y) +CSRCS += up_can.c +endif + +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +ARCH_SRCDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src +ifeq ($(WINTOOL),y) + CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/chip}" \ + -I "${shell cygpath -w $(ARCH_SRCDIR)/common}" \ + -I "${shell cygpath -w $(ARCH_SRCDIR)/armv7-m}" +else + CFLAGS += -I$(ARCH_SRCDIR)/chip -I$(ARCH_SRCDIR)/common -I$(ARCH_SRCDIR)/armv7-m +endif + +all: libboard$(LIBEXT) + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS) $(LINKOBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +libboard$(LIBEXT): $(OBJS) + @( for obj in $(OBJS) ; do \ + $(call ARCHIVE, $@, $${obj}); \ + done ; ) + +.depend: Makefile $(SRCS) + @$(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @touch $@ + +depend: .depend + +clean: + @rm -f libboard$(LIBEXT) *~ .*.swp + $(call CLEAN) + +distclean: clean + @rm -f Make.dep .depend + +-include Make.dep diff --git a/nuttx/configs/olimex-stm32-p107/src/up_boot.c b/nuttx/configs/olimex-stm32-p107/src/up_boot.c new file mode 100644 index 0000000000..d8cba509e4 --- /dev/null +++ b/nuttx/configs/olimex-stm32-p107/src/up_boot.c @@ -0,0 +1,181 @@ +/************************************************************************************ + * configs/olimex-stm32-p107/src/up_boot.c + * arch/arm/src/board/up_boot.c + * + * Copyright (C) 2009, 2012 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 "up_arch.h" + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ + +/************************************************************************************ + * Private Functions + ************************************************************************************/ + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: stm32_boardinitialize + * + * Description: + * All STM32 architectures must provide the following entry point. This entry point + * is called early in the intitialization -- after all memory has been configured + * and mapped but before any devices have been initialized. + * + ************************************************************************************/ + +void stm32_boardinitialize(void) +{ +} + +/************************************************************************************ + * Name: stm32_board_clockconfig + * + * Description: + * Any STM32 board may replace the "standard" board clock configuration logic with + * its own, custom clock cofiguration logic. + * + ************************************************************************************/ + +#ifdef CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG +void stm32_board_clockconfig(void) +{ + uint32_t regval; + + regval = getreg32(STM32_RCC_CR); + regval &= ~RCC_CR_HSEBYP; /* Disable HSE clock bypass */ + regval |= RCC_CR_HSEON; /* Enable HSE */ + putreg32(regval, STM32_RCC_CR); + + /* Set flash wait states + * Sysclk runs with 72MHz -> 2 waitstates. + * 0WS from 0-24MHz + * 1WS from 24-48MHz + * 2WS from 48-72MHz + */ + + regval = getreg32(STM32_FLASH_ACR); + regval &= ~FLASH_ACR_LATENCY_MASK; + regval |= (FLASH_ACR_LATENCY_2|FLASH_ACR_PRTFBE); + putreg32(regval, STM32_FLASH_ACR); + + regval = getreg32(STM32_RCC_CFGR2); + regval &= ~(RCC_CFGR2_PREDIV2_MASK + | RCC_CFGR2_PLL2MUL_MASK + | RCC_CFGR2_PREDIV1SRC_MASK + | RCC_CFGR2_PREDIV1_MASK); + regval |= RCC_CFGR2_PREDIV2d5; /* 25MHz / 5 */ + regval |= RCC_CFGR2_PLL2MULx8; /* 5MHz * 8 => 40MHz */ + regval |= RCC_CFGR2_PREDIV1SRC_PLL2; /* Use PLL2 as input for PREDIV1 */ + regval |= RCC_CFGR2_PREDIV1d5; /* 40MHz / 5 => 8MHz */ + putreg32(regval, STM32_RCC_CFGR2); + + /* Set the PCLK2 divider */ + + regval = getreg32(STM32_RCC_CFGR); + regval &= ~(RCC_CFGR_PPRE2_MASK | RCC_CFGR_HPRE_MASK); + regval |= STM32_RCC_CFGR_PPRE2; + regval |= RCC_CFGR_HPRE_SYSCLK; + putreg32(regval, STM32_RCC_CFGR); + + /* Set the PCLK1 divider */ + + regval = getreg32(STM32_RCC_CFGR); + regval &= ~RCC_CFGR_PPRE1_MASK; + regval |= STM32_RCC_CFGR_PPRE1; + putreg32(regval, STM32_RCC_CFGR); + + regval = getreg32(STM32_RCC_CR); + regval |= RCC_CR_PLL2ON; + putreg32(regval, STM32_RCC_CR); + + /* Wait for PLL2 ready */ + + while((getreg32(STM32_RCC_CR) & RCC_CR_PLL2RDY) == 0); + + /* Setup PLL3 for RMII clock on MCO */ + + regval = getreg32(STM32_RCC_CFGR2); + regval &= ~(RCC_CFGR2_PLL3MUL_MASK); + regval |= RCC_CFGR2_PLL3MULx10; + putreg32(regval, STM32_RCC_CFGR2); + + /* Switch PLL3 on */ + + regval = getreg32(STM32_RCC_CR); + regval |= RCC_CR_PLL3ON; + putreg32(regval, STM32_RCC_CR); + + while ((getreg32(STM32_RCC_CR) & RCC_CR_PLL3RDY) == 0); + + /* Set main PLL source 8MHz * 9 => 72MHz*/ + + regval = getreg32(STM32_RCC_CFGR); + regval &= ~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLMUL_MASK); + regval |= (RCC_CFGR_PLLSRC | RCC_CFGR_PLLMUL_CLKx9); + putreg32(regval, STM32_RCC_CFGR); + + /* Switch main PLL on */ + + regval = getreg32(STM32_RCC_CR); + regval |= RCC_CR_PLLON; + putreg32(regval, STM32_RCC_CR); + + while ((getreg32(STM32_RCC_CR) & RCC_CR_PLLRDY) == 0); + + /* Select PLL as system clock source */ + + regval = getreg32(STM32_RCC_CFGR); + regval &= ~RCC_CFGR_SW_MASK; + regval |= RCC_CFGR_SW_PLL; + putreg32(regval, STM32_RCC_CFGR); + + /* Wait until PLL is used as the system clock source */ + + while ((getreg32(STM32_RCC_CFGR) & RCC_CFGR_SWS_PLL) == 0); +} +#endif diff --git a/nuttx/configs/olimex-stm32-p107/src/up_can.c b/nuttx/configs/olimex-stm32-p107/src/up_can.c new file mode 100644 index 0000000000..f750092a3f --- /dev/null +++ b/nuttx/configs/olimex-stm32-p107/src/up_can.c @@ -0,0 +1,132 @@ +/************************************************************************************ + * configs/olimex-stm32-p107/src/up_can.c + * + * Copyright (C) 2012 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 + +#include "chip.h" +#include "up_arch.h" + +#include "stm32.h" +#include "stm32_can.h" + +#if defined(CONFIG_CAN) && (defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2)) + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ +/* Configuration ********************************************************************/ +/* The STM32F107VC supports CAN1 and CAN2 */ + +#define CAN_PORT 1 + +/* Debug ***************************************************************************/ +/* Non-standard debug that may be enabled just for testing CAN */ + +#ifdef CONFIG_DEBUG_CAN +# define candbg dbg +# define canvdbg vdbg +# define canlldbg lldbg +# define canllvdbg llvdbg +#else +# define candbg(x...) +# define canvdbg(x...) +# define canlldbg(x...) +# define canllvdbg(x...) +#endif + +/************************************************************************************ + * Private Functions + ************************************************************************************/ + +/************************************************************************************ + * Public Functions + ************************************************************************************/ + +/************************************************************************************ + * Name: can_devinit + * + * Description: + * All STM32 architectures must provide the following interface to work with + * examples/can. + * + ************************************************************************************/ + +int can_devinit(void) +{ + static bool initialized = false; + struct can_dev_s *can; + int ret; + + /* Check if we have already initialized */ + + if (!initialized) + { + /* Call stm32_caninitialize() to get an instance of the CAN interface */ + + can = stm32_caninitialize(CAN_PORT); + if (can == NULL) + { + candbg("ERROR: Failed to get CAN interface\n"); + return -ENODEV; + } + + /* Register the CAN driver at "/dev/can0" */ + + ret = can_register("/dev/can0", can); + if (ret < 0) + { + candbg("ERROR: can_register failed: %d\n", ret); + return ret; + } + + /* Now we are initialized */ + + initialized = true; + } + + return OK; +} + +#endif /* CONFIG_CAN && CONFIG_STM32_CAN1 */ diff --git a/nuttx/configs/vsn/include/board.h b/nuttx/configs/vsn/include/board.h index 9fa58de004..f2c6f48cb3 100644 --- a/nuttx/configs/vsn/include/board.h +++ b/nuttx/configs/vsn/include/board.h @@ -45,6 +45,7 @@ ************************************************************************************/ #include + #ifndef __ASSEMBLY__ # include #endif @@ -54,7 +55,6 @@ #include "muxbus.h" - /************************************************************************************ * Definitions ************************************************************************************/ @@ -88,9 +88,9 @@ /* AHB clock (HCLK, 36 MHz) is SYSCLK on HSI or SYSCLK/2 on HSE */ -#define STM32_RCC_CFGR_HPRE_HSI RCC_CFGR_HPRE_SYSCLK -#define STM32_RCC_CFGR_HPRE_HSE RCC_CFGR_HPRE_SYSCLKd2 -#define STM32_HCLK_FREQUENCY STM32_BOARD_HCLK +#define STM32_RCC_CFGR_HPRE_HSI RCC_CFGR_HPRE_SYSCLK +#define STM32_RCC_CFGR_HPRE_HSE RCC_CFGR_HPRE_SYSCLKd2 +#define STM32_HCLK_FREQUENCY STM32_BOARD_HCLK /* APB2 clock (PCLK2) is HCLK (36MHz) */ @@ -179,7 +179,7 @@ #define LED_SIGNAL 5 /* ... */ #define LED_ASSERTION 6 /* ... */ #define LED_PANIC 7 /* ... */ -#define LED_IDLE 8 /* shows idle state */ +#define LED_IDLE 8 /* shows idle state */ /************************************************************************************ @@ -200,9 +200,6 @@ extern "C" { * Board Clock Configuration, called immediatelly after boot ************************************************************************************/ -EXTERN void stm32_board_clockconfig(void); - - /************************************************************************************ * Name: stm32_boardinitialize * @@ -215,6 +212,18 @@ EXTERN void stm32_board_clockconfig(void); EXTERN void stm32_boardinitialize(void); +/************************************************************************************ + * Name: stm32_board_clockconfig + * + * Description: + * Any STM32 board may replace the "standard" board clock configuration logic with + * its own, custom clock cofiguration logic. + * + ************************************************************************************/ + +#ifdef CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG +EXTERN void stm32_board_clockconfig(void); +#endif /************************************************************************************ * Button support. (TODO: button is not yet supported) @@ -225,7 +234,6 @@ EXTERN void up_buttoninit(void); EXTERN uint8_t up_buttons(void); #endif - #undef EXTERN #if defined(__cplusplus) } From 7189150b33612e4c91f6d9ec08a00fdfe0eece65 Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 10 Aug 2012 22:01:12 +0000 Subject: [PATCH 11/13] STM32 SDIO DMA setup was losing DMA priority git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5019 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/ChangeLog | 5 +++- nuttx/arch/arm/src/stm32/stm32_serial.c | 25 ++++++++++++++++ nuttx/arch/arm/src/stm32/stm32_spi.c | 33 ++++++++++++++++++++-- nuttx/arch/arm/src/stm32/stm32f20xxx_dma.c | 4 +-- nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c | 4 +-- 5 files changed, 64 insertions(+), 7 deletions(-) diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index c6ce0f1307..a5da942f38 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3143,4 +3143,7 @@ * arch/arm/*/stm32: Add support for STM32 F107 "Connectivity Line" Ethernet (contributed by Max Holtzberg). * configs/olimex-stm32-p107: Add board support for the Olimiex STM32-P107 - board (contributed by Max Holtzberg). \ No newline at end of file + board (contributed by Max Holtzberg). + * arch/arm/src/stm32/stm32f2xx_dma.c, stm32f4xx_dma.c, stm32_serial.c, and + stm32_spic.c: DMA priority was getting zeroed by STM32 F2/F4 DMA drivers + so that all DMAs ran at the lowest priority. diff --git a/nuttx/arch/arm/src/stm32/stm32_serial.c b/nuttx/arch/arm/src/stm32/stm32_serial.c index 01c519b399..265abfbf35 100644 --- a/nuttx/arch/arm/src/stm32/stm32_serial.c +++ b/nuttx/arch/arm/src/stm32/stm32_serial.c @@ -132,6 +132,30 @@ */ # define RXDMA_BUFFER_SIZE 32 + +/* DMA priority */ + +# ifndef CONFIG_USART_DMAPRIO +# if defined(CONFIG_STM32_STM32F10XX) +# define CONFIG_USART_DMAPRIO DMA_CCR_PRIMED +# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# define CONFIG_USART_DMAPRIO DMA_SCR_PRIMED +# else +# error "Unknown STM32 DMA" +# endif +# endif +# if defined(CONFIG_STM32_STM32F10XX) +# if (CONFIG_USART_DMAPRIO & ~DMA_CCR_PL_MASK) != 0 +# error "Illegal value for CONFIG_USART_DMAPRIO" +# endif +# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# if (CONFIG_USART_DMAPRIO & ~DMA_SCR_PL_MASK) != 0 +# error "Illegal value for CONFIG_USART_DMAPRIO" +# endif +# else +# error "Unknown STM32 DMA" +# endif + #endif /* Power management definitions */ @@ -975,6 +999,7 @@ static int up_dma_setup(struct uart_dev_s *dev) DMA_SCR_MINC | DMA_SCR_PSIZE_8BITS | DMA_SCR_MSIZE_8BITS | + CONFIG_USART_DMAPRIO | DMA_SCR_PBURST_SINGLE | DMA_SCR_MBURST_SINGLE); diff --git a/nuttx/arch/arm/src/stm32/stm32_spi.c b/nuttx/arch/arm/src/stm32/stm32_spi.c index 7fdd988cbb..06a994524c 100644 --- a/nuttx/arch/arm/src/stm32/stm32_spi.c +++ b/nuttx/arch/arm/src/stm32/stm32_spi.c @@ -88,18 +88,47 @@ * Definitions ************************************************************************************/ /* Configuration ********************************************************************/ +/* SPI interrupts */ #ifdef CONFIG_STM32_SPI_INTERRUPTS # error "Interrupt driven SPI not yet supported" #endif +/* Can't have both interrupt driven SPI and SPI DMA */ + #if defined(CONFIG_STM32_SPI_INTERRUPTS) && defined(CONFIG_STM32_SPI_DMA) # error "Cannot enable both interrupt mode and DMA mode for SPI" #endif -/* DMA channel configuration */ +/* SPI DMA priority */ -#define SPI_DMA_PRIO DMA_CCR_PRIMED /* Check this to alter priority */ +#ifdef CONFIG_STM32_SPI_DMA + +# if defined(CONFIG_SPI_DMAPRIO) +# define SPI_DMA_PRIO CONFIG_SPI_DMAPRIO +# elif defined(CONFIG_STM32_STM32F10XX) +# define SPI_DMA_PRIO DMA_CCR_PRIMED +# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# define SPI_DMA_PRIO DMA_SCR_PRIMED +# else +# error "Unknown STM32 DMA" +# endif + +# if defined(CONFIG_STM32_STM32F10XX) +# if (SPI_DMA_PRIO & ~DMA_CCR_PL_MASK) != 0 +# error "Illegal value for CONFIG_SPI_DMAPRIO" +# endif +# elif defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# if (SPI_DMA_PRIO & ~DMA_SCR_PL_MASK) != 0 +# error "Illegal value for CONFIG_SPI_DMAPRIO" +# endif +# else +# error "Unknown STM32 DMA" +# endif + +#endif + +/* DMA channel configuration */ #define SPI_RXDMA16_CONFIG (SPI_DMA_PRIO|DMA_CCR_MSIZE_16BITS|DMA_CCR_PSIZE_16BITS|DMA_CCR_MINC ) #define SPI_RXDMA8_CONFIG (SPI_DMA_PRIO|DMA_CCR_MSIZE_8BITS |DMA_CCR_PSIZE_8BITS |DMA_CCR_MINC ) diff --git a/nuttx/arch/arm/src/stm32/stm32f20xxx_dma.c b/nuttx/arch/arm/src/stm32/stm32f20xxx_dma.c index 7e3ece2fa7..e69f6d329b 100644 --- a/nuttx/arch/arm/src/stm32/stm32f20xxx_dma.c +++ b/nuttx/arch/arm/src/stm32/stm32f20xxx_dma.c @@ -721,11 +721,11 @@ void stm32_dmasetup(DMA_HANDLE handle, uint32_t paddr, uint32_t maddr, regval = dmast_getreg(dmast, STM32_DMA_SCR_OFFSET); regval &= ~(DMA_SCR_PFCTRL|DMA_SCR_DIR_MASK|DMA_SCR_PINC|DMA_SCR_MINC| DMA_SCR_PSIZE_MASK|DMA_SCR_MSIZE_MASK|DMA_SCR_PINCOS| - DMA_SCR_CIRC|DMA_SCR_DBM|DMA_SCR_CT| + DMA_SCR_CIRC|DMA_SCR_DBM|DMA_SCR_CT|DMA_SCR_PL_MASK| DMA_SCR_PBURST_MASK|DMA_SCR_MBURST_MASK); scr &= (DMA_SCR_PFCTRL|DMA_SCR_DIR_MASK|DMA_SCR_PINC|DMA_SCR_MINC| DMA_SCR_PSIZE_MASK|DMA_SCR_MSIZE_MASK|DMA_SCR_PINCOS| - DMA_SCR_DBM|DMA_SCR_CIRC| + DMA_SCR_DBM|DMA_SCR_CIRC|DMA_SCR_PL_MASK| DMA_SCR_PBURST_MASK|DMA_SCR_MBURST_MASK); regval |= scr; dmast->nonstop = (scr & (DMA_SCR_DBM|DMA_SCR_CIRC)) != 0; diff --git a/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c b/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c index c3555d7147..dce340ff9c 100644 --- a/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c +++ b/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c @@ -721,11 +721,11 @@ void stm32_dmasetup(DMA_HANDLE handle, uint32_t paddr, uint32_t maddr, regval = dmast_getreg(dmast, STM32_DMA_SCR_OFFSET); regval &= ~(DMA_SCR_PFCTRL|DMA_SCR_DIR_MASK|DMA_SCR_PINC|DMA_SCR_MINC| DMA_SCR_PSIZE_MASK|DMA_SCR_MSIZE_MASK|DMA_SCR_PINCOS| - DMA_SCR_CIRC|DMA_SCR_DBM|DMA_SCR_CT| + DMA_SCR_CIRC|DMA_SCR_DBM|DMA_SCR_CT|DMA_SCR_PL_MASK| DMA_SCR_PBURST_MASK|DMA_SCR_MBURST_MASK); scr &= (DMA_SCR_PFCTRL|DMA_SCR_DIR_MASK|DMA_SCR_PINC|DMA_SCR_MINC| DMA_SCR_PSIZE_MASK|DMA_SCR_MSIZE_MASK|DMA_SCR_PINCOS| - DMA_SCR_DBM|DMA_SCR_CIRC| + DMA_SCR_DBM|DMA_SCR_CIRC|DMA_SCR_PL_MASK| DMA_SCR_PBURST_MASK|DMA_SCR_MBURST_MASK); regval |= scr; dmast->nonstop = (scr & (DMA_SCR_DBM|DMA_SCR_CIRC)) != 0; From 850df30e06d5384081371d6b291cbadec2e2fd48 Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 10 Aug 2012 22:42:46 +0000 Subject: [PATCH 12/13] Drop STM32 F2/4 SDIO clock from 24 to 16 MHz. Seems to fix SD accesses on STM3240G-EVAL git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5020 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/ChangeLog | 4 ++++ nuttx/arch/arm/src/stm32/stm32f20xxx_dma.c | 1 + nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c | 1 + nuttx/configs/stm3220g-eval/include/board.h | 4 ++-- nuttx/configs/stm3240g-eval/include/board.h | 4 ++-- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index a5da942f38..3889dcd228 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3147,3 +3147,7 @@ * arch/arm/src/stm32/stm32f2xx_dma.c, stm32f4xx_dma.c, stm32_serial.c, and stm32_spic.c: DMA priority was getting zeroed by STM32 F2/F4 DMA drivers so that all DMAs ran at the lowest priority. + * configs/stm3240g-eval/include/board.h and configs/stm3220: Drop SD card + frequency from 24 to 16 MHz. Apparently 24 MHz is too fast for the board. + This (plus the change to the STM32 DMA (above) fixes SDIO DMA on the + STM3240G-EVAL (and probably STM3220G-EVAL -- untested). diff --git a/nuttx/arch/arm/src/stm32/stm32f20xxx_dma.c b/nuttx/arch/arm/src/stm32/stm32f20xxx_dma.c index e69f6d329b..f0d6bb4cd2 100644 --- a/nuttx/arch/arm/src/stm32/stm32f20xxx_dma.c +++ b/nuttx/arch/arm/src/stm32/stm32f20xxx_dma.c @@ -783,6 +783,7 @@ void stm32_dmastart(DMA_HANDLE handle, dma_callback_t callback, void *arg, bool * mode to determine when the buffer is half-full, or in double-buffered * mode to determine when one of the two buffers is full. */ + scr |= (half ? DMA_SCR_HTIE : 0) | DMA_SCR_TCIE | DMA_SCR_TEIE; } diff --git a/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c b/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c index dce340ff9c..907650b1df 100644 --- a/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c +++ b/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c @@ -783,6 +783,7 @@ void stm32_dmastart(DMA_HANDLE handle, dma_callback_t callback, void *arg, bool * mode to determine when the buffer is half-full, or in double-buffered * mode to determine when one of the two buffers is full. */ + scr |= (half ? DMA_SCR_HTIE : 0) | DMA_SCR_TCIE | DMA_SCR_TEIE; } diff --git a/nuttx/configs/stm3220g-eval/include/board.h b/nuttx/configs/stm3220g-eval/include/board.h index be9bb886dd..dc2f04b9e4 100644 --- a/nuttx/configs/stm3220g-eval/include/board.h +++ b/nuttx/configs/stm3220g-eval/include/board.h @@ -185,12 +185,12 @@ # define SDIO_MMCXFR_CLKDIV (2 << SDIO_CLKCR_CLKDIV_SHIFT) #endif -/* DMA ON: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(0+2)= 24 MHz +/* DMA ON: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(1+2)= 16 MHz * DMA OFF: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(2+2)= 12 MHz */ #ifdef CONFIG_SDIO_DMA -# define SDIO_SDXFR_CLKDIV (0 << SDIO_CLKCR_CLKDIV_SHIFT) +# define SDIO_SDXFR_CLKDIV (1 << SDIO_CLKCR_CLKDIV_SHIFT) #else # define SDIO_SDXFR_CLKDIV (2 << SDIO_CLKCR_CLKDIV_SHIFT) #endif diff --git a/nuttx/configs/stm3240g-eval/include/board.h b/nuttx/configs/stm3240g-eval/include/board.h index a438dcc1bb..6583552633 100755 --- a/nuttx/configs/stm3240g-eval/include/board.h +++ b/nuttx/configs/stm3240g-eval/include/board.h @@ -182,12 +182,12 @@ # define SDIO_MMCXFR_CLKDIV (2 << SDIO_CLKCR_CLKDIV_SHIFT) #endif -/* DMA ON: HSDIOCLK=48MHz, SDIO_CK=SDIOCLK/(0+2)=24 MHz +/* DMA ON: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(1+2)=16 MHz * DMA OFF: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(2+2)=12 MHz */ #ifdef CONFIG_SDIO_DMA -# define SDIO_SDXFR_CLKDIV (0 << SDIO_CLKCR_CLKDIV_SHIFT) +# define SDIO_SDXFR_CLKDIV (1 << SDIO_CLKCR_CLKDIV_SHIFT) #else # define SDIO_SDXFR_CLKDIV (2 << SDIO_CLKCR_CLKDIV_SHIFT) #endif From 0512367a9c707f26b9a2b9057cf64714f46a0dc4 Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 10 Aug 2012 23:16:01 +0000 Subject: [PATCH 13/13] Back out the last STM32 DMA priority change. It is not necessary; just dropping the SD frequency was sufficient git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5021 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/ChangeLog | 3 +++ nuttx/arch/arm/src/stm32/stm32f20xxx_dma.c | 4 ++-- nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 3889dcd228..364de21a3d 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3151,3 +3151,6 @@ frequency from 24 to 16 MHz. Apparently 24 MHz is too fast for the board. This (plus the change to the STM32 DMA (above) fixes SDIO DMA on the STM3240G-EVAL (and probably STM3220G-EVAL -- untested). + * arch/arm/src/stm32/stm32f2xx_dma.c and stm32f4xx_dma.c: Backed out the + DMA priority change just above. The reduced SD card frequency was + necessary and sufficient to resolve the problem. diff --git a/nuttx/arch/arm/src/stm32/stm32f20xxx_dma.c b/nuttx/arch/arm/src/stm32/stm32f20xxx_dma.c index f0d6bb4cd2..55aab352f1 100644 --- a/nuttx/arch/arm/src/stm32/stm32f20xxx_dma.c +++ b/nuttx/arch/arm/src/stm32/stm32f20xxx_dma.c @@ -721,11 +721,11 @@ void stm32_dmasetup(DMA_HANDLE handle, uint32_t paddr, uint32_t maddr, regval = dmast_getreg(dmast, STM32_DMA_SCR_OFFSET); regval &= ~(DMA_SCR_PFCTRL|DMA_SCR_DIR_MASK|DMA_SCR_PINC|DMA_SCR_MINC| DMA_SCR_PSIZE_MASK|DMA_SCR_MSIZE_MASK|DMA_SCR_PINCOS| - DMA_SCR_CIRC|DMA_SCR_DBM|DMA_SCR_CT|DMA_SCR_PL_MASK| + DMA_SCR_CIRC|DMA_SCR_DBM|DMA_SCR_CT| DMA_SCR_PBURST_MASK|DMA_SCR_MBURST_MASK); scr &= (DMA_SCR_PFCTRL|DMA_SCR_DIR_MASK|DMA_SCR_PINC|DMA_SCR_MINC| DMA_SCR_PSIZE_MASK|DMA_SCR_MSIZE_MASK|DMA_SCR_PINCOS| - DMA_SCR_DBM|DMA_SCR_CIRC|DMA_SCR_PL_MASK| + DMA_SCR_DBM|DMA_SCR_CIRC| DMA_SCR_PBURST_MASK|DMA_SCR_MBURST_MASK); regval |= scr; dmast->nonstop = (scr & (DMA_SCR_DBM|DMA_SCR_CIRC)) != 0; diff --git a/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c b/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c index 907650b1df..dcbbf1856f 100644 --- a/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c +++ b/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c @@ -721,11 +721,11 @@ void stm32_dmasetup(DMA_HANDLE handle, uint32_t paddr, uint32_t maddr, regval = dmast_getreg(dmast, STM32_DMA_SCR_OFFSET); regval &= ~(DMA_SCR_PFCTRL|DMA_SCR_DIR_MASK|DMA_SCR_PINC|DMA_SCR_MINC| DMA_SCR_PSIZE_MASK|DMA_SCR_MSIZE_MASK|DMA_SCR_PINCOS| - DMA_SCR_CIRC|DMA_SCR_DBM|DMA_SCR_CT|DMA_SCR_PL_MASK| + DMA_SCR_CIRC|DMA_SCR_DBM|DMA_SCR_CT| DMA_SCR_PBURST_MASK|DMA_SCR_MBURST_MASK); scr &= (DMA_SCR_PFCTRL|DMA_SCR_DIR_MASK|DMA_SCR_PINC|DMA_SCR_MINC| DMA_SCR_PSIZE_MASK|DMA_SCR_MSIZE_MASK|DMA_SCR_PINCOS| - DMA_SCR_DBM|DMA_SCR_CIRC|DMA_SCR_PL_MASK| + DMA_SCR_DBM|DMA_SCR_CIRC| DMA_SCR_PBURST_MASK|DMA_SCR_MBURST_MASK); regval |= scr; dmast->nonstop = (scr & (DMA_SCR_DBM|DMA_SCR_CIRC)) != 0;