Tao Te Beavis

TP For Your Soul

Raspberry Pi: USB Block Erupter Mining


I have done much searching around the net for how to get my Pi set up just they way I want it to mine my new ASICs. I’ve already posted about how to mine with BFGMiner on Windows 7, but the Pi was my ultimate goal because I’m one of those dudes who still shuts down his main PC at night.
I bought my Block Erupters with the intent of running them even after their hashrate gets left in the dust when more higher powered ASICs really kick the difficulty in the nuts, just because the power usage/heat is negligible and I could use them on my Raspberry Pi which does nothing cool except be an SNES arcade. Homebrewing a Wii sure changed that, and thus the Pi sat in the dark, powered off, all alone.

This is what I’m not covering in this guide

  • Installing an Operating System on the Pi
  • Updating firmware (It may help with hardware compatibility, I don’t know)

General Info

Here’s My Setup

Hardware (Verbose in case there’s some Pi n00bs setting up for the first time):


General steps to take (not all are really in particular order)

  1. Turn on SSH (if you want to – I am using it) by running sudo raspi-config
  2. Make sure your USB hub AND wireless adapter (if you’re using one) is detected by the Pi. Run the command to see if your WiFi adapter and Hub show up: lsusb
    (My 3 Erupters are already running, so ignore those around the top)
  3. Connect to WiFi via the shortcut on the desktop. It’ll make it easy to connect you to your AP and will connect to it by default when the system boots (even without login).
  4. Download, extract, compile cgminer-3.1.1, and customize the cgminer.conf file
  5. Execute this command, which will obviously vary depending on where you compiled cgminer and how many miners you have (In this case, 3):
    /home/pi/mining/cgminer-3.1.1/./cgminer --icarus-options 115200:1:1 --icarus-timing 3.0=100 -S /dev/ttyUSB0 -S /dev/ttyUSB1 -S /dev/ttyUSB2
  6. If you want the Pi to begin mining when it boots, create a script in /etc/init.d/ that will execute the mining command as a non-root user (WordPress is intent on screwing up the formatting, so make sure there’s no issues in copying or anything):
    # File Location: /etc/init.d/
    case "$1" in
        echo "**starting script**"
        # Start Mining
        sleep 10 # This may not be necessary
        # -dmS options DETATCH the display so you can resume it v    ia SSH later.
        # -S creates an arbitrary name to reference this screen
        COMMAND='screen -dmS MINER ./cgminer --icarus-options 11     5200:1:1 --icarus-timing 3.0=100 -S /dev/ttyUSB0 -S /dev/    ttyUSB1 -S /dev/ttyUSB2'
        # Change the working directory to where cgminer is compil    ed
        cd /home/pi/mining/cgminer-3.1.1 
        # Execute script has the user pi, and not as root
        echo "**starting cgminer**"
        sudo -u pi $COMMAND
        echo "Stopping **cgminer**"
        # kill any cgminer processes
        killall cgminer
        # Improper command usage notification
        echo "Usage: /etc/init.d/mining.sh {start|stop}"
        exit 1
    exit 0
    1. What this will do is start your command detached from any SSH session so that if you log out of your session, it will continue running. You can see if it’s running by using:
      screen -ls
      You can attach your shell to it by using:
      screen -r MINER
    2. Make this script executable:
      chmod 755 /etc/init.d/mining.sh
    3. Test to make sure your script runs:
      /etc/init.d/mining.sh start
    4. To stop the script, use:
      /etc/init.d/mining.sh stop
    5. Register your script to launch on boot (if you don’t do this, your script will be ignored):
      sudo update-rc.d NameOfYourScript defaults
    6. If, in the future, you want to remove this script from being registered, use:
      sudo update-rc.d -f  NameOfYourScript remove

BTC Tip Address: 16K64nVpfTsUz9UxuzJFRKcTNwyEPf2KM3