getting there...

This commit is contained in:
Mariano Alvira 2010-02-21 18:47:12 -05:00
parent 5adb6413d7
commit 1759ff01a0
9 changed files with 296 additions and 164 deletions

View file

@ -1,117 +1,24 @@
# LINKERSCRIPT = $(MC1322X)/mc1322x.lds
# (C) Copyright 2000-2004 LIBMC1322X = $(MC1322X)/libmc1322x
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
#
# See file CREDITS for list of people who contributed to this
# project.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
# Deal with colliding definitions from tcsh etc. include $(MC1322X)/config.mk
VENDOR=
######################################################################### include $(MC1322X)/board/Makefile.board
include $(MC1322X)/libmc1322x/Makefile.lib
ARCH = arm ARCH = arm
CPU = arm7tdmi-s CPU = arm7tdmi-s
export ARCH CPU VENDOR export ARCH CPU VENDOR
# load other configuration $(OBJDIR)/isr.o: isr.c
include $(LIBMC1322x)/config.mk $(CC) $(CFLAGS) $(ARM_FLAGS) $< -c -o $@
######################################################################### %.o: %.c
$(CC) $(CFLAGS) $(THUMB_FLAGS) $< -c
AOBJS = $(OBJDIR)/%.o: %.c
COBJS = $(patsubst %.c,%.o,$(wildcard $(LIBMC1322x)/src/*.c)) $(CC) $(CFLAGS) $(THUMB_FLAGS) -c $< -o $@
#TESTS = $(wildcard tests/*.c)
#TESTS = tests/blink-red.c #tests/nvm-read.c
TARGETS = $(patsubst %.c,%.o,$(TESTS))
# Add GCC lib
PLATFORM_LIBS += --no-warn-mismatch -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
#########################################################################
ALL = $(TESTS:.c=.srec) $(TESTS:.c=.bin) $(TESTS:.c=.dis)
.PRECIOUS: $(COBJS) $(TARGETS) $(TESTS:.c=.obj)
LIBOBJS = $(patsubst %.c,%.o,$(wildcard libmc1322x/*.c))
include $(LIBMC1322x)/board/dev/Makefile
libmc1322x: libmc1322x.a
libmc1322x.a: $(LIBOBJS)
$(AR) r libmc1322x.a $(LIBOBJS)
#all: src/start.o src/isr.o $(ALL)
#tests/flasher.obj: src/maca.o src/nvm.o
#tests/nvm-read.obj: src/maca.o src/nvm.o
#tests/nvm-write.obj: src/maca.o src/nvm.o
#tests/rftest-rx.obj: src/maca.o src/nvm.o
#tests/rftest-tx.obj: src/maca.o src/nvm.o
#tests/tmr-ints.obj: src/isr.o
#tests/sleep.obj: src/isr.o src/maca.o src/nvm.o
NOTHUMB_CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS) \
-D__KERNEL__ -DTEXT_BASE=$(TEXT_BASE) \
-I$(LIBMC1322x)/libmc1322x/include \
-fno-builtin -ffreestanding -nostdinc -isystem \
$(gccincdir) -pipe
NOTHUMB_CPPFLAGS_EXTRA = -march=armv4t -mlong-calls -mtune=arm7tdmi-s -DCONFIG_ARM -D__ARM__ -mthumb-interwork
src/isr.o: src/isr.c
$(CC) $(NOTHUMB_CPPFLAGS) $(NOTHUMB_CPPFLAGS_EXTRA) -c -o $@ $<
%.srec: %.obj
$(OBJCOPY) ${OBJCFLAGS} -O srec $< $@
%.ihex: %.obj
$(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
%.bin: %.obj
$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
%.dis: %.obj
$(OBJDUMP) -SD $< > $@
%.obj: $(LDSCRIPT) %.o src/isr.o
$(LD) $(LDFLAGS) $(AOBJS) \
--start-group $(PLATFORM_LIBS) --end-group \
-Map $*.map $^ -o $@
%.System.map: %.obj
@$(NM) $< | \
grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
sort > $*.System.map
#########################################################################
.depend: Makefile $(AOBJS:.o=.S) $(COBJS:.o=.c)
$(CC) -M $(CFLAGS) $(AOBJS:.o=.S) $(COBJS:.o=.c) > $@
sinclude .depend
#########################################################################
clean: clean:
find . -type f \ find . -type f \
@ -131,9 +38,3 @@ clobber: clean
mrproper \ mrproper \
distclean: clobber distclean: clobber
backup:
F=`basename $(LIBMC1322x)` ; cd .. ; \
tar --force-local -zcvf `date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F
#########################################################################

7
board/Makefile.board Normal file
View file

@ -0,0 +1,7 @@
CFLAGS += -I obj_$(BOARD)_board
OBJDIR = obj_$(BOARD)_board
board:
@echo "setup object directory for dev board"
mkdir -p $(OBJDIR)
cp $(MC1322X)/board/$(BOARD).h $(OBJDIR)

View file

@ -1,7 +0,0 @@
#ifdef BOARD_REDBEE_DEV
#include "redbee-dev.h"
#endif
#ifdef BOARD_REDWIRE_R1
#include "red-r1.h"
#endif

4
board/redbee-dev.h Normal file
View file

@ -0,0 +1,4 @@
#ifndef BOARD_REDBEE_DEV_H
#define BOARD_REDBEE_DEV_H
#endif

View file

@ -1,33 +1,7 @@
#
# (C) Copyright 2000
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
#
# See file CREDITS for list of people who contributed to this
# project.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#########################################################################
# clean the slate ...
PLATFORM_LDFLAGS = PLATFORM_LDFLAGS =
PLATFORM_RELFLAGS = -fno-strict-aliasing -fno-common -ffixed-r8 -ffunction-sections -msoft-float -Wcast-align -Wall PLATFORM_RELFLAGS = -fno-strict-aliasing -fno-common -ffixed-r8 -ffunction-sections -msoft-float -Wcast-align -Wall
PLATFORM_CPPFLAGS = -march=armv4t -mlong-calls -mtune=arm7tdmi-s -DCONFIG_ARM -D__ARM__ -mcallee-super-interworking -mthumb -mthumb-interwork PLATFORM_CPPFLAGS = -march=armv4t -mlong-calls -mtune=arm7tdmi-s -DCONFIG_ARM -D__ARM__ -mthumb-interwork
TEXT_BASE = 0x00400000 THUMB_FLAGS=-mthumb -mcallee-super-interworking
######################################################################### #########################################################################
@ -55,22 +29,15 @@ gccincdir := $(shell $(CC) -print-file-name=include)
CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS) \ CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS) \
-D__KERNEL__ -DTEXT_BASE=$(TEXT_BASE) \ -D__KERNEL__ -DTEXT_BASE=$(TEXT_BASE) \
-I$(TOPDIR)/libmc1322x/include \
-I$(TOPDIR)/board \
-fno-builtin -ffreestanding -nostdinc -isystem \ -fno-builtin -ffreestanding -nostdinc -isystem \
$(gccincdir) -pipe $(PLATFORM_CPPFLAGS) $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)
ifdef BUILD_TAG CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wcast-align -Wcast-align
CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes \
-DBUILD_TAG='"$(BUILD_TAG)"'
else
CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes
endif
AFLAGS_DEBUG := -Wa,-gstabs AFLAGS_DEBUG := -Wa,-gstabs
AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS) AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS) LDFLAGS += -T $(LINKERSCRIPT) -nostartfiles -static -Wl,-Map=$@-$(BOARD).map,-export-dynamic
######################################################################### #########################################################################
@ -84,6 +51,6 @@ export TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
%.o: %.S %.o: %.S
$(CC) $(AFLAGS) -c -o $@ $(CURDIR)/$< $(CC) $(AFLAGS) -c -o $@ $(CURDIR)/$<
%.o: %.c %.o: %.c
$(CC) $(CFLAGS) -c -o $@ $< $(CC) $(CFLAGS) $(THUMB_FLAGS) -c -o $@ $<
######################################################################### #########################################################################

1
libmc1322x/Makefile.lib Normal file
View file

@ -0,0 +1 @@
CFLAGS += -I$(LIBMC1322X)/include

262
mc1322x.lds Normal file
View file

@ -0,0 +1,262 @@
/* Script for -z combreloc: combine and sort reloc sections */
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm",
"elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
SECTIONS
{
SYS_STACK_SIZE = 1024;
IRQ_STACK_SIZE = 256;
FIQ_STACK_SIZE = 256;
SVC_STACK_SIZE = 256;
ABT_STACK_SIZE = 16;
UND_STACK_SIZE = 16;
HEAP_SIZE = 1024;
/* Read-only sections, merged into text segment: */
PROVIDE (__executable_start = 0x00400000); . = 0x00400000;
.text :
{
*startup.o (.text)
*(.irq)
*(.text .stub .text.* .gnu.linkonce.t.*)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)
} =0
.stack : {
__stack_start__ = . ;
. += IRQ_STACK_SIZE;
. = ALIGN (4);
__irq_stack_top__ = . ;
. += FIQ_STACK_SIZE;
. = ALIGN (4);
__fiq_stack_top__ = . ;
. += SVC_STACK_SIZE;
. = ALIGN (4);
__svc_stack_top__ = . ;
. += ABT_STACK_SIZE;
. = ALIGN (4);
__abt_stack_top__ = . ;
. += UND_STACK_SIZE;
. = ALIGN (4);
__und_stack_top__ = . ;
. += SYS_STACK_SIZE;
. = ALIGN (4);
__sys_stack_top__ = . ;
__stack_end__ = .;
}
.interp : { *(.interp) }
.note.gnu.build-id : { *(.note.gnu.build-id) }
.hash : { *(.hash) }
.gnu.hash : { *(.gnu.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.dyn :
{
*(.rel.init)
*(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
*(.rel.fini)
*(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
*(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*)
*(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
*(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
*(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
*(.rel.ctors)
*(.rel.dtors)
*(.rel.got)
*(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
}
.rela.dyn :
{
*(.rela.init)
*(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
*(.rela.fini)
*(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
*(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
*(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
*(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
*(.rela.ctors)
*(.rela.dtors)
*(.rela.got)
*(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
}
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.init :
{
KEEP (*(.init))
} =0
.plt : { *(.plt) }
.fini :
{
KEEP (*(.fini))
} =0
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
.rodata1 : { *(.rodata1) }
.eh_frame_hdr : { *(.eh_frame_hdr) }
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
.gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
/* Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up. */
/* . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)); */
. = ALIGN(4);
. = DATA_SEGMENT_ALIGN(4,4);
/* Exception handling */
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
.gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
/* Thread Local Storage sections */
.tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
}
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
}
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
}
.ctors :
{
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin.o(.ctors))
KEEP (*crtbegin?.o(.ctors))
/* We don't want to include the .ctor section from
the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*crtbegin?.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}
.jcr : { KEEP (*(.jcr)) }
.data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
.dynamic : { *(.dynamic) }
. = DATA_SEGMENT_RELRO_END (0, .);
.got : { *(.got.plt) *(.got) }
.data :
{
__data_start = . ;
*(.data .data.* .gnu.linkonce.d.*)
SORT(CONSTRUCTORS)
}
.data1 : { *(.data1) }
_edata = .; PROVIDE (edata = .);
__bss_start = .;
__bss_start__ = .;
.bss :
{
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections.
FIXME: Why do we need it? When there is no .bss section, we don't
pad the .data section. */
. = ALIGN(. != 0 ? 32 / 8 : 1);
}
_bss_end__ = . ; __bss_end__ = . ;
. = ALIGN(32 / 8);
.heap : {
__heap_start__ = . ;
*(.heap);
. += HEAP_SIZE;
. = ALIGN (4);
__heap_end__ = . ;
}
. = ALIGN(32 / 8);
__end__ = . ;
_end = .; PROVIDE (end = .);
. = DATA_SEGMENT_END (.);
/* 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) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
/* DWARF 3 */
.debug_pubtypes 0 : { *(.debug_pubtypes) }
.debug_ranges 0 : { *(.debug_ranges) }
.gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
.note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) }
}

View file

@ -1,7 +1,5 @@
LIBMC1322x = .. MC1322X = ..
BOARD=dev include $(MC1322X)/Makefile.include
include $(LIBMC1322x)/Makefile.include
all: blink-red all: blink-red

View file

@ -1,5 +1,4 @@
#include <mc1322x.h> #include <mc1322x.h>
#include <boards.h>
#define MBAR_GPIO 0x80000000 #define MBAR_GPIO 0x80000000
#define GPIO_PAD_DIR0 ((volatile uint32_t *) 0x80000000) #define GPIO_PAD_DIR0 ((volatile uint32_t *) 0x80000000)
@ -7,18 +6,18 @@
#define UART1_DATA ((volatile uint32_t *) 0x80005008) #define UART1_DATA ((volatile uint32_t *) 0x80005008)
#define DELAY 400000 #define DELAY 400000
#define LED_BITS LED_RED //#define LED_BITS LED_RED
__attribute__ ((section ("startup"))) __attribute__ ((section ("startup")))
void main(void) { void main(void) {
volatile uint32_t i; volatile uint32_t i;
*GPIO_PAD_DIR0 = LED_BITS; // *GPIO_PAD_DIR0 = LED_BITS;
while(1) { while(1) {
*GPIO_DATA0 = LED_BITS; // *GPIO_DATA0 = LED_BITS;
for(i=0; i<DELAY; i++) { continue; } for(i=0; i<DELAY; i++) { continue; }