Subversion Repositories freemyipod

Rev

Rev 442 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 442 Rev 452
Line 482... Line 482...
482
        return self.lib.monitorcommand(struct.pack("IIII", 20, 0, 0, 0), "III", (None, None, None))
482
        return self.lib.monitorcommand(struct.pack("IIII", 20, 0, 0, 0), "III", (None, None, None))
483
    
483
    
484
    @command()
484
    @command()
485
    def execimage(self, addr):
485
    def execimage(self, addr):
486
        """ Runs the emCORE app at 'addr' """
486
        """ Runs the emCORE app at 'addr' """
487
        return self.lib.monitorcommand(struct.pack("IIII", 21, addr, 0, 0), "III", ("rc", None, None))
487
        return self.lib.monitorcommand(struct.pack("IIII", 21, addr, 0, 0), "III", ("thread", None, None))
488
    
488
    
489
    @command()
489
    @command()
490
    def run(self, app):
490
    def run(self, app):
491
        """ Uploads and runs the emCORE app in the string 'app' """
491
        """ Uploads and runs the emCORE app in the string 'app' """
492
        try:
-
 
493
            appheader = struct.unpack("<8sIIIIIIIIII", app[:48])
-
 
494
        except struct.error:
492
        if app[:8] != "emCOexec":
495
            raise ArgumentError("The specified app is not an emCORE application")
493
            raise ArgumentError("The specified app is not an emCORE application")
496
        header = appheader[0]
-
 
497
        if header != "emBIexec":
-
 
498
            raise ArgumentError("The specified app is not an emCORE application")
-
 
499
        baseaddr = appheader[2]
-
 
500
        threadnameptr = appheader[8]
-
 
501
        nameptr = threadnameptr - baseaddr
-
 
502
        name = ""
-
 
503
        while True:
-
 
504
            char = app[nameptr:nameptr+1]
-
 
505
            try:
-
 
506
                if ord(char) == 0:
-
 
507
                    break
-
 
508
            except TypeError:
-
 
509
                raise ArgumentError("The specified app is not an emCORE application")
-
 
510
            name += char
-
 
511
            nameptr += 1
-
 
512
        usermem = self.getusermemrange()
494
        baseaddr = self.malloc(len(app))
513
        if usermem.lower > baseaddr or usermem.upper < baseaddr + len(app):
-
 
514
            raise ArgumentError("The baseaddress of the specified emCORE application is out of range of the user memory range on the device. Are you sure that this application is compatible with your device?")
-
 
515
        self.write(baseaddr, app)
495
        self.write(baseaddr, app)
516
        self.execimage(baseaddr)
496
        result = self.execimage(baseaddr)
517
        return Bunch(baseaddr=baseaddr, name=name)
497
        return Bunch(thread=result.thread)
518
    
498
    
519
    @command(timeout = 5000)
499
    @command(timeout = 5000)
520
    def bootflashread(self, memaddr, flashaddr, size):
500
    def bootflashread(self, memaddr, flashaddr, size):
521
        """ Copies the data in the bootflash at 'flashaddr' of the specified size
501
        """ Copies the data in the bootflash at 'flashaddr' of the specified size
522
            to the memory at addr 'memaddr'
502
            to the memory at addr 'memaddr'