From 503cd98f98975ac0996dfdb39986bb7265104216 Mon Sep 17 00:00:00 2001 From: Tat-Chee Wan (USM) Date: Mon, 14 Feb 2011 11:50:09 +0800 Subject: added hooks to invoke debugger from nxt firmware comm module --- AT91SAM7S256/SAM7S256/gcc/Makefile | 5 +++-- AT91SAM7S256/Source/c_comm.c | 14 +++++++++++++- AT91SAM7S256/Source/c_comm.h | 3 +++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/AT91SAM7S256/SAM7S256/gcc/Makefile b/AT91SAM7S256/SAM7S256/gcc/Makefile index 002539c..cbaef77 100644 --- a/AT91SAM7S256/SAM7S256/gcc/Makefile +++ b/AT91SAM7S256/SAM7S256/gcc/Makefile @@ -18,7 +18,7 @@ THUMB_SOURCES = c_button.c c_cmd.c c_comm.c c_display.c c_input.c c_ioctrl.c \ errno.c sbrk.c strtod.c sscanf.c \ Cstartup_SAM7.c -ASM_ARM_SOURCE = Cstartup.S undef_handler.S debug_stub.S debug_comm.S +ASM_ARM_SOURCE = Cstartup.S undef_handler.S debug_stub.S debug_comm.S debug_runlooptasks.S ASM_THUMB_SOURCE = vpath %.c $(SRCDIR) @@ -29,10 +29,11 @@ vpath %.S $(CPUINCDIR) $(DBGDIR) INCLUDES = -I../../armdebug/Debugger 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) + $(STARTOFUSERFLASH_DEFINES) $(VERSION_DEFINES) $(DEBUG_DEFINES) OPTIMIZE = -Os -fno-strict-aliasing \ -ffunction-sections -fdata-sections WARNINGS = -Wall -W -Wundef -Wno-unused -Wno-format diff --git a/AT91SAM7S256/Source/c_comm.c b/AT91SAM7S256/Source/c_comm.c index ee0c6ae..bebf5f3 100644 --- a/AT91SAM7S256/Source/c_comm.c +++ b/AT91SAM7S256/Source/c_comm.c @@ -26,6 +26,9 @@ #include "d_bt.h" #include #include +#ifdef __ARMDEBUG__ +#include "debug_stub.h" +#endif enum { @@ -422,6 +425,16 @@ UWORD cCommInterprete(UBYTE *pInBuf, UBYTE *pOutBuf, UBYTE *pLength, UBYTE C } break; +#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 */ + assert ((pInBuf[0]) & NO_REPLY_BIT); + *pLength = 0; + } + break; +#endif default: { @@ -476,7 +489,6 @@ UWORD cCommInterprete(UBYTE *pInBuf, UBYTE *pOutBuf, UBYTE *pLength, UBYTE C return(ReturnStatus); } - UWORD cCommInterpreteCmd(UBYTE Cmd, UBYTE *pInBuf, UBYTE *pOutBuf, UBYTE *pLength, UBYTE CmdBit, UWORD MsgLength) { ULONG FileLength; diff --git a/AT91SAM7S256/Source/c_comm.h b/AT91SAM7S256/Source/c_comm.h index a1e112c..9003b24 100644 --- a/AT91SAM7S256/Source/c_comm.h +++ b/AT91SAM7S256/Source/c_comm.h @@ -67,6 +67,9 @@ enum DIRECT_CMD = 0x00, SYSTEM_CMD = 0x01, REPLY_CMD = 0x02, +#ifdef __ARMDEBUG__ + DEBUG_CMD = 0x0d, +#endif NO_REPLY_BIT = 0x80 }; -- cgit v1.2.3