tools/chainload.py: Allow specifying entrypoint for raw images

This allows running images other than m1n1 that don't have the
entrypoint at 0x800. If unspecified, it defaults to 0x800 for m1n1.

Signed-off-by: Javier Alvarez <javier.alvarez@allthingsembedded.net>
This commit is contained in:
Javier Alvarez 2022-08-19 21:45:33 +02:00 committed by Hector Martin
parent 5e6a6abcfb
commit 6836e8a72f

View file

@ -10,6 +10,7 @@ parser.add_argument('-q', '--quiet', action="store_true", help="Disable framebuf
parser.add_argument('-n', '--no-sepfw', action="store_true", help="Do not preserve SEPFW") parser.add_argument('-n', '--no-sepfw', action="store_true", help="Do not preserve SEPFW")
parser.add_argument('-c', '--call', action="store_true", help="Use call mode") parser.add_argument('-c', '--call', action="store_true", help="Use call mode")
parser.add_argument('-r', '--raw', action="store_true", help="Image is raw") parser.add_argument('-r', '--raw', action="store_true", help="Image is raw")
parser.add_argument('-E', '--entry-point', action="store", type=int, help="Entry point for the raw image", default=0x800)
parser.add_argument('payload', type=pathlib.Path) parser.add_argument('payload', type=pathlib.Path)
parser.add_argument('boot_args', default=[], nargs="*") parser.add_argument('boot_args', default=[], nargs="*")
args = parser.parse_args() args = parser.parse_args()
@ -24,7 +25,7 @@ new_base = u.base
if args.raw: if args.raw:
image = args.payload.read_bytes() image = args.payload.read_bytes()
image += b"\x00\x00\x00\x00" image += b"\x00\x00\x00\x00"
entry = new_base + 0x800 entry = new_base + args.entry_point
else: else:
macho = MachO(args.payload.read_bytes()) macho = MachO(args.payload.read_bytes())
image = macho.prepare_image() image = macho.prepare_image()
@ -33,8 +34,6 @@ else:
entry -= macho.vmin entry -= macho.vmin
entry += new_base entry += new_base
if args.quiet: if args.quiet:
p.iodev_set_usage(IODEV.FB, 0) p.iodev_set_usage(IODEV.FB, 0)