freemyipod r164 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r163‎ | r164 | r165 >
Date:04:03, 19 August 2010
Author:theseven
Status:new
Tags:
Comment:
Add emBIOS app embedding tool
Modified paths:
  • /embios/trunk/tools/embiosembedapp.py (added) (history)

Diff [purge]

Index: embios/trunk/tools/embiosembedapp.py
@@ -0,0 +1,56 @@
 2+#!/usr/bin/env python
 3+#
 4+#
 5+# Copyright 2010 TheSeven
 6+#
 7+#
 8+# This file is part of emBIOS.
 9+#
 10+# emBIOS is free software: you can redistribute it and/or
 11+# modify it under the terms of the GNU General Public License as
 12+# published by the Free Software Foundation, either version 2 of the
 13+# License, or (at your option) any later version.
 14+#
 15+# emBIOS is distributed in the hope that it will be useful,
 16+# but WITHOUT ANY WARRANTY; without even the implied warranty of
 17+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 18+# See the GNU General Public License for more details.
 19+#
 20+# You should have received a copy of the GNU General Public License
 21+# along with emBIOS. If not, see <http://www.gnu.org/licenses/>.
 22+#
 23+#
 24+
 25+import sys
 26+import libembiosbootcfg
 27+from optparse import *
 28+
 29+parser = OptionParser("usage: %prog [options] <embiosbin> <embiosapp> <outfile>")
 30+parser.add_option("--run-from", type = "int", metavar = "ADDR",
 31+ help = "Ensures that the app is executed from memory address ADDR")
 32+parser.add_option("--compressed", action = "store_true", default = False,
 33+ help = "Specify this if the executable is compressed")
 34+(options, args) = parser.parse_args()
 35+if len(args) != 3: parser.error("incorrect number of arguments")
 36+
 37+file = open(args[0], "rb")
 38+data = file.read()
 39+file.close()
 40+
 41+file = open(args[1], "rb")
 42+app = file.read()
 43+file.close()
 44+
 45+config = {"reset": True, "trymmap": True}
 46+config["mmapaddr"] = 0x08000000 + len(data)
 47+config["mmapsize"] = len(app)
 48+if options.compressed: config["mmapcomp"] = True
 49+if options.run_from:
 50+ config["mmapcopy"] = True
 51+ config["mmapdest"] = options.run_from
 52+
 53+data = libembiosbootcfg.configure(data, **config)
 54+
 55+file = open(args[2], "wb")
 56+file.write(data + app)
 57+file.close()