Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
207 theseven 1
#!/usr/bin/env python
2
#
3
#
4
#    Copyright 2010 TheSeven
5
#
6
#
427 farthen 7
#    This file is part of emCORE.
207 theseven 8
#
427 farthen 9
#    emCORE is free software: you can redistribute it and/or
207 theseven 10
#    modify it under the terms of the GNU General Public License as
11
#    published by the Free Software Foundation, either version 2 of the
12
#    License, or (at your option) any later version.
13
#
427 farthen 14
#    emCORE is distributed in the hope that it will be useful,
207 theseven 15
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
16
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
#    See the GNU General Public License for more details.
18
#
19
#    You should have received a copy of the GNU General Public License along
427 farthen 20
#    with emCORE.  If not, see <http://www.gnu.org/licenses/>.
207 theseven 21
#
22
#
23
 
24
 
25
import sys
26
import time
427 farthen 27
import libemcoreldr
207 theseven 28
 
29
 
30
def usage():
31
  print ""
32
  print "Please provide a command and (if needed) parameters as command line arguments"
33
  print ""
34
  print "Available commands:"
35
  print ""
36
  print "  upload <address> <file>"
37
  print "    Uploads the specified file to the specified memory address on the device."
38
  print ""
39
  print "  download <address> <size> <file>"
40
  print "    Downloads <size> bytes of data from the specified address on the device,"
41
  print "    and stores it in the specified file."
42
  print ""
43
  print "  execute <address> <stack>"
44
  print "    Executes code at the specified address in the device's memory."
45
  print "    The stack pointer will be set to <stack> before jumping to <address>."
46
  print "    iBugger will probably lose control of the device,"
47
  print "    if the code isn't explicitly written for it."
48
  print ""
49
  print "  run <file>"
50
  print "    Loads the specified file to 0x08000000 (SDRAM) and executes it."
51
  print "    This is what you usually want to do."
52
  print ""
53
  print "All numbers are hexadecimal!"
54
  exit(2)
55
 
56
 
57
def parsecommand(dev, argv):
58
  if len(argv) < 2: usage()
59
 
60
  elif argv[1] == "upload":
61
    if len(argv) != 4: usage()
62
    dev.upload(int(argv[2], 16), argv[3])
63
 
64
  elif argv[1] == "download":
65
    if len(argv) != 5: usage()
66
    dev.download(int(argv[2], 16), int(argv[3], 16), argv[4])
67
 
68
  elif argv[1] == "execute":
69
    if len(argv) != 4: usage()
70
    dev.execute(int(argv[2], 16), int(argv[3], 16))
71
 
72
  elif argv[1] == "run":
73
    if len(argv) != 3: usage()
74
    dev.run(argv[2])
75
 
76
  else: usage()
77
 
78
 
427 farthen 79
dev = libemcoreldr.emcoreldr()
207 theseven 80
parsecommand(dev, sys.argv)