OpenWrt – Diff between revs 2 and 3

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 2 Rev 3
Line 1... Line 1...
1 #!/usr/bin/env python3 1 #!/usr/bin/python
2   -  
3 import argparse -  
Line 4... Line 2...
4   2  
5 from ftplib import FTP 3 from ftplib import FTP
6 from sys import argv 4 from sys import argv
Line 7... Line -...
7 from os import stat -  
8   5 from os import stat
9 parser = argparse.ArgumentParser(description='Tool to boot AVM EVA ramdisk images.') 6  
10 parser.add_argument('ip', type=str, help='IP-address to transfer the image to') -  
11 parser.add_argument('image', type=str, help='Location of the ramdisk image') 7 assert len(argv) == 3
Line 12... Line 8...
12 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.') 8 ip = argv[1]
13 args = parser.parse_args() 9 image = argv[2]
14   10  
Line 15... Line -...
15 size = stat(args.image).st_size -  
16 # arbitrary size limit, to prevent the address calculations from overflows etc. -  
17 assert size < 0x2000000 -  
18   -  
19 if args.offset: -  
20 addr = size 11 size = stat(image).st_size
-   12 # arbitrary size limit, to prevent the address calculations from overflows etc.
21 haddr = args.offset 13 assert size < 0x2000000
22 else: 14  
-   15 # We need to align the address. A page boundary seems to be sufficient on 7362sl
Line 23... Line -...
23 # We need to align the address. -  
24 # A page boundary seems to be sufficient on 7362sl and 7412 16 # and 7412
Line 25... Line 17...
25 addr = ((0x8000000 - size) & ~0xfff) 17 addr = ((0x8000000 - size) & ~0xfff)
26 haddr = 0x80000000 + addr 18 haddr = 0x80000000 + addr
27   19 img = open(image, "rb")
28 img = open(args.image, "rb") 20