willinliv (OP)
Newbie
Offline
Activity: 26
Merit: 0
|
|
July 13, 2013, 02:10:30 PM Last edit: August 01, 2013, 08:27:35 PM by willinliv |
|
Walkthrough: Raspberry Pi/Block Erupter mining rig setup with autostart and vncObjectiveThe objective of this project was to put together a Raspberry Pi controlled Block Erupter USB mining rig using CGminer, that is contributing to a mining pool (in this case Slush's mining pool https://mining.bitcoin.cz/), with enhancements that make it headless, with automatic log on and start up, whilst being accessible via VNC. There are already some very good tutorials out there (used here), but I found that each of these had slighlty different enhancements of no interest to me, which meant that their specific commands were not ideal. So this is my attempt as muddling through things, interfacing different solutions together to get what I need, and troubleshooting problems as they arise using online sources. I hope others find this walkthough useful, I am sure that you'd be able to find these solutions for yourself, but I thought it might be useful for others who maybe are less confident or don't know the right search terms to put into Google. Plus it's a record in case I forget should I need to recreate it. If you do find this walkthrough a timesaver, and something that gets you up and running, you might like to buy me a shandy or two by tossing me a few milibits: bitcoin:1PhtdmAhwUB2ywGiYGEYHLY7ponXykKfBYhttp://s22.postimg.org/ou7ozavep/miner.jpg(updated image 1/8/13 - everything is fixed on a heavy stand that provides a nice volume of air underneath. There are two Arctic Breeze mobile fans in there too) As pointed out by J35st3r, the version of CGMiner that the tutorial below get's you to install is version 3.1.1. Apparently (according to the Adafruit tutorial) http://learn.adafruit.com/piminer-raspberry-pi-bitcoin-miner/install-cgminer the most recent version 3.3.1 has problems addressing the USB devices under Raspbian. But I'd be interested in trying it out sometimeSourcesEquipment- Raspberry Pi
- SD Card (I use a 2gb one)
- Powered USB hub/s, choose one that has an adapter that will allow for 0.5amps per block erupter. You may be able to power the raspberry pi from this also, plus an optional fan. (The Raspberry Pi has one microUSB connection for it's power but you must also use one of it's full sized USB sockets to carry data to the hub). I use Belkin USB2.0 4-port F5U23QEA, which has a 2.6A adapter which should allow for 4 block erupters ok, or if powering the RPi and a fan then 3.
- Asicminer usb Block Erupter. I first heard about these through the Raspberry Pi blog (http://www.raspberrypi.org/archives/4243), having previously used ATi cards for mining. Adafruit talks about using Bitmit, and there are inticing prices if you can but some Bitcoin, but there are also some UK scammers on there (just make sure that you make use of it's Escrow service). Prices on eBay are coming down. All the calculators out there such as this one suggest that with ever increasing mining difficulty (as more bitcoins get released), it's pretty clear that this is a project just for kicks rather than income, and this diversion is going to be costing you money for the privillage of playing a miner. Still apparently the world is aching for a decentralised currency outside of local govt control, and if the oil producing countries get on board there is a potential to destablise the dollar, and things might get interesting (according to my economist friend over a pint that is!)
- Monitor (hdmi, or hdmi to dvi cable), usb keyboard, mouse
Prerequisites- You will have and account created at Slush's Mining Pool.
- On the My account screen of Slush's, you will need to have registered a new worker as your RPi, giving it a descriptive name for yourself and password, leaving the difficulty as unset or auto.
- You may wish to set up a Bitcoin wallet. There are many to choose from but I just use the main one 'Bitcoin-Qt. This is a piece of software that you have installed on a computer. When you first run it it takes ages to download all of the blocks of the blockchain (probably an overnight job). But afterwards on the Recieve tab you can create new addresses, and create one of these to enter into Slush's My account page for when it pay's out. Also in the My Accounts screen you might want to set a more manageable payout threshold from 1BTC to maybe 0.15BTC.
InstructionsStep 1 - Prepare the Raspberry Pi- 1. Download the most recent version of Wheezy from the RaspberryPi foundations website (http://www.raspberrypi.org/downloads). This is the operating system for the RPi, that sits on the SD card. I extract it onto the SD card on a PC with a card reader and Win 32 Disk Imager. When you turn on the Raspberry Pi the username is 'pi' and the password is 'raspberry', and after this you are taken to the bash prompt (which looks like Command Prompt in windoze).
- 2. Now to install CGminer on the Raspberry Pi, follow the instructions from the Adafruit tutorial on installing software. You need to have an internet connection, via ideally an ethernet cable which is the route covered here. You can control the Raspberry Pi over SSH as the tutorial suggests, but for simplicity for the initial setup use a local monitor via hdmi, or a hdmi to DVI adapter, keyboard and mouse. The tutorial will ask you to enter commands into the bash: you can either do this directly in the bash terminal (after you enter the username and passwd above), or you can launch LXDE which is a gui interface similar to windows, which means that you can enter the commands through a windowed application called LXterminal, but you can also have a website open in Midora so that you can copy an paste the tutorials commands from the interent instead fo having to type them in. Run LXDE in the first place by typing 'startx' when you reach the initial bash terminal, and both Lxterminal and Midora have icons on the desktop.
Other things worth mentioning:
- In LXDE you can logout which returns you to the bash terminal.
- In either the LXterminal window or at the bash you can enter these two commands 'sudo reboot' and 'sudo halt' to restart or shut down the raspberry pi nicely.
- A lot of commands start out with the word sudo, which is essentially gives your authorisation as a super user on the computer for commands considered risky for the system (think Windows 7 constantly firing up it's UAC each time you want to install something)
- Another common thing and a feature in the instructions is to use the command nano, this fires up a basic text editor in which you can enter/edit text and then save it out to the same or a new file.
- 3. So following Adafruit's instructions you install CGminer. Ignore the PiMiner step, but go to the next page Configure Settings where you set up a config file for CGminer to tell it about your setup and your username and password. Use your Slush miner login details as created in the prereqs section above. The PoolAddress as suggested in the tutorial is the one you need ("http://stratum.bitcoin.cz:3333").
Now with Cgminer installed, and the config file setup, how do we actually run Cgminer for the first time just to check that everything works? Step 2 - Initial check of hardwareHere we need to bifurcate slightly from the Adafruit tutorial, because they want us to use PiMiner using their LCD Raspberry Pi shield, which is nice but not what we are after. - 1. First we need to find out what hardware address the RPi has given our block erupter (plug it in now if it is not, via the powered USB hub). The Start Mining page of the Adafruit tutorial tells how to so this, essentially type this at either the Bash terminal or LXterminal from within LXDE:
ls /dev/*USB* This should give you some addresses such as /dev/ttyUSB0 which you should make a note of. - 2. Next we need to return the rpi back to the root directory rather than any subfolders such as the one for cgminer. Enter:
cd\ (this returns the bash prompt back at the root directory, so afterwards you should see pi@raspberrypi ~ $ instead of pi@raspberrypi ~/cgminer-3.1.1 $. - 3. Now to launch cgminer, in a slightly different way from the Adafruit tutorial. Enter:
sudo ./cgminer-3.1.1/cgminer --config /home/pi/cgminer.conf -S /dev/ttyUSB0 (if you have more than one block erupter add extra of these -S /dev/ttyUSB1 and -S /dev/ttyUSB2 and so on. This command launches cgminer, tells about the config file and the hardware we want it to use.
Now hopefully you should see CGminer starting up, then connecting to your pool, and then starting to receive and send work (Accepted blocks). If there are any problems then check things such as your cgminer config file, by retracing your steps. http://s17.postimg.org/k34h33c1r/cgminer.jpgStep 3 - Set up Auto-login and autostart of Rpi and CGminerNext up, to set it so that the Raspberry Pi automatically starts mining when the Raspberry Pi is turned on, without any intervention. This means that if there is a power cut it comes back online unaided, and also we can do away with the keyboard and mouse and screen. You can set it so that it mines without having to run through LXDE (loads CGminer directly at the bash), but you lose the ability to use VNC, and whilst you can use SSH to control the computer there are disadvantages to this which I will come on to in the next section. There did not seem to be any advantages in hashrate one way or the other, so do it like this. - 1. Follow the instructions in Issue 3, page 3 of the excellent Raspberry Pi fanzine The MagPi: http://issuu.com/themagpi/docs/the_magpi_issue_3_final?e=4599523/2586562
Rebooting (sudo reboot in the bash/lxterminal) you should find that from power on, the Rpi automatically fires up LXDE. Ok, but what about firing up CGminer with our settings? - 2. To do this we follow part of Jafc76's super tutorial: https://forums.butterflylabs.com/bitcoin-discussion/3238-super-tutorial-raspberry-pi-raspbian-cgminer-tightvnc-wifi-boot.html.Look down his walkthrough until you see " - The last step is to autostart CGMiner every time...." in step 10. At the bash/lxterminal prompt enter:
sudo nano /etc/xdg/lxsession/LXDE/autostart - 3. Then (slightly different from his instructions) type:
@/usr/bin/lxterminal --geometry=90x35 -e sudo ./cgminer-3.1.1/cgminer --config /home/pi/cgminer.conf -S /dev/ttyUSB0 -S /dev/ttyUSB1 -S /dev/ttyUSB2 -S /dev/ttyUSB3 -S /dev/ttyUSB4 -S /dev/ttyUSB5 (adding or taking extra block erupters if required). This tells cgminer about the config we want it to use. - 4. Now rebooting the machine (sudo reboot), you should find that Rpi fires up LXDE, and then launches cgminer in a window. If it does not check that you entered the above correctly.
That means that we can now get rid of the screen and keyboard, and locate the machine somewhere remotely, but what about if we want to be able to remotely access the machine and update it's settings in some way? Step 4 - Setting up VNC accessThis is for controlling the Raspberry Pi remotely through another computer and the network rather than having to use a monitor, keyboard and mouse directly on the Raspberry Pi. There are two options put forward in the tutorials, neither work well enough for what we need: - Control the bash remotely using SSH, this is good if you run CGminer outside of LXDE, or for basic stuff like rebooting (sudo reboot) etc. Follow the Adafruit instructions here.
- Alternatively run a VNC server, gives you the ability to control LXDE as if you were sat in front of it, giving you a moving image screenshot of what would be on the screen. Adafruit's instructions for this are here.
The trouble with both of these is that when you login via these means it creates a second and new concurrent user session, so you can't see what the original one in terms of seeing what is the current session/desktop is doing. This is clever stuff and a fundamental basis of Linux, but no good when you want to dip in every now and again to see how CGminer and the block erupters are getting on.You need to have access to the actual session, not have create a new one. - 1. To solve this, I followed the instructions here http://www.raspberrypi.org/phpBB3/viewtopic.php?p=108862#p108862. This installs x11vnc instead of the tightvncserver Adafruit uses, which is still VNC protocol but lets you control the existing user session.
- 2. Now after a restart (sudo reboot) you should find that you can log-in remotely to the existing session. On my Windows7 machine I use TightVNC viewer.
- 3. You'll need the IP address of your Raspberry Pi to connect. To find this, type this into the bash on the Raspberry Pi (so don't disconnect the monitor, mouse and kb just yet!)
sudo ifconfig
It should be the first IP address (i.e. 192.168.1.7). This gives you the ip address of the rpi. If you connect to the internet through a router, this may be only a local network address; if you would like to access the RPi from outside your local network you'll need to set up port forwarding on your router. - 4. So this works great until you disconnect your monitor and then that VNC is now giving you a crappy 640x480 resolution when you next connect. This seems to be becuase the Raspberry Pi, detects no HDMI connection, and then gives you a composite video sized desktop. I tried various things that didn't work, but finally found this thread: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=26&t=19600
The solution for me was identified by the poster Simon. In the bash/Lxterminal enter: sudo nano /boot/config.txt
Then in the nano editor, scroll downwards a few pages until you see the line '#hdmi_force_hotplug=1' and delete the # (making the line of code visible to the machine). I didn't need to go any further, as I was quite happy with the widescreen HDMI dimensions over anything like VGA. - 5. Reboot the computer, and then give it 10-20 seconds to boot into LXDE by itself again, and then you should be able to access it from you favourite vnc client.
http://s17.postimg.org/4wyfc5m0v/cgminer_vnc.jpgUsing the system- For mining the system should 'just work', provided that it has an ethernet connection, block erupters, and sufficient usb power.
- To check things quickly you can log into the My Accounts page of Slush's website, to check that last share is at 0minutes ago.
- If you need to restart cgminer for whatever reason, I think it's preferable to quit CGminer via the Q key, and then do a sudo halt, or sudo reboot. Although pulling the plug I think is ok
- If you need to change any settings, then VNC into into the RPi, after powering on and leaving it for 10-20 secs for LXDE to load
- If you want to add further block erupters then you need to find their addresses (see Step 2 ls /dev/*USB*), then edit the /etc/xdg/lxsession/LXDE/autostart text file in Step 3 to include the new address/es
- If you move your miner to a new location and new ethernet/IP address, you'd need to reconnect a monitor and keyboard/mouse to run the sudo ifconfig command again, although I think there is software to sniff out local IP addresses which you could use to identify the rpi.
Power consumptionAccording to my maplins energy meter, at 12p/kwh (EDF 2013), for 744 hrs/month. - Raspberry Pi alone - 5w - £0.48 p.m.
- Raspberry Pi w. 1 block erupter - 8w - £0.77 p.m. (335mh/s)
- Raspberry Pi w. 2 block erupter - 11w - £1.06 p.m. (670mh/s)
- Raspberry Pi w. 6 block erupters - 28w - £2.50 p.m. (2004mh/s) (actual with seperate wallwart for RPi)
Things I'd like to improveAny pointers or suggestions I'd welcome - It would be nice to find out how to tie the cgminer launch command to an LXDE desktop icon, so that I would not have to reboot the machine to relaunch cgminer or manually type it into lxterminal
- A failover device that would monitor the hashrate of CGminer and restart either CGminer or the system if it detected a crash of some sort
- In cases where the Rpi freezes completely, the ability to remotely or automatically restart the rpi
- Add wifi capabaility instead of ethernet. This is really easy to do given the time, although certain Aruba wifi networks I use have complicated browser based logins that I'm not sure how it would work with RPi, and seondly at home I'd be worried about my wifi router freezing up every now and again.
- Try out the MinePeon project to see how it compares
- Try out with a more recent version of CGMiner - I'd have to move away from the Adafruit guide though so a big job I think
- A way of bringing down the difficulty of bitcoin mining for a few months
Updates to this post14/07/13 - Added info about the old CGminer version used[/list][/list] 01/08/13 - Updated image to show setup with Arctic fans Updates to add when I get round to it01/08/13 - Add info about adding a backup pool to cgminer.conf
|
|
|
|
J35st3r
|
|
July 13, 2013, 03:10:54 PM |
|
You are using quite an old version of cgminer (3.1.1) here. As a heads up for any newbies reading this, this is the latest version that supports the -S parameter. More recent versions expect to communicate directly with the the USB driver, so the setup procedure is quite different. Perhaps you would like to update your tutorial with this information?
|
1Jest66T6Jw1gSVpvYpYLXR6qgnch6QYU1 NumberOfTheBeast ... go on, give it a try
|
|
|
daze
Newbie
Offline
Activity: 10
Merit: 0
|
|
July 13, 2013, 03:33:48 PM |
|
You are using quite an old version of cgminer (3.1.1) here. As a heads up for any newbies reading this, this is the latest version that supports the -S parameter. More recent versions expect to communicate directly with the the USB driver, so the setup procedure is quite different. Perhaps you would like to update your tutorial with this information?
That's a good point. I did compile the latest version (3.3.1), but couldn't get it to run. But if I can get it to run, I'll post the instructions here.
|
|
|
|
pty84
Newbie
Offline
Activity: 10
Merit: 0
|
|
July 13, 2013, 04:11:44 PM |
|
Looks badass, want to try this. Are you breaking even? You should update us on your production/costs.
|
|
|
|
J35st3r
|
|
July 13, 2013, 04:24:35 PM |
|
You are using quite an old version of cgminer (3.1.1) here. As a heads up for any newbies reading this, this is the latest version that supports the -S parameter. More recent versions expect to communicate directly with the the USB driver, so the setup procedure is quite different. Perhaps you would like to update your tutorial with this information?
That's a good point. I did compile the latest version (3.3.1), but couldn't get it to run. But if I can get it to run, I'll post the instructions here. The definitive thread for Block Erupters on RPi is https://bitcointalk.org/index.php?topic=220905.0 . I gather than minepeon https://bitcointalk.org/index.php?topic=137934.0 (a stand-alone RPi distribution based on ArchLinux) is well thought of too.
|
1Jest66T6Jw1gSVpvYpYLXR6qgnch6QYU1 NumberOfTheBeast ... go on, give it a try
|
|
|
willinliv (OP)
Newbie
Offline
Activity: 26
Merit: 0
|
|
July 14, 2013, 09:26:29 AM |
|
You are using quite an old version of cgminer (3.1.1) here. As a heads up for any newbies reading this, this is the latest version that supports the -S parameter. More recent versions expect to communicate directly with the the USB driver, so the setup procedure is quite different. Perhaps you would like to update your tutorial with this information?
Thanks for your suggestion, and I just put a note about this in the original post. I'd be interested to see the command for running block erupters under linux for the most recent version 3.3.1. Adafruit did say there was a problem with this under Raspbian, but that might just be because they were trying to use -S tags.
|
|
|
|
J35st3r
|
|
July 14, 2013, 10:51:06 AM |
|
Thanks for your suggestion, and I just put a note about this in the original post. I'd be interested to see the command for running block erupters under linux for the most recent version 3.3.1. Adafruit did say there was a problem with this under Raspbian, but that might just be because they were trying to use -S tags.
Great, thanks. I only mentioned it just in case someone downloaded the latest cgminer instead (like not everybody reads the instructions in full before starting ). I had a scan through the cgminer support forum, and it looks like its best to stick with 3.1.1 for now vis https://bitcointalk.org/index.php?topic=28402.msg2632152#msg2632152 (lead developer recommends 3.1.1 as newer versions are unstable on RPi).
|
1Jest66T6Jw1gSVpvYpYLXR6qgnch6QYU1 NumberOfTheBeast ... go on, give it a try
|
|
|
willinliv (OP)
Newbie
Offline
Activity: 26
Merit: 0
|
|
July 15, 2013, 06:50:56 PM |
|
Great thanks for looking for confirmation on that point, and again for raising it in the first place!
To answer the other commenter, with 6 erupters at just over 2gh/s it's making about 0.04BTC per day at present but I can't realistically expect to see any ROI financially given increasing hashrates and difficulty.
|
|
|
|
40-Pin
Newbie
Offline
Activity: 13
Merit: 0
|
|
July 15, 2013, 10:37:32 PM |
|
I got two Pi boards myself, they are a lot of fun to mess around with. I have to ask the question though... why would one not use a 1 foot usb extension cords on each port of the hub to keep the Erupters farther apart? Hell could take a block Erupter shell off and vaccum seal all the PCBs and the exposed usb parts and just lay them in a few buckets of water, might melt the plastic but who knows! Iunno fun stuff
|
|
|
|
daze
Newbie
Offline
Activity: 10
Merit: 0
|
|
July 15, 2013, 10:59:16 PM |
|
Great thanks for looking for confirmation on that point, and again for raising it in the first place!
To answer the other commenter, with 6 erupters at just over 2gh/s it's making about 0.04BTC per day at present but I can't realistically expect to see any ROI financially given increasing hashrates and difficulty.
Other than eBay, where the USB Erupters are over priced, is there another site or place that sells them for less? If I may ask, where did you get yours from, and did you use BTC to pay for them? Thanks!
|
|
|
|
billdavis
Newbie
Offline
Activity: 19
Merit: 0
|
|
July 15, 2013, 11:18:23 PM |
|
oh my god that is so cool
|
|
|
|
willinliv (OP)
Newbie
Offline
Activity: 26
Merit: 0
|
|
July 16, 2013, 06:06:00 PM |
|
I got two Pi boards myself, they are a lot of fun to mess around with. I have to ask the question though... why would one not use a 1 foot usb extension cords on each port of the hub to keep the Erupters farther apart? Hell could take a block Erupter shell off and vaccum seal all the PCBs and the exposed usb parts and just lay them in a few buckets of water, might melt the plastic but who knows! Iunno fun stuff Yes I thought about that (the extension lead thing) and I have heard of other people using these - I just decided it was more trouble than it's worth. The hubs nicely arrange the erupters for the fan to blow over them, I think it's important to have theit heatsinks facing upwards for the heat to convex (?) off of them. I have also fitted those raspberry pi heatsinks to the be chips (on the underside), and they heat up considerably so must be doing a good job. It's surprising effective a fan is at colling down those heatsinks. Having said that I don't have the fan running at night, and some days too (and it's warm here at present) and I haven't noticed any increas in Hardware errors by having the fans off, if anything it's slightly lower by a smidgen, but we're only talking 1.002% as opposed to 0.998% errors. On the raspberry pi, I now have three - one for running Xbian to play films ( http://youtu.be/G2-eUrGbl0I) from my bittorrent directories on my PC, this one for mining and another as kind of a testing one. Really versatile and keeping a lot of people very happy!
|
|
|
|
phrog
Newbie
Offline
Activity: 35
Merit: 0
|
|
July 18, 2013, 08:45:23 AM |
|
Note: this is not the latest version of cgminer, at the time of this writing, the current version (3.3.1) has issues communicating with Block Erupter USB on Raspbian FYI, I also experienced issues with Block Erupter USB's on Raspbain. However I was successful at building and running cgminer from git (3.3.1) after dist-upgrading Raspbain from wheesy to jessie.
|
|
|
|
willinliv (OP)
Newbie
Offline
Activity: 26
Merit: 0
|
|
July 19, 2013, 08:28:33 PM |
|
Note: this is not the latest version of cgminer, at the time of this writing, the current version (3.3.1) has issues communicating with Block Erupter USB on Raspbian FYI, I also experienced issues with Block Erupter USB's on Raspbain. However I was successful at building and running cgminer from git (3.3.1) after dist-upgrading Raspbain from wheesy to jessie. I hope this isn't being lazy but is there any benefits in going to 3.3.1 (It would be quite a bit of work for me to learn how to do that)
|
|
|
|
phrog
Newbie
Offline
Activity: 35
Merit: 0
|
|
July 20, 2013, 12:13:48 AM Last edit: July 20, 2013, 12:33:39 AM by phrog |
|
hot plugging works perfect in 3.3.1 and you don't need -S anymore, also I'm getting a bunch less hardware errors. And was easy to get it to boot up and run at init without having to check for ttyUSB's. I'm sure there must be other improvements with keeping up with the latest versions.
|
|
|
|
btcton
Legendary
Offline
Activity: 1302
Merit: 1007
|
|
July 20, 2013, 04:35:55 AM |
|
Where did you buy the USB Block Erupter from?
|
The signature campaign posters adding useless redundant fluff to their posts to reach their minimum word count are lowering my IQ.
|
|
|
Hornedfrog
Newbie
Offline
Activity: 18
Merit: 0
|
|
July 21, 2013, 09:06:15 PM |
|
hot plugging works perfect in 3.3.1 and you don't need -S anymore, also I'm getting a bunch less hardware errors. And was easy to get it to boot up and run at init without having to check for ttyUSB's. I'm sure there must be other improvements with keeping up with the latest versions.
Excellent. Is there a guide for this setup? Many thanks!
|
|
|
|
netfun2000
Member
Offline
Activity: 66
Merit: 10
|
|
July 22, 2013, 08:32:32 AM |
|
|
|
|
|
pcpro101
Newbie
Offline
Activity: 16
Merit: 0
|
|
July 22, 2013, 08:48:11 AM |
|
you will never get an roi
|
|
|
|
Hornedfrog
Newbie
Offline
Activity: 18
Merit: 0
|
|
July 22, 2013, 01:47:22 PM |
|
|
|
|
|
|