[Dead] kb3gtn's bladeRF setup guide

Follow our development of DSP and SDR tutorials
Post Reply
kb3gtn
Posts: 10
Joined: Sat Aug 03, 2013 10:46 pm

[Dead] kb3gtn's bladeRF setup guide

Post by kb3gtn »

*******************************************************************************************
**** THIS SETUP GUIDE Works with the kernel driver implementation only ****
**** This setup guide was broken by libusb transition. You must use libusb for now. ****
**** LIBUSB implementation setup guide to come soon. ****
*******************************************************************************************
Please use: for setups now..
http://forum.nuand.com/forums/viewtopic.php?f=9&t=2992

----- OLD STUFF Below -----
The gnuradio build instruction I think are still valid..

This is a quick guide I put together for setup the bladeRF on a (?)ubuntu 13.04 AMD64 system.
These instructions are not well tested at this time, feedback and corrections are welcome..
Someone was talking about converting this into a script one could just run.

I just got my board in, and the setup instructions I found to be a bit scattered brain.. So this is an attempt to consolidate the knowledge.

*******************************************************************************************
**** THIS SETUP GUIDE Works with the kernel driver implementation only ****
**** LIBUSB implementation setup guide to come soon. ****
*******************************************************************************************

Change List:
8/5/2013 : based on suggestions from lousyg
corrected missing ../ on cmake
added updated information about redhat based distros..

8/7/2013
Correct init_board.sh script to only load the FPGA
Once the FX3 flash has been loaded, you don't need to touch it, unless there is an upgraded flash image.

8/18/2013
Fixed some typos.

------- START ------------------------------

Pete's BladeRF build/install instructions (as of 8/3/2012): tested (k)ubuntu 13.04 linux-3.8.0-27-generic x86_64
Peter Fetterer (kb3gtn) <[email protected]>

This procedure builds the nuand code / FX3 firmware / builds gnuradio-3.7 (from git) / and gr-osmosdr (from git)
It is assumed you have installed build-essential / linux-headers-`uname -r` and have a general idea of figuring out other missing (apt-getable) depends.
In this example install procedure we will be installing everything into a /opt/[bladeRF]|[cypress]|[gnuradio-3.7.1git]
Because of the custom location, it does require us to update libarary search paths / and pythonpath enviroments / and optionally exec path. (covered here)
This procedure is tailored to ubuntu systems, but could be adapted to other distros like Centos / Gentoo etc...

*** Now to build the Nunad software ***

Make a directory in your home directory called ~/sandbox
We will be doing all our builds in here..

Clone the Nuand repository to your box.

Code: Select all

$ git clone https://github.com/ ./bladeRf/
Start with the kernel module:

Code: Select all

$ cd ~/sandbox/bladeRF/linux/kernel
( Assuming you have the linux-headers or sources installed.. )

Code: Select all

$ make
( may see a warning about 1088 bytes > 1024 bytes, not sure if this is a problem, seems to work anyway.. )

Now to install it (manually)

Code: Select all

$ sudo mkdir -p /lib/modules/`uname -r`/kernel/extras/bladeRF/
$ sudo cp bladeRF.ko /lib/modules/`uname -r`/kernel/extras/bladeRF/
$ sudo depmod
$ sudo modprobe bladeRF
Make it so the module is loaded on boot (add bladeRf to the list of modules in /etc/modules)

Code: Select all

$ sudo -s 
# echo "bladeRF" >> /etc/modules
# exit
Now build the libbladerf library:

Code: Select all

$ cd ~/sandbox/bladeRF/linux/lib/
$ make DEBUG=y
$ sudo make install

Now build the bladeRF-cli program

(Need to install prereq libtecla1 libtecla1-dev)

Code: Select all

$ sudo apt-get install libtecla1 libtecla1-dev
$ cd ~/sandbox/bladeRF/linux/apps
$ make
Now we have to manually install the resulting bin

Code: Select all

$ sudo mkdir -p /opt/bladeRF/fpga
$ sudo mkdir /opt/bladeRF/firmware
$ sudo mkdir /opt/bladeRF/bin
# manually install bin into our custom directory structure.
$ sudo cp bin/bladeRF-cli /opt/bladeRF/bin
*** FX3 Firmware Build ***
You will need to go and download the FX3 toolchain and sources from: http://www.cypress.com/?rID=57990
( This requires you to get an account and download a 300 Mb tarball.. sigh.. )

or you can skip this step and use this known good firmware: (Thanks Brian)
FX3 Image: http://www.nuand.com/~bpadalino/bladeRF.img
FX3 Image MD5sum: 34c158b08f89f7cec614f2fc603f0e6b
FPGA Image that matches: http://nuand.com/fpga/f6c6a3abcb22d2794 ... tedx40.rbf

Setup cypress FX3 build environment and toolchain stuff

Code: Select all

$ sudo mkdir -p /opt/cypress/fx3_sdk
$ cd /opt/cypress/fx3_sdk
$ sudo tar -xvzf <download/path>/FX3_SDK_B125.tar.gz ./
$ sudo tar -xvzf ARM_GCC.tgz
$ sudo tar -xvzf cyusb_linux_1.0.3.tar.gz
$ sudo tar -xvzf FX3_Firmware.tar.gz
(don't need the eclipse stuff for this simple build only)

Now to build the FX3 firmware for the BladeRF

Code: Select all

$ cd ~/sandbox/baldeRf/fx3_firmware
$ cp ./make/toolchain.mk.sample ./make/toolchain.mk
$ make DEBUG=yes
This should produce a bladeRF.img file. The "256 bytes of interrupt vector code" warning is expected..
(manual install)

Code: Select all

$ sudo cp bladeRF.img /opt/bladeRf/firmware/
*** Make kernel udev load and setup our device for us ***
(This is an optional step, you can allways run init_board.sh manually.)

with you favorite text editor create this new file (needs sudo) (vim in my case :-P)

Code: Select all

$ sudo vi /etc/udev/rules.d/10-bladerf.rules
SUBSYSTEM=="usbmisc", KERNEL=="bladerf*", MODE:="0666", RUN+="/opt/bladeRF/init_board.sh $tempnode"
mode could be set to a more restrictive 0660 and then add a GROUP:="plugdev" to constrained access to it, for the more security conscious.

Now create a init_board.sh script

Code: Select all

$ sudo vi /opt/bladeRF/init_board.sh
#!/bin/bash
# get configuration variables
source /opt/bladeRF/etc/bladeRF.cfg
#Once firmware is loaded. you don't need to do it again, unless your updating it. Its flashed onto the FX3..
#echo "Loading new bladeRF device at $1 with firmware ${firmware_image} and fpga ${fpga_image}"
#/opt/bladeRF/bin/bladeRF-cli -b -d $1 -f ${firmware_image} -l ${fpga_image}

# use this instead..
echo "Loading new bladeRF device at $1 with fpga ${fpga_image}"
/opt/bladeRF/bin/bladeRF-cli -b -d $1 -l ${fpga_image}
echo "Complete."
Make the new script we made executable.

Code: Select all

$ sudo chmod +x /opt/bladeRF/init_board.sh
now create the configuration file..

Code: Select all

$ sudo vi /opt/bladeRF/etc/bladeRF.cfg
#!/bin/bash
# This file gets sourced for configuration information variables.
# This a configuration information file about what firmware and fpga image to load
# TODO: figure out how to tell the difference between board types and change what FPGA to load...
# For Now: simple fix configuration.
firmware_image=/opt/bladeRF/firmware/bladeRF.img
fpga_image=/opt/bladeRF/fpga/hostedx40.rbf
export firmware_image fpga_image
you might want to change the hostedx40.rbf with hostedx115.rbf if you have the fancier board.

*** Building GNURADIO from GIT ***

Code: Select all

$ cd ~/sandbox
$ mkdir gnuradio-builds
$ cd gnuradio-builds
$ wget http://www.sbrac.org/files/build-gnuradio
$ chmod +x ./build-gnuradio.sh
$ ./build-gnuradio.sh -m prereqs gitfetch
This takes a while... check top, seems like it sits a long time on checking prerequisits with no output.

Code: Select all

$ cd ~/sandobx/gnuradio-builds/gnuradio/
$ mkdir build
$ cd build
$ cmake -DCMAKE_INSTALL_PREFIX=/opt/gnuradio-3.7.1git  ../ (based on git release, change as needed)
$ make
( This is a large build and will take some time.. good time to take a break..)

Code: Select all

$ sudo make install
Now for some voodoo to get the new program installed into system libraries and python paths and executable path.

With your favorite text editor.. ( vim :-P ) create a new file call /etc/profile.d/gnuradio.sh
you will need sudo for this...

Code: Select all

sudo vi /etc/profile.d/gnuradio.sh
Put the following into it:
#!/bin/bash
# add gnuradio and bladerf stuff to path
export PATH=$PATH:/opt/gnuradio-3.7.1git/bin:/opt/bladeRF/
# add gnuradio python libraries to python search path
if [ $PYTHONPATH ]; then
export PYTHONPATH=$PYTHONPATH:/opt/gnuradio-3.7.1git/lib/python2.7/dist-packages
else
export PYTHONPATH=/opt/gnuradio-3.7.1git/lib/python2.7/dist-packages
fi
update path above if you deviated from gnuradio-3.7.1git
If your on some non-debian based distro, you might need to replace "dist-packages" with "site-packages".

Again, with your favorite text editor, create a new file call /etc/ld.so.conf.d/gnuradio.conf
you will need sudo for this again.. (one line file)

Code: Select all

$ sudo vi /etc/ld.so.conf.d/gnuradio.conf
/opt/gnuradio-3.7.1git/lib
(note:) on some 64 bit systems, you might need a lib64 directory in this file as well?

now update your library cache:

Code: Select all

$ sudo ldconfig -v | grep gnuradio
should see this or something simular..
/opt/gnuradio-3.7.1git/lib:
libgnuradio-atsc-3.7.1git.so.0.0.0 -> libgnuradio-atsc.so
libgnuradio-trellis-3.7.1git.so.0.0.0 -> libgnuradio-trellis.so
libgnuradio-analog-3.7.1git.so.0.0.0 -> libgnuradio-analog.so
libgnuradio-pager-3.7.1git.so.0.0.0 -> libgnuradio-pager.so
libgnuradio-vocoder-3.7.1git.so.0.0.0 -> libgnuradio-vocoder.so
libgnuradio-video-sdl-3.7.1git.so.0.0.0 -> libgnuradio-video-sdl.so
libgnuradio-pmt-3.7.1git.so.0.0.0 -> libgnuradio-pmt.so
libgnuradio-noaa-3.7.1git.so.0.0.0 -> libgnuradio-noaa.so
libgnuradio-filter-3.7.1git.so.0.0.0 -> libgnuradio-filter.so
libgnuradio-digital-3.7.1git.so.0.0.0 -> libgnuradio-digital.so
libgnuradio-channels-3.7.1git.so.0.0.0 -> libgnuradio-channels.so
libgnuradio-qtgui-3.7.1git.so.0.0.0 -> libgnuradio-qtgui.so
libgnuradio-wxgui-3.7.1git.so.0.0.0 -> libgnuradio-wxgui.so
libgnuradio-fec-3.7.1git.so.0.0.0 -> libgnuradio-fec.so
libgnuradio-wavelet-3.7.1git.so.0.0.0 -> libgnuradio-wavelet.so
libgnuradio-fcd-3.7.1git.so.0.0.0 -> libgnuradio-fcd.so
libgnuradio-blocks-3.7.1git.so.0.0.0 -> libgnuradio-blocks.so
libgnuradio-fft-3.7.1git.so.0.0.0 -> libgnuradio-fft.so
libgnuradio-runtime-3.7.1git.so.0.0.0 -> libgnuradio-runtime.so
libgnuradio-audio-3.7.1git.so.0.0.0 -> libgnuradio-audio.so
If so.. All is good.

you will now need to logout and log back in for the profile.d settings to take effect.
Once you have logged back in to your desktop, you should be able to run gnuradio-companion.
If you get a pop up about PYTHONPATH or LD_LIBRARY_PATH, check env to see if the python path or ldconfig returns the correct libraries.

*** Now for gr-osmosdr ***

Now pull the git version of gr-osmosdr

Code: Select all

$ cd ~/sandbox
$ git clone git://git.osmocom.org/gr-osmosdr ./gr-osmosdr
$ mkdir ~/sandbox/gr-osmosdr/build
$ cd ~/sandbox/gr-osmosdr/build
$ cmake -DCMAKE_INSTALL_PREFIX=/opt/gnuradio-3.7.1git ../  (change as needed)
$ make
$ sudo make install
***************************************************************
*** Now for the Fun part, playing with the new toy ****
***************************************************************

you can use bladeRF-CLI to control board parameters.
https://github.com/Nuand/bladeRF/tree/b ... a-setuptxt

you can use the osmocom_siggen and osmocom_fft applications located in /opt/gnuradio-3.7.1git/bin/ to do a FFT spectrum and signal generation.
You can now use gnuradio to build and receive signals. use the osmocom sink and sources block.

Have fun, happy hacking..
Last edited by kb3gtn on Tue Aug 27, 2013 5:24 pm, edited 19 times in total.
bpadalino
Posts: 303
Joined: Mon Mar 04, 2013 4:53 pm

Re: kb3gtn setup guide

Post by bpadalino »

This is spectacular! Thanks very much for doing this!
lousyg
Posts: 9
Joined: Fri Aug 02, 2013 6:38 pm

Re: kb3gtn setup guide

Post by lousyg »

You, my friend, are a saint. If I knew you or where you were, I would buy you a beer. I tried on my own to get osmocom_fft working, but had no success. Now, thanks to your instructions, I'm currently watching a spectrum on my Fedora 19 installation!

A few notes to clean up your instructions:

- In your cmake call for gnuradio, you're missing the "../"
- You may want to add a note that those who are using a 64-bit machine will have to modify their library paths (to use "lib64")
- If you're using a non-debian distro (Fedora, CentOS, RHEL, etc.), you'll want to use "site-packages" instead of "dist-packages" for your Python path.

Thank you again. This post should really be a sticky until the Nuand guys are able to put up some of their tutorials!
shaun_tx
Posts: 1
Joined: Mon Aug 05, 2013 6:54 pm

Re: kb3gtn's bladeRF setup guide

Post by shaun_tx »

Very nice my friend. Thanks for your hard work and dedication! :) Beer on me.
tfm55x
Posts: 5
Joined: Sat Aug 03, 2013 5:15 pm

Re: kb3gtn's bladeRF setup guide

Post by tfm55x »

FWIW, if you use this process on the Kali linux distribution, edit /etc/debian_version and change the "Kali Linux 1.0" string to "Kali Linux 6.0" . This will allow the Debian version check in the build-gnuradio script to work properly.
madengr
Posts: 34
Joined: Fri Mar 01, 2013 6:51 am

Re: kb3gtn's bladeRF setup guide

Post by madengr »

Cool thanks. Maybe I can get this thing to insmod when it boots.

BTW when everything is working, run volk_profile for a real speed-up in GNU Radio.

http://gnuradio.org/redmine/projects/gnuradio/wiki/Volk
qjax
Posts: 1
Joined: Sat Aug 17, 2013 12:30 pm

Re: kb3gtn's bladeRF setup guide

Post by qjax »

kb3gtn thanks for the setup guide. However, I was unsuccessful with my bladeRF install on Ubuntu 12.04 VMware install using the RTL-SDR/HackRF Live DVD from http://www.rtl-sdr.com/rtl-sdrhackrf-live-dvd/

Here is what I tried but could not get the bladerf0 to initiate or open with 'bladerf-cli'.

Qjax 8/17/2013 update to kb3gtn's bladeRF setup guide for Ubuntu 12.04 and SDK v1.2.3

Qjax: Corrected references to directory /bladedRf and changed to /bladeRF
Qjax: Determined my running gcc version ‘gcc –version’
Qjax: Determined that the new SDK v1.2.3 downloaded from Cypress required corrections below.
Qjax: Downloaded the EZ-USB FX3 SDK v1.2.3 for Linux from http://secure.cypress.com
Qjax: Downloaded the FX3_SDK_B125 for Linux from http://secure.cypress.com
Qjax: Downloaded the EZ-USB FX3 SDK v1.2.3 for Windows from http://secure.cypress.com
Qjax: Edit toolchain.mk to reflect the directory structure of the new SDK v1.2.3.
Qjax: I replaced spaces with “-“ in SDK v1.2.3 directory EZ-USB-FX3-SDK .
Qjax: Corrected ARMGCC_VERSION ?= 4.6.3 in /make/toolchain.mk
Qjax: Corrected FX3_FW_DIR : in /make/toolchain.mk with my path
Qjax: Corrected ELF2IMG_DIR: in /make/toolchain.mk with my path

My toolchain.mk file looked like this >

FX3_ROOT ?= /opt/cypress/fx3_sdk
ARMGCC_INSTALL_PATH ?= $(FX3_ROOT)/arm-2011.03
FX3_FW_DIR := $(FX3_ROOT)/cy_fx3_sdk_v1.2.3/cy_fx3_sdk_v1.2.3/EZ-USB-FX3-SDK/1.2/firmware
ELF2IMG_DIR := $(FX3_ROOT)/ cy_fx3_sdk_v1.2.3/EZ-USB-FX3-SDK/1.2/util/elf2img

$ make DEBUG=yes >>>>>>> the make was UNSUCCESSFUL and did not produce a bladeRF.img file

OUTPUT OF ERROR
qjax@qjax-virtual-machine:~/sandbox/bladeRF/fx3_firmware$ make DEBUG=yes
/opt/cypress/fx3_sdk/arm-2011.03/bin/arm-none-eabi-gcc -Wall -Wextra -Wno-unused-parameter -DCYU3P_FX3=1 -D__CYU3P_TX__=1 -mcpu=arm926ej-s -mthumb-interwork -I/opt/cypress/fx3_sdk/cy_fx3_sdk_v1.2.3/EZ-USB-FX3-SDK/1.2/firmware/u3p_firmware/inc -DTX_ENABLE_EVENT_TRACE -O0 -ggdb3 -DDEBUG -c -o bladeRF.o bladeRF.c
make: /opt/cypress/fx3_sdk/arm-2011.03/bin/arm-none-eabi-gcc: Command not found
make: *** [bladeRF.o] Error 127

Any help would be appreciated.
piranha32
Posts: 26
Joined: Fri Mar 01, 2013 6:25 am

Re: kb3gtn's bladeRF setup guide

Post by piranha32 »

qjax wrote:[...]
$ make DEBUG=yes >>>>>>> the make was UNSUCCESSFUL and did not produce a bladeRF.img file

OUTPUT OF ERROR
qjax@qjax-virtual-machine:~/sandbox/bladeRF/fx3_firmware$ make DEBUG=yes
/opt/cypress/fx3_sdk/arm-2011.03/bin/arm-none-eabi-gcc -Wall -Wextra -Wno-unused-parameter -DCYU3P_FX3=1 -D__CYU3P_TX__=1 -mcpu=arm926ej-s -mthumb-interwork -I/opt/cypress/fx3_sdk/cy_fx3_sdk_v1.2.3/EZ-USB-FX3-SDK/1.2/firmware/u3p_firmware/inc -DTX_ENABLE_EVENT_TRACE -O0 -ggdb3 -DDEBUG -c -o bladeRF.o bladeRF.c
make: /opt/cypress/fx3_sdk/arm-2011.03/bin/arm-none-eabi-gcc: Command not found
make: *** [bladeRF.o] Error 127

Any help would be appreciated.
Add /opt/cypress/fx3_sdk/arm-2011.03/bin to PATH. E.g.

Code: Select all

PATH=$PATH:/opt/cypress/fx3_sdk/arm-2011.03/bin make
tompanderson
Posts: 2
Joined: Thu Aug 01, 2013 12:53 pm

Re: kb3gtn's bladeRF setup guide

Post by tompanderson »

H,

You mentioned the possibility of a script you could just run. I'd be happy to pay for such a script for raspberry pi. Any interest?

Thanks,

Tom

W6TPA
dewzenol
Posts: 1
Joined: Sat Aug 17, 2013 4:05 pm

Re: kb3gtn's bladeRF setup guide

Post by dewzenol »

EDIT TO ADD: My problems disappeared after reboot!


regarding:
/opt/bladeRF/etc/bladeRF.cfg
I believe there are two lower-case 'f's in that file that need to be upper case.

Also, in the following command, the .f here should be a .d:
sudo vi /etc/ld.so.conf.f/gnuradio.conf

I honestly believe that without the scripts you've provided, I would have spent weeks of cobbling together pieces of tutorials to get up and running. Now, spending countless hours playing with gnuradio and neglecting my family, responsibilities, and sleep is so close that I can almost smell it.

With your script I've managed to get bladeRF-cli to see the device, and even capture a sample. I've got gnuradio up and running, but have not yet managed to get it to sample data from bladeRF. My first flow graph consists of a) an osmocom source sample rate of 1M at 936.250mhz and b) a WX GUI Waterfall Sink. Unfortunately when I execute, I get the following ouptut:
linux; GNU C++ version 4.7.3; Boost_104900; UHD_003.005.003-129-g95e6bfea

Using Volk machine: avx_64_mmx_orc
gr-osmosdr v0.0.2-8-gd0a043ac (0.0.3git) gnuradio 3.6.5.1
built-in source types: file fcd rtl rtl_tcp uhd hackrf bladerf
Using nuand LLC bladeRF #1 SN 0000000000000000 FW v1.0 FPGA v0.0
[DEBUG src/bladerf.c:578] Read failed with errno=1: Operation not permitted
Failed to read samples: File or device I/O failure
Invalid LNA gain requested: 10, setting to LNA_MAX (6dB)
This is probably unrelated to the scripts provided here so I think I'll open up a thread elsewhere, unless you think otherwise. I'm sure there's lots more info I can and should provide and I don't want to clutter your thread.

****
EDIT TO ADD
****
The errors above disappeared after reboot. It works! THANKS!
pcharest
Posts: 1
Joined: Fri Mar 29, 2013 2:07 pm

Re: kb3gtn's bladeRF setup guide

Post by pcharest »

Hello all,

I had a problem of bladerf driver not registering to the usb driver. To detect the problem, after connecting the device, you try

Code: Select all

ls /dev/blade*
If you see nothing, then you might have the same problem as I had. My kernel is older (3.0) and the function module_usb_driver does not work, although I did not get any compilation error. I modified the bladeRF.c driver source code.

Remove the line

Code: Select all

module_usb_driver(bladerf_driver);
and replace with

Code: Select all

static int __init bladerf_init(void)
{
    return usb_register(&bladerf_driver);
}
module_init(bladerf_init);

static void __exit bladerf_exit(void)
{
    usb_deregister(&bladerf_driver);
}
module_exit(bladerf_exit);
Recompile, reinstall and reload the driver. Unplug and plug the device. Then launch again

Code: Select all

ls /dev/blade*
I can now see the device and it is accessible with the CLI. I hope it will help those with a similar problem to mine.
dk5ras
Posts: 70
Joined: Fri Mar 01, 2013 3:23 am

Re: kb3gtn's bladeRF setup guide

Post by dk5ras »

For me all this stuff does not fit. Got my BladeRF right now released from customs (paid 88.22 EUR tax!), downloaded and built the stuff from the git repo, even flashed the new firmware (whatever this is - the fx3 stuff?), but as a Linux beginner I have no clue about this kernel stuff. The folders mentioned here are non existent in my bladerf folder.

Btw., now my existing gr-osmosdr setup recognizes the bladerf package, but when trying to re-build gr-osmosdr it fails with some errors. So I am sure lots of things are missing.

What I have is an existing and working setup (built all from sources) with USRP1, Gnuradio 3.7, gqrx, OpenBTS, OS is Kubuntu 12.04 LTS. Seems to be much more complicated to integrate the bladerf into this environment?!

Ralph.
Post Reply