diff --git a/ChangeLog b/ChangeLog
index a424504ad5c5a53b5b491c56cac4ca23e4a55d48..9aa4e40face7e928007196db8e48288b124d6509 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1231,3 +1231,19 @@
 	  the arch/arm/src/Makefile for now.
 	* arch/arm/src/lpc17xx/lpc17_internal.h - Add missing parentheses in
 	  macros definitions (patch submitted by Tiago Maluta).
+	* Documents/NuttxPortingGuide.html, configs/README.txt, etc. -
+	  Replaced CONFIG_EXAMPLE with CONFIG_APP_DIR (see documents for
+	  desciption).  This allows NuttX application code to be built
+	  outside of the examples/ directory.
+
+	  For people who have their own configurations and/or Makefiles,
+	  you will need to make a couple of changes:
+
+          - Replace all occurrences of CONFIG_EXAMPLE=foobar with
+	    CONFIG_APP_DIR=examples/foobar in all of the configuration
+	    files.
+	  - Replace any occurrences of examples/$(CONFIG_EXAMPLE) with
+	    $(CONFIG_APP_DIR)
+	  - Replace any occurrences of lib$(CONFIG_EXAMPLE)$(LIBEXT)
+	    with libapp$(LIBEXT) in your Makefiles.
+	  - Check any other occurrences of CONFIG_EXAMPLE.
diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html
index f7f2e499c3a5f583eb7e43b9eddfd0ae9dd7ee47..80b7d5bd16587dbe0b499a94a1444cefb8af2103 100644
--- a/Documentation/NuttX.html
+++ b/Documentation/NuttX.html
@@ -8,7 +8,7 @@
   <tr align="center" bgcolor="#e4e4e4">
     <td>
       <h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
-      <p>Last Updated: August 27, 2010</p>
+      <p>Last Updated: August 28, 2010</p>
     </td>
   </tr>
 </table>
@@ -1903,8 +1903,22 @@ nuttx-5.10 2010-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
 	  the arch/arm/src/Makefile for now.
 	* arch/arm/src/lpc17xx/lpc17_internal.h - Add missing parentheses in
 	  macros definitions (patch submitted by Tiago Maluta).
-
-pascal-2.1 2010-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
+	* Documents/NuttxPortingGuide.html, configs/README.txt, etc. -
+	  Replaced CONFIG_EXAMPLE with CONFIG_APP_DIR (see documents for
+	  desciption).  This allows NuttX application code to be built
+	  outside of the examples/ directory.
+
+	  For people who have their own configurations and/or Makefiles,
+	  you will need to make a couple of changes:
+
+          - Replace all occurrences of CONFIG_EXAMPLE=foobar with
+	    CONFIG_APP_DIR=examples/foobar in all of the configuration
+	    files.
+	  - Replace any occurrences of examples/$(CONFIG_EXAMPLE) with
+	    $(CONFIG_APP_DIR)
+	  - Replace any occurrences of lib$(CONFIG_EXAMPLE)$(LIBEXT)
+	    with libapp$(LIBEXT) in your Makefiles.
+	  - Check any other occurrences of CONFIG_EXAMPLE.pascal-2.1 2010-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
 
 buildroot-1.9 2010-xx-xx <spudmonkey@racsa.co.cr>
 </pre></ul>
diff --git a/Documentation/NuttxPortingGuide.html b/Documentation/NuttxPortingGuide.html
index 0df7896996ab59693d5ab92645e81bae6497a21d..2f3d8af8f7b8cf2b373e4dc7e256ea2cf598a2bc 100644
--- a/Documentation/NuttxPortingGuide.html
+++ b/Documentation/NuttxPortingGuide.html
@@ -12,7 +12,7 @@
       <h1><big><font color="#3c34ec">
         <i>NuttX RTOS Porting Guide</i>
       </font></big></h1>
-      <p>Last Updated: August 27, 2010</p>
+      <p>Last Updated: August 29, 2010</p>
     </td>
   </tr>
 </table>
@@ -2178,6 +2178,7 @@ extern void up_ledoff(int led);
     The start address of DRAM (virtual)</li>
 </ul>
 
+<h2>Build Options</h2>
 <p>
   General build options:
 </p>
@@ -2206,9 +2207,9 @@ extern void up_ledoff(int led);
     have been defined in the configurations <code>Make.defs</code> file.
   </li>
 </ul>
-
-<h2>General OS setup</h2>
-
+<p>
+  Building application code:
+</p>
 <ul>
   <li>
     <p>
@@ -2261,6 +2262,38 @@ build
       It can be used, for example, to include makefile fragments (e.g., <code>.config</code> or <code>Make.defs</code>) or to set up include file paths.
     </p>
   </li>
+</ul>
+<p>
+  Two-pass Build Options.
+  If the 2 pass build option is selected, then these options configure the make system build a extra link object.
+  This link object is assumed to be an incremental (relative) link object, but could be a static library (archive)
+  (some modification to this Makefile would be required if CONFIG_PASS1_OBJECT is an archive).
+  Pass 1 1ncremental (relative) link objects should be put into the processor-specific source directory 
+  where other link objects will be created - ff the pass1 obect is an archive, it could	go anywhere.
+</p>
+<ul>
+  <li>
+    <code>CONFIG_BUILD_2PASS</code>:
+      Enables the two pass build options.
+  </li>
+</ul>
+<p>
+  When the two pass build option is enabled, the following also apply:
+</p>
+<ul>
+  <li>
+    <code>CONFIG_PASS1_OBJECT</code>: The name of the first pass object.
+  </li>
+  <li><code>CONFIG_PASS1_BUILDIR</code>:
+  The path, relative to the top NuttX build directory to directory that contains the Makefile to build the first pass object.
+  The Makefile must support the following targets:
+  <ul>
+    <li>The special target <code>arch/$(CONFIG_ARCH)/src/$(CONFIG_PASS1_OBJECT)</code>, and</li>
+    <li>The usual depend, clean, and distclean targets.</li>
+  </ul>
+</ul>
+
+<h2>General OS setup</h2>
   <li>
     <code>CONFIG_DEBUG</code>: enables built-in debug options
   </li>
@@ -2434,7 +2467,8 @@ build
 </ul>
 
 <p>
-  If CONFIG_PAGING is selected, then the following also apply:
+  If CONFIG_PAGING is selected, then you will probabaly need <code>CONFIG_BUILD_2PASS</code> to correctly position
+  the code and the following configuration options also apply:
 </p>
 <ul>
   <li>
diff --git a/Makefile b/Makefile
index 90bd2f202e002bc1733bc6c9eece239f4bb3bdde..7b71b7298a9750d00c5c1c51f4a41f8b09a44d51 100644
--- a/Makefile
+++ b/Makefile
@@ -101,10 +101,15 @@ MAKEDIRS	+= $(FSDIRS)
 endif
 
 #
-# Extra objects used in the final link
+# Extra objects used in the final link.
+#
+# Pass 1 1ncremental (relative) link objects should be put into the
+# processor-specific source directory (where other link objects will
+# be created).  If the pass1 obect is an archive, it could go anywhere.
 
 ifeq ($(CONFIG_BUILD_2PASS),y)
-EXTRA_OBJS	= $(TOPDIR)/$(CONFIG_PASS1_DIR)/$(CONFIG_PASS1_LIB)
+#EXTRA_OBJS	= $(TOPDIR)/$(CONFIG_PASS1_BUILDIR)/$(CONFIG_PASS1_OBJECT)
+EXTRA_OBJS	+= $(CONFIG_PASS1_OBJECT)
 endif
 
 # LINKLIBS is the list of NuttX libraries that is passed to the
@@ -256,25 +261,31 @@ graphics/libgraphics$(LIBEXT): context
 $(CONFIG_APP_DIR)/libapp$(LIBEXT): context
 	@$(MAKE) -C $(CONFIG_APP_DIR) TOPDIR="$(TOPDIR)" libapp$(LIBEXT)
 
+# If the 2 pass build option is selected, then this pass1 target is
+# configured be build a extra link object. This is assumed to be an
+# incremental (relative) link object, but could be a static library
+# (archive); some modification to this Makefile would be required if
+# CONFIG_PASS1_OBJECT is an archive.
+
 pass1:
 ifeq ($(CONFIG_BUILD_2PASS),y)
-	@if [ -z "$(CONFIG_PASS1_LIB)" ]; then \
-		echo "ERROR: CONFIG_PASS1_LIB not defined"; \
+	@if [ -z "$(CONFIG_PASS1_OBJECT)" ]; then \
+		echo "ERROR: CONFIG_PASS1_OBJECT not defined"; \
 		exit 1; \
 	fi
-	@if [ -z "$(CONFIG_PASS1_DIR)" ]; then \
-		echo "ERROR: CONFIG_PASS1_DIR not defined"; \
+	@if [ -z "$(CONFIG_PASS1_BUILDIR)" ]; then \
+		echo "ERROR: CONFIG_PASS1_BUILDIR not defined"; \
 		exit 1; \
 	fi
-	@if [ ! -d "$(CONFIG_PASS1_DIR)" ]; then \
-		echo "ERROR: CONFIG_PASS1_DIR does not exist"; \
+	@if [ ! -d "$(CONFIG_PASS1_BUILDIR)" ]; then \
+		echo "ERROR: CONFIG_PASS1_BUILDIR does not exist"; \
 		exit 1; \
 	fi
-	@if [ ! -f "$(CONFIG_PASS1_DIR)/Makefile" ]; then \
-		echo "ERROR: No Makefile in CONFIG_PASS1_DIR"; \
+	@if [ ! -f "$(CONFIG_PASS1_BUILDIR)/Makefile" ]; then \
+		echo "ERROR: No Makefile in CONFIG_PASS1_BUILDIR"; \
 		exit 1; \
 	fi
-	@$(MAKE) -C $(CONFIG_PASS1_DIR) TOPDIR="$(TOPDIR)" LINKLIBS="$(LINKLIBS)" $(CONFIG_PASS1_LIB)
+	@$(MAKE) -C $(CONFIG_PASS1_BUILDIR) TOPDIR="$(TOPDIR)" LINKLIBS="$(LINKLIBS)" "$(ARCH_SRC)/$(CONFIG_PASS1_OBJECT)"
 endif
 
 $(BIN):	context depend $(LINKLIBS) pass1
@@ -312,7 +323,7 @@ subdir_clean:
 	@$(MAKE) -C tools -f Makefile.mkconfig TOPDIR="$(TOPDIR)" clean
 	@$(MAKE) -C mm -f Makefile.test TOPDIR="$(TOPDIR)" clean
 ifeq ($(CONFIG_BUILD_2PASS),y)
-	@$(MAKE) -C $(CONFIG_PASS1_DIR) TOPDIR="$(TOPDIR)" clean
+	@$(MAKE) -C $(CONFIG_PASS1_BUILDIR) TOPDIR="$(TOPDIR)" clean
 endif
 
 clean: subdir_clean
@@ -328,5 +339,5 @@ subdir_distclean:
 distclean: clean subdir_distclean clean_context
 	@rm -f Make.defs setenv.sh .config
 ifeq ($(CONFIG_BUILD_2PASS),y)
-	@$(MAKE) -C $(CONFIG_PASS1_DIR) TOPDIR="$(TOPDIR)" distclean
+	@$(MAKE) -C $(CONFIG_PASS1_BUILDIR) TOPDIR="$(TOPDIR)" distclean
 endif
diff --git a/configs/README.txt b/configs/README.txt
index c1b73b310d304eb7a124ba12820e10084f311559..6603c9848e1207da53f13f921c4592adc70c080d 100644
--- a/configs/README.txt
+++ b/configs/README.txt
@@ -139,7 +139,7 @@ defconfig -- This is a configuration file similar to the Linux
 		CONFIG_DRAM_START - The start address of DRAM (physical)
 		CONFIG_DRAM_VSTART - The start address of DRAM (virtual)
 
-	General build options
+	General build options:
 
 		CONFIG_RRLOAD_BINARY - make the rrload binary format used with
 		  BSPs from www.ridgerun.com using the tools/mkimage.sh script.
@@ -157,7 +157,7 @@ defconfig -- This is a configuration file similar to the Linux
 		  COMPILEXX have been defined in the configuratins Make.defs
 		  file.
 
-	General OS setup
+	Building application code:
 
 		CONFIG_APP_DIR - Identifies the directory that builds the
 		  application to link with NuttX. This symbol must be assigned
@@ -201,6 +201,28 @@ defconfig -- This is a configuration file similar to the Linux
 		  example, to include makefile fragments (e.g., .config or Make.defs)
 		  or to set up include file paths.
 
+	Two-pass build options.  If the 2 pass build option is selected, then these
+	options configure the make system build a extra link object. This link object
+	is assumed to be an incremental (relative) link object, but could be a static
+	library (archive) (some modification to this Makefile would be required if
+	CONFIG_PASS1_OBJECT is an archive). Pass 1 1ncremental (relative) link objects
+	should be put into the processor-specific source directory (where other
+	link objects will be created).  If the pass1 obect is an archive, it could
+	go anywhere.
+
+		CONFIG_BUILD_2PASS - Enables the two pass build options.
+
+	When the two pass build option is enabled, the following also apply:
+
+		CONFIG_PASS1_OBJECT - The name of the first pass object.
+		CONFIG_PASS1_BUILDIR - The path, relative to the top NuttX build
+		  directory to directory that contains the Makefile to build the
+		  first pass object.  The Makefile must support the following targets:
+		  - The special target arch/$(CONFIG_ARCH)/src/$(CONFIG_PASS1_OBJECT)
+		  - and the usual depend, clean, and distclean targets.
+
+	General OS setup
+
 		CONFIG_DEBUG - enables built-in debug options
 		CONFIG_DEBUG_VERBOSE - enables verbose debug output
 		CONFIG_DEBUG_SYMBOLS - build without optimization and with
@@ -308,7 +330,8 @@ defconfig -- This is a configuration file similar to the Linux
 		  enable the on-demand paging feature as described in
 		  http://www.nuttx.org/NuttXDemandPaging.html.
 
-    If CONFIG_PAGING is selected, then the following also apply:
+    If CONFIG_PAGING is selected, then you will probabaly need CONFIG_BUILD_2PASS to
+    correctly position the code and the following configuration options also apply:
 
 		CONFIG_PAGING_PAGESIZE - The size of one managed page.  This must
 		  be a value supported by the processor's memory management unit.
diff --git a/configs/ea3131/locked/Makefile b/configs/ea3131/locked/Makefile
index b4566ae40bf87d53ca745942f7e8620685aa0f39..26a62a683c50540cfa5aac20d3973d4d237f49e3 100755
--- a/configs/ea3131/locked/Makefile
+++ b/configs/ea3131/locked/Makefile
@@ -36,10 +36,18 @@
 -include $(TOPDIR)/.config
 -include $(TOPDIR)/Make.defs
 
-# Remove the application library (libapp) from the list of libraries.
+# Board-specific directory, board library, and application library
 
+PASS1_SRCDIR	= arch/$(CONFIG_ARCH)/src
+PASS1_BOARDDIR	= $(PASS1_SRCDIR)/board
+PASS1_LIBBOARD	= $(PASS1_BOARDDIR)/libboard$(LIBEXT)
 PASS1_LIBAPP	= $(CONFIG_APP_DIR)/libapp$(LIBEXT)
+
+# Remove the application library (libapp) from the list of libraries.  Add
+# the boad library (liboard)
+
 PASS1_LINKLIBS	= $(filter-out $(PASS1_LIBAPP),$(LINKLIBS))
+PASS1_LINKLIBS	+= $(PASS1_LIBBOARD)
 
 # Get the paths to the libraries and the links script path in format that
 # is appropriate for the host OS
@@ -58,8 +66,12 @@ PASS1_LDFLAGS	= -r $(PASS1_LDSCRIPT)
 PASS1_LDLIBS	= $(patsubst lib%,-l%,$(basename $(notdir $(PASS1_LINKLIBS))))
 PASS1_LIBGCC	= "${shell $(CC) -print-libgcc-file-name}"
 
+# Targets:
+
 all: locked.r
 
+.PHONY:	depend clean distclean
+
 # Create include-able linker script that specifies all of the symbols to be
 # resolved in the locked.r file.
 
@@ -67,18 +79,26 @@ ld-locked.inc: mklocked.sh $(TOPDIR)/.config
 	@echo "MK:  ld-locked.inc"
 	@./mklocked.sh "$(TOPDIR)"
 
+# Make the board library. This is normally done in arch/arm/src/Makefile.
+# However, we need it earlier here when doing a two-pass build so that libboard.a
+# is available to link against.
+
+$(PASS1_LIBBOARD):
+	@$(MAKE) -C $(TOPDIR)/configs/ea3131/src TOPDIR="$(TOPDIR)" libboard$(LIBEXT)
+
 # Create the locked.r file containing all of the code (except the start-up code)
 # that needs to lie in the locked text region.
 
-locked.r: ld-locked.inc
+locked.r: ld-locked.inc $(PASS1_LIBBOARD)
 	@echo "LD:  locked.r"
 	@$(LD) -o $@ $(PASS1_LDFLAGS) $(PASS1_LIBPATHS) --start-group $(PASS1_LDLIBS) --end-group $(PASS1_LIBGCC) 
-	@echo "NM:  locked.map"
 	@$(NM) $@ > locked.map
 	@fgrep " U " locked.map | grep -v os_start
-	@echo "SZ:"
 	@$(CROSSDEV)size $@
 
+$(PASS1_SRCDIR)/locked.r: locked.r
+	@cp -a locked.r $(TOPDIR)/$(PASS1_SRCDIR)/locked.r
+
 .depend:
 
 depend: .depend
diff --git a/configs/ea3131/locked/ld-locked.script b/configs/ea3131/locked/ld-locked.script
index f89d8549f9306d09d35d6be40cc6009e35e7389f..5b5feeb1aa314ff3b0e4fe9d61d9dd1b508d596d 100644
--- a/configs/ea3131/locked/ld-locked.script
+++ b/configs/ea3131/locked/ld-locked.script
@@ -37,8 +37,7 @@ INCLUDE ld-locked.inc
 OUTPUT_ARCH(arm)
 SECTIONS
 {
-	.locked : {
-		*(.vectors)
-		*(.text .text.*)        
-	}
+	.text.locked : { *(.text .text.*) }
+	.data : { *(.data) } 
+	.bss :  { *(.bss)  *(COMMON) } 
 }
\ No newline at end of file
diff --git a/configs/ea3131/pgnsh/defconfig b/configs/ea3131/pgnsh/defconfig
index db542a647f765cbbd8db8e5b264902042f6c5d65..58480f8753e26c5dca6a9fda7f0d1df516063cd6 100755
--- a/configs/ea3131/pgnsh/defconfig
+++ b/configs/ea3131/pgnsh/defconfig
@@ -202,8 +202,8 @@ CONFIG_HAVE_LIBM=n
 # Setup for a two-pass build
 #
 CONFIG_BUILD_2PASS=y
-CONFIG_PASS1_DIR=configs/ea3131/locked
-CONFIG_PASS1_LIB=locked.r
+CONFIG_PASS1_BUILDIR=configs/ea3131/locked
+CONFIG_PASS1_OBJECT=locked.r
 
 #
 # General OS setup
diff --git a/configs/ea3131/pgnsh/ld.script b/configs/ea3131/pgnsh/ld.script
index 0dc76825703b11187f0bbd4deedec770e774b4da..131ee62f9c8d65623c3897c41988ffb2f0d48c5e 100755
--- a/configs/ea3131/pgnsh/ld.script
+++ b/configs/ea3131/pgnsh/ld.script
@@ -32,7 +32,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  *
  ****************************************************************************/
-
+ 
 /* The LPC3131 has 192Kb of ISRAM beginning at virtual address 0x1102:8000.
  * LPC313x boot ROM expects the boot image be compiled with entry point at
  * 0x1102:9000.  A 128b header will appear at this address (applied by
@@ -45,6 +45,10 @@
  * locked - Pages locked in memory.     Start: 0x1102 8000 Size: 36Kb
  * paged  - Pages in nonvolatile store. Start: 0x1103 1000 Size: 384Kb
  * data   - .data/.bss/heap.            Start: 0x1109 1000 Size: 44Kb
+ *
+ * These region sizes must match the size in pages specified for each region
+ * in the NuttX configuration file:  CONFIG_PAGING_NLOCKED, CONFIG_PAGING_NVPAGED,
+ * and CONFIG_PAGING_NDATA.
  */
 
 MEMORY
@@ -61,10 +65,10 @@ SECTIONS
 	.locked : {
 		_slocked = ABSOLUTE(.);
 		*(.vectors)
-		*(.locked)
+		locked.r (.text)
 		_elocked = ABSOLUTE(.);
 	} >locked
-	_eronly = ABSOLUTE(.);		/* See below                    */
+	_eronly = ABSOLUTE(.);
 
 	.paged : {
 		_spaged = ABSOLUTE(.);