From 2e770cc4395ae7a39315a55b84b4936250b6c18b Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Sat, 4 Feb 2012 01:01:57 +0100 Subject: make armdebug compilation conditional Set ARMDEBUG to y in the Makefile to enable armdebug compilation. --- AT91SAM7S256/SAM7S256/Include/Cstartup.S | 11 +++++++++++ AT91SAM7S256/SAM7S256/Include/sam7s256.c | 4 ++-- AT91SAM7S256/SAM7S256/gcc/Makefile | 22 ++++++++++++++++------ AT91SAM7S256/Source/c_comm.c | 4 ++-- AT91SAM7S256/Source/c_comm.h | 2 +- 5 files changed, 32 insertions(+), 11 deletions(-) diff --git a/AT91SAM7S256/SAM7S256/Include/Cstartup.S b/AT91SAM7S256/SAM7S256/Include/Cstartup.S index e3e996e..8a6a540 100644 --- a/AT91SAM7S256/SAM7S256/Include/Cstartup.S +++ b/AT91SAM7S256/SAM7S256/Include/Cstartup.S @@ -136,11 +136,20 @@ 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 @@ -271,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__ +#endif /*- Set up Fast Interrupt Mode and set FIQ Mode Stack*/ msr CPSR_c, #ARM_MODE_FIQ | I_BIT | F_BIT 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 e96e153..f236a08 100644 --- a/AT91SAM7S256/SAM7S256/gcc/Makefile +++ b/AT91SAM7S256/SAM7S256/gcc/Makefile @@ -8,6 +8,9 @@ CUSTOM_FIRMWAREVERSION = $(GIT_VERSION) TARGET = nxt_firmware +# 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 \ @@ -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/Source/c_comm.c b/AT91SAM7S256/Source/c_comm.c index 1411b5d..176a1ff 100644 --- a/AT91SAM7S256/Source/c_comm.c +++ b/AT91SAM7S256/Source/c_comm.c @@ -26,7 +26,7 @@ #include "d_bt.h" #include #include -#ifdef __ARMDEBUG__ +#ifdef ARMDEBUG #include "debug_stub.h" #endif @@ -425,7 +425,7 @@ 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 */ diff --git a/AT91SAM7S256/Source/c_comm.h b/AT91SAM7S256/Source/c_comm.h index ac24b02..06137b2 100644 --- a/AT91SAM7S256/Source/c_comm.h +++ b/AT91SAM7S256/Source/c_comm.h @@ -67,7 +67,7 @@ enum DIRECT_CMD = 0x00, SYSTEM_CMD = 0x01, REPLY_CMD = 0x02, -#ifdef __ARMDEBUG__ +#ifdef ARMDEBUG DEBUG_CMD = 0x0d, #endif NO_REPLY_BIT = 0x80 -- cgit v1.2.3