Post
Topic
Board Mining (Altcoins)
Re: sgminer: Baikal Giant X10 / N / B - Open Source - Confirmed OC Giant B!
by
CNoteFan
on 04/04/2018, 01:14:01 UTC
Incorrect link to STM Chip firmware is now updated. Also included is multiple firmwares i have received from others.
Hello! Tell me please, in this way, I get the firmware of my STM chip ?   https://bitcointalk.org/index.php?topic=2790982.msg29642597#msg29642597  

I just created a python script to do it.  Just duplicate one of the python files in /usr/bin/ and paste this code into it.  Then, if successful, then result will reside as /home/baikal/GX10 (Extracted).bin
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/GX10 (Extracted).bin'
USBDEVFS_RESET= 21780

# enter dfu mode
def enter_dfumode():
  subprocess.call('sudo /opt/scripta/startup/miner-stop.sh', shell=True)
  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 extract_firmware():
  print "Extracting firmware..."
  cmd = 'sudo dfu-util -a 0 -d 0483:df11 -s 0x08000000:leave -U ' + tmpfile
  subprocess.call(cmd, shell=True)
  #n = os.path.getsize(fwfile[0])
  #cmd = 'cmp '+ fwfile[0] + ' ' + tmpfile + ' -n ' + str(n)
  #ret = subprocess.call(cmd, shell=True)
  #subprocess.call('sudo rm -rf /home/baikal/tmp.bin', shell=True)
  #return ret
 
enter_dfumode()
reset_usb("STM32F407")
reset_usb("DFU")

extract_firmware()
exit_dfumode()

print "Done"