Monitor now does CALL and EXEC.
authortravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Thu, 7 Jan 2010 13:38:10 +0000 (13:38 +0000)
committertravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Thu, 7 Jan 2010 13:38:10 +0000 (13:38 +0000)
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
client/goodfet.monitor
firmware/apps/monitor/monitor.c

index 70e383e..562c654 100755 (executable)
@@ -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];
index 991c53e..f5eb1ca 100755 (executable)
@@ -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);
index 33b31c7..323691f 100644 (file)
@@ -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);