diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-12-09 18:20:49 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-12-09 18:20:49 +0000 |
commit | cc68077a20e91fb4cda22453a04db488b754dd8b (patch) | |
tree | ad1f7e88029dce87e0e67d41fdf56aae858d1520 | |
parent | 248fef86608d465419947c9f442ecd5d88b60df8 (diff) | |
download | nuttx-cc68077a20e91fb4cda22453a04db488b754dd8b.tar.gz nuttx-cc68077a20e91fb4cda22453a04db488b754dd8b.tar.bz2 nuttx-cc68077a20e91fb4cda22453a04db488b754dd8b.zip |
Some initial changes for 8051 build update
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5423 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r-- | nuttx/arch/8051/src/Makefile | 205 | ||||
-rw-r--r-- | nuttx/arch/8051/src/Makefile.sdccl | 273 | ||||
-rw-r--r-- | nuttx/configs/pjrc-8051/Make.defs | 146 | ||||
-rwxr-xr-x | nuttx/configs/pjrc-8051/setenv.sh | 32 |
4 files changed, 427 insertions, 229 deletions
diff --git a/nuttx/arch/8051/src/Makefile b/nuttx/arch/8051/src/Makefile index 61e40d84b..867024b62 100644 --- a/nuttx/arch/8051/src/Makefile +++ b/nuttx/arch/8051/src/Makefile @@ -33,203 +33,22 @@ # ############################################################################ --include $(TOPDIR)/Make.defs - -CFLAGS += -I$(TOPDIR)/sched -ASFLAGS = -x -j -g -l -s -p -CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -D__ASSEMBLY__ - -SSRCS = -ASRCS = $(SSRCS:.S=$(ASMEXT)) -AOBJS = $(ASRCS:$(ASMEXT)=$(OBJEXT)) -CSRCS = up_initialize.c up_idle.c up_interruptcontext.c \ - up_initialstate.c up_unblocktask.c up_blocktask.c \ - up_releasepending.c up_reprioritizertr.c \ - up_exit.c up_assert.c up_allocateheap.c \ - up_irq.c up_savecontext.c up_restorecontext.c \ - up_timerisr.c up_putc.c up_debug.c up_delay.c -COBJS = $(CSRCS:.c=$(OBJEXT)) -SRCS = $(SSRCS) $(CSRCS) -OBJS = $(AOBJS) $(COBJS) - -SDCCLIBDIR = /usr/local/share/sdcc/lib/large-stack-auto -SDCCPATH = -L$(SDCCLIBDIR) -SDCCLIBS = -llibfloat.lib -llibint.lib -lliblong.lib -llibmysdcc.lib -lmcs51.lib - -LINKSSRCS = up_head.S -LINKASRCS = $(LINKSSRCS:.S=$(ASMEXT)) -LINKOBJS = $(LINKASRCS:$(ASMEXT)=$(OBJEXT)) -LINKLIBS ?= -LIBPATHS = -L"$(TOPDIR)/lib" -LDLIBS = $(patsubst %.a,%,$(patsubst lib%,-l%,$(LINKLIBS))) - -TESTSRCS = up_irqtest.c -TESTOBJS = $(TESTSRCS:.c=$(OBJEXT)) -TESTLINKOBJS = up_head$(OBJEXT) -TESTEXTRAOBJS = up_savecontext$(OBJEXT) up_restorecontext$(OBJEXT) - -BOARDDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src/board - -IRAM_SIZE = 0x100 -DEF_STACK_BASE = 0x24 -LDFLAGS += --model-large --nostdlib \ - --data-loc $(DEF_STACK_BASE) --iram-size $(IRAM_SIZE) \ - --code-loc 0x2100 --code-size 0x5f40 \ - --xram-loc $(IRAM_SIZE) --xram-size 0x1f00 - -DEPSRCS = $(SRCS) $(LINKSSRCS) - -HEAP1_BASE = ${shell \ - if [ -e pass1.mem ]; then \ - cat pass1.mem | grep "EXTERNAL RAM" | \ - sed -e "s/[ ][ ]*/ /g" | cut -d' ' -f5 ; \ - else \ - echo $(IRAM_SIZE) ; \ - fi \ - } -DEF_HEAP2_BASE = 0x6000 -HEAP2_BASE = ${shell \ - if [ -e pass1.mem ]; then \ - cat pass1.mem | grep "ROM/EPROM/FLASH" | \ - sed -e "s/[ ][ ]*/ /g" | cut -d' ' -f4 ; \ - else \ - echo $(DEF_HEAP2_BASE) ; \ - fi \ - } -STACK_BASE = ${shell \ - if [ -e pass1.mem ]; then \ - cat pass1.mem | grep "Stack starts" | \ - cut -d' ' -f4 ; \ - else \ - echo $(DEF_STACK_BASE) ; \ - fi \ - } - -all: up_head$(OBJEXT) libarch$(LIBEXT) - -.PHONY: board/libboard$(LIBEXT) - -$(ASRCS) $(LINKASRCS): %$(ASMEXT): %.S - $(CPP) -P $(CPPFLAGS) $< -o $@ - -$(AOBJS) $(LINKOBJS): $(ASRCS) $(LINKASRCS) - $(call ASSEMBLE, $<, $@) - -$(COBJS) $(TESTOBJS): %$(OBJEXT): %.c - $(call COMPILE, $<, $@) - -# Create a header file that contains addressing information needed by the code - -pass1.mem: +# Makefile fragments -up_mem.h: pass1.mem - @echo "#ifndef __ARCH_MEM_H" >up_mem.h - @echo "#define __ARCH_MEM_H" >>up_mem.h - @echo "" >>up_mem.h - @echo "#define UP_DEFAULT_STACK_BASE $(DEF_STACK_BASE)" >>up_mem.h - @echo "#define UP_DEFAULT_HEAP1_BASE $(IRAM_SIZE)" >> up_mem.h - @echo "#define UP_DEFAULT_HEAP2_BASE $(DEF_HEAP2_BASE)" >> up_mem.h - @echo "" >>up_mem.h - @echo "#define UP_STACK_BASE $(STACK_BASE)" >>up_mem.h - @echo "#if UP_STACK_BASE > UP_DEFAULT_STACK_BASE" >>up_mem.h - @echo "# error \"Stack overlap: $(DEF_STACK_BASE) < $(STACK_BASE)\"" >>up_mem.h - @echo "#elif UP_STACK_BASE < UP_DEFAULT_STACK_BASE" >>up_mem.h - @echo "# warning \"Wasted stack: $(DEF_STACK_BASE) > $(STACK_BASE)\"" >>up_mem.h - @echo "#endif" >>up_mem.h - @echo "" >>up_mem.h - @echo "#define UP_HEAP1_BASE $(HEAP1_BASE)" >> up_mem.h - @echo "#define UP_HEAP1_END 0x2000" >> up_mem.h - @echo "" >>up_mem.h - @echo "#define UP_HEAP2_BASE $(HEAP2_BASE)" >> up_mem.h - @echo "#define UP_HEAP2_END 0x8000" >> up_mem.h - @echo "" >>up_mem.h - @echo "#endif /* __ARCH_MEM_H */" >>up_mem.h - -# Combine all objects in this directory into a library - -libarch$(LIBEXT): up_mem.h $(OBJS) - $(call ARCHIVE, $@, $(OBJS)) - -# This is a kludge to work around some conflicting symbols in libsdcc.liXqueb - -$(SDCCLIBDIR)/libmysdcc.lib: $(SDCCLIBDIR)/libsdcc.lib - $(Q) cat $(SDCCLIBDIR)/libsdcc.lib | \ - grep -v calloc | grep -v malloc | grep -v realloc | \ - grep -v free | grep -v vprintf | grep -v _strncpy | \ - grep -v _strchr | grep -v _strlen | grep -v _strcmp | \ - grep -v _strcpy | grep -v _memcmp | grep -v _memcpy | \ - grep -v _memset \ - > libmysdcc.lib - $(Q) mv -f libmysdcc.lib $(SDCCLIBDIR)/libmysdcc.lib - -# This builds the libboard library in the board/ subdirectory - -board/libboard$(LIBEXT): - $(Q) $(MAKE) -C board TOPDIR=$(TOPDIR) libboard$(LIBEXT) EXTRADEFINES=$(EXTRADEFINES) - -# This target builds the final executable - -pass1.hex: up_mem.h $(SDCCLIBDIR)/libmysdcc.lib $(LINKOBJS) board/libboard$(LIBEXT) - @echo "LD: $@" - $(Q) "$(CC)" $(LDFLAGS) $(LIBPATHS) -L$(BOARDDIR) $(SDCCPATH) $(LINKOBJS) \ - $(LDLIBS) -llibboard$(LIBEXT) $(SDCCLIBS) -o $@ - $(Q) rm -f up_mem.h - $(Q) rm -f up_allocateheap$(OBJEXT) libarch$(LIBEXT) - $(Q) $(MAKE) TOPDIR=$(TOPDIR) libarch$(LIBEXT) - -nuttx.hex: up_mem.h $(SDCCLIBDIR)/libmysdcc.lib $(LINKOBJS) - @echo "LD: $@" - $(Q) "$(CC)" $(LDFLAGS) $(LIBPATHS) -L$(BOARDDIR) $(SDCCPATH) $(LINKOBJS) \ - $(LDLIBS) -llibboard$(LIBEXT) $(SDCCLIBS) -o $@ - -nuttx$(EXEEXT): pass1.hex nuttx.hex - $(Q) rm -f pass1.* - $(Q) packihx nuttx.hex > $(TOPDIR)/nuttx$(EXEEXT) - $(Q) cp -f nuttx.map $(TOPDIR)/. - -# This is part of the top-level export target - -export_head: board/libboard$(LIBEXT) p_head$(OBJEXT) - $(Q) if [ -d "$(EXPORT_DIR)/startup" ]; then \ - cp -f up_head$(OBJEXT) "$(EXPORT_DIR)/startup"; \ - else \ - echo "$(EXPORT_DIR)/startup does not exist"; \ - exit 1; \ - fi - -# This target builds a test program to verify interrupt context switching. irqtest is -# a PHONY target that just sets upt the up_irqtest build correctly - -up_irqtest.hex: $(TESTOBJS) - $(Q) "$(CC)" $(LDFLAGS) -L. $(SDCCPATH) $(TESTLINKOBJS) $(TESTOBJS) $(TESTEXTRAOBJS) $(SDCCLIBS) -o $@ - -irqtest: - $(Q) $(MAKE) TOPDIR=../../.. up_irqtest.hex +-include $(TOPDIR)/Make.defs +-include chip/Make.defs +-include board/Make.defs -# Build dependencies +# Check for SDCC native windows build -.depend: Makefile up_mem.h $(DEPSRCS) - $(Q) if [ -e board/Makefile ]; then \ - $(MAKE) -C board TOPDIR=$(TOPDIR) depend ; \ - fi - $(Q) $(MKDEP) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep - $(Q) touch $@ +ifeq ($(CONFIG_WINDOWS_NATIVE),y) -depend: .depend + # SDCC Windows native build -clean: - $(Q) if [ -e board/Makefile ]; then \ - $(MAKE) -C board TOPDIR=$(TOPDIR) clean ; \ - fi - $(call DELFILE, libarch$(LIBEXT)) - $(call DELFILE, up_mem.h) - $(call CLEAN) + include Makefile.sdccw +else -distclean: clean - $(Q) if [ -e board/Makefile ]; then \ - $(MAKE) -C board TOPDIR=$(TOPDIR) distclean ; \ - fi - $(call DELFILE, Make.dep) - $(call DELFILE, .depend) + # SDCC in a POSIX environment (Linux, OSX, or Cygwin/MSYS) --include Make.dep + include Makefile.sdccl +endif diff --git a/nuttx/arch/8051/src/Makefile.sdccl b/nuttx/arch/8051/src/Makefile.sdccl new file mode 100644 index 000000000..e90ef23e9 --- /dev/null +++ b/nuttx/arch/8051/src/Makefile.sdccl @@ -0,0 +1,273 @@ +############################################################################ +# arch/8051/src/Makefile.sdccl +# +# Copyright (C) 2007, 2008, 2011-2012 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt <gnutt@nuttx.org> +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +-include $(TOPDIR)/Make.defs + +# Tools +# CFLAGS, CPPFLAGS, ASFLAGS, LDFLAGS are set in $(TOPDIR)/Make.defs + +CFLAGS += -I$(TOPDIR)/sched +CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -D__ASSEMBLY__ + +LDFLAGS += --model-large --nostdlib --data-loc $(DEF_STACK_BASE) \ + --iram-size $(IRAM_SIZE) --code-loc 0x2100 --code-size 0x5f40 \ + --xram-loc $(IRAM_SIZE) --xram-size 0x1f00 + +# Files and directories +# There should be one head source (.asm file) + +HEAD_SSRC = up_head.S +HEAD_ASRC = $(HEAD_SSRC:.S=$(ASMEXT)) +HEAD_OBJ = $(HEAD_ASRC:$(ASMEXT)=$(OBJEXT)) + +# Assembly sources and objects + +SSRCS = +ASRCS = $(SSRCS:.S=$(ASMEXT)) +AOBJS = $(ASRCS:$(ASMEXT)=$(OBJEXT)) + +# C sources and objects + +CSRCS = up_initialize.c up_idle.c up_interruptcontext.c up_initialstate.c \ + up_unblocktask.c up_blocktask.c up_releasepending.c \ + up_reprioritizertr.c up_exit.c up_assert.c up_allocateheap.c \ + up_irq.c up_savecontext.c up_restorecontext.c up_timerisr.c up_putc.c \ + up_debug.c up_delay.c +COBJS = $(CSRCS:.c=$(OBJEXT)) + +# All sources and objcts + +SRCS = $(SSRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +DEPSRCS = $(SRCS) $(HEAD_SSRC) + +# Board path + +BOARDDIR = $(TOPDIR)/arch/$(CONFIG_ARCH)/src/board + +# Source path + +VPATH = chip:common:board + +# Libraries + +SDCCLIBS = -llibfloat.lib -llibint.lib -lliblong.lib -llibmysdcc.lib -lmcs51.lib + +LINKLIBS ?= +LIBPATHS = -L"$(TOPDIR)/lib" +LDLIBS = $(patsubst %.a,%,$(patsubst lib%,-l%,$(LINKLIBS))) + +# Test sources + +TESTSRCS = up_irqtest.c +TESTOBJS = $(TESTSRCS:.c=$(OBJEXT)) +TESTLINKOBJS = up_head$(OBJEXT) +TESTEXTRAOBJS = up_savecontext$(OBJEXT) up_restorecontext$(OBJEXT) + +# Memory + +HEAP1_BASE = ${shell \ + if [ -e pass1.mem ]; then \ + cat pass1.mem | grep "EXTERNAL RAM" | \ + sed -e "s/[ ][ ]*/ /g" | cut -d' ' -f5 ; \ + else \ + echo $(IRAM_SIZE) ; \ + fi \ + } +DEF_HEAP2_BASE = 0x6000 +HEAP2_BASE = ${shell \ + if [ -e pass1.mem ]; then \ + cat pass1.mem | grep "ROM/EPROM/FLASH" | \ + sed -e "s/[ ][ ]*/ /g" | cut -d' ' -f4 ; \ + else \ + echo $(DEF_HEAP2_BASE) ; \ + fi \ + } +STACK_BASE = ${shell \ + if [ -e pass1.mem ]; then \ + cat pass1.mem | grep "Stack starts" | \ + cut -d' ' -f4 ; \ + else \ + echo $(DEF_STACK_BASE) ; \ + fi \ + } + +# Targets + +all: up_head$(OBJEXT) libarch$(LIBEXT) + +.PHONY: board/libboard$(LIBEXT) + +$(ASRCS) $(HEAD_ASRC): %$(ASMEXT): %.S + $(CPP) -P $(CPPFLAGS) $< -o $@ + +$(AOBJS) $(HEAD_OBJ): $(ASRCS) $(HEAD_ASRC) + $(call ASSEMBLE, $<, $@) + +$(COBJS) $(TESTOBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +# This is a kludge to work around some conflicting symbols in the SDCC libraries + +$(TOPDIR)/lib/$(SDCCLIB): $(SDCC_LIBDIR)/$(SDCCLIB) + $(Q) cp $(SDCC_LIBDIR)/$(SDCCLIB) $(TOPDIR)/lib/$(SDCCLIB) + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _calloc.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _malloc.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _realloc.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _free.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) printf_large.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) sprintf.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) vprintf.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) strcpy.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) strlen.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strcat.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strchr.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strcmp.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strcspn.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strncat.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strncmp.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strncpy.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strpbrk.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strrchr.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strspn.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strstr.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _strtok.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _memchr.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _memcmp.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _memcpy.rel + $(Q) sdar d $(TOPDIR)/lib/$(SDCCLIB) _memset.rel + +# Create a header file that contains addressing information needed by the code + +up_mem.h: pass1.mem + @echo "#ifndef __ARCH_MEM_H" >up_mem.h + @echo "#define __ARCH_MEM_H" >>up_mem.h + @echo "" >>up_mem.h + @echo "#define UP_DEFAULT_STACK_BASE $(DEF_STACK_BASE)" >>up_mem.h + @echo "#define UP_DEFAULT_HEAP1_BASE $(IRAM_SIZE)" >> up_mem.h + @echo "#define UP_DEFAULT_HEAP2_BASE $(DEF_HEAP2_BASE)" >> up_mem.h + @echo "" >>up_mem.h + @echo "#define UP_STACK_BASE $(STACK_BASE)" >>up_mem.h + @echo "#if UP_STACK_BASE > UP_DEFAULT_STACK_BASE" >>up_mem.h + @echo "# error \"Stack overlap: $(DEF_STACK_BASE) < $(STACK_BASE)\"" >>up_mem.h + @echo "#elif UP_STACK_BASE < UP_DEFAULT_STACK_BASE" >>up_mem.h + @echo "# warning \"Wasted stack: $(DEF_STACK_BASE) > $(STACK_BASE)\"" >>up_mem.h + @echo "#endif" >>up_mem.h + @echo "" >>up_mem.h + @echo "#define UP_HEAP1_BASE $(HEAP1_BASE)" >> up_mem.h + @echo "#define UP_HEAP1_END 0x2000" >> up_mem.h + @echo "" >>up_mem.h + @echo "#define UP_HEAP2_BASE $(HEAP2_BASE)" >> up_mem.h + @echo "#define UP_HEAP2_END 0x8000" >> up_mem.h + @echo "" >>up_mem.h + @echo "#endif /* __ARCH_MEM_H */" >>up_mem.h + +# Combine all objects in this directory into a library + +libarch$(LIBEXT): up_mem.h $(OBJS) + $(call ARCHIVE, $@, $(OBJS)) + +# This builds the libboard library in the board/ subdirectory + +board/libboard$(LIBEXT): + $(Q) $(MAKE) -C board TOPDIR="$(TOPDIR)" libboard$(LIBEXT) EXTRADEFINES=$(EXTRADEFINES) + +# This target builds the final executable + +pass1.hex: up_mem.h $(TOPDIR)/lib/$(SDCCLIB) $(HEAD_OBJ) board/libboard$(LIBEXT) + @echo "LD: $@" + $(Q) "$(CC)" $(LDFLAGS) $(LIBPATHS) -L$(BOARDDIR) $(SDCCPATH) $(HEAD_OBJ) \ + $(LDLIBS) -llibboard$(LIBEXT) $(SDCCLIBS) -o $@ + $(Q) rm -f up_mem.h + $(Q) rm -f up_allocateheap$(OBJEXT) libarch$(LIBEXT) + $(Q) $(MAKE) TOPDIR=$(TOPDIR) libarch$(LIBEXT) + +nuttx.hex: up_mem.h $(TOPDIR)/lib/$(SDCCLIB) $(HEAD_OBJ) + @echo "LD: $@" + $(Q) "$(CC)" $(LDFLAGS) $(LIBPATHS) -L$(BOARDDIR) $(SDCCPATH) $(HEAD_OBJ) \ + $(LDLIBS) -llibboard$(LIBEXT) $(SDCCLIBS) -o $@ + +nuttx$(EXEEXT): pass1.hex nuttx.hex + $(Q) rm -f pass1.* + $(Q) packihx nuttx.hex > $(TOPDIR)/nuttx$(EXEEXT) + $(Q) cp -f nuttx.map $(TOPDIR)/. + +# This is part of the top-level export target + +export_head: board/libboard$(LIBEXT) p_head$(OBJEXT) + $(Q) if [ -d "$(EXPORT_DIR)/startup" ]; then \ + cp -f up_head$(OBJEXT) "$(EXPORT_DIR)/startup"; \ + else \ + echo "$(EXPORT_DIR)/startup does not exist"; \ + exit 1; \ + fi + +# This target builds a test program to verify interrupt context switching. irqtest is +# a PHONY target that just sets upt the up_irqtest build correctly + +up_irqtest.hex: $(TESTOBJS) + $(Q) "$(CC)" $(LDFLAGS) -L. $(SDCCPATH) $(TESTLINKOBJS) $(TESTOBJS) $(TESTEXTRAOBJS) $(SDCCLIBS) -o $@ + +irqtest: + $(Q) $(MAKE) TOPDIR=../../.. up_irqtest.hex + +# Build dependencies + +.depend: Makefile up_mem.h $(DEPSRCS) + $(Q) if [ -e board/Makefile ]; then \ + $(MAKE) -C board TOPDIR=$(TOPDIR) depend ; \ + fi + $(Q) $(MKDEP) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep + $(Q) touch $@ + +depend: .depend + +clean: + $(Q) if [ -e board/Makefile ]; then \ + $(MAKE) -C board TOPDIR=$(TOPDIR) clean ; \ + fi + $(call DELFILE, libarch$(LIBEXT)) + $(call DELFILE, up_mem.h) + $(call CLEAN) + +distclean: clean + $(Q) if [ -e board/Makefile ]; then \ + $(MAKE) -C board TOPDIR=$(TOPDIR) distclean ; \ + fi + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) + +-include Make.dep diff --git a/nuttx/configs/pjrc-8051/Make.defs b/nuttx/configs/pjrc-8051/Make.defs index 803455522..d4716dedc 100644 --- a/nuttx/configs/pjrc-8051/Make.defs +++ b/nuttx/configs/pjrc-8051/Make.defs @@ -36,49 +36,135 @@ include ${TOPDIR}/.config include ${TOPDIR}/tools/Config.mk +# These are the directories where the SDCC toolchain is installed. NOTE +# that short 8.3 path names are used in order to avoid spaces. On my machine +# I have: +# +# C:\PROGRA~1\ = C:\Profram Files\ +# C:\PROGRA~2\ = C:\Program Files (x86)\ +# +# Your PC may be configured differently. + +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + SDCC_INSTALLDIR = C:\PROGRA~2\SDCC + SDCC_BINDIR = $(SDCC_INSTALLDIR)\bin + SDCC_LIBDIR = $(SDCC_INSTALLDIR)\lib\large-stack-auto +else + SDCC_INSTALLDIR = /usr/local + SDCC_BINDIR = $(SDCC_INSTALLDIR)/bin + SDCC_LIBDIR = $(SDCC_INSTALLDIR)/share/sdcc/lib/large-stack-auto +endif + +CROSSDEV = +CC = sdcc +CPP = sdcpp +LD = sdld +AS = sdas8051 +AR = sdar -r + +IRAM_SIZE = 0x100 +DEF_STACK_BASE = 0x24 + ifeq ($(CONFIG_DEBUG_SYMBOLS),y) - ARCHOPTIMIZATION = --debug + ARCHOPTIMIZATION = --debug else - ARCHOPTIMIZATION = + ARCHOPTIMIZATION = endif -ARCHCPUFLAGS = -mmcs51 --stack-auto --model-large --int-long-reent --float-reent -ARCHPICFLAGS = -ARCHWARNINGS = -ARCHDEFINES = -ARCHINCLUDES = -I. -I$(TOPDIR)/include - -CROSSDEV = -CC = sdcc -CPP = sdcpp -LD = aslink -AS = asx8051 -#AR = sdar -r -AR = sdcclib -a - -CFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \ - $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) - -ASMEXT = .asm -OBJEXT = .rel -LIBEXT = .lib -EXEEXT = .hex +ARCHCPUFLAGS = -mmcs51 --stack-auto --model-large --int-long-reent --float-reent +ARCHPICFLAGS = +ARCHWARNINGS = +ARCHDEFINES = +ARCHINCLUDES = -I. -I$(TOPDIR)/include + +CFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) +CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) +AFLAGS = -x -j -g -l -s -p + +SDCCLIB = libsdcc.lib + +ASMEXT = .asm +OBJEXT = .rel +LIBEXT = .lib +EXEEXT = .hex + +# Custom ASSEMBLE definition. The most common toolchain, GCC, uses the +# compiler to assemble files because this has the advantage of running the C +# Pre-Processor against. This is not possible with other SDCC; we need to +# define AS and over-ride the common definition in order to use the assembler +# directly. define ASSEMBLE @echo "AS: $1" @$(AS) $(AFLAGS) $1 endef +# Custom CLEAN definition + +ifeq ($(CONFIG_WINDOWS_NATIVE),y) define CLEAN - @rm -f *.asm *.rel *.lst *.rst *.sym *.adb *.lnk *.map *.mem *.hex + $(Q) if exist *.o (del /f /q *.o) + $(Q) if exist *.asm (del /f /q *.asm) + $(Q) if exist *.rel (del /f /q *.rel) + $(Q) if exist *.lst (del /f /q *.lst) + $(Q) if exist *.rst (del /f /q *.rst) + $(Q) if exist *.sym (del /f /q *.sym) + $(Q) if exist *.adb (del /f /q *.adb) + $(Q) if exist *.lnk (del /f /q *.lnk) + $(Q) if exist *.map (del /f /q *.map) + $(Q) if exist *.mem (del /f /q *.mem) + $(Q) if exist *.hex (del /f /q *.hex) + $(Q) if exist *.cmd (del /f /q *.cmd) endef +else +define CLEAN + $(Q) rm -f *.o *.asm *.rel *.lst *.rst *.sym *.adb *.lnk *.map *.mem *.hex *.cmd +endef +endif -MKDEP = $(TOPDIR)/tools/mkdeps.sh +# Windows native host tool definitions -HOSTCC = gcc -HOSTINCLUDES = -I. -HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe -HOSTLDFLAGS = +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + HOSTCC = mingw32-gcc.exe + HOSTINCLUDES = -I. + HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe + HOSTLDFLAGS = + HOSTEXEEXT = .exe + # Windows-native host tools + MKDEP = $(TOPDIR)\tools\mkdeps.exe --winnative + + # Use NTFS links or directory copies + +ifeq ($(CONFIG_WINDOWS_MKLINK),y) + DIRLINK = $(TOPDIR)$(DELIM)tools$(DELIM)link.bat +else + DIRLINK = $(TOPDIR)$(DELIM)tools$(DELIM)copydir.bat +endif +DIRUNLINK = $(TOPDIR)$(DELIM)tools$(DELIM)unlink.bat + +else + +# Linux/Cygwin host tool definitions + + HOSTCC = gcc + HOSTINCLUDES = -I. + HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe + HOSTLDFLAGS = + + # This is the tool to use for dependencies (i.e., none) + + MKDEP = $(TOPDIR)$(DELIM)tools$(DELIM)mknulldeps.sh + + # SDCC for Linux, OSX, or Cygwin understands symbolic links. Windows SDCC + # running under Cygwin does not + +ifeq ($(WINTOOL),y) + DIRLINK = $(TOPDIR)$(DELIM)tools$(DELIM)copydir.sh +else + DIRLINK = $(TOPDIR)$(DELIM)tools$(DELIM)link.sh +endif +DIRUNLINK = $(TOPDIR)$(DELIM)tools$(DELIM)unlink.sh + +endif diff --git a/nuttx/configs/pjrc-8051/setenv.sh b/nuttx/configs/pjrc-8051/setenv.sh index d71c234ba..621bb27b1 100755 --- a/nuttx/configs/pjrc-8051/setenv.sh +++ b/nuttx/configs/pjrc-8051/setenv.sh @@ -1,7 +1,7 @@ #!/bin/bash -# pjrc-8051/setenv.sh +# configs/pjrc-8051/setenv.sh # -# Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. +# Copyright (C) 2007-2008, 2012 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -32,14 +32,34 @@ # POSSIBILITY OF SUCH DAMAGE. # -if [ "$(basename $0)" = "setenv.sh" ] ; then +if [ "$_" = "$0" ] ; then echo "You must source this script, not run it!" 1>&2 exit 1 fi -if [ -z ${PATH_ORIG} ]; then export PATH_ORIG=${PATH}; 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 -export SDCC_BIN=/usr/local/bin -export PATH=${SDCC_BIN}:/sbin:/usr/sbin:${PATH_ORIG} +# +# This is the normal installation directory for SDCC under Linux, OSX +# or Linux: +# +export TOOLCHAIN_BIN=/usr/local/bin +# +# This is the normal installation directory for SDCC under Windows +# +#export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/SDCC/bin" + +# +# Add the path to the toolchain to the PATH varialble +# +export PATH="${TOOLCHAIN_BIN}":/sbin:/usr/sbin:${PATH_ORIG} echo "PATH : ${PATH}" |