From f2bee319a0c1b0a6c7618c02dbdfeacd68d5fea0 Mon Sep 17 00:00:00 2001 From: travisutk Date: Thu, 7 Jan 2010 13:38:10 +0000 Subject: [PATCH] Monitor now does CALL and EXEC. This is useful for re-entering the bootloader when DTR/RTS aren't connected. Also for quick patches in machine language. git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@261 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- client/GoodFET.py | 4 ++++ client/goodfet.monitor | 8 ++++++++ firmware/apps/monitor/monitor.c | 9 ++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/client/GoodFET.py b/client/GoodFET.py index 70e383e..562c654 100755 --- a/client/GoodFET.py +++ b/client/GoodFET.py @@ -149,6 +149,10 @@ class GoodFET: def dir(self,byte): """Write a byte to P5DIR.""" self.writecmd(0,0xA0,1,[byte]); + def call(self,adr): + """Call to an address.""" + self.writecmd(0,0x30,2, + [adr&0xFF,(adr>>8)&0xFF]); def peekbyte(self,address): """Read a byte of memory from the monitor.""" self.data=[address&0xff,address>>8]; diff --git a/client/goodfet.monitor b/client/goodfet.monitor index 991c53e..f5eb1ca 100755 --- a/client/goodfet.monitor +++ b/client/goodfet.monitor @@ -16,6 +16,9 @@ if(len(sys.argv)==1): print "%s ramfill" % sys.argv[0]; print "%s ramdepth" % sys.argv[0]; print "%s info" % sys.argv[0]; + print "%s info" % sys.argv[0]; + print "%s call 0x$start" % sys.argv[0]; + print "%s exec '0x35 0x00 0x..'" % sys.argv[0]; sys.exit(); #Initailize FET and set baud rate @@ -28,6 +31,11 @@ if(sys.argv[1]=="on"): if(sys.argv[1]=="off"): client.out(0x00); +if(sys.argv[1]=="call"): + adr=int(sys.argv[2],16); + print "Calling %04x" % adr; + client.call(adr); + client.monitortest(); if(sys.argv[1]=="info"): a=client.peekbyte(0xff0); b=client.peekbyte(0xff1); diff --git a/firmware/apps/monitor/monitor.c b/firmware/apps/monitor/monitor.c index 33b31c7..323691f 100644 --- a/firmware/apps/monitor/monitor.c +++ b/firmware/apps/monitor/monitor.c @@ -9,9 +9,9 @@ //! Call a function by address. int fncall(unsigned int adr){ - //TODO replace this with portable C. - //Preprocessor definition might help. - __asm__("call r15"); //r12 on IAR + int (*machfn)() = 0; + machfn= (int (*)()) adr; + return machfn(); } //! Handles a monitor command. @@ -19,6 +19,9 @@ void monitorhandle(unsigned char app, unsigned char verb, unsigned long len){ switch(verb){ + default: + debugstr("ERROR: Command unsupported by debug monitor."); + break; case PEEK: cmddata[0]=memorybyte[cmddataword[0]]; txdata(app,verb,1); -- 2.20.1