Skip to content

Instantly share code, notes, and snippets.

@JBlackCat
Last active February 24, 2023 18:08
Show Gist options
  • Save JBlackCat/db625d6a8c0c4f3e2566 to your computer and use it in GitHub Desktop.
Save JBlackCat/db625d6a8c0c4f3e2566 to your computer and use it in GitHub Desktop.
Rapberry-Pi-2-Antminer-U2-CGMiner-Bitcoin-Mining

Fix Formatting and figure out startup script.

  1. Setup a bitcoin wallet. You can find a list of available wallets at https://bitcoin.org/en/choose-your-wallet. I decided to https://www.coinbase.com to start.

  2. Sign up for a bitcoin pool. A comparison of mining pools can be found at https://en.bitcoin.it/wiki/Comparison_of_mining_pools. I found this a bit overwhelming so I decide to start with Slush's pool, (https://mining.bitcoin.cz), as a few tutorials were using it. This video contains some info on setting it up. https://www.youtube.com/watch?v=blDhGFTGuhU

  3. ssh into your raspberry pi

  4. Pull down any updates to any packages you have currently installed, $ sudo apt-get update

  5. Install the updates you just downloaded, $ sudo apt-get upgrade

  6. Install our depencies $ sudo apt-get install libusb-1.0-0-dev libusb-1.0-0 libcurl4-openssl-dev libncurses5-dev libudev-dev libtool automake pkg-config libjansson-dev tmux

  7. If not already there go to your home directory/ $ cd

  8. Clone cgminer from github. $ https://github.com/ckolivas/cgminer.git

  9. Go to the cgminer directory you just cloned. $ cd cgminer

  10. We first need to do some configuration before compiling cgminer. There seems to be a number of options to set. I wasn't 100% sure what needed to be set for using the U2, so I decided to keep following https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=103046 for this step.

$ sudo ./autogen.sh
$ export LIBCURL_CFLAGS=’-I/usr/include/curl’
$ ./configure --enable-icarus

Note: Running autogen and configure may take a bit to start after running the command, so be patient.

  1. Now it's time to compile. $ make.

  2. $ sudo make install

  3. Time for a snack break. You are now on your way to this. hacking gif or this frustration gif

  4. Time to start up our miner. Open a tmux session so we can detach without closing the program. $ tmux

  5. $ cd cgminer Changes working directory to cgminer directory. Assumes you are in your home directory. $ cd if you are unsure.

  6. Start up cgminger. This setup is for Antminer U2's your setup may differ. $ sudo ./cgminer --bmsc-options 115200:20 -o POOL -u USERNAME -p PASSWORD --bmsc-freq 0981

Since I am using slush's pool, I replaced "POOL" with stratum+tcp://stratum.bitcoin.cz:3333. Yours will be different if you are using a pool other than Slush. Some tutorials say you need to add your devices, but since I am running 2 U2's only, cgminer automatically detects and runs both. If I was running different miners, say a U2 and a U3 I would need to specify the correct device to apply the correct settings.

Reference:(Clean Me!) https://github.com/AntMiner/AntGen1/tree/master/cgminer, http://bitcoinrigs.org/instructions/antminer-u1/, http://denis-gobo.squarespace.com/denisgobo/2014/5/17/how-to-install-and-overclock-a-bitmain-antminer-u2-2ghs-usb-bitcoin-asic-miner-on-windows, [http://www.granthamm.com/bitcoin-mining-raspberry-pi-antminer-u1-fun/](http://www.granthamm.com/bitcoin-mining-raspberry-pi-a ntminer-u1-fun/), https://learn.adafruit.com/piminer-raspberry-pi-bitcoin-miner/install-cgminer, https://www.youtube.com/watch?v=dPWTSytzN7g&index=2&list=PLPedo-T7QiNseMLPwm6xdknAAbZMGpQtB, https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=103046, https://www.youtube.com/watch?v=blDhGFTGuhU, https://bitcointalk.org/index.php?topic=259574.0, https://bitcointalk.org/index.php?topic=585225.0,
http://www.getfreebitcoins.us/bitcoin-mining/,
https://bitcointalk.org/index.php?topic=555638.0

CGMiner

  1. Deciphering the interface http://bitcoin.stackexchange.com/questions/19260/deciphering-cgminer-interface-in-terminal

AntMiner U3

  1. https://www.raspberrypi.org/forums/viewtopic.php?f=66&t=103046
  2. https://bitcointalk.org/index.php?topic=827356.840

Multidevice Resources

  1. http://askubuntu.com/questions/184526/how-to-get-bus-and-device-relationship-for-a-dev-ttyusb
  2. http://unix.stackexchange.com/questions/144029/command-to-determine-ports-of-a-device-like-dev-ttyusb0

Additional Info:

@UnKulMunki
Copy link

has anyone tried building this on a raspberry pi recently? I can't get this to build on my pi2B 3B or 4. with the most recent Raspberry PI OS's. Tried on both 32 and 64 bit and I get an epic crap-ton of errors in the compile. The first error is that CIRL is not located in '/usr/include/curl'

I would be interested in some help with this as I try to build cgminer for asic USB miners like the U2 and the NEWPAC miners

@jinglenode
Copy link

@UnKulMunki yes, I managed to run it and compile it with GCC 10.x .
1/ do NOT export LIBCURL_CFLAGS ! leave it empty.
2/ add export CFLAGS="-fcommon" to remove all the duplicated declaration errors you would have.
3/ don't use bmsc-options, freq and volt. Use instead --au3-freq xxx (ex: 240) and --au-volt XXX (ex:800).
You should be fine !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment