ath10k-firmware: update Candela Tech firmware images
[openwrt/openwrt.git] / scripts / flashing / eva_ramboot.py
1 #!/usr/bin/python
2
3 from ftplib import FTP
4 from sys import argv
5 from os import stat
6
7 assert len(argv) == 3
8 ip = argv[1]
9 image = argv[2]
10
11 size = stat(image).st_size
12 # arbitrary size limit, to prevent the address calculations from overflows etc.
13 assert size < 0x2000000
14
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")
20
21 ftp = FTP(ip, 'adam2', 'adam2')
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()