8 parser
= argparse
.ArgumentParser(description
='Tool to boot AVM EVA ramdisk images.')
9 parser
.add_argument('ip', type=str, help='IP-address to transfer the image to')
10 parser
.add_argument('image', type=str, help='Location of the ramdisk image')
11 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.')
12 args
= parser
.parse_args()
14 size
= stat(args
.image
).st_size
15 # arbitrary size limit, to prevent the address calculations from overflows etc.
16 assert size
< 0x2000000
22 # We need to align the address.
23 # A page boundary seems to be sufficient on 7362sl and 7412
24 addr
= ((0x8000000 - size
) & ~
0xfff)
25 haddr
= 0x80000000 + addr
27 img
= open(args
.image
, "rb")
28 ftp
= FTP(args
.ip
, 'adam2', 'adam2')
32 resp
= ftp
.sendcmd(cmd
)
34 assert resp
[0:3] == "200"
37 # The following parameters allow booting the avm recovery system with this
39 adam('SETENV memsize 0x%08x'%(addr))
40 adam('SETENV kernel_args_tmp mtdram1=0x%08x,0x88000000'%(haddr))
42 ftp
.storbinary('STOR 0x%08x 0x88000000'%(haddr), img
)