From: travisutk Date: Thu, 20 Aug 2009 14:01:43 +0000 (+0000) Subject: Monitor improved to measure stack depth of any other application. X-Git-Url: http://git.rot13.org/?p=goodfet;a=commitdiff_plain;h=da2061d1d45ea077c127af4e74c189bb51abd441;ds=sidebyside Monitor improved to measure stack depth of any other application. See today's blog post for details. git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@79 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- diff --git a/firmware/Makefile b/firmware/Makefile index b17708b..1d6134e 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -23,7 +23,6 @@ run: install: $(app).hex $(BSL) -e -p $(app).hex - #$(BSL) -P $(app).hex -r $(app): $(app).c $(libs) $(apps) $(app).hex: $(app) msp430-objcopy goodfet -O ihex goodfet.hex diff --git a/firmware/apps/monitor/monitor.c b/firmware/apps/monitor/monitor.c index e5c320a..78aaa91 100644 --- a/firmware/apps/monitor/monitor.c +++ b/firmware/apps/monitor/monitor.c @@ -1,5 +1,6 @@ #include "command.h" #include "platform.h" +#include "monitor.h" //! Handles a monitor command. void monitorhandle(unsigned char app, @@ -21,5 +22,36 @@ void monitorhandle(unsigned char app, setbaud(cmddata[0]); //txdata(app,verb,0); break; + case MONITOR_RAM_PATTERN: + monitor_ram_pattern();//reboots, will never return + break; + case MONITOR_RAM_DEPTH: + cmddataword[0]=monitor_ram_depth(); + txdata(app,verb,2); + break; } } + +//! Overwrite all of RAM with 0xBEEF, then reboot. +void monitor_ram_pattern(){ + register int *a; + + //Wipe all of ram. + for(a=(int*)0x1100;a<(int*)0x2500;a++){//TODO get these from the linker. + *((int*)a) = 0xBEEF; + } + txdata(0x00,0x90,0); + + //Reboot + asm("br &0xfffe"); +} + +//! Return the number of contiguous bytes 0xBEEF, to measure RAM usage. +unsigned int monitor_ram_depth(){ + register int a; + register int count=0; + for(a=0x1100;a<0x2500;a+=2) + if(*((int*)a)==0xBEEF) count+=2; + + return count; +} diff --git a/firmware/apps/spi/spi.c b/firmware/apps/spi/spi.c index c70cdb4..5c733eb 100644 --- a/firmware/apps/spi/spi.c +++ b/firmware/apps/spi/spi.c @@ -96,7 +96,7 @@ void spiflash_setstatus(unsigned char c){ spitrans8(0x01);//SET STATUS spitrans8(c); P5OUT|=SS; //Raise !SS to end transaction. - return c; + //return c; } //! Handles a monitor command. diff --git a/firmware/include/command.h b/firmware/include/command.h index ece0ad1..d5e22e6 100644 --- a/firmware/include/command.h +++ b/firmware/include/command.h @@ -19,6 +19,8 @@ extern unsigned char cmddata[256]; // Monitor Commands #define MONITOR_CHANGE_BAUD 0x80 +#define MONITOR_RAM_PATTERN 0x90 +#define MONITOR_RAM_DEPTH 0x91 //CHIPCON commands #define CC_CHIP_ERASE 0x80