mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
Add AVR32 start function
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2970 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -43,16 +43,21 @@ endif
|
|||||||
|
|
||||||
ifeq ($(WINTOOL),y)
|
ifeq ($(WINTOOL),y)
|
||||||
NUTTX = "${shell cygpath -w $(TOPDIR)/nuttx}"
|
NUTTX = "${shell cygpath -w $(TOPDIR)/nuttx}"
|
||||||
CFLAGS += -I "${shell cygpath -w $(ARCH_SRCDIR)/chip}" \
|
INCLUDES = -I "${shell cygpath -w $(ARCH_SRCDIR)/chip}" \
|
||||||
-I "${shell cygpath -w $(ARCH_SRCDIR)/common}" \
|
-I "${shell cygpath -w $(ARCH_SRCDIR)/common}" \
|
||||||
-I "${shell cygpath -w $(ARCH_SRCDIR)/$(ARCH_SUBDIR)}" \
|
-I "${shell cygpath -w $(ARCH_SRCDIR)/$(ARCH_SUBDIR)}" \
|
||||||
-I "${shell cygpath -w $(TOPDIR)/sched}"
|
-I "${shell cygpath -w $(TOPDIR)/sched}"
|
||||||
else
|
else
|
||||||
NUTTX = $(TOPDIR)/nuttx
|
NUTTX = $(TOPDIR)/nuttx
|
||||||
CFLAGS += -I$(ARCH_SRCDIR)/chip -I$(ARCH_SRCDIR)/common \
|
INCLUDES = -I$(ARCH_SRCDIR)/chip -I$(ARCH_SRCDIR)/common \
|
||||||
-I$(ARCH_SRCDIR)/$(ARCH_SUBDIR) -I$(TOPDIR)/sched
|
-I$(ARCH_SRCDIR)/$(ARCH_SUBDIR) -I$(TOPDIR)/sched
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
CPPFLAGS += $(INCLUDES)
|
||||||
|
CFLAGS += $(INCLUDES)
|
||||||
|
CXXFLAGS += $(INCLUDES)
|
||||||
|
AFLAGS += $(INCLUDES)
|
||||||
|
|
||||||
HEAD_AOBJ = $(HEAD_ASRC:.S=$(OBJEXT))
|
HEAD_AOBJ = $(HEAD_ASRC:.S=$(OBJEXT))
|
||||||
|
|
||||||
ASRCS = $(CHIP_ASRCS) $(CMN_ASRCS)
|
ASRCS = $(CHIP_ASRCS) $(CMN_ASRCS)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
# The start-up, "head", file
|
# The start-up, "head", file
|
||||||
|
|
||||||
HEAD_ASRC =
|
HEAD_ASRC = up_nommuhead.S
|
||||||
|
|
||||||
# Common AVR/AVR32 files
|
# Common AVR/AVR32 files
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,180 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* arch/avr32/src/arm/up_nommuhead.S
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
|
||||||
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
#include <arch/avr32/avr32.h>
|
||||||
|
|
||||||
|
#include "up_internal.h"
|
||||||
|
#include "up_arch.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* External Symbols
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
.global _sbss /* Start of .bss. Defined by ld.script */
|
||||||
|
.global _ebss /* End of .bss. Defined by ld.script */
|
||||||
|
#ifdef CONFIG_BOOT_RUNFROMFLASH
|
||||||
|
.global _sdata /* Start of .data section in RAM */
|
||||||
|
.global _edata /* End of .data section in RAM */
|
||||||
|
.global _erdonly /* Start of .data section in FLASH */
|
||||||
|
#endif
|
||||||
|
.global up_lowinit /* Perform low level initialization */
|
||||||
|
.global up_boardinit /* Low-level board initialization */
|
||||||
|
.global os_start /* NuttX entry point */
|
||||||
|
.global vectors /* Vector base address */
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Macros
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG
|
||||||
|
.macro showprogress, code
|
||||||
|
.endm
|
||||||
|
.macro doputc, code
|
||||||
|
mov r12, \code
|
||||||
|
mcall up_putc
|
||||||
|
.endm
|
||||||
|
#else
|
||||||
|
.macro showprogress, code
|
||||||
|
.endm
|
||||||
|
.macro doputc, code
|
||||||
|
.endm
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* OS Entry Point
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* The following entry point must be linked to execute at 0x80000000 if it
|
||||||
|
* is to execute upon reset.
|
||||||
|
*/
|
||||||
|
.text
|
||||||
|
.global __start
|
||||||
|
.type __start, @function
|
||||||
|
__start:
|
||||||
|
|
||||||
|
/* Set the IDLE thread stack pointer. This stack will be used
|
||||||
|
* through NuttX initialization and will, eventually, be inherited
|
||||||
|
* by the IDLE thread when threading is enabled.
|
||||||
|
*/
|
||||||
|
|
||||||
|
lddpc r0, .Lstackbase
|
||||||
|
ld.w sp, r0[0]
|
||||||
|
|
||||||
|
/* Set up the vector base address so interrupts can be enabled. */
|
||||||
|
|
||||||
|
lda.w r0, vectors
|
||||||
|
mtsr AVR32_EVBA, r0
|
||||||
|
|
||||||
|
/* Enable exception processing */
|
||||||
|
|
||||||
|
csrf AVR32_SR_EM_SHIFT
|
||||||
|
showprogress 'A'
|
||||||
|
|
||||||
|
/* Clear system BSS section */
|
||||||
|
|
||||||
|
lda.w r0, _sbss /* R =Start of .bss */
|
||||||
|
lda.w r1, _ebss /* r1=End of .bss */
|
||||||
|
mov r2, 0 /* Value to write to .bss */
|
||||||
|
rjmp 2f /* Start at the bottom of the loop */
|
||||||
|
1:
|
||||||
|
st.d r0++, r2 /* Zero .bss */
|
||||||
|
2:
|
||||||
|
cp r0, r1 /* Finished? */
|
||||||
|
brlo 1b /* No... keep looping */
|
||||||
|
|
||||||
|
showprogress 'B'
|
||||||
|
|
||||||
|
/* Copy system .data sections to new home in RAM. */
|
||||||
|
|
||||||
|
#ifdef CONFIG_BOOT_RUNFROMFLASH
|
||||||
|
|
||||||
|
lda.w r0, _sdata /* r0=Start of .data section in RAM */
|
||||||
|
lda.w r1, _edata /* r1=End of .data section in RAM */
|
||||||
|
lda.w r2, _erdonly /* r2=Start of .data in FLASH */
|
||||||
|
rjmp 4f /* Start at the bottom of the loop */
|
||||||
|
3:
|
||||||
|
ld.d r4, r2++ /* Fetch the next data value */
|
||||||
|
st.d r0++, r4 /* Write it to the .data section */
|
||||||
|
4:
|
||||||
|
cp r0, r1 /* Finished? */
|
||||||
|
brlo 3b /* No... keep looping */
|
||||||
|
|
||||||
|
showprogress 'C'
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Clear the frame pointer and link register since this is the outermost
|
||||||
|
* frame.
|
||||||
|
*/
|
||||||
|
|
||||||
|
mov r7, 0
|
||||||
|
mov lr, 0
|
||||||
|
|
||||||
|
/* Perform low-level initialization */
|
||||||
|
|
||||||
|
mcall up_lowinit
|
||||||
|
|
||||||
|
doputc 'D'
|
||||||
|
|
||||||
|
/* Board specific early initialization */
|
||||||
|
|
||||||
|
mcall up_ledinit
|
||||||
|
|
||||||
|
/* Then jump to OS entry (will not return) */
|
||||||
|
|
||||||
|
rjmp os_start
|
||||||
|
|
||||||
|
.Lstackbase:
|
||||||
|
.long _ebss+CONFIG_IDLETHREAD_STACKSIZE-4
|
||||||
|
.size __start, .-__start
|
||||||
|
|
||||||
|
/* This global variable is unsigned long g_heapbase and is
|
||||||
|
* exported from here only because of its coupling to other
|
||||||
|
* uses of _ebss in this file
|
||||||
|
*/
|
||||||
|
|
||||||
|
.data
|
||||||
|
.align 4
|
||||||
|
.globl g_heapbase
|
||||||
|
.type g_heapbase, object
|
||||||
|
g_heapbase:
|
||||||
|
.long _ebss+CONFIG_IDLETHREAD_STACKSIZE
|
||||||
|
.size g_heapbase, .-g_heapbase
|
||||||
|
.end
|
||||||
|
|
||||||
@@ -725,7 +725,7 @@ CONFIG_EXAMPLES_USBSERIAL_TRACEINTERRUPTS=n
|
|||||||
#
|
#
|
||||||
# CONFIG_BOOT_RUNFROMFLASH - Some configurations support XIP
|
# CONFIG_BOOT_RUNFROMFLASH - Some configurations support XIP
|
||||||
# operation from FLASH but must copy initialized .data sections to RAM.
|
# operation from FLASH but must copy initialized .data sections to RAM.
|
||||||
# (should also be =n for the AVR32 which always runs from flash)
|
# (should always be =y for this AVR32 which always runs from flash)
|
||||||
# CONFIG_BOOT_COPYTORAM - Some configurations boot in FLASH
|
# CONFIG_BOOT_COPYTORAM - Some configurations boot in FLASH
|
||||||
# but copy themselves entirely into RAM for better performance.
|
# but copy themselves entirely into RAM for better performance.
|
||||||
# CONFIG_CUSTOM_STACK - The up_ implementation will handle
|
# CONFIG_CUSTOM_STACK - The up_ implementation will handle
|
||||||
@@ -742,7 +742,7 @@ CONFIG_EXAMPLES_USBSERIAL_TRACEINTERRUPTS=n
|
|||||||
# CONFIG_HEAP_BASE - The beginning of the heap
|
# CONFIG_HEAP_BASE - The beginning of the heap
|
||||||
# CONFIG_HEAP_SIZE - The size of the heap
|
# CONFIG_HEAP_SIZE - The size of the heap
|
||||||
#
|
#
|
||||||
CONFIG_BOOT_RUNFROMFLASH=n
|
CONFIG_BOOT_RUNFROMFLASH=y
|
||||||
CONFIG_BOOT_COPYTORAM=n
|
CONFIG_BOOT_COPYTORAM=n
|
||||||
CONFIG_CUSTOM_STACK=n
|
CONFIG_CUSTOM_STACK=n
|
||||||
CONFIG_STACK_POINTER=
|
CONFIG_STACK_POINTER=
|
||||||
|
|||||||
@@ -33,21 +33,18 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* The AT91UC3B0256 has 256Kb of FLASH beginning at address 0x0000:0000 and
|
OUTPUT_FORMAT("elf32-avr32", "elf32-avr32", "elf32-avr32")
|
||||||
* 64Kb of total SRAM: 32Kb of SRAM in the CPU block beginning at address
|
OUTPUT_ARCH(avr32:uc)
|
||||||
* 0x10000000 and 32Kb of AHB SRAM in two banks of 16Kb beginning at addresses
|
ENTRY(_stext)
|
||||||
* 0x20070000 and 0x20080000. Here we assume that .data and .bss will all fit
|
|
||||||
* into the 32Kb CPU SRAM address range.
|
|
||||||
*/
|
|
||||||
|
|
||||||
MEMORY
|
MEMORY
|
||||||
{
|
{
|
||||||
flash (rx) : ORIGIN = 0x00000000, LENGTH = 256K
|
flash (rxai!w) : ORIGIN = 0x80000000, LENGTH = 0x00020000
|
||||||
sram (rwx) : ORIGIN = 0x10000000, LENGTH = 32K
|
intram (wxa!ri) : ORIGIN = 0x00000004, LENGTH = 0x00007FFC
|
||||||
|
userpage : ORIGIN = 0x80800000, LENGTH = 0x00000200
|
||||||
|
factorypage : ORIGIN = 0x80800200, LENGTH = 0x00000200
|
||||||
}
|
}
|
||||||
|
|
||||||
OUTPUT_ARCH(avr32)
|
|
||||||
ENTRY(_stext)
|
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
.text : {
|
.text : {
|
||||||
@@ -74,7 +71,7 @@ SECTIONS
|
|||||||
*(.gnu.linkonce.d.*)
|
*(.gnu.linkonce.d.*)
|
||||||
CONSTRUCTORS
|
CONSTRUCTORS
|
||||||
_edata = ABSOLUTE(.);
|
_edata = ABSOLUTE(.);
|
||||||
} > sram AT > flash
|
} > intram AT > flash
|
||||||
|
|
||||||
.bss : { /* BSS */
|
.bss : { /* BSS */
|
||||||
_sbss = ABSOLUTE(.);
|
_sbss = ABSOLUTE(.);
|
||||||
@@ -82,7 +79,7 @@ SECTIONS
|
|||||||
*(.gnu.linkonce.b.*)
|
*(.gnu.linkonce.b.*)
|
||||||
*(COMMON)
|
*(COMMON)
|
||||||
_ebss = ABSOLUTE(.);
|
_ebss = ABSOLUTE(.);
|
||||||
} > sram
|
} > intram
|
||||||
/* Stabs debugging sections. */
|
/* Stabs debugging sections. */
|
||||||
.stab 0 : { *(.stab) }
|
.stab 0 : { *(.stab) }
|
||||||
.stabstr 0 : { *(.stabstr) }
|
.stabstr 0 : { *(.stabstr) }
|
||||||
|
|||||||
Reference in New Issue
Block a user