eva_ramboot.py 896 B

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