aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Schodet2012-02-11 17:39:48 +0100
committerNicolas Schodet2012-02-11 17:40:50 +0100
commiteb584f8d27a856e8f4d2ddebdd1173ff04217946 (patch)
tree83bbf94ff00b0120c3e37aeb3f725561b03f1c5d
parent35d4c19a154b0b4366876783eacb13bec27d288c (diff)
parent99a4c90dee42104638933096728bebc45e28bf1a (diff)
Merge branch 'master'
Conflicts: AT91SAM7S256/SAM7S256/Include/Cstartup.S AT91SAM7S256/SAM7S256/Include/sam7s256.c AT91SAM7S256/SAM7S256/gcc/Makefile AT91SAM7S256/SAM7S256/gcc/nxt.ld AT91SAM7S256/Source/c_comm.c AT91SAM7S256/Source/c_comm.h
-rw-r--r--AT91SAM7S256/SAM7S256/Include/Cstartup.S38
-rw-r--r--AT91SAM7S256/SAM7S256/Include/sam7s256.c4
-rw-r--r--AT91SAM7S256/SAM7S256/gcc/Makefile26
-rw-r--r--AT91SAM7S256/SAM7S256/gcc/nxt.ld48
-rw-r--r--AT91SAM7S256/Source/c_comm.c13
-rw-r--r--AT91SAM7S256/Source/c_comm.h4
6 files changed, 83 insertions, 50 deletions
diff --git a/AT91SAM7S256/SAM7S256/Include/Cstartup.S b/AT91SAM7S256/SAM7S256/Include/Cstartup.S
index d02cf3f..0293251 100644
--- a/AT91SAM7S256/SAM7S256/Include/Cstartup.S
+++ b/AT91SAM7S256/SAM7S256/Include/Cstartup.S
@@ -136,20 +136,31 @@ FIQ_Handler_Entry:
/* end of fiqhandler */
Reset_Addr: .word InitReset
+#ifdef ARMDEBUG
Undef_Addr: .word undef_handler /* BKPT instruction trap */
+#else
+Undef_Addr: .word Undef_Handler
+#endif
SWI_Addr: .word SWI_Handler
/*SWI_Addr: .word SoftwareInterruptASM*/ /*in swi_handler.S */
+#ifdef ARMDEBUG
PAbt_Addr: .word prefetch_abort_handler
DAbt_Addr: .word data_abort_handler
+#else
+PAbt_Addr: .word PAbt_Handler
+DAbt_Addr: .word DAbt_Handler
+#endif
IRQ_Addr: .word IRQ_Handler_Entry
- .global default_undef_handler
+ .global default_undef_handler
default_undef_handler:
Undef_Handler: B Undef_Handler
SWI_Handler: B SWI_Handler
- .global default_prefetch_abort_handler
+ .global default_prefetch_abort_handler
+default_prefetch_abort_handler:
PAbt_Handler: B PAbt_Handler
- .global default_data_abort_handler
+ .global default_data_abort_handler
+default_data_abort_handler:
DAbt_Handler: B DAbt_Handler
@@ -259,7 +270,7 @@ already_remapped:
.EQU ARM_MODE_FIQ, 0x11
.EQU ARM_MODE_IRQ, 0x12
.EQU ARM_MODE_SVC, 0x13
- .EQU ARM_MODE_ABT, 0x17
+ .EQU ARM_MODE_ABT, 0x17
.EQU I_BIT, 0x80
.EQU F_BIT, 0x40
@@ -269,9 +280,11 @@ already_remapped:
//*-------------------------------*/
mov r0, sp /* see (**) */
+#ifdef ARMDEBUG
/*- Set up Abort Mode Stack for Debugger*/
msr CPSR_c, #ARM_MODE_ABT | I_BIT | F_BIT
- ldr sp, =__abort_stack_top__
+ ldr sp, =__abort_stack_top__
+#endif
/*- Set up Fast Interrupt Mode and set FIQ Mode Stack*/
msr CPSR_c, #ARM_MODE_FIQ | I_BIT | F_BIT
@@ -295,8 +308,6 @@ already_remapped:
mov sp, r0 /* Init stack Sup */
-
-
/*- Enable interrupt & Set up Supervisor Mode and set Supervisor Mode Stack*/
/* Relocate .data section (Copy from ROM to RAM)
@@ -449,5 +460,18 @@ AT91F_Spurious_handler:
.size AT91F_Spurious_handler, . - AT91F_Spurious_handler
.endfunc
+/*------------------------------------------------------------------------------
+//*- Various debugger stacks.
+//*-------------------------------*/
+
+#ifdef ARMDEBUG
+.section .stack.abort, "aw", %nobits
+ .space 0x80; /* 128 byte abort mode stack. */
+.section .stack.debugger, "aw", %nobits
+ .space 0x48; /* 16 user mode registers + SPSR + UNDEF Next Instruction Address */
+.section .breakpoints, "aw", %nobits
+ .space 0x40; /* Single Stepping Breakpoint + 7 Breakpoints */
+#endif
+
.end
diff --git a/AT91SAM7S256/SAM7S256/Include/sam7s256.c b/AT91SAM7S256/SAM7S256/Include/sam7s256.c
index 8ff0ab4..b2657d5 100644
--- a/AT91SAM7S256/SAM7S256/Include/sam7s256.c
+++ b/AT91SAM7S256/SAM7S256/Include/sam7s256.c
@@ -11,7 +11,7 @@
//
// Platform C
//
-#ifdef __ARMDEBUG__
+#ifdef ARMDEBUG
#include "debug_stub.h"
#endif
@@ -21,7 +21,7 @@ void main(void)
{
HARDWAREInit;
mSchedInit();
-#ifdef __ARMDEBUG__
+#ifdef ARMDEBUG
dbg__bkpt_init();
#endif
while(TRUE == mSchedCtrl())
diff --git a/AT91SAM7S256/SAM7S256/gcc/Makefile b/AT91SAM7S256/SAM7S256/gcc/Makefile
index f8f8561..93334fa 100644
--- a/AT91SAM7S256/SAM7S256/gcc/Makefile
+++ b/AT91SAM7S256/SAM7S256/gcc/Makefile
@@ -1,6 +1,6 @@
BASE = ../..
-DBGDIR = $(BASE)/armdebug/Debugger
SRCDIR = $(BASE)/Source
+DBGDIR = $(BASE)/armdebug/Debugger
CPUINCDIR = $(BASE)/SAM7S256/Include
GIT_VERSION := $(shell git rev-parse --short=7 HEAD)
@@ -8,7 +8,10 @@ CUSTOM_FIRMWAREVERSION = $(GIT_VERSION)
TARGET = nxt_firmware
-ARM_SOURCES =
+# Set to 'y' to enable embedded debuger.
+ARMDEBUG = n
+
+ARM_SOURCES =
THUMB_SOURCES = c_button.c c_cmd.c c_comm.c c_display.c c_input.c c_ioctrl.c \
c_loader.c c_lowspeed.c c_output.c c_sound.c c_ui.c \
d_bt.c d_button.c d_display.c d_hispeed.c d_input.c \
@@ -18,23 +21,21 @@ THUMB_SOURCES = c_button.c c_cmd.c c_comm.c c_display.c c_input.c c_ioctrl.c \
abort.c errno.c sbrk.c strtod.c sscanf.c \
Cstartup_SAM7.c
-ASM_ARM_SOURCE = Cstartup.S abort_handler.S undef_handler.S debug_hexutils.S \
- debug_stub.S debug_comm.S debug_opcodes.S debug_runlooptasks.S
+ASM_ARM_SOURCE = Cstartup.S
ASM_THUMB_SOURCE =
vpath %.c $(SRCDIR)
vpath %.c $(CPUINCDIR)
vpath %.c lib
-vpath %.S $(CPUINCDIR) $(DBGDIR)
+vpath %.S $(CPUINCDIR)
-INCLUDES = -I../../armdebug/Debugger
+INCLUDES =
MCU = arm7tdmi
-DEBUG_DEFINES = -D__ARMDEBUG__
STARTOFUSERFLASH_DEFINES = -DSTARTOFUSERFLASH_FROM_LINKER=1
VERSION_DEFINES = -DCUSTOM_FIRMWAREVERSION=\"$(CUSTOM_FIRMWAREVERSION)\"
DEFINES = -DPROTOTYPE_PCB_4 -DNEW_MENU -DROM_RUN -DVECTORS_IN_RAM \
- $(STARTOFUSERFLASH_DEFINES) $(VERSION_DEFINES) $(DEBUG_DEFINES)
+ $(STARTOFUSERFLASH_DEFINES) $(VERSION_DEFINES)
OPTIMIZE = -Os -fno-strict-aliasing \
-ffunction-sections -fdata-sections
WARNINGS = -Wall -W -Wundef -Wno-unused -Wno-format
@@ -46,6 +47,15 @@ LDSCRIPT = nxt.ld
LDFLAGS = -nostdlib -T $(LDSCRIPT) -Wl,--gc-sections
LDLIBS = -lc -lm -lgcc
+ifeq ($(ARMDEBUG),y)
+ASM_ARM_SOURCE += abort_handler.S undef_handler.S debug_hexutils.S \
+ debug_stub.S debug_comm.S debug_opcodes.S \
+ debug_runlooptasks.S
+vpath %.S $(DBGDIR)
+DEFINES += -DARMDEBUG
+INCLUDES += -I../../armdebug/Debugger
+endif
+
CROSS_COMPILE = arm-none-eabi-
CC = $(CROSS_COMPILE)gcc
OBJDUMP = $(CROSS_COMPILE)objdump
diff --git a/AT91SAM7S256/SAM7S256/gcc/nxt.ld b/AT91SAM7S256/SAM7S256/gcc/nxt.ld
index 7b5a9e2..e54bc5d 100644
--- a/AT91SAM7S256/SAM7S256/gcc/nxt.ld
+++ b/AT91SAM7S256/SAM7S256/gcc/nxt.ld
@@ -87,30 +87,29 @@ SECTIONS
__STARTOFUSERFLASH_FROM_LINKER =
ALIGN (LOADADDR (.data) + SIZEOF (.data), 0x100);
- /*
- * The various debugger stacks.
- */
- .stack : ALIGN(8) {
-
- /* abort stack */
- __abort_stack_bottom__ = . ;
- . += 0x80; /* 128 byte abort mode stack. */
- __abort_stack__ = .;
- __abort_stack_top__ = . ;
-
- /* debugger state */
- __debugger_stack_bottom__ = . ;
- . += 0x48; /* 16 user mode registers + SPSR + UNDEF Next Instruction Address */
- __debugger_stack__ = .;
- __debugger_stack_top__ = . ;
-
- /* breakpoints */
- __breakpoints_start__ = . ;
- . += 0x40; /* Single Stepping Breakpoint + 7 Breakpoints */
- __breakpoints_end__ = . ;
- } > DATA
-
- __breakpoints_num__ = (__breakpoints_end__ - __breakpoints_start__) / 8;
+ /*
+ * The various debugger stacks.
+ */
+ .stack : ALIGN(8) {
+ /* abort stack */
+ __abort_stack_bottom__ = . ;
+ KEEP(*(.stack.abort))
+ __abort_stack__ = . ;
+ __abort_stack_top__ = . ;
+
+ /* debugger state */
+ __debugger_stack_bottom__ = . ;
+ KEEP(*(.stack.debugger))
+ __debugger_stack__ = . ;
+ __debugger_stack_top__ = . ;
+
+ /* breakpoints */
+ __breakpoints_start__ = . ;
+ KEEP(*(.breakpoints))
+ __breakpoints_end__ = . ;
+ } > DATA
+
+ __breakpoints_num__ = (__breakpoints_end__ - __breakpoints_start__) / 8;
/* .bss section which is used for uninitialized data */
.bss (NOLOAD) :
@@ -128,7 +127,6 @@ SECTIONS
__bss_end__ = . ;
-
_end = .;
PROVIDE (end = .);
diff --git a/AT91SAM7S256/Source/c_comm.c b/AT91SAM7S256/Source/c_comm.c
index b4d3be0..42fbe2f 100644
--- a/AT91SAM7S256/Source/c_comm.c
+++ b/AT91SAM7S256/Source/c_comm.c
@@ -26,7 +26,7 @@
#include "d_bt.h"
#include <string.h>
#include <ctype.h>
-#ifdef __ARMDEBUG__
+#ifdef ARMDEBUG
#include "debug_stub.h"
#endif
@@ -454,16 +454,17 @@ UWORD cCommInterprete(UBYTE *pInBuf, UBYTE *pOutBuf, UBYTE *pLength, UBYTE C
}
break;
-#ifdef __ARMDEBUG__
+#ifdef ARMDEBUG
case DEBUG_CMD:
{
- ReturnStatus = cCommHandleDebug(&(pInBuf[0]), CmdBit, MsgLength); /* Pass everything (incl. message command byte) to function */
- /* Check that Debug Command does not expect reply */
- ReturnStatus = (0 == ((pInBuf[0]) & NO_REPLY_BIT));
- *pLength = 0;
+ ReturnStatus = cCommHandleDebug(&(pInBuf[0]), CmdBit, MsgLength); /* Pass everything (incl. message command byte) to function */
+ /* Check that Debug Command does not expect reply */
+ ReturnStatus = (0 == ((pInBuf[0]) & NO_REPLY_BIT));
+ *pLength = 0;
}
break;
#endif
+
default:
{
diff --git a/AT91SAM7S256/Source/c_comm.h b/AT91SAM7S256/Source/c_comm.h
index 9003b24..06137b2 100644
--- a/AT91SAM7S256/Source/c_comm.h
+++ b/AT91SAM7S256/Source/c_comm.h
@@ -67,8 +67,8 @@ enum
DIRECT_CMD = 0x00,
SYSTEM_CMD = 0x01,
REPLY_CMD = 0x02,
-#ifdef __ARMDEBUG__
- DEBUG_CMD = 0x0d,
+#ifdef ARMDEBUG
+ DEBUG_CMD = 0x0d,
#endif
NO_REPLY_BIT = 0x80
};