Post
Topic
Board Mining (Altcoins)
Re: Baikal X10 ⚡OVERCLOCK⚡ Claim reward 0.2 BTC for TUTORIAL HOW TO :)⚡⚡⚡⚡
by
TheCubanMiner
on 09/02/2018, 20:44:38 UTC
The filename must start with G.

The reason behind that is that the file, update_fw.py. Located in the \usr\bin folder.

Code:
#!/usr/bin/env python
import subprocess
import os
import sys
from subprocess import Popen, PIPE
import fcntl
import time
import glob
tmpfile = '/home/baikal/tmp.bin'
path = '/media/boot/G*.bin'
fwfile = glob.glob(path)
if not fwfile:
print 'No firmware'
sys.exit()

USBDEVFS_RESET= 21780

# enter dfu mode
def enter_dfumode():
  subprocess.call('echo 0 > /sys/class/gpio_sw/PA18/data', shell=True)
  subprocess.call('echo 0 > /sys/class/gpio_sw/PA10/data', shell=True)
  subprocess.call('echo 1 > /sys/class/gpio_sw/PA10/data', shell=True)

def exit_dfumode():
  subprocess.call('echo 1 > /sys/class/gpio_sw/PA18/data', shell=True)
  subprocess.call('echo 0 > /sys/class/gpio_sw/PA10/data', shell=True)
  subprocess.call('echo 1 > /sys/class/gpio_sw/PA10/data', shell=True)

def reset_usb(driver):
  try:
    lsusb_out = Popen("lsusb | grep -i %s"%driver, shell=True, bufsize=64, stdin=PIPE, stdout=PIPE, close_fds=True).stdout.read().strip().split()
    bus = lsusb_out[1]
    device = lsusb_out[3][:-1]
    f = open("/dev/bus/usb/%s/%s"%(bus, device), 'w', os.O_WRONLY)
    fcntl.ioctl(f, USBDEVFS_RESET, 0)
  except Exception, msg:
    print ""

def update_firmware():
  enter_dfumode()
  reset_usb("DFU")
  print 'Downloading... ' + fwfile[0]
  cmd = 'sudo dfu-util -a 0 -d 0483:df11 -s 0x08000000:leave -D ' + fwfile[0]
  subprocess.call(cmd, shell=True)
  cmd = 'sudo rm -rf ' + path
  subprocess.call(cmd, shell=True)

enter_dfumode()
reset_usb("STM32F407")
reset_usb("DFU")
update_firmware()
exit_dfumode()

print "Done"