Building A Bitcoin Miner
This is the description of my endeavor to turn my Gizmo board into a bitcoin miner.
I scrounged up an unused drive from an old laptop and a USB2.0 drive enclosure that I had lying around and installed Ubuntu. (I first installed to a flash drive from http://www.pendrivelinux.com – video coming soon). After plugging the drive into the usb header on the Gizmo board, the system booted on the first try. Next task is to install the AMD graphics drivers.
I found instructions for installing the AMD drivers on askubuntu.com ( http://askubuntu.com/questions/285609/how-to-install-amd-ati-radeon-graphics-hd-6770m-on-ubuntu-13-04-64bit ).
Installing the AMD drivers:
Download the driver from http://support.amd.com/us/gpudownload/embedded/Pages/embedded_linux.aspx
Install the ia32 libraries:
[email protected]:~$ sudo apt-get install ia32-libs
Install the generic linux headers:
[email protected]:~$ sudo apt-get install linux-headers-generic
[email protected]:~$ sudo apt-get install dkms
Install the Catalyst driver, which I downloaded in step 1:
[email protected]:~$ chmod +x amd-driver-installer-13.10-x86.x86_64.run [email protected]:~$ sudo sh amd-driver-installer-13.10-x86.x86_64.run
The installer completed and now tells me to run aticonfig from a console window:
[email protected]:~$ sudo aticonfig –initial
And that’s it. All seems to have proceeded well to this point and it appears that I will need a reboot to have my system start running with the new driver.
Had a bit of trouble as the AMD drivers seemed to break the Unity desktop. I did a bunch of research and found a fix.
After booting, I was presented with just the background image on my desktop without the toolbar. By hitting Ctr-Alt-T I was able to get a terminal window.
From there, I was able to install the compizconfig settings manager:
[email protected]:~$ sudo apt-get install compizconfig-settings-manager
After this completed installing, I ran it using:
[email protected]:~$ ccsm
This brought up a graphical interface window. In the window, I selected the checkbox for OpenGL plugin. Then I clicked the Ubuntu Unity Plugin, which brought me to another screen in which I selected the Enable Ubuntu Unity Plugin checkbox. After I was done, I exited the ccsm and logged out (Ctrl-Alt-Del).
When I logged back in the desktop was back to normal.
I tested my accelerated graphics driver using:
[email protected]:~$ /usr/lib/fglrx/bin/fgl_glxgears
I watched the gears spin for a little while and got these results:
/usr/lib/fglrx/bin/fgl_glxgears Using GLX_SGIX_pbuffer 1147 frames in 5.0 seconds = 229.400 FPS 1163 frames in 5.0 seconds = 232.600 FPS 1148 frames in 5.0 seconds = 229.600 FPS 1156 frames in 5.0 seconds = 231.200 FPS 1155 frames in 5.0 seconds = 231.000 FPS
I don’t think that will win any awards, but remember, this is a fanless system that sells for under $200 and fits in the palm of your hand (although I wouldn’t recommend holding it by the heat sink!). I’m pretty happy with this result and am ready to move on to the next step.
Before I can begin mining, there’s some things I need to do first. If you are new to Bitcoins, as I am, you need to start by creating yourself a wallet. I am starting at: bitcoin.org/en/ how-it-works
There is a lot of good information there. Make sure to read the “You need to know” information.
I installed the Bitcoin-Qt wallet to store my mined Bitcoins. Start by installing the libqtgui4:
[email protected]:~$ sudo apt-get install libqtgui4 [email protected]:~$ cd ~/bitcoin-0.8.3-linux [email protected]:~/bitcoin-0.8.3-linux$ cat README.md [email protected]:~/bitcoin-0.8.3-linux$ cd bin/64 [email protected]:~/bitcoin-0.8.3-linux/bin/64$ ./bitcoind
This informed me that I need to edit the bitcoin configuration file to add a username and password. I use vi, but you can use whatever text editor you prefer. I am going with the recommended username and password since I am new to bitcoins and am not ready to wander off quite yet.
[email protected]:~/bitcoin-0.8.3-linux/bin/64$ vi ~/.bitcoin/bitcoin.conf
I inserted lines to define the “rpcuser” and “rpcpassword” and added the “alertnotify” line as suggested. I am now ready to start up the bitcoin wallet. There are two ways to run it. If you run the qt program, it runs as a GUI, if you run the ‘d’ version, it runs as a background daemon. For now, I am going to run the Gui, so I can more easily monitor what is happening.
[email protected]:~/bitcoin-0.8.3-linux/bin/64$ ./bitcoin-qt &
So, now I have the bitcoin daemon running in the background. I can see that the wallet is currently syncing and it looks like it may take some time. The miner will not be able to connect to the wallet until the syncing is done.
I let the bitcoin-qt run for quite a while as it synced up with over 244000 previous blocks. I believe it took so long because the process was swapping as the Gizmo only has 1GB of ram. This process is not the bitcoin miner, but only part of the setup, so once it completed syncing the bitcoin-qt job moves into the background and leaves the full Gizmo resources available to the miner.
The final piece that needs to be installed before the bitcoin miner can run is the Java Runtime Environment or JRE. DiabloMiner is written in Java and requires the JRE to run. I chose to install openJRE rather than the Oracle JRE although you can use either. To install openJRE I used:
[email protected]:~$ sudo apt-get install openjdk-7-jre openjdk-7-jdk icedtea-7-plugin
The icedtea plugin is not necessary for bitcoin mining but provides a browser plugin for web based java applications.
Now all that is left is to download the DiabloMiner and start it up. I got mine from here. There is a link to the newest binary in the download section. You will end up with a file named DiabloMiner.zip. You can open it with the archive manager and extract it using the GUI or you can save the file to your downloads directory and then unzip it using the command line.
After the file is unzipped, you will end up with a directory named DiabloMiner. The contents of the directory should be:
[email protected]:~/DiabloMiner$ ls DiabloMiner-Linux.sh DiabloMiner-Windows.exe README.md DiabloMiner-OSX.sh DiabloMiner-Windows.l4j.ini target DiabloMiner-Solaris.sh LICENSE
The README.md file contains some useful information, but at this point running the program is quite simple. Before you start though, you need to edit the bitcoin configuration file to add the line "server=1". The bitcoin configuration file is "~/.bitcoin/bitcoin.conf".
After editing the file you will need to restart the bitcoin-qt or you can run the bitcoind daemon which runs in the background. Since the bitcoin wallet has already synced, it should not take too much time to restart it. I decided I like running bitcoin-qt because that way I can see the current status and hold off on running the miner until the wallet is ready to accept the connection. The bitcoin miner will not be able to connect to the wallet until the syncing is done, so you have to be somewhat patient and wait until the wallet has completed processing all blocks.
All the pieces are now in place and ready to go, so time to start mining:
[email protected]:~/DiabloMiner$ DiabloMiner-linux.sh -u username -p password -o localhost -r 8332
The username and password above are the same as what is stored in the bitcoin configuration file (~/.bitcoin/bitcoin.conf). Assuming that everything has been installed correctly, this is what you should see:
[email protected]:~/DiabloMiner$ ~/bitcoin-0.8.3-linux/bin/64/bitcoin-qt &  10074 [email protected]:~/DiabloMiner$ ~/DiabloMiner/DiabloMiner-Linux.sh -u bitcoinrpc -p 8U66KyBAV4gsmcpQ9ZgGd8qkMbpdwx219nNTjY16Uc6t -o localhost -r 8332 [7/3/13 12:36:53 PM] Started [7/3/13 12:36:53 PM] Connecting to: http://localhost:8332/ [7/3/13 12:37:18 PM] Using AMD Accelerated Parallel Processing OpenCL 1.2 AMD-APP (1214.3) [7/3/13 12:37:39 PM] Added Loveland (#1) (2 CU, local work size of 256) mhash: 5.9/2.0 | accept: 0 | reject: 0 | hw error: 0
If you get a "Connection refused" message, it is either because you don’t have the line "server=1" in your bitcoin.conf file or that the bitcoin wallet hasn’t finished initializing and syncing.
The Gizmo is now mining!
Now that our miner is running, let’s talk about performance. I am seeing a fairly consistent 5.9-6.0 mhash/s rate on my Gizmo.
The Gizmo performance is roughly equivalent to a 3GHz 65W Athlon II, it’s about 10 times the performance of the closest ARM core, and is again roughly equivalent to a quad-core, 3.83GHz Core i7 950 from Intel.
Since the Gizmo in this configuration is running at under 10W, that gives us a mhash/J of over 0.6. Comparing that to all of the other processors in the list, there are no Intel parts that come anywhere close. The ARM cores compare favorably in performance/Watt.
Of course today’s high-end bitcoin miners are all FPGA or ASIC based so they can provide much higher numbers. And that drives the difficulty up for everyone else.
I’m thinking that I can improve my performance and increase my chances of getting a return by joining a mining pool. That way I wouldn’t have to have the bitcoind running on my machine and thus free up the CPU resources for running more hashes.
I’ll do a little more research into mining pools and post a follow-up in a day or two.
I ran several days in a solo mining setup and did not get any accepted blocks.I created an account with the mining pool deepbit.net. I now startup my diablominer using:
[email protected]:~/DiabloMiner$ ~/DiabloMiner/DiabloMiner-Linux.sh -u [email protected] -p password -o deepbit.net -r 8332
My account page at deepbit.net reports that my Gizmo performance is 7.10MH/s. I’ve been running for several days and have 589 accepted blocks.
I’m on my way to riches. Over five cents already.
My bitcoin miner has been running now for two weeks without any interruptions. No crashes, restarts, reboots or any issues at all. I would say it is humming along nicely, although without a fan on board, there is actually no humming at all.
You can see a snapshot of my mining pool page in the experiment images.