OpenWrt – Blame information for rev 3
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
3 | office | 1 | #!/usr/bin/python |
1 | office | 2 | |
3 | from ftplib import FTP |
||
4 | from sys import argv |
||
5 | from os import stat |
||
6 | |||
3 | office | 7 | assert len(argv) == 3 |
8 | ip = argv[1] |
||
9 | image = argv[2] |
||
1 | office | 10 | |
3 | office | 11 | size = stat(image).st_size |
1 | office | 12 | # arbitrary size limit, to prevent the address calculations from overflows etc. |
13 | assert size < 0x2000000 |
||
14 | |||
3 | office | 15 | # We need to align the address. A page boundary seems to be sufficient on 7362sl |
16 | # and 7412 |
||
17 | addr = ((0x8000000 - size) & ~0xfff) |
||
18 | haddr = 0x80000000 + addr |
||
19 | img = open(image, "rb") |
||
1 | office | 20 | |
3 | office | 21 | ftp = FTP(ip, 'adam2', 'adam2') |
1 | office | 22 | |
23 | def adam(cmd): |
||
24 | print("> %s"%(cmd)) |
||
25 | resp = ftp.sendcmd(cmd) |
||
26 | print("< %s"%(resp)) |
||
27 | assert resp[0:3] == "200" |
||
28 | |||
29 | ftp.set_pasv(True) |
||
30 | # The following parameters allow booting the avm recovery system with this |
||
31 | # script. |
||
32 | adam('SETENV memsize 0x%08x'%(addr)) |
||
33 | adam('SETENV kernel_args_tmp mtdram1=0x%08x,0x88000000'%(haddr)) |
||
34 | adam('MEDIA SDRAM') |
||
35 | ftp.storbinary('STOR 0x%08x 0x88000000'%(haddr), img) |
||
36 | img.close() |
||
37 | ftp.close() |