aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/flashing
diff options
context:
space:
mode:
authorDavid Bauer <mail@david-bauer.net>2019-02-18 23:58:32 +0100
committerChristian Lamparter <chunkeey@gmail.com>2019-02-28 11:32:55 +0100
commite7bc8984d9ca348b19551c79c6589aab260e7544 (patch)
treea119b7ea71225dcffaa748893522187fc25f3a0a /scripts/flashing
parent18e942b6c4e51a5a717a121697a63f3f98d93b19 (diff)
downloadupstream-e7bc8984d9ca348b19551c79c6589aab260e7544.tar.gz
upstream-e7bc8984d9ca348b19551c79c6589aab260e7544.tar.bz2
upstream-e7bc8984d9ca348b19551c79c6589aab260e7544.zip
scripts: make eva_ramboot.py offset configurable
The current eva_ramboot.py script is currently only compatible with Lantiq based AVM devices. For IPQ40xx devices, the offset needs to be changed. Also an alignment is not necessary here. Adjust the script to be able to pass an optional offset to load the image to. In case no offset is provided, the script behaves exactly as before this commit. Signed-off-by: David Bauer <mail@david-bauer.net>
Diffstat (limited to 'scripts/flashing')
-rwxr-xr-xscripts/flashing/eva_ramboot.py30
1 files changed, 19 insertions, 11 deletions
diff --git a/scripts/flashing/eva_ramboot.py b/scripts/flashing/eva_ramboot.py
index b825d2768b..b182f09d21 100755
--- a/scripts/flashing/eva_ramboot.py
+++ b/scripts/flashing/eva_ramboot.py
@@ -1,24 +1,32 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
+
+import argparse
from ftplib import FTP
from sys import argv
from os import stat
-assert len(argv) == 3
-ip = argv[1]
-image = argv[2]
+parser = argparse.ArgumentParser(description='Tool to boot AVM EVA ramdisk images.')
+parser.add_argument('ip', type=str, help='IP-address to transfer the image to')
+parser.add_argument('image', type=str, help='Location of the ramdisk image')
+parser.add_argument('--offset', type=lambda x: int(x,0), help='Offset to load the image to in hex format with leading 0x. Only needed for non-lantiq devices.')
+args = parser.parse_args()
-size = stat(image).st_size
+size = stat(args.image).st_size
# arbitrary size limit, to prevent the address calculations from overflows etc.
assert size < 0x2000000
-# We need to align the address. A page boundary seems to be sufficient on 7362sl
-# and 7412
-addr = ((0x8000000 - size) & ~0xfff)
-haddr = 0x80000000 + addr
-img = open(image, "rb")
+if args.offset:
+ addr = size
+ haddr = args.offset
+else:
+ # We need to align the address.
+ # A page boundary seems to be sufficient on 7362sl and 7412
+ addr = ((0x8000000 - size) & ~0xfff)
+ haddr = 0x80000000 + addr
-ftp = FTP(ip, 'adam2', 'adam2')
+img = open(args.image, "rb")
+ftp = FTP(args.ip, 'adam2', 'adam2')
def adam(cmd):
print("> %s"%(cmd))