From 1759ff01a0eaf3f88a0dc8d64b0d69a34b9a65e9 Mon Sep 17 00:00:00 2001 From: Mariano Alvira Date: Sun, 21 Feb 2010 18:47:12 -0500 Subject: [PATCH] getting there... --- Makefile.include | 123 ++----------------- board/Makefile.board | 7 ++ board/boards.h | 7 -- board/redbee-dev.h | 4 + config.mk | 43 +------ libmc1322x/Makefile.lib | 1 + mc1322x.lds | 262 ++++++++++++++++++++++++++++++++++++++++ tests/Makefile | 6 +- tests/blink-red.c | 7 +- 9 files changed, 296 insertions(+), 164 deletions(-) create mode 100644 board/Makefile.board delete mode 100644 board/boards.h create mode 100644 board/redbee-dev.h create mode 100644 libmc1322x/Makefile.lib create mode 100644 mc1322x.lds diff --git a/Makefile.include b/Makefile.include index 38dd85d99..6f90ce88a 100644 --- a/Makefile.include +++ b/Makefile.include @@ -1,117 +1,24 @@ -# -# (C) Copyright 2000-2004 -# 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 -# +LINKERSCRIPT = $(MC1322X)/mc1322x.lds +LIBMC1322X = $(MC1322X)/libmc1322x -# Deal with colliding definitions from tcsh etc. -VENDOR= +include $(MC1322X)/config.mk -######################################################################### +include $(MC1322X)/board/Makefile.board + +include $(MC1322X)/libmc1322x/Makefile.lib ARCH = arm CPU = arm7tdmi-s export ARCH CPU VENDOR -# load other configuration -include $(LIBMC1322x)/config.mk +$(OBJDIR)/isr.o: isr.c + $(CC) $(CFLAGS) $(ARM_FLAGS) $< -c -o $@ -######################################################################### +%.o: %.c + $(CC) $(CFLAGS) $(THUMB_FLAGS) $< -c -AOBJS = -COBJS = $(patsubst %.c,%.o,$(wildcard $(LIBMC1322x)/src/*.c)) -#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 - -######################################################################### +$(OBJDIR)/%.o: %.c + $(CC) $(CFLAGS) $(THUMB_FLAGS) -c $< -o $@ clean: find . -type f \ @@ -131,9 +38,3 @@ clobber: clean mrproper \ distclean: clobber - -backup: - F=`basename $(LIBMC1322x)` ; cd .. ; \ - tar --force-local -zcvf `date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F - -######################################################################### diff --git a/board/Makefile.board b/board/Makefile.board new file mode 100644 index 000000000..bcc333625 --- /dev/null +++ b/board/Makefile.board @@ -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) \ No newline at end of file diff --git a/board/boards.h b/board/boards.h deleted file mode 100644 index 6dfe63f53..000000000 --- a/board/boards.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifdef BOARD_REDBEE_DEV -#include "redbee-dev.h" -#endif - -#ifdef BOARD_REDWIRE_R1 -#include "red-r1.h" -#endif diff --git a/board/redbee-dev.h b/board/redbee-dev.h new file mode 100644 index 000000000..af7c38ffa --- /dev/null +++ b/board/redbee-dev.h @@ -0,0 +1,4 @@ +#ifndef BOARD_REDBEE_DEV_H +#define BOARD_REDBEE_DEV_H + +#endif diff --git a/config.mk b/config.mk index 5af284c46..a0a1533fa 100644 --- a/config.mk +++ b/config.mk @@ -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_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 -TEXT_BASE = 0x00400000 +PLATFORM_CPPFLAGS = -march=armv4t -mlong-calls -mtune=arm7tdmi-s -DCONFIG_ARM -D__ARM__ -mthumb-interwork +THUMB_FLAGS=-mthumb -mcallee-super-interworking ######################################################################### @@ -55,22 +29,15 @@ gccincdir := $(shell $(CC) -print-file-name=include) CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS) \ -D__KERNEL__ -DTEXT_BASE=$(TEXT_BASE) \ - -I$(TOPDIR)/libmc1322x/include \ - -I$(TOPDIR)/board \ -fno-builtin -ffreestanding -nostdinc -isystem \ $(gccincdir) -pipe $(PLATFORM_CPPFLAGS) -ifdef BUILD_TAG -CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes \ - -DBUILD_TAG='"$(BUILD_TAG)"' -else -CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -endif +CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wcast-align -Wcast-align AFLAGS_DEBUG := -Wa,-gstabs 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 $(CC) $(AFLAGS) -c -o $@ $(CURDIR)/$< %.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< + $(CC) $(CFLAGS) $(THUMB_FLAGS) -c -o $@ $< ######################################################################### diff --git a/libmc1322x/Makefile.lib b/libmc1322x/Makefile.lib new file mode 100644 index 000000000..41076d2fb --- /dev/null +++ b/libmc1322x/Makefile.lib @@ -0,0 +1 @@ +CFLAGS += -I$(LIBMC1322X)/include diff --git a/mc1322x.lds b/mc1322x.lds new file mode 100644 index 000000000..061604a23 --- /dev/null +++ b/mc1322x.lds @@ -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) } +} diff --git a/tests/Makefile b/tests/Makefile index e064d7352..b360356f6 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,7 +1,5 @@ -LIBMC1322x = .. +MC1322X = .. -BOARD=dev - -include $(LIBMC1322x)/Makefile.include +include $(MC1322X)/Makefile.include all: blink-red \ No newline at end of file diff --git a/tests/blink-red.c b/tests/blink-red.c index cde4ef6e1..16a2189ee 100644 --- a/tests/blink-red.c +++ b/tests/blink-red.c @@ -1,5 +1,4 @@ #include -#include #define MBAR_GPIO 0x80000000 #define GPIO_PAD_DIR0 ((volatile uint32_t *) 0x80000000) @@ -7,18 +6,18 @@ #define UART1_DATA ((volatile uint32_t *) 0x80005008) #define DELAY 400000 -#define LED_BITS LED_RED +//#define LED_BITS LED_RED __attribute__ ((section ("startup"))) void main(void) { volatile uint32_t i; - *GPIO_PAD_DIR0 = LED_BITS; +// *GPIO_PAD_DIR0 = LED_BITS; while(1) { - *GPIO_DATA0 = LED_BITS; +// *GPIO_DATA0 = LED_BITS; for(i=0; i