Two pass build for on-demand paging now works

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2896 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2010-08-29 14:27:58 +00:00
parent 8c36daf6a2
commit f7b1fbb045
9 changed files with 157 additions and 36 deletions

View File

@ -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.

View File

@ -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).
* 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.
pascal-2.1 2010-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
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>

View File

@ -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>

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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) }
}

View File

@ -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

View File

@ -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(.);