| Index: emcore/trunk/tools/emcore.py |
| — | — | @@ -51,9 +51,9 @@ |
| 52 | 52 | self.seen = seen
|
| 53 | 53 | def __str__(self):
|
| 54 | 54 | if self.seen:
|
| 55 | | - return "Expected " + str(self.expected) + " but saw " + str(self.seen)
|
| | 55 | + return "Expected %s but got %s" % (self.expected, self.seen)
|
| 56 | 56 | else:
|
| 57 | | - return "Expected " + str(self.expected) + ", but saw something else"
|
| | 57 | + return "Expected %s, but saw something else" % self.expected
|
| 58 | 58 |
|
| 59 | 59 |
|
| 60 | 60 | def usage(errormsg=None, specific=False, docstring=True):
|
| — | — | @@ -155,7 +155,7 @@ |
| 156 | 156 | except TypeError, e:
|
| 157 | 157 | # Only act on TypeErrors for the function we called, not on TypeErrors raised by another function.
|
| 158 | 158 | if str(e).split(" ", 1)[0] == func + "()":
|
| 159 | | - self.logger.error(usage("Argument Error in '" + func + "': Wrong argument count", specific=func) + "\n")
|
| | 159 | + self.logger.error(usage("Argument Error in '%s': Wrong argument count" % func, specific=func))
|
| 160 | 160 | else:
|
| 161 | 161 | raise
|
| 162 | 162 | except libemcore.usb.core.USBError:
|
| — | — | @@ -181,7 +181,7 @@ |
| 182 | 182 | return True
|
| 183 | 183 | elif something.lower() in falselist:
|
| 184 | 184 | return False
|
| 185 | | - raise ArgumentTypeError("bool", "'"+str(something)+"'")
|
| | 185 | + raise ArgumentTypeError("bool", "'%s'" % something)
|
| 186 | 186 |
|
| 187 | 187 | @staticmethod
|
| 188 | 188 | def _hexint(something):
|
| — | — | @@ -196,16 +196,12 @@ |
| 197 | 197 | try:
|
| 198 | 198 | return int(something, 16)
|
| 199 | 199 | except ValueError:
|
| 200 | | - raise ArgumentTypeError("hexadecimal coded integer", "'"+str(something)+"'")
|
| | 200 | + raise ArgumentTypeError("hexadecimal coded integer", "'%s'" % something)
|
| 201 | 201 | elif something is None:
|
| 202 | 202 | return None
|
| 203 | 203 | else:
|
| 204 | | - raise ArgumentTypeError("hexadecimal coded integer", "'"+str(something)+"'")
|
| | 204 | + raise ArgumentTypeError("hexadecimal coded integer", "'%s'" % something)
|
| 205 | 205 |
|
| 206 | | - @staticmethod
|
| 207 | | - def _hex(integer):
|
| 208 | | - return "0x%x" % integer
|
| 209 | | -
|
| 210 | 206 | @command
|
| 211 | 207 | def help(self):
|
| 212 | 208 | """ Displays this help """
|
| — | — | @@ -219,26 +215,26 @@ |
| 220 | 216 | """
|
| 221 | 217 | if infotype == "version":
|
| 222 | 218 | hwtype = gethwname(self.emcore.lib.dev.hwtypeid)
|
| 223 | | - self.logger.info("Connected to " + \
|
| 224 | | - libemcoredata.swtypes[self.emcore.lib.dev.swtypeid] + \
|
| 225 | | - " v" + str(self.emcore.lib.dev.version.majorv) + \
|
| 226 | | - "." + str(self.emcore.lib.dev.version.minorv) + \
|
| 227 | | - "." + str(self.emcore.lib.dev.version.patchv) + \
|
| 228 | | - " r" + str(self.emcore.lib.dev.version.revision) + \
|
| 229 | | - " running on " + hwtype + "\n")
|
| | 219 | + self.logger.info("Connected to %s v%d.%d.%d r%d running on %s\n" % (
|
| | 220 | + libemcoredata.swtypes[self.emcore.lib.dev.swtypeid],
|
| | 221 | + self.emcore.lib.dev.version.majorv,
|
| | 222 | + self.emcore.lib.dev.version.minorv,
|
| | 223 | + self.emcore.lib.dev.version.patchv,
|
| | 224 | + self.emcore.lib.dev.version.revision,
|
| | 225 | + hwtype))
|
| 230 | 226 |
|
| 231 | 227 | elif infotype == "packetsize":
|
| 232 | | - self.logger.info("Maximum packet sizes: \n command out: " + str(self.emcore.lib.dev.packetsizelimit.cout) + \
|
| 233 | | - "\n command in: " + str(self.emcore.lib.dev.packetsizelimit.cin) + \
|
| 234 | | - "\n data in: " + str(self.emcore.lib.dev.packetsizelimit.din) + \
|
| 235 | | - "\n data out: " + str(self.emcore.lib.dev.packetsizelimit.dout)+ "\n")
|
| | 228 | + self.logger.info("Maximum packet sizes:\n")
|
| | 229 | + self.logger.info("command out: %d\n" % self.emcore.lib.dev.packetsizelimit.cout, 4)
|
| | 230 | + self.logger.info("command in: %d\n" % self.emcore.lib.dev.packetsizelimit.cin, 4)
|
| | 231 | + self.logger.info("data out: %d\n" % self.emcore.lib.dev.packetsizelimit.dout, 4)
|
| | 232 | + self.logger.info("data in: %d\n" % self.emcore.lib.dev.packetsizelimit.din, 4)
|
| 236 | 233 |
|
| 237 | 234 | elif infotype == "usermemrange":
|
| 238 | 235 | resp = self.emcore.getusermemrange()
|
| 239 | | - self.logger.info("The user memory range is " + \
|
| 240 | | - self._hex(self.emcore.lib.dev.usermem.lower) + \
|
| 241 | | - " - " + \
|
| 242 | | - self._hex(self.emcore.lib.dev.usermem.upper - 1) + "\n")
|
| | 236 | + self.logger.info("The user memory range is 0x%X - 0x%X" % (
|
| | 237 | + self.emcore.lib.dev.usermem.lower,
|
| | 238 | + self.emcore.lib.dev.usermem.upper - 1))
|
| 243 | 239 |
|
| 244 | 240 | else:
|
| 245 | 241 | raise ArgumentTypeError("one out of 'version', 'packetsize', 'usermemrange'", infotype)
|
| — | — | @@ -280,10 +276,9 @@ |
| 281 | 277 | except IOError:
|
| 282 | 278 | raise ArgumentError("File not readable. Does it exist?")
|
| 283 | 279 | if addr is not None:
|
| 284 | | - self.logger.info("Writing file '" + filename + \
|
| 285 | | - "' to memory at " + self._hex(addr) + "...\n")
|
| | 280 | + self.logger.info("Writing file '%s' to memory at 0x%X...\n" % (filename, addr))
|
| 286 | 281 | else:
|
| 287 | | - self.logger.info("Writing file '" + filename + " to an allocated memory region...\n")
|
| | 282 | + self.logger.info("Writing file '%s' to an allocated memory region...\n" % filename)
|
| 288 | 283 | with f:
|
| 289 | 284 | if addr is not None:
|
| 290 | 285 | self.emcore.write(addr, f.read())
|
| — | — | @@ -291,7 +286,7 @@ |
| 292 | 287 | addr = self.emcore.upload(f.read())
|
| 293 | 288 | size = f.tell()
|
| 294 | 289 | f.close()
|
| 295 | | - self.logger.info("Done uploading " + str(size) + " bytes to 0x" + self._hex(addr) + "\n")
|
| | 290 | + self.logger.info("Done uploading %d bytes to 0x%X\n" % (size, addr))
|
| 296 | 291 | return addr, size
|
| 297 | 292 |
|
| 298 | 293 | @command
|
| — | — | @@ -308,9 +303,8 @@ |
| 309 | 304 | f = open(filename, 'wb')
|
| 310 | 305 | except IOError:
|
| 311 | 306 | raise ArgumentError("Can not open file for write!")
|
| 312 | | - self.logger.info("Reading data from address " + self._hex(addr) + \
|
| 313 | | - " with the size " + self._hex(size) + \
|
| 314 | | - " to '"+filename+"'...")
|
| | 307 | + self.logger.info("Reading data from address 0x%X with the size 0x%X to '%s'..." %
|
| | 308 | + (addr, size, filename))
|
| 315 | 309 | with f:
|
| 316 | 310 | f.write(self.emcore.read(addr, size))
|
| 317 | 311 | f.close()
|
| — | — | @@ -329,8 +323,7 @@ |
| 330 | 324 | raise ArgumentError("Specified integer too long")
|
| 331 | 325 | data = struct.pack("I", integer)
|
| 332 | 326 | self.emcore.write(addr, data)
|
| 333 | | - self.logger.info("Integer '" + self._hex(integer) + \
|
| 334 | | - "' written successfully to " + self._hex(addr) + "\n")
|
| | 327 | + self.logger.info("Integer '0x%X' written successfully to 0x%X\n" % (integer, addr))
|
| 335 | 328 |
|
| 336 | 329 | @command
|
| 337 | 330 | def downloadint(self, addr):
|
| — | — | @@ -341,8 +334,7 @@ |
| 342 | 335 | addr = self._hexint(addr)
|
| 343 | 336 | data = self.emcore.read(addr, 4)
|
| 344 | 337 | integer = struct.unpack("I", data)[0]
|
| 345 | | - self.logger.info("Integer '" + self._hex(integer) + \
|
| 346 | | - "' read from address " + self._hex(addr) + "\n")
|
| | 338 | + self.logger.info("Read '0x%X' from address 0x%X\n" % (integer, addr))
|
| 347 | 339 |
|
| 348 | 340 | @command
|
| 349 | 341 | def i2cread(self, bus, slave, addr, size):
|
| — | — | @@ -402,7 +394,7 @@ |
| 403 | 395 | for word in args:
|
| 404 | 396 | text += word + " "
|
| 405 | 397 | text = text[:-1]
|
| 406 | | - self.logger.info("Writing '"+ text +"' to the usb console\n")
|
| | 398 | + self.logger.info("Writing '%s' to the usb console\n" % text)
|
| 407 | 399 | self.emcore.usbcwrite(text)
|
| 408 | 400 |
|
| 409 | 401 | @command
|
| — | — | @@ -428,8 +420,7 @@ |
| 429 | 421 | for word in args:
|
| 430 | 422 | text += word + " "
|
| 431 | 423 | text = text[:-1]
|
| 432 | | - self.logger.info("Writing '" + text + \
|
| 433 | | - "' to the device consoles identified with " + self._hex(bitmask) + "\n")
|
| | 424 | + self.logger.info("Writing '%s' to the device consoles identified with 0x%X\n" % (text, bitmask))
|
| 434 | 425 | self.emcore.cwrite(text, bitmask)
|
| 435 | 426 |
|
| 436 | 427 | @command
|
| — | — | @@ -439,8 +430,7 @@ |
| 440 | 431 | <bitmask>: the bitmask of the consoles to be flushed
|
| 441 | 432 | """
|
| 442 | 433 | bitmask = self._hexint(bitmask)
|
| 443 | | - self.logger.info("Flushing consoles identified with the bitmask " + \
|
| 444 | | - self._hex(bitmask) + "\n")
|
| | 434 | + self.logger.info("Flushing consoles identified with the bitmask 0x%X\n" % bitmask)
|
| 445 | 435 | self.emcore.cflush(bitmask)
|
| 446 | 436 |
|
| 447 | 437 | @command
|
| — | — | @@ -463,16 +453,16 @@ |
| 464 | 454 | % (len(threads), cpuload * 100, coreload * 100, threadload * 100))
|
| 465 | 455 | self.logger.info("Thread dump:\n")
|
| 466 | 456 | for thread in threads:
|
| 467 | | - self.logger.info(thread.name+":\n", 2)
|
| 468 | | - self.logger.info("Threadstruct address: " + self._hex(thread.addr)+"\n", 4)
|
| 469 | | - self.logger.info("Thread type: " + str(thread.thread_type)+"\n", 4)
|
| 470 | | - self.logger.info("Thread state: " + str(thread.state)+"\n", 4)
|
| 471 | | - self.logger.info("Block type: " + str(thread.block_type)+"\n", 4)
|
| 472 | | - self.logger.info("Blocked by: " + self._hex(thread.blocked_by)+"\n", 4)
|
| 473 | | - self.logger.info("Priority: " + str(thread.priority)+"/255\n", 4)
|
| | 457 | + self.logger.info("%s:\n" % thread.name, 2)
|
| | 458 | + self.logger.info("Threadstruct address: 0x%X\n" % thread.addr, 4)
|
| | 459 | + self.logger.info("Thread type: %s\n" % thread.thread_type, 4)
|
| | 460 | + self.logger.info("Thread state: %s\n" % thread.state, 4)
|
| | 461 | + self.logger.info("Block type: %s\n" % thread.block_type, 4)
|
| | 462 | + self.logger.info("Blocked by: 0x%X\n" % thread.blocked_by, 4)
|
| | 463 | + self.logger.info("Priority: %d/255\n" % thread.priority, 4)
|
| 474 | 464 | self.logger.info("Current CPU load: %.1f%%\n" % ((thread.cpuload * 100) / 255.), 4)
|
| 475 | | - self.logger.info("CPU time (total): "+str(datetime.timedelta(microseconds = thread.cputime_total))+"\n", 4)
|
| 476 | | - self.logger.info("Stack address: " + self._hex(thread.stack)+"\n", 4)
|
| | 465 | + self.logger.info("CPU time (total): %s\n" % datetime.timedelta(microseconds = thread.cputime_total), 4)
|
| | 466 | + self.logger.info("Stack address: 0x%X\n" % thread.stack, 4)
|
| 477 | 467 | self.logger.info("Registers:\n", 4)
|
| 478 | 468 | for registerrange in range(4):
|
| 479 | 469 | self.logger.info(" ")
|
| — | — | @@ -500,57 +490,54 @@ |
| 501 | 491 | self.emcore.unlockscheduler()
|
| 502 | 492 |
|
| 503 | 493 | @command
|
| 504 | | - def suspendthread(self, threadid):
|
| | 494 | + def suspendthread(self, threadaddr):
|
| 505 | 495 | """
|
| 506 | | - Suspends/resumes the thread with thread ID <threadid>
|
| | 496 | + Suspends the thread with the thread address <threadaddr>
|
| 507 | 497 | """
|
| 508 | | - threadid = self._hexint(threadid)
|
| 509 | | - self.logger.info("Suspending the thread with the threadid "+self._hex(threadid)+"\n")
|
| 510 | | - self.emcore.suspendthread(threadid)
|
| | 498 | + threadaddr = self._hexint(threadaddr)
|
| | 499 | + self.logger.info("Suspending the thread with the threadaddr 0x%X\n" % threadaddr)
|
| | 500 | + self.emcore.suspendthread(threadaddr)
|
| 511 | 501 |
|
| 512 | 502 | @command
|
| 513 | | - def resumethread(self, threadid):
|
| | 503 | + def resumethread(self, threadaddr):
|
| 514 | 504 | """
|
| 515 | | - Resumes the thread with thread ID <threadid>
|
| | 505 | + Resumes the thread with the thread address <threadaddr>
|
| 516 | 506 | """
|
| 517 | | - threadid = self._hexint(threadid)
|
| 518 | | - self.logger.info("Resuming the thread with the threadid "+self._hex(threadid)+"\n")
|
| 519 | | - self.emcore.resumethread(threadid)
|
| | 507 | + threadaddr = self._hexint(threadaddr)
|
| | 508 | + self.logger.info("Resuming the thread with the threadaddr 0x%X\n" % threadaddr)
|
| | 509 | + self.emcore.resumethread(threadaddr)
|
| 520 | 510 |
|
| 521 | 511 | @command
|
| 522 | | - def killthread(self, threadid):
|
| | 512 | + def killthread(self, threadaddr):
|
| 523 | 513 | """
|
| 524 | | - Kills the thread with thread ID <threadid>
|
| | 514 | + Kills the thread with the thread address <threadaddr>
|
| 525 | 515 | """
|
| 526 | | - threadid = self._hexint(threadid)
|
| 527 | | - self.logger.info("Killing the thread with the threadid " + self._hex(threadid) + "\n")
|
| 528 | | - self.emcore.killthread(threadid)
|
| | 516 | + threadaddr = self._hexint(threadaddr)
|
| | 517 | + self.logger.info("Killing the thread with the threadaddr 0x%X\n" % threadaddr)
|
| | 518 | + self.emcore.killthread(threadaddr)
|
| 529 | 519 |
|
| 530 | 520 | @command
|
| 531 | 521 | def createthread(self, nameptr, entrypoint, stackptr, stacksize, threadtype, priority, state):
|
| 532 | 522 | """
|
| 533 | | - Creates a new thread and returns its thread ID
|
| | 523 | + Creates a new thread and returns its thread pointer
|
| 534 | 524 | <namepointer>: a pointer to the thread's name
|
| 535 | 525 | <entrypoint>: a pointer to the entrypoint of the thread
|
| 536 | 526 | <stackpointer>: a pointer to the stack of the thread
|
| 537 | 527 | <stacksize>: the size of the thread's stack
|
| 538 | | - <type>: the thread type, vaild are: 0 => user thread, 1 => system thread
|
| | 528 | + <threadtype>: the thread type, vaild are: 0 => user thread, 1 => system thread
|
| 539 | 529 | <priority>: the priority of the thread, from 1 to 255
|
| 540 | 530 | <state>: the thread's initial state, valid are: 1 => ready, 0 => suspended
|
| 541 | 531 | """
|
| 542 | 532 | nameptr = self._hexint(nameptr)
|
| 543 | 533 | entrypoint = self._hexint(entrypoint)
|
| 544 | | - stackpointer = self._hexint(stackpointer)
|
| | 534 | + stackptr = self._hexint(stackptr)
|
| 545 | 535 | stacksize = self._hexint(stacksize)
|
| 546 | 536 | priority = self._hexint(priority)
|
| 547 | | - data = self.emcore.createthread(nameptr, entrypoint, stackptr, stacksize, type, priority, state)
|
| | 537 | + data = self.emcore.createthread(nameptr, entrypoint, stackptr, stacksize, threadtype, priority, state)
|
| 548 | 538 | name = self.emcore.readstring(nameptr)
|
| 549 | | - self.logger.info("Created a thread with the threadid " + data.id + \
|
| 550 | | - ", the name \"" + name + "\"" + \
|
| 551 | | - ", the entrypoint at " + self._hex(entrypoint) + \
|
| 552 | | - ", the stack at " + self._hex(stackpointer) + \
|
| 553 | | - " with a size of " + self._hex(stacksize) + \
|
| 554 | | - " and a priority of " + self._hex(priority) + "\n")
|
| | 539 | + self.logger.info("Created a thread with the thread pointer 0x%X, the name \"%s\", the entrypoint at 0x%X," \
|
| | 540 | + "the stack at 0x%X with a size of 0x%X and a priority of %d/255\n" %
|
| | 541 | + (data.threadptr, name, entrypoint, stackptr, stacksize, priority))
|
| 555 | 542 |
|
| 556 | 543 | @command
|
| 557 | 544 | def run(self, filename):
|
| — | — | @@ -564,7 +551,7 @@ |
| 565 | 552 | raise ArgumentError("File not readable. Does it exist?")
|
| 566 | 553 | with f:
|
| 567 | 554 | data = self.emcore.run(f.read())
|
| 568 | | - self.logger.info("Executed emCORE application as thread " + self._hex(data.thread) + "\n")
|
| | 555 | + self.logger.info("Executed emCORE application as thread 0x%X\n" % data.thread)
|
| 569 | 556 |
|
| 570 | 557 | @command
|
| 571 | 558 | def execimage(self, addr):
|
| — | — | @@ -572,7 +559,7 @@ |
| 573 | 560 | Executes the emCORE application at <addr>.
|
| 574 | 561 | """
|
| 575 | 562 | addr = self._hexint(addr)
|
| 576 | | - self.logger.info("Starting emCORE app at "+self._hex(addr)+"\n")
|
| | 563 | + self.logger.info("Starting emCORE app at 0x%X\n" % addr)
|
| 577 | 564 | self.emcore.execimage(addr)
|
| 578 | 565 |
|
| 579 | 566 | @command
|
| — | — | @@ -594,8 +581,8 @@ |
| 595 | 582 | addr_flash = self._hexint(addr_flash)
|
| 596 | 583 | addr_mem = self._hexint(addr_mem)
|
| 597 | 584 | size = self._hexint(size)
|
| 598 | | - self.logger.info("Dumping boot flash addresses "+self._hex(addr_flash)+" - "+
|
| 599 | | - hex(addr_flash+size)+" to "+self._hex(addr_mem)+" - "+self._hex(addr_mem+size)+"\n")
|
| | 585 | + self.logger.info("Dumping boot flash from 0x%X - 0x%X to 0x%X - 0x%X\n" %
|
| | 586 | + (addr_flash, addr_flash + size, addr_mem, addr_mem + size))
|
| 600 | 587 | self.emcore.bootflashread(addr_mem, addr_flash, size)
|
| 601 | 588 |
|
| 602 | 589 | @command
|
| — | — | @@ -612,8 +599,8 @@ |
| 613 | 600 | addr_mem = self._hexint(addr_mem)
|
| 614 | 601 | size = self._hexint(size)
|
| 615 | 602 | force = self._bool(force)
|
| 616 | | - self.logger.warn("Writing boot flash from the memory in "+self._hex(addr_mem)+" - "+
|
| 617 | | - hex(addr_mem+size)+" to "+self._hex(addr_flash)+" - "+self._hex(addr_flash+size)+"\n")
|
| | 603 | + self.logger.warn("Writing boot flash from the memory in 0x%X - 0x%X to 0x%X - 0x%X\n" %
|
| | 604 | + (addr_mem, addr_mem + size, addr_flash, addr_flash + size))
|
| 618 | 605 | if force == False:
|
| 619 | 606 | self.logger.warn("If this was not what you intended press Ctrl-C NOW")
|
| 620 | 607 | for i in range(10):
|
| — | — | @@ -637,8 +624,9 @@ |
| 638 | 625 | """
|
| 639 | 626 | Moves the firmware at <addr> with <size> to <targetaddr> and executes it
|
| 640 | 627 | """
|
| | 628 | + targetaddr = self._hexint(targetaddr)
|
| 641 | 629 | addr = self._hexint(addr)
|
| 642 | | - self.logger.info("Running firmware at "+self._hex(targetaddr)+". Bye.\n")
|
| | 630 | + self.logger.info("Running firmware at 0x%X. Bye.\n" % targetaddr)
|
| 643 | 631 | self.emcore.execfirmware(targetaddr, addr, size)
|
| 644 | 632 |
|
| 645 | 633 | @command
|
| — | — | @@ -679,14 +667,13 @@ |
| 680 | 668 | size = self._hexint(size)
|
| 681 | 669 | destination = self._hexint(destination)
|
| 682 | 670 | sha1size = 0x14
|
| 683 | | - self.logger.info("Generating hmac-sha1 hash from the buffer at " + self._hex(addr) + \
|
| 684 | | - " with the size " + self._hex(size) + " and saving it to " + \
|
| 685 | | - self._hex(destination) + " - " + self._hex(destination+sha1size) + "...")
|
| | 671 | + self.logger.info("Generating hmac-sha1 hash from the buffer at 0x%X with the size 0x%X and saving it to 0x%X - 0x%X\n" %
|
| | 672 | + (addr, size, destination, destination + sha1size))
|
| 686 | 673 | self.emcore.hmac_sha1(addr, size, destination)
|
| 687 | 674 | self.logger.info("done\n")
|
| 688 | 675 | data = self.emcore.read(destination, sha1size)
|
| 689 | 676 | hash = ord(data)
|
| 690 | | - self.logger.info("The generated hash is "+self._hex(hash)+"\n")
|
| | 677 | + self.logger.info("The generated hash is 0x%X\n" % hash)
|
| 691 | 678 |
|
| 692 | 679 | @command
|
| 693 | 680 | def ipodnano2g_getnandinfo(self):
|
| — | — | @@ -695,11 +682,11 @@ |
| 696 | 683 | Gathers some information about the NAND chip used
|
| 697 | 684 | """
|
| 698 | 685 | data = self.emcore.ipodnano2g_getnandinfo()
|
| 699 | | - self.logger.info("NAND chip type: " + self._hex(data["type"])+"\n")
|
| 700 | | - self.logger.info("Number of banks: " + str(data["banks"])+"\n")
|
| 701 | | - self.logger.info("Number of blocks: " + str(data["blocks"])+"\n")
|
| 702 | | - self.logger.info("Number of user blocks: " + str(data["userblocks"])+"\n")
|
| 703 | | - self.logger.info("Pages per block: " + str(data["pagesperblock"])+"\n")
|
| | 686 | + self.logger.info("NAND chip type: 0x%X\n" % data["type"])
|
| | 687 | + self.logger.info("Number of banks: %d\n" % data["banks"])
|
| | 688 | + self.logger.info("Number of blocks: %d\n" % data["blocks"])
|
| | 689 | + self.logger.info("Number of user blocks: %d\n" % data["userblocks"])
|
| | 690 | + self.logger.info("Pages per block: %d\n" % data["pagesperblock"])
|
| 704 | 691 |
|
| 705 | 692 | @command
|
| 706 | 693 | def ipodnano2g_nandread(self, addr, start, count, doecc=True, checkempty=True):
|
| — | — | @@ -717,8 +704,8 @@ |
| 718 | 705 | count = self._hexint(count)
|
| 719 | 706 | doecc = self._bool(doecc)
|
| 720 | 707 | checkempty = self._bool(checkempty)
|
| 721 | | - self.logger.info("Reading " + self._hex(count) + " NAND pages starting at " + \
|
| 722 | | - self._hex(start) + " to " + self._hex(addr) + "...")
|
| | 708 | + self.logger.info("Reading 0x%X NAND pages starting at 0x%X to memory at 0x%X..." %
|
| | 709 | + (count, start, addr))
|
| 723 | 710 | self.emcore.ipodnano2g_nandread(addr, start, count, doecc, checkempty)
|
| 724 | 711 | self.logger.info("done\n")
|
| 725 | 712 |
|
| — | — | @@ -736,8 +723,8 @@ |
| 737 | 724 | start = self._hexint(start)
|
| 738 | 725 | count = self._hexint(count)
|
| 739 | 726 | doecc = self._bool(doecc)
|
| 740 | | - self.logger.info("Writing " + self._hex(count) + " NAND pages starting at " + \
|
| 741 | | - self._hex(start) + " from " + self._hex(addr) + "...")
|
| | 727 | + self.logger.info("Writing 0x%X NAND pages starting at 0x%X from memory at 0x%X..." %
|
| | 728 | + (count, start, addr))
|
| 742 | 729 | self.emcore.ipodnano2g_nandwrite(addr, start, count, doecc)
|
| 743 | 730 | self.logger.info("done\n")
|
| 744 | 731 |
|
| — | — | @@ -753,8 +740,8 @@ |
| 754 | 741 | addr = self._hexint(addr)
|
| 755 | 742 | start = self._hexint(start)
|
| 756 | 743 | count = self._hexint(count)
|
| 757 | | - self.logger.info("Erasing " + self._hex(count) + " NAND blocks starting at " + \
|
| 758 | | - self._hex(start) + " and logging to " + self._hex(addr) + "...")
|
| | 744 | + self.logger.info("Erasing 0x%X NAND pages starting at 0x%X and logging to 0x%X..." %
|
| | 745 | + (count, start, addr))
|
| 759 | 746 | self.emcore.ipodnano2g_nanderase(addr, start, count)
|
| 760 | 747 | self.logger.info("done\n")
|
| 761 | 748 |
|
| — | — | @@ -774,11 +761,11 @@ |
| 775 | 762 | statusfile = open(filenameprefix+"_status.bin", 'wb')
|
| 776 | 763 | except IOError:
|
| 777 | 764 | raise ArgumentError("Can not open file for writing!")
|
| 778 | | - infofile.write("NAND chip type: " + self._hex(info["type"]) + "\r\n")
|
| 779 | | - infofile.write("Number of banks: " + str(info["banks"]) + "\r\n")
|
| 780 | | - infofile.write("Number of blocks: " + str(info["blocks"]) + "\r\n")
|
| 781 | | - infofile.write("Number of user blocks: "+ str(info["userblocks"]) + "\r\n")
|
| 782 | | - infofile.write("Pages per block: " + str(info["pagesperblock"]) + "\r\n")
|
| | 765 | + infofile.write("NAND chip type: 0x%X\r\n" % info["type"])
|
| | 766 | + infofile.write("Number of banks: %d\r\n" % info["banks"])
|
| | 767 | + infofile.write("Number of blocks: %d\r\n" % info["blocks"])
|
| | 768 | + infofile.write("Number of user blocks: %d\r\n" % info["userblocks"])
|
| | 769 | + infofile.write("Pages per block: %d\r\n" % info["pagesperblock"])
|
| 783 | 770 | for i in range(info["banks"] * info["blocks"] * info["pagesperblock"] / 8192):
|
| 784 | 771 | self.logger.info(".")
|
| 785 | 772 | self.emcore.ipodnano2g_nandread(0x08000000, i * 8192, 8192, 1, 1)
|
| — | — | @@ -844,11 +831,11 @@ |
| 845 | 832 | """
|
| 846 | 833 | volume = self._hexint(volume)
|
| 847 | 834 | data = self.emcore.storage_get_info(volume)
|
| 848 | | - self.logger.info("Sector size: "+str(data["sectorsize"])+"\n")
|
| 849 | | - self.logger.info("Number of sectors: "+str(data["numsectors"])+"\n")
|
| 850 | | - self.logger.info("Vendor: "+data["vendor"]+"\n")
|
| 851 | | - self.logger.info("Product: "+data["product"]+"\n")
|
| 852 | | - self.logger.info("Revision: "+data["revision"]+"\n")
|
| | 835 | + self.logger.info("Sector size: %d\n" % data["sectorsize"])
|
| | 836 | + self.logger.info("Number of sectors: %d\n" % data["numsectors"])
|
| | 837 | + self.logger.info("Vendor: %s\n" % data["vendor"])
|
| | 838 | + self.logger.info("Product: %s\n" % data["product"])
|
| | 839 | + self.logger.info("Revision: %s\n" % data["revision"])
|
| 853 | 840 |
|
| 854 | 841 | @command
|
| 855 | 842 | def readrawstorage(self, volume, sector, count, addr):
|
| — | — | @@ -961,7 +948,7 @@ |
| 962 | 949 | """
|
| 963 | 950 | Creates a directory with the name <dirname>
|
| 964 | 951 | """
|
| 965 | | - self.logger.info("Creating directory " + dirname + "...")
|
| | 952 | + self.logger.info("Creating directory %s..." % dirname)
|
| 966 | 953 | self.emcore.dir_create(dirname)
|
| 967 | 954 | self.logger.info(" done\n")
|
| 968 | 955 |
|
| — | — | @@ -970,7 +957,7 @@ |
| 971 | 958 | """
|
| 972 | 959 | Removes an empty directory with the name <dirname>
|
| 973 | 960 | """
|
| 974 | | - self.logger.info("Removing directory " + dirname + "...")
|
| | 961 | + self.logger.info("Removing directory %s..." % dirname)
|
| 975 | 962 | self.emcore.dir_remove(dirname)
|
| 976 | 963 | self.logger.info(" done\n")
|
| 977 | 964 |
|
| — | — | @@ -979,7 +966,7 @@ |
| 980 | 967 | """
|
| 981 | 968 | Removes a file with the name <filename>
|
| 982 | 969 | """
|
| 983 | | - self.logger.info("Removing file " + filename + "...")
|
| | 970 | + self.logger.info("Removing file %s..." % filename)
|
| 984 | 971 | self.emcore.file_unlink(filename)
|
| 985 | 972 | self.logger.info(" done\n")
|
| 986 | 973 |
|
| — | — | @@ -1006,7 +993,7 @@ |
| 1007 | 994 | """
|
| 1008 | 995 | Renames or moves file or directory <oldname> to <newname>
|
| 1009 | 996 | """
|
| 1010 | | - self.logger.info("Renaming " + oldname + " to " + newname + "...")
|
| | 997 | + self.logger.info("Renaming %s to %s..." % (oldname, newname))
|
| 1011 | 998 | self.emcore.file_rename(oldname, newname)
|
| 1012 | 999 | self.logger.info(" done\n")
|
| 1013 | 1000 |
|
| — | — | @@ -1036,7 +1023,7 @@ |
| 1037 | 1024 | buffer = self._hexint(buffer)
|
| 1038 | 1025 | malloc = False
|
| 1039 | 1026 | try:
|
| 1040 | | - self.logger.info("Downloading file " + remotename + " to " + localname + "...")
|
| | 1027 | + self.logger.info("Downloading file %s to %s..." % (remotename, localname))
|
| 1041 | 1028 | while size > 0:
|
| 1042 | 1029 | bytes = self.emcore.file_read(fd, buffsize, buffer).rc
|
| 1043 | 1030 | f.write(self.emcore.read(buffer, bytes))
|
| — | — | @@ -1108,7 +1095,7 @@ |
| 1109 | 1096 | buffer = self._hexint(buffer)
|
| 1110 | 1097 | malloc = False
|
| 1111 | 1098 | try:
|
| 1112 | | - self.logger.info("Uploading file " + localname + " to " + remotename + "...")
|
| | 1099 | + self.logger.info("Uploading file %s to %s..." % (localname, remotename))
|
| 1113 | 1100 | fd = self.emcore.file_open(remotename, 0x15)
|
| 1114 | 1101 | try:
|
| 1115 | 1102 | while True:
|
| — | — | @@ -1167,7 +1154,7 @@ |
| 1168 | 1155 | [path]: the path which is listed
|
| 1169 | 1156 | """
|
| 1170 | 1157 | handle = self.emcore.dir_open(path)
|
| 1171 | | - self.logger.info("Directory listing of " + path + ":\n")
|
| | 1158 | + self.logger.info("Directory listing of %s:\n" % path)
|
| 1172 | 1159 | while True:
|
| 1173 | 1160 | try:
|
| 1174 | 1161 | entry = self.emcore.dir_read(handle)
|
| Index: emcore/trunk/tools/libemcore.py |
| — | — | @@ -438,9 +438,9 @@ |
| 439 | 439 | state = 1
|
| 440 | 440 | else:
|
| 441 | 441 | raise ArgumentError("State must be either 'ready' or 'suspended'")
|
| 442 | | - resp = self.lib.monitorcommand(struct.pack("IIIIIIII", 19, nameptr, entrypoint, stackptr, stacksize, threadtype, priority, state), "III", (id, None, None))
|
| 443 | | - if resp.id < 0:
|
| 444 | | - raise DeviceError("The device returned the error code "+str(resp.id))
|
| | 442 | + resp = self.lib.monitorcommand(struct.pack("IIIIIIII", 19, nameptr, entrypoint, stackptr, stacksize, threadtype, priority, state), "III", ("threadptr", None, None))
|
| | 443 | + if resp.threadptr < 0:
|
| | 444 | + raise DeviceError("The device returned the error code "+str(resp.threadptr))
|
| 445 | 445 | return resp
|
| 446 | 446 |
|
| 447 | 447 | @command()
|