RTEMS 的 AT91SAM9260 移植(8): 编译

到这里,代码部分就修改完毕了,还需要修改该的就是Autotools的宏和链接脚本。

 

为了宏生成速度快,我把其他所有无关的BSP全部删除了。

Autotools宏的修改相对比较简单,文件位置参考以上的连载,有贴出具体目录下的文件。

这里首先修改:

c/src/lib/libbsp/arm/acinclude.am

这个文件修简单,相当于case语句一样,增加一个case语句的分支。让M4宏可以处理该BSP的configure和make.

at9200 ) AC_CONFIG_SUBDIRS([at9200]);;

 

 

 

 

c/src/lib/libbsp/arm/at9260/Makefile.am

## ## $Id: Makefile.am,v 1.14 2008/08/21 19:33:47 joel Exp $ ## ACLOCAL_AMFLAGS = -I ../../../../aclocal include $(top_srcdir)/../../../../automake/compile.am include $(top_srcdir)/../../bsp.am dist_project_lib_DATA = bsp_specs include_HEADERS = include/bsp.h include_HEADERS += include/tm27.h include_HEADERS += ../../../libcpu/@RTEMS_CPU@/@RTEMS_CPU_MODEL@/include/at91sam9260.h nodist_include_HEADERS = include/bspopts.h DISTCLEANFILES = include/bspopts.h noinst_PROGRAMS = nodist_include_HEADERS += ../../shared/include/coverhd.h EXTRA_DIST = start/start.S start.$(OBJEXT): start/start.S $(CPPASCOMPILE) -o $@ -c $< project_lib_DATA = start.$(OBJEXT) dist_project_lib_DATA += startup/linkcmds startup_SOURCES = ../../shared/bsplibc.c ../../shared/bsppost.c / ../../shared/bsppredriverhook.c / startup/bspstart.c startup/bspclean.c startup/memmap.c / ../../shared/bootcard.c ../../shared/sbrk.c / ../../shared/gnatinstallhandler.c console_SOURCES = console/uarts.c ../../shared/console.c abort_SOURCES = ../shared/abort/abort.c if HAS_NETWORKING network_CPPFLAGS = -D__INSIDE_RTEMS_BSD_TCPIP_STACK__ noinst_PROGRAMS += network.rel network_rel_SOURCES = network/network.c network_rel_CPPFLAGS = $(AM_CPPFLAGS) $(network_CPPFLAGS) network_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) endif noinst_LIBRARIES = libbsp.a libbsp_a_SOURCES = $(startup_SOURCES) $(console_SOURCES) $(abort_SOURCES) libbsp_a_LIBADD = ../../../libcpu/@RTEMS_CPU@/shared/arm920.rel / ../../../libcpu/@RTEMS_CPU@/@RTEMS_CPU_MODEL@/clock.rel / ../../../libcpu/@RTEMS_CPU@/@RTEMS_CPU_MODEL@/dbgu.rel / ../../../libcpu/@RTEMS_CPU@/@RTEMS_CPU_MODEL@/timer.rel / ../../../libcpu/@RTEMS_CPU@/@RTEMS_CPU_MODEL@/pmc.rel / ../../../libcpu/@RTEMS_CPU@/@RTEMS_CPU_MODEL@/irq.rel / ../../../libcpu/@RTEMS_CPU@/@RTEMS_CPU_MODEL@/memcpy.rel if HAS_NETWORKING libbsp_a_LIBADD += network.rel endif include $(srcdir)/preinstall.am include $(top_srcdir)/../../../../automake/local.am

 

c/src/lib/libbsp/arm/at9260/configure.ac

 

## Process this file with autoconf to produce a configure script. ## ## configure.ac,v 1.5 2003/03/11 09:39:07 ralf Exp AC_PREREQ(2.60) AC_INIT([rtems-c-src-lib-libbsp-arm-at9260],[_RTEMS_VERSION],[[email protected]]) AC_CONFIG_SRCDIR([bsp_specs]) RTEMS_TOP(../../../../../..) RTEMS_CANONICAL_TARGET_CPU AM_INIT_AUTOMAKE([no-define nostdinc foreign 1.10]) RTEMS_BSP_CONFIGURE RTEMS_PROG_CC_FOR_TARGET([-ansi -fasm]) RTEMS_CANONICALIZE_TOOLS RTEMS_PROG_CCAS RTEMS_CHECK_NETWORKING AM_CONDITIONAL(HAS_NETWORKING,test "$HAS_NETWORKING" = "yes") # Explicitly list all Makefiles here AC_CONFIG_FILES([Makefile]) AC_OUTPUT

 

c/src/lib/libcpu/arm/Makefile.am

## ## $Id: Makefile.am,v 1.12 2008/05/06 20:58:05 joel Exp $ ## ACLOCAL_AMFLAGS = -I ../../../aclocal include $(top_srcdir)/../../../automake/compile.am EXTRA_DIST = noinst_PROGRAMS = ## shared/include if shared include_libcpudir = $(includedir)/libcpu include_libcpu_HEADERS = shared/include/mmu.h ## shared/arm920 noinst_PROGRAMS += shared/arm920.rel shared_arm920_rel_SOURCES = shared/arm920/mmu.c shared_arm920_rel_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/shared/src shared_arm920_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) endif if at91sam9260 include_HEADERS = at91sam9260/include/at91sam9260.h / at91sam9260/include/bits.h ## at91sam9260/clock noinst_PROGRAMS += at91sam9260/clock.rel at91sam9260_clock_rel_SOURCES = at91sam9260/clock/clock.c at91sam9260_clock_rel_CPPFLAGS = $(AM_CPPFLAGS) at91sam9260_clock_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) ## at91sam9260/dbgu noinst_PROGRAMS += at91sam9260/dbgu.rel at91sam9260_dbgu_rel_SOURCES = at91sam9260/dbgu/dbgu.c at91sam9260_dbgu_rel_CPPFLAGS = $(AM_CPPFLAGS) at91sam9260_dbgu_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) ## at91sam9260/timer noinst_PROGRAMS += at91sam9260/timer.rel at91sam9260_timer_rel_SOURCES = at91sam9260/timer/timer.c at91sam9260_timer_rel_CPPFLAGS = $(AM_CPPFLAGS) at91sam9260_timer_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) ## at91sam9260/pmc noinst_PROGRAMS += at91sam9260/pmc.rel at91sam9260_pmc_rel_SOURCES = at91sam9260/pmc/pmc.c at91sam9260_pmc_rel_CPPFLAGS = $(AM_CPPFLAGS) at91sam9260_pmc_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) ## at91sam9260/interrupt include_HEADERS += at91sam9260/irq/irq.h noinst_PROGRAMS += at91sam9260/irq.rel at91sam9260_irq_rel_SOURCES = at91sam9260/irq/irq.c at91sam9260/irq/bsp_irq_init.c / ../../libbsp/arm/shared/irq/irq_init.c at91sam9260/irq/bsp_irq_asm.S / ../../libbsp/arm/shared/irq/irq_asm.S at91sam9260/irq/irq.h at91sam9260_irq_rel_CPPFLAGS = $(AM_CPPFLAGS) at91sam9260_irq_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) ## at91sam9260/memcpy noinst_PROGRAMS += at91sam9260/memcpy.rel at91sam9260_memcpy_rel_SOURCES = at91sam9260/memcpy/memcpy.S at91sam9260_memcpy_rel_CPPFLAGS = $(AM_CPPFLAGS) at91sam9260_memcpy_rel_LDFLAGS = $(RTEMS_RELLDFLAGS) endif include $(srcdir)/preinstall.am include $(top_srcdir)/../../../automake/local.am

 

c/src/lib/libcpu/arm/configure.ac

## Process this file with autoconf to produce a configure script. ## ## $Id: configure.ac,v 1.14 2008/05/06 20:58:05 joel Exp $ AC_PREREQ(2.60) AC_INIT([rtems-c-src-lib-libcpu-arm],[_RTEMS_VERSION],[http://www.rtems.org/bugzilla]) AC_CONFIG_SRCDIR([shared]) RTEMS_TOP([../../../../..],[../../..]) RTEMS_CANONICAL_TARGET_CPU AM_INIT_AUTOMAKE([no-define foreign subdir-objects 1.10]) AM_MAINTAINER_MODE RTEMS_ENV_RTEMSBSP RTEMS_PROJECT_ROOT RTEMS_PROG_CC_FOR_TARGET AM_PROG_CC_C_O RTEMS_CANONICALIZE_TOOLS RTEMS_PROG_CCAS AM_CONDITIONAL(shared, test "$RTEMS_CPU_MODEL" = "at91sam9260") AM_CONDITIONAL(at91sam9260, test "$RTEMS_CPU_MODEL" = "at91sam9260") RTEMS_AMPOLISH3 # Explicitly list all Makefiles here AC_CONFIG_FILES([Makefile ]) AC_OUTPUT

 

 

 

 

 

 

再来看看链接脚本。

这个链接脚本是我带以太网缓冲区的链接脚本,但并不影响不带以太网程序的使用。

AT9260的板子上提供了64MB的内存。

虽然AT9260的内部有两个4KB的SRAM,但我尝试使用这两个SRAM,总有这样或者

那样的运行时刻问题,我一怒之下,全部使用SDRAM。没有深究用SRAM为什么会有问题,

前后没有改什么代码,就是调试以太网时,以太网缓冲区在SRAM里转到SDRAM中。

这个问题先记下,还是要再查查。

/* * AT91SAM9260 link script * Bacon Xu */ OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") OUTPUT_ARCH(arm) ENTRY(_start) MEMORY { sdram : ORIGIN = 0x20000000, LENGTH = 64M } /* * Declare some sizes. */ _sdram_base = DEFINED(_sdram_base) ? _sdram_base : 0x20000000; _sdram_size = DEFINED(_sdram_size) ? _sdram_size : 64M; _irq_stack_size = DEFINED(_irq_stack_size) ? _irq_stack_size : 0x2000; _fiq_stack_size = DEFINED(_fiq_stack_size) ? _fiq_stack_size : 0x400; _abt_stack_size = DEFINED(_abt_stack_size) ? _abt_stack_size : 0x100; _svc_stack_size = DEFINED(_svc_stack_size) ? _svc_stack_size : 0x2000; SECTIONS { .init : { KEEP (*(.init)) } > sdram /*=0*/ .text : { _text_start = .; CREATE_OBJECT_SYMBOLS *(.text) *(.text.*) /* * Special FreeBSD sysctl sections. */ . = ALIGN (16); __start_set_sysctl_set = .; *(set_sysctl_*); __stop_set_sysctl_set = ABSOLUTE(.); *(set_domain_*); *(set_pseudo_*); /* .gnu.warning sections are handled specially by elf32.em. */ *(.gnu.warning) *(.gnu.linkonce.t*) *(.glue_7) *(.glue_7t) /* I think these come from the ld docs: */ ___CTOR_LIST__ = .; LONG((___CTOR_END__ - ___CTOR_LIST__) / 4 - 2) *(.ctors) LONG(0) ___CTOR_END__ = .; ___DTOR_LIST__ = .; LONG((___DTOR_END__ - ___DTOR_LIST__) / 4 - 2) *(.dtors) LONG(0) ___DTOR_END__ = .; _etext = .; PROVIDE (etext = .); } > sdram .fini : { KEEP (*(.fini)) } > sdram /*=0*/ .data : { *(.data) *(.data.*) *(.gnu.linkonce.d*) *(.jcr) SORT(CONSTRUCTORS) _edata = .; } > sdram .eh_frame : { *(.eh_frame) } > sdram .data1 : { *(.data1) } > sdram .eh_frame : { *(.eh_frame) } > sdram .gcc_except_table : { *(.gcc_except_table*) } > sdram .rodata : { *(.rodata) *(.rodata.*) *(.gnu.linkonce.r*) } > sdram .bss : { /* 256 byte aligned rx buffer header array */ /*. = ALIGN (0x100);*/ at91sam9260_emac_rxbuf_hdrs = .; . += (8 * 512 + 32); at91sam9260_emac_txbuf_hdrs = .; . += (8 * 1 + 32); /* 1 transmit buffer, 0x600 size */ at91sam9260_emac_txbuf = .; . += (2048 + 32); /* 24 receive buffers, 128 each */ at91sam9260_emac_rxbufs = .; . += (128 * 512 + 32); _bss_start_ = .; _clear_start = .; *(.bss) *(.bss.*) *(.gnu.linkonce.b.*) *(COMMON) . = ALIGN(64); _clear_end = .; . = ALIGN (256); _abt_stack = .; . += _abt_stack_size; . = ALIGN (256); _irq_stack = .; . += _irq_stack_size; . = ALIGN (256); _fiq_stack = .; . += _fiq_stack_size; . = ALIGN (256); _svc_stack = .; . += _svc_stack_size; _bss_end_ = .; _end = .; __end = .; /* * Ideally, the MMU's translation table would be in SRAM. But we need * 16K which is the size of SRAM. If we do the mapping right, the TLB * should be big enough that to hold all the translations that matter, * so keeping the table in SDRAM won't be a problem. */ . = ALIGN (16 * 1024); _ttbl_base = .; . += (16 * 1024); . = ALIGN (1024); _bss_free_start = .; } > sdram /* Debugging stuff follows? */ /* 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) } .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) } /* .stack 0x80000 : { _stack = .; *(.stack) }*/ /* These must appear regardless of . */ }

 

 

这一切全部修改该完毕后,我们就开始编译啦,首先进入开发系统:

 

export PATH=/opt/rtems-4.9/bin:$PATH

 

然后进入顶层的源代码目录夹,运行以下三条命令:

 

./bootstrap -c

 

./bootstrap -p

 

./bootstrap

 

注意提示,如果出现异常请检查我们改写的autotools的宏是否有问题。

 

然后建立一个at9260文件夹用于编译。

 

mkdir at9260

 

cd at9260

 

../configure --target=arm-rtems4.9 --disable-posix --disable-cxx --disable-networking --enable-rtemsbsp=at9260 --prefix=/opt/rtems-4.9

 

make

 

make install

 

如果编译成功,恭喜,那我们可以从官方网站上下载个例子来试试了。

如果没编译成功,请不要放弃,仔细检查每个环节,是否是哪里出问题了。如果是编译的过程中出问题,请仔细检查代码,一点点修改。

如果您对我说的方法有异议,请联系我。谢谢。

 

 下回聊聊如何搞定 Helloworld!!!

 

 

你可能感兴趣的:(timer,list,include,makefile,networking,debugging)