Subversion Repositories freemyipod

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
164 theseven 1
#!/usr/bin/env python
2
#
3
#
4
#    Copyright 2010 TheSeven
5
#
6
#
7
#    This file is part of emBIOS.
8
#
9
#    emBIOS is free software: you can redistribute it and/or
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
#
14
#    emBIOS is distributed in the hope that it will be useful,
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
20
#    along with emBIOS.  If not, see <http://www.gnu.org/licenses/>.
21
#
22
#
23
 
24
import sys
25
import libembiosbootcfg
26
from optparse import *
27
 
28
parser = OptionParser("usage: %prog [options] <embiosbin> <embiosapp> <outfile>")
29
parser.add_option("--run-from", type = "int", metavar = "ADDR",
30
                  help = "Ensures that the app is executed from memory address ADDR")
31
parser.add_option("--compressed", action = "store_true", default = False,
32
                  help = "Specify this if the executable is compressed")
33
(options, args) = parser.parse_args()
34
if len(args) != 3: parser.error("incorrect number of arguments")
35
 
36
file = open(args[0], "rb")
37
data = file.read()
38
file.close()
39
 
40
file = open(args[1], "rb")
41
app = file.read()
42
file.close()
43
 
44
config = {"reset": True, "trymmap": True}
45
config["mmapaddr"] = 0x08000000 + len(data)
46
config["mmapsize"] = len(app)
47
if options.compressed: config["mmapcomp"] = True
48
if options.run_from:
49
    config["mmapcopy"] = True
50
    config["mmapdest"] = options.run_from
51
 
52
data = libembiosbootcfg.configure(data, **config)
53
 
54
file = open(args[2], "wb")
55
file.write(data + app)
56
file.close()