Compiling cgminer for the Raspberry Pi and Butterfly Labs “Jalapeño”

These instructions are for compiling cgminer on Raspian (a debian distro for the Raspberry Pi).

First, dependencies have to be installed:


sudo apt-get update
sudo apt-get install build-essential git pkg-config libtool \ libcurl4-openssl-dev libncurses5-dev libudev-dev autoconf \ automake

Next clone the source files from github:

git clone https://github.com/ckolivas/cgminer.git

Once you have the source files, move to that directory and compile the code:

cd cgminer
./autogen.sh
CFLAGS="-O2 -Wall" ./configure --enable-bflsc
make
sudo make install

All that’s left is to plug in your Jalapeño (or any other BFL device) and run cgminer with:

./cgminer

If you encounter any problems, it’s likely because your build environment is different (or I forgot something). Leave a comment or message me and I can try to help.

24 thoughts on “Compiling cgminer for the Raspberry Pi and Butterfly Labs “Jalapeño””

  1. Thanks, I was planning on using my Raspberry Pi to mine BTC when I get my BFL Jalaepeno and this is exactly what I needed to know ;-)

  2. Dominus,

    Do you have a BFL Jalapeno plugged into a Raspberry Pi and mining BTC using cgminer? If so, how’s that working out for you?

  3. That’s a great tutorial too – much more comprehensive and novice friendly. I may or may not get a Jalapeño. For me mining is more of a hobby, so it’s fascinating to tinker with, but I don’t really expect to make money off of it or anything. I’ve been mining with some GPUs as well: Radeon 5830s and 7850s. I did switch to altcoins like Litecoin for a while, but it was a hassle to keep on top of, so I switched back to just Bitcoin.

  4. This sequence doesn’t compile on my RPi. I get the following errors:

    root@mike:/home/pi/workarea/cgminer# CFLAGS=”-O2 -WAll -march=native” ./configure –enable-bflsc
    checking build system type… armv6l-unknown-linux-gnueabihf
    checking host system type… armv6l-unknown-linux-gnueabihf
    checking target system type… armv6l-unknown-linux-gnueabihf
    checking for a BSD-compatible install… /usr/bin/install -c
    checking whether build environment is sane… yes
    checking for a thread-safe mkdir -p… /bin/mkdir -p
    checking for gawk… no
    checking for mawk… mawk
    checking whether make sets $(MAKE)… yes
    checking whether make supports nested variables… yes
    checking for style of include used by make… GNU
    checking for gcc… gcc
    checking whether the C compiler works… no
    configure: error: in `/home/pi/workarea/cgminer’:
    configure: error: C compiler cannot create executables
    See `config.log’ for more details
    root@mike:/home/pi/workarea/cgminer#

    When I look at config.log, I see the following:

    Thread model: posix
    gcc version 4.6.3 (Debian 4.6.3-14+rpi1)
    configure:3850: $? = 0
    configure:3839: gcc -V >&5
    gcc: error: unrecognized option ‘-V’
    gcc: fatal error: no input files
    compilation terminated.
    configure:3850: $? = 4
    configure:3839: gcc -qversion >&5
    gcc: error: unrecognized option ‘-qversion’
    gcc: fatal error: no input files
    compilation terminated.
    configure:3850: $? = 4
    configure:3870: checking whether the C compiler works
    configure:3892: gcc -O2 -WAll -march=native conftest.c >&5
    cc1: error: bad value (native) for -march switch
    cc1: error: unrecognized command line option ‘-WAll’
    configure:3896: $? = 1
    configure:3934: result: no
    configure: failed program was:
    | /* confdefs.h */
    | #define PACKAGE_NAME “cgminer”
    | #define PACKAGE_TARNAME “cgminer”
    | #define PACKAGE_VERSION “3.8.5”
    | #define PACKAGE_STRING “cgminer 3.8.5”
    | #define PACKAGE_BUGREPORT “[email protected]
    | #define PACKAGE_URL “”
    | #define PACKAGE “cgminer”
    | #define VERSION “3.8.5”
    | /* end confdefs.h. */
    |
    | int
    | main ()
    | {
    |
    | ;
    | return 0;
    | }
    configure:3939: error: in `/home/pi/workarea/cgminer’:
    configure:3941: error: C compiler cannot create executables

    Any ideas? Be gentle, I am new to all this…

  5. I don’t have an RPi with Raspian installed to do any checking unfortunately. Looking at those logs though, I do see that these seem to be the culprits as far as I can tell:
    cc1: error: bad value (native) for -march switch
    cc1: error: unrecognized command line option ‘-WAll’

    At least for the second, it looks like it might be because the ‘a’ is capitalised. I’m not sure about the first, but you might try leaving it out and see what happens.

    If you don’t need the absolute bleeding edge version of cgminer, you can download a slightly older binary from here: https://github.com/kanoi/cgminer-binaries/tree/master/RPi_Raspbian. In the mean time, I’ll see if I can’t track down what the problem is when compiling.

    Edit: My instructions compile fine on an RPi, albeit one running Arch and not Rasbpian. Let me know if the capitalisation fix works – if not I’ll do some more digging on why it might be failing.

  6. I fixed the -Wall switch and retried the command. The stream ends with:


    checking whether gcc and cc understand -c and -o together… yes
    checking operating system… Linux
    checking for clock_gettime in -lrt… yes
    ./configure: line 11925: -pthread: command not found
    checking libudev.h usability… no
    checking libudev.h presence… no
    checking for libudev.h… no
    configure: error: “udev support requested but libudev not installed”
    configure: error: ./configure failed for compat/libusb-1.0
    root@mike:/home/pi/workarea/cgminer#

    I had already installed libusb. I retried with:

    root@mike:/home/pi/workarea/cgminer# sudo apt-get install libusb
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package libusb
    root@mike:/home/pi/workarea/cgminer# sudo apt-get install libusb-1.0
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    Note, selecting ‘libusb-1.0-0’ for regex ‘libusb-1.0’
    Note, selecting ‘libusb-1.0-0-dev’ for regex ‘libusb-1.0’
    libusb-1.0-0 is already the newest version.
    libusb-1.0-0 set to manually installed.
    libusb-1.0-0-dev is already the newest version.
    0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
    root@mike:/home/pi/workarea/cgminer#

    and the make failed with:

    1. It seems that I misspelled libudev-dev in my apt-get install command. After fixing that and the -Wall spelling error, and removing “-march=native”, it worked fine. Your directions only need to be tweaked to remove the “march” switch. Thanks for your efforts.

      Too bad, but I can copy/paste from my RPi to my Windows machine, but I can’t copy/paste from Windows to RPi. That was the source of my two spelling errors.

      Thanks again. Your post is very helpful.

  7. First off, Dominus, great guide, Thank you!

    I can confirm that the -march switch will cause the compile to fail. Omitting it works just fine!

    Also Harvy thanks for coming back and following up on your post!

  8. To run cgminer as a regular user you should also install the udev rules:
    sudo cp /usr/src/cgminer/01-cgminer.rules /etc/udev/rules.d/
    …then un- and replug the Jalapeño.

    Run cgminer under its own user “cgminer”:
    sudo mkdir /var/local/lib
    sudo adduser –system –home /var /local/lib/cgminer cgminer
    sudo adduser cgminer plugdev

    …and let it autostart:
    sudo cp /etc/init.d/skeleton /etc/init.d/cgminer
    Edit /etc/init.d/cgminer to your needs:

    NAME=cgminer
    DAEMON=/usr/local/bin/$NAME
    DAEMON_ARGS=”-o http://yourpool.com:3333 -u your_user -p your_password -o http://stratum.btcguild.com:3333 –real-quiet –syslog –text-only”
    PIDFILE=/var/run/$NAME.pid
    SCRIPTNAME=/etc/init.d/$NAME

    And make sure start-stop-daemon backgrounds the process. Do this by adding the follwing switches to the lines in the do_start function between –start and –quiet:
    –background –chuid $NAME:nogroup
    Save and make executable:
    sudo chmod u+x /etc/init.d/cgminer
    And let it autostart on boot:
    sudo update-rc.d cgminer defaults 99

    Now start cgminer system service:
    sudo service cgminer start

    Regards, Adrian.

  9. I get the same error message as Harvey. How can I remove the “march-native”? I am really new to all this and try to start learning some linux syntaxes. Could anyone provide me a step-by-step guide to this “remove-thing”? This would be very much appreciated!

    1. I had confirmed that the -march=native flag was not needed, so it’s no longer in the instructions above. It used to be part of the line “CFLAGS=”-O2 -Wall” ./configure –enable-bflsc”.

      If you can’t figure out how to compile it, you can download some slightly older binaries of cgminer built by kano here. Otherwise feel free to post or email the specific error you’re getting and I can try to help out.

      I’ve never learned about Linux in any formal setting. When I can’t figure something out, I’ve found that I can generally just search for what I need to do; there’s a huge amount of documentation out there between various manuals, tutorials, etc. I learned a lot by experimenting and making mistakes.

  10. Hi DT
    You are really a “dominus temporis” to me :-)
    Thanks a lot for your fast comment. When I want to run the compiling again – do I have to remove some files from the last compiling or can I just start the process again with the commands?
    If it don’t works I would be very happy to post you the error-text.

    Thanks for your help.
    Daniel

  11. Hi DT
    I have copied the error message here:

    pi@raspberrypi ~/cgminer $ CFLAGS=”-o2 -Wall” ./configure –enable-bflsc
    checking build system type… armv6l-unknown-linux-gnueabihf
    checking host system type… armv6l-unknown-linux-gnueabihf
    checking target system type… armv6l-unknown-linux-gnueabihf
    checking for a BSD-compatible install… /usr/bin/install -c
    checking whether build environment is sane… yes
    checking for a thread-safe mkdir -p… /bin/mkdir -p
    checking for gawk… no
    checking for mawk… mawk
    checking whether make sets $(MAKE)… yes
    checking whether make supports nested variables… yes
    checking for style of include used by make… GNU
    checking for gcc… gcc
    checking whether the C compiler works… no
    configure: error: in `/home/pi/cgminer’:
    configure: error: C compiler cannot create executables
    See `config.log’ for more details
    pi@raspberrypi ~/cgminer $

    Could you find a hint in all this?

    Thanks! Daniel

    1. You don’t always have to remove any files. You can run the command “make clean” just in case though.

      Looking at the above, I do see two things. One is that you have the “o” as lowercase, where it should be capitalised. The other is that you only have one dash in front of “enable-bflsc”, whereas it should be two.

      If fixing those doesn’t work, try sending/posting the contents of config.log and I’ll see if there’s anything useful in there.

      1. Hi DT
        Everything worked fine now. Thanks so much. I’m mining now with 50GH/s. When I get my first payout I will think of you (seems that this will take a little bit of time :-) )

        Cheers!
        Daniel

  12. This complied fine for me with no errors but despite having plugged in my zeus blizzard X6 i am not getting any hash rate? what have i done wrong

    1. The directions here are for vanilla cgminer, and a cursory search seems to indicate you probably need the version of cgminer from zeusminer, which is based on v3.11, or this other fork from dmaxl based on v4.3.5. It looks like the steps are mostly the same, except that you run

      ./configure --enable-scrypt --enable-zeus

      when compiling, and there are some other command line options that need to be set at runtime. The Readme on dmaxl’s version seems to be pretty clear, so you might start there.

      1. thanks for the reply, installed the new cgminer as advised but still get the error of no devices detected?

        Do you know of anyway to see if the miner unit is actually talking to the pi or not?

  13. This was a delight to read. You show an impressive grasp on this subject! I specialize about Cosmetics and you can see my posts here at my blog FQ4 Keep up the incredible work!

Leave a Reply

Your email address will not be published. Required fields are marked *