Index: emcore/trunk/tools/emcore.py |
— | — | @@ -85,7 +85,7 @@ |
86 | 86 | logger.write(doc[function]['documentation']+"\n", 4)
|
87 | 87 | logger.write("\n")
|
88 | 88 | logger.write("\n")
|
89 | | -
|
| 89 | +
|
90 | 90 | if errormsg:
|
91 | 91 | logger.error(str(errormsg)+"\n")
|
92 | 92 | exit(2)
|
— | — | @@ -134,7 +134,7 @@ |
135 | 135 | self.logger.error("No emCORE device found!\n")
|
136 | 136 | exit(1)
|
137 | 137 | self.getinfo("version")
|
138 | | -
|
| 138 | +
|
139 | 139 | def _parsecommand(self, func, args):
|
140 | 140 | # adds self to the commandline args.
|
141 | 141 | # this is needed because the functions need access to their class.
|
— | — | @@ -182,7 +182,7 @@ |
183 | 183 | elif something.lower() in falselist:
|
184 | 184 | return False
|
185 | 185 | raise ArgumentTypeError("bool", "'%s'" % something)
|
186 | | -
|
| 186 | +
|
187 | 187 | @staticmethod
|
188 | 188 | def _hexint(something):
|
189 | 189 | """
|
— | — | @@ -309,7 +309,7 @@ |
310 | 310 | f.write(self.emcore.read(addr, size))
|
311 | 311 | f.close()
|
312 | 312 | self.logger.info("done\n")
|
313 | | -
|
| 313 | +
|
314 | 314 | @command
|
315 | 315 | def uploadint(self, addr, integer):
|
316 | 316 | """
|
— | — | @@ -324,7 +324,7 @@ |
325 | 325 | data = struct.pack("I", integer)
|
326 | 326 | self.emcore.write(addr, data)
|
327 | 327 | self.logger.info("Integer '0x%X' written successfully to 0x%X\n" % (integer, addr))
|
328 | | -
|
| 328 | +
|
329 | 329 | @command
|
330 | 330 | def downloadint(self, addr):
|
331 | 331 | """
|
— | — | @@ -335,7 +335,7 @@ |
336 | 336 | data = self.emcore.read(addr, 4)
|
337 | 337 | integer = struct.unpack("I", data)[0]
|
338 | 338 | self.logger.info("Read '0x%X' from address 0x%X\n" % (integer, addr))
|
339 | | -
|
| 339 | +
|
340 | 340 | @command
|
341 | 341 | def i2cread(self, bus, slave, addr, size):
|
342 | 342 | """
|
— | — | @@ -354,7 +354,7 @@ |
355 | 355 | self.logger.info("Data read from I2C:\n")
|
356 | 356 | for index, byte in enumerate(bytes):
|
357 | 357 | self.logger.info("%02X: %02X\n" % (index, byte))
|
358 | | -
|
| 358 | +
|
359 | 359 | @command
|
360 | 360 | def i2cwrite(self, bus, slave, addr, *args):
|
361 | 361 | """
|
— | — | @@ -374,7 +374,7 @@ |
375 | 375 | self.logger.info("Writing data to I2C...\n")
|
376 | 376 | self.emcore.i2cwrite(bus, slave, addr, data)
|
377 | 377 | self.logger.info("done\n")
|
378 | | -
|
| 378 | +
|
379 | 379 | @command
|
380 | 380 | def console(self):
|
381 | 381 | """
|
— | — | @@ -384,7 +384,7 @@ |
385 | 385 | resp = self.emcore.usbcread()
|
386 | 386 | self.logger.write(resp.data)
|
387 | 387 | time.sleep(0.1 / resp.maxsize * (resp.maxsize - len(resp.data)))
|
388 | | -
|
| 388 | +
|
389 | 389 | @command
|
390 | 390 | def writeusbconsole(self, *args):
|
391 | 391 | """
|
— | — | @@ -396,7 +396,7 @@ |
397 | 397 | text = text[:-1]
|
398 | 398 | self.logger.info("Writing '%s' to the usb console\n" % text)
|
399 | 399 | self.emcore.usbcwrite(text)
|
400 | | -
|
| 400 | +
|
401 | 401 | @command
|
402 | 402 | def readdevconsole(self, bitmask):
|
403 | 403 | """
|
— | — | @@ -422,7 +422,7 @@ |
423 | 423 | text = text[:-1]
|
424 | 424 | self.logger.info("Writing '%s' to the device consoles identified with 0x%X\n" % (text, bitmask))
|
425 | 425 | self.emcore.cwrite(text, bitmask)
|
426 | | -
|
| 426 | +
|
427 | 427 | @command
|
428 | 428 | def flushconsolebuffers(self, bitmask):
|
429 | 429 | """
|
— | — | @@ -432,7 +432,7 @@ |
433 | 433 | bitmask = self._hexint(bitmask)
|
434 | 434 | self.logger.info("Flushing consoles identified with the bitmask 0x%X\n" % bitmask)
|
435 | 435 | self.emcore.cflush(bitmask)
|
436 | | -
|
| 436 | +
|
437 | 437 | @command
|
438 | 438 | def getprocinfo(self):
|
439 | 439 | """
|
— | — | @@ -497,7 +497,7 @@ |
498 | 498 | threadaddr = self._hexint(threadaddr)
|
499 | 499 | self.logger.info("Suspending the thread with the threadaddr 0x%X\n" % threadaddr)
|
500 | 500 | self.emcore.suspendthread(threadaddr)
|
501 | | -
|
| 501 | +
|
502 | 502 | @command
|
503 | 503 | def resumethread(self, threadaddr):
|
504 | 504 | """
|
— | — | @@ -506,7 +506,7 @@ |
507 | 507 | threadaddr = self._hexint(threadaddr)
|
508 | 508 | self.logger.info("Resuming the thread with the threadaddr 0x%X\n" % threadaddr)
|
509 | 509 | self.emcore.resumethread(threadaddr)
|
510 | | -
|
| 510 | +
|
511 | 511 | @command
|
512 | 512 | def killthread(self, threadaddr):
|
513 | 513 | """
|
— | — | @@ -515,7 +515,7 @@ |
516 | 516 | threadaddr = self._hexint(threadaddr)
|
517 | 517 | self.logger.info("Killing the thread with the threadaddr 0x%X\n" % threadaddr)
|
518 | 518 | self.emcore.killthread(threadaddr)
|
519 | | -
|
| 519 | +
|
520 | 520 | @command
|
521 | 521 | def createthread(self, nameptr, entrypoint, stackptr, stacksize, threadtype, priority, state):
|
522 | 522 | """
|
— | — | @@ -552,7 +552,7 @@ |
553 | 553 | with f:
|
554 | 554 | data = self.emcore.run(f.read())
|
555 | 555 | self.logger.info("Executed emCORE application as thread 0x%X\n" % data.thread)
|
556 | | -
|
| 556 | +
|
557 | 557 | @command
|
558 | 558 | def execimage(self, addr):
|
559 | 559 | """
|
— | — | @@ -674,7 +674,7 @@ |
675 | 675 | data = self.emcore.read(destination, sha1size)
|
676 | 676 | hash = ord(data)
|
677 | 677 | self.logger.info("The generated hash is 0x%X\n" % hash)
|
678 | | -
|
| 678 | +
|
679 | 679 | @command
|
680 | 680 | def ipodnano2g_getnandinfo(self):
|
681 | 681 | """
|
— | — | @@ -687,7 +687,7 @@ |
688 | 688 | self.logger.info("Number of blocks: %d\n" % data["blocks"])
|
689 | 689 | self.logger.info("Number of user blocks: %d\n" % data["userblocks"])
|
690 | 690 | self.logger.info("Pages per block: %d\n" % data["pagesperblock"])
|
691 | | -
|
| 691 | +
|
692 | 692 | @command
|
693 | 693 | def ipodnano2g_nandread(self, addr, start, count, doecc=True, checkempty=True):
|
694 | 694 | """
|
— | — | @@ -708,7 +708,7 @@ |
709 | 709 | (count, start, addr))
|
710 | 710 | self.emcore.ipodnano2g_nandread(addr, start, count, doecc, checkempty)
|
711 | 711 | self.logger.info("done\n")
|
712 | | -
|
| 712 | +
|
713 | 713 | @command
|
714 | 714 | def ipodnano2g_nandwrite(self, addr, start, count, doecc=True):
|
715 | 715 | """
|
— | — | @@ -727,7 +727,7 @@ |
728 | 728 | (count, start, addr))
|
729 | 729 | self.emcore.ipodnano2g_nandwrite(addr, start, count, doecc)
|
730 | 730 | self.logger.info("done\n")
|
731 | | -
|
| 731 | +
|
732 | 732 | @command
|
733 | 733 | def ipodnano2g_nanderase(self, addr, start, count):
|
734 | 734 | """
|
— | — | @@ -744,7 +744,7 @@ |
745 | 745 | (count, start, addr))
|
746 | 746 | self.emcore.ipodnano2g_nanderase(addr, start, count)
|
747 | 747 | self.logger.info("done\n")
|
748 | | -
|
| 748 | +
|
749 | 749 | @command
|
750 | 750 | def ipodnano2g_dumpnand(self, filenameprefix):
|
751 | 751 | """
|
— | — | @@ -777,7 +777,7 @@ |
778 | 778 | sparefile.close()
|
779 | 779 | statusfile.close()
|
780 | 780 | self.logger.info("done\n")
|
781 | | -
|
| 781 | +
|
782 | 782 | @command
|
783 | 783 | def ipodnano2g_wipenand(self, filename, force=False):
|
784 | 784 | """
|
— | — | @@ -805,7 +805,7 @@ |
806 | 806 | statusfile.write(self.emcore.read(0x08000000, 0x00000100))
|
807 | 807 | statusfile.close()
|
808 | 808 | self.logger.info("done\n")
|
809 | | -
|
| 809 | +
|
810 | 810 | @command
|
811 | 811 | def ipodclassic_writebbt(self, tempaddr, filename):
|
812 | 812 | """
|
— | — | @@ -822,7 +822,7 @@ |
823 | 823 | data = self.emcore.ipodclassic_writebbt(f.read(), tempaddr)
|
824 | 824 | f.close()
|
825 | 825 | self.logger.info(" done\n")
|
826 | | -
|
| 826 | +
|
827 | 827 | @command
|
828 | 828 | def getvolumeinfo(self, volume):
|
829 | 829 | """
|
— | — | @@ -836,7 +836,7 @@ |
837 | 837 | self.logger.info("Vendor: %s\n" % data["vendor"])
|
838 | 838 | self.logger.info("Product: %s\n" % data["product"])
|
839 | 839 | self.logger.info("Revision: %s\n" % data["revision"])
|
840 | | -
|
| 840 | +
|
841 | 841 | @command
|
842 | 842 | def readrawstorage(self, volume, sector, count, addr):
|
843 | 843 | """
|
— | — | @@ -849,7 +849,7 @@ |
850 | 850 | self.logger.info("Reading volume %s sectors %X - %X to %08X..." % (volume, sector, sector + count - 1, addr))
|
851 | 851 | self.emcore.storage_read_sectors_md(volume, sector, count, addr)
|
852 | 852 | self.logger.info("done\n")
|
853 | | -
|
| 853 | +
|
854 | 854 | @command
|
855 | 855 | def writerawstorage(self, volume, sector, count, addr):
|
856 | 856 | """
|
— | — | @@ -862,7 +862,7 @@ |
863 | 863 | self.logger.info("Writing %08X to volume %s sectors %X - %X..." % (addr, volume, sector, sector + count - 1))
|
864 | 864 | self.emcore.storage_write_sectors_md(volume, sector, count, addr)
|
865 | 865 | self.logger.info("done\n")
|
866 | | -
|
| 866 | +
|
867 | 867 | @command
|
868 | 868 | def readrawstoragefile(self, volume, sector, count, file, buffsize = 0x100000, buffer = None):
|
869 | 869 | """
|
— | — | @@ -900,7 +900,7 @@ |
901 | 901 | finally:
|
902 | 902 | f.close()
|
903 | 903 | self.logger.info("done\n")
|
904 | | -
|
| 904 | +
|
905 | 905 | @command
|
906 | 906 | def writerawstoragefile(self, volume, sector, count, file, buffsize = 0x100000, buffer = None):
|
907 | 907 | """
|
— | — | @@ -942,7 +942,7 @@ |
943 | 943 | finally:
|
944 | 944 | f.close()
|
945 | 945 | self.logger.info("done\n")
|
946 | | -
|
| 946 | +
|
947 | 947 | @command
|
948 | 948 | def mkdir(self, dirname):
|
949 | 949 | """
|
— | — | @@ -951,7 +951,7 @@ |
952 | 952 | self.logger.info("Creating directory %s..." % dirname)
|
953 | 953 | self.emcore.dir_create(dirname)
|
954 | 954 | self.logger.info(" done\n")
|
955 | | -
|
| 955 | +
|
956 | 956 | @command
|
957 | 957 | def rmdir(self, dirname):
|
958 | 958 | """
|
— | — | @@ -960,7 +960,7 @@ |
961 | 961 | self.logger.info("Removing directory %s..." % dirname)
|
962 | 962 | self.emcore.dir_remove(dirname)
|
963 | 963 | self.logger.info(" done\n")
|
964 | | -
|
| 964 | +
|
965 | 965 | @command
|
966 | 966 | def rm(self, filename):
|
967 | 967 | """
|
— | — | @@ -969,7 +969,7 @@ |
970 | 970 | self.logger.info("Removing file %s..." % filename)
|
971 | 971 | self.emcore.file_unlink(filename)
|
972 | 972 | self.logger.info(" done\n")
|
973 | | -
|
| 973 | +
|
974 | 974 | @command
|
975 | 975 | def rmtree(self, path):
|
976 | 976 | """
|
— | — | @@ -987,7 +987,7 @@ |
988 | 988 | except: break
|
989 | 989 | self.emcore.dir_close(handle)
|
990 | 990 | self.rmdir(path)
|
991 | | -
|
| 991 | +
|
992 | 992 | @command
|
993 | 993 | def mv(self, oldname, newname):
|
994 | 994 | """
|
— | — | @@ -996,7 +996,7 @@ |
997 | 997 | self.logger.info("Renaming %s to %s..." % (oldname, newname))
|
998 | 998 | self.emcore.file_rename(oldname, newname)
|
999 | 999 | self.logger.info(" done\n")
|
1000 | | -
|
| 1000 | +
|
1001 | 1001 | @command
|
1002 | 1002 | def get(self, remotename, localname, buffsize = 0x10000, buffer = None):
|
1003 | 1003 | """
|
— | — | @@ -1036,7 +1036,7 @@ |
1037 | 1037 | finally:
|
1038 | 1038 | f.close()
|
1039 | 1039 | self.logger.info(" done\n")
|
1040 | | -
|
| 1040 | +
|
1041 | 1041 | @command
|
1042 | 1042 | def gettree(self, remotepath, localpath, buffsize = 0x10000, buffer = None):
|
1043 | 1043 | """
|
— | — | @@ -1071,7 +1071,7 @@ |
1072 | 1072 | self.emcore.free(buffer)
|
1073 | 1073 | finally:
|
1074 | 1074 | self.emcore.dir_close(handle)
|
1075 | | -
|
| 1075 | +
|
1076 | 1076 | @command
|
1077 | 1077 | def put(self, localname, remotename, buffsize = 0x10000, buffer = None):
|
1078 | 1078 | """
|
— | — | @@ -1113,7 +1113,7 @@ |
1114 | 1114 | finally:
|
1115 | 1115 | f.close()
|
1116 | 1116 | self.logger.info(" done\n")
|
1117 | | -
|
| 1117 | +
|
1118 | 1118 | @command
|
1119 | 1119 | def puttree(self, localpath, remotepath, buffsize = 0x10000, buffer = None):
|
1120 | 1120 | """
|
— | — | @@ -1146,7 +1146,7 @@ |
1147 | 1147 | finally:
|
1148 | 1148 | if malloc == True:
|
1149 | 1149 | self.emcore.free(buffer)
|
1150 | | -
|
| 1150 | +
|
1151 | 1151 | @command
|
1152 | 1152 | def ls(self, path = "/"):
|
1153 | 1153 | """
|
Index: emcore/trunk/tools/libemcore.py |
— | — | @@ -617,7 +617,7 @@ |
618 | 618 | self.lib.monitorcommand(struct.pack("IIII", 58, state, 0, 0), "III", (None, None, None))
|
619 | 619 | if state != 0: self.logger.debug("Enabled FAT flushing\n")
|
620 | 620 | else: self.logger.debug("Disabled FAT flushing\n")
|
621 | | -
|
| 621 | +
|
622 | 622 | @command(timeout = 30000)
|
623 | 623 | def file_open(self, filename, mode):
|
624 | 624 | """ Opens a file and returns the handle """
|
— | — | @@ -902,8 +902,8 @@ |
903 | 903 | """ Frees all memory allocations created by the monitor thread """
|
904 | 904 | self.logger.debug("Freeing all memory allocations created by the monitor thread\n")
|
905 | 905 | return self.lib.monitorcommand(struct.pack("IIII", 57, 0, 0, 0), "III", (None, None, None))
|
906 | | -
|
907 | 906 |
|
| 907 | +
|
908 | 908 | class Lib(object):
|
909 | 909 | def __init__(self, logger):
|
910 | 910 | self.logger = logger
|
— | — | @@ -966,7 +966,7 @@ |
967 | 967 |
|
968 | 968 | self.interface = 0
|
969 | 969 | self.timeout = 100
|
970 | | -
|
| 970 | +
|
971 | 971 | self.connect()
|
972 | 972 | self.findEndpoints()
|
973 | 973 |
|