Friday, August 23, 2013

Installing Gnuradio for bladeRF

Tonight I finished the installation of the software.

I managed to get gnuradio installed without any problems.

And it worked, I managed to run my helloworld-gnuradio-program

This program consists of a source (a noise-generator), a throttle and a sink.

I tried to use audio as a sink but that did not work, not any noise.
I tried an FFT and it displayed my noise-source.
I changed the noise source for two signal generators.
One generator with a sine at 400 Hz , the other a sine at 1000 Hz.
I added the two signals into an FFT-display. (yes, with a throttle in between)

That worked fine!!

I got a real-time FFT-display.

If I do exactly the same on Windows ( I installed gnuradio a few weeks before on Windows)
I have a problem with the display. Errors about a circular buffer. If I disable OPENGL it works but not all functions behave normally. The FFT is OK, but histograms does not work.

So, linux (Ubuntu) under VMWare is able to correctly run gnuradio.
My Windows implimentation of gnuradio is not functioning correctly.

WORST OF ALL:

Somehow my precious, expensive, bladeRF-board (a 115-type!) is not seen by linux/VMWare/Windows.

Any way bladeRF-cli does not see any bladeRFnn
Any way Windows DOES mention a bladeRF-device that does not start up.

I am afraid I have a VMWare-USB-Windows problem!

What to do now????

1. Investigate the USB-VMware-problem
2. Give up and boot my laptop from a live linux-CD/DVD or install multiboot???

I don't know what is the best strategy to be able to play with my bladeRF-115-toy!

COMMENTS ARE MORE THAN WELCOME, IE helpful suggestions please!


Time to show myself and my dog, Boris, in Caminha, Portugal,
 at the end of 2012. My wife takes this picture, I guess...


Thursday, August 22, 2013

Install remaining software for BladeRF

Another evening stumbling upon/through/over linux.

Warning: I copied/pasted a lot of info from my diary. Not at all to impress you, but to show what I did and had to do to get my BladeRF-board working. I can tell you, I did not succeed this evening. I am afraid many more evenings will come...

I took the marvelous installation guide from the bladeRF - forum,
kb3gtn's bladeRF setup guide at
 http://forums.nuand.com/forums/viewtopic.php?f=9&t=2804

Painfully I followed the instructions.

The problem is, however, that I am regaining old linux knowledge that was almost gone. Old forgotten braincells suddenly awaken and try to help me.

I had to experiment with well known linux commands. Ok, dir, sudo, cp, mkdir, rmdir, rmd, whatever, a lot of commands I understand. I managed to switch between my terminal-session, my diary in Word in windows and Chrome, or Fox for internet-access. All in different windows. And, Ubuntu is running in VMWare.

I re-learned ~ is your home-directory. Trivial perhaps for experienced linux-users.


About libusb, there seem to be two flavors: libusb-dev, the developers lib and libusb, the underlying lib.

I read something about aptitude. DO I have that installed in Ubuntu? Just ask the system and you get:

The program 'aptitude' is currently not installed.  You can install it by typing:
sudo apt-get install aptitude

So I did

OK, so now I can use aptitude or apt-get to semi-automagically install packages...

ecokees@ubuntu:/mnt/hgfs/bladeRF/linux/lib$ sudo apt-get update
ecokees@ubuntu:/mnt/hgfs/bladeRF/linux/lib$ sudo apt-get install libusb
ecokees@ubuntu:/mnt/hgfs/bladeRF/linux/lib$ sudo apt-get install libusb-1.0.0
ecokees@ubuntu:/mnt/hgfs/bladeRF/linux/apps$ make

Do I use the wrong libusb?? I use 1.0.0 but there is also a quite different 0.1.0
Which one do I need?

In directory C:\Users\lonneke\Documents\GitHub\bladeRF-1\linux\lib
is a makefile that reads
# Enable libusb (>= 1.0) support by defining ENABLE_BACKEND_LIBUSB


ecokees@ubuntu:/mnt/hgfs/bladeRF/linux/lib$ sudo apt-get install libtecla1 libtecla1-dev
ecokees@ubuntu:/mnt/hgfs/bladeRF/linux/apps$ make
I get a lot of undefined reference to


NOPE…

Now I am gonna try the exact procedure at http://forums.nuand.com/forums/viewtopic.php?f=9&t=2804

ecokees@ubuntu:~$ sudo apt-get install git
 ecokees@ubuntu:~$ sudo apt-get install git-core


The program 'gitk' is currently not installed.  You can install it by typing:

sudo apt-get install gitk
ecokees@ubuntu:~/myProject$ sudo apt-get install git-gui


How to see hidden files in the file-browser?  Ctrl-H or edit preferences
Now I can see all hidden files that start with a . (dot)

ecokees@ubuntu:~/bladeRF$ git clone https://github.com/Nuand/bladeRF.git

this is the URL for help about git:  http://git-scm.com/book/en/Git-Basics

ecokees@ubuntu:~/bladeRF/bladeRF/linux/kernel$ make
ecokees@ubuntu:~/bladeRF/bladeRF/linux/kernel$ sudo insmod bladeRF.ko
ecokees@ubuntu:~/bladeRF/bladeRF/linux/lib$ make all
ecokees@ubuntu:~/bladeRF/bladeRF/linux/apps$ make

ecokees@ubuntu:~/bladeRF/bladeRF/linux/apps$ dir bin
bladeRF-cli
ecokees@ubuntu:~/bladeRF/bladeRF/linux/apps$

OK: now I have my bladeRF-cli  !!!!!!!!!!!!!!!!

The setup guide starts with a remark:

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...

So, there we go again:


ecokees@ubuntu:~/bladeRF/bladeRF/linux/apps/bin$ sudo apt-get update
ecokees@ubuntu:~/bladeRF/bladeRF/linux/apps/bin$ sudo apt-get install gcc
ecokees@ubuntu:~/bladeRF/bladeRF/linux/apps/bin$ sudo apt-get install g++
ecokees@ubuntu:~/bladeRF/bladeRF/linux/apps/bin$ sudo apt-get install libc6-dev

and finally:

ecokees@ubuntu:~/bladeRF/bladeRF/linux/apps/bin$ sudo apt-get install build-essential

What is linux-headers??

Kernel *headers* are the header files used to compile the kernel - and other
applications which depend on the symbols / structures defined in these
header files, like kernel modules. An example can be graphic card drivers;
if the driver does not have a binary matching the running kernel and needs
to be compiled.

ecokees@ubuntu:~/bladeRF/bladeRF/linux/apps/bin$ sudo apt-get install linux-headers-generic

ecokees@ubuntu:~/sandbox$ git clone https://github.com/Nuand/bladeRF.git

Yep: I have a bladeRF directory                                NOTE: it is bladeRF, not bladeRf!!

OK, again:

ecokees@ubuntu:~/sandbox/bladeRF/linux/kernel$ make

A lot of warnings, hope that is no problem later on

ecokees@ubuntu:~/sandbox/bladeRF/linux/kernel$ sudo mkdir -p /lib/modules/'uname -r'/kernel/extras/bladeRF/

-p, --parents
no error if existing, make parent directories as needed

ecokees@ubuntu:~/sandbox/bladeRF/linux/kernel$ sudo depmod

The depmod and modprobe utilities are intended to make a Linux modular kernel manageable for all users, administrators and distribution maintainers.
Depmod creates a "Makefile"-like dependency file, based on the symbols it finds in the set of modules mentioned on the command line or from the directories specified in the configuration file. This dependency file is later used by modprobe to automatically load the correct module or stack of modules.

DESCRIPTION
Linux kernel modules can provide services (called "symbols") for other modules to use (using EXPORT_SYMBOL in the code). If a second module uses this symbol, that second module clearly depends on the first module. These dependencies can get quite complex.

depmod creates a list of module dependencies, by reading each module under /lib/modules/version and determining what symbols it exports, and what symbols it needs. By default this list is written to modules.dep in the same directory. If filenames are given on the command line, only those modules are examined (which is rarely useful, unless all modules are listed).

If a version is provided, then that kernel version’s module directory is used, rather than the current kernel version (as returned by "uname -r").

depmod will also generate various map files in this directory, for use by the hotplug infrastructure.


 Do you understand this all?

ecokees@ubuntu:~/sandbox/bladeRF/linux/kernel$ sudo modprobe bladeRF
FATAL: Module bladeRF not found.
ecokees@ubuntu:~/sandbox/bladeRF/linux/kernel$

For some reason the mkdir command did not make the right directory and the cp command also did not what it had to do

This is interesting:

ecokees@ubuntu:/lib/modules$ cd $(uname -r)
ecokees@ubuntu:/lib/modules/3.2.0-51-generic-pae$ cd kernel

playing with root

ecokees@ubuntu:~/sandbox/bladeRF/linux/kernel$ sudo -s
root@ubuntu:~/sandbox/bladeRF/linux/kernel# echo "bladeRF" >> /etc/modules
root@ubuntu:~/sandbox/bladeRF/linux/kernel# exit
exit
ecokees@ubuntu:~/sandbox/bladeRF/linux/kernel$

ecokees@ubuntu:~/sandbox/bladeRF/linux/lib$ make DEBUG=y
ecokees@ubuntu:~/sandbox/bladeRF/linux/lib$ sudo apt-get install libtecla1 libtecla1-dev
ecokees@ubuntu:~/sandbox/bladeRF/linux/apps$ make
ecokees@ubuntu:~/sandbox/bladeRF/linux/lib$ sudo apt-get install libtecla1 libtecla1-dev
ecokees@ubuntu:~/sandbox/bladeRF/linux/apps$ make
ecokees@ubuntu:~/sandbox/bladeRF/linux/apps$ sudo mkdir -p /opt/bladeRF/fpga
ecokees@ubuntu:~/sandbox/bladeRF/linux/apps$ sudo mkdir /opt/bladeRF/firmware
ecokees@ubuntu:~/sandbox/bladeRF/linux/apps$ sudo mkdir /opt/bladeRF/bin
ecokees@ubuntu:~/sandbox/bladeRF/linux/apps$
ecokees@ubuntu:~/sandbox/bladeRF/linux/apps$ sudo cp bin/bladeRF-cli /opt/bladeRF/bin
ecokees@ubuntu:~/sandbox/bladeRF/linux/apps$

WAUW!!!

ecokees@ubuntu:~/sandbox/bladeRF/linux/apps/bin$ ./bladeRF-cli --help
Usage: ./bladeRF-cli [options]
bladeRF command line interface and test utility (0.2.0)

Options:
  -d, --device <device>            Use the specified bladeRF device.
  -f, --flash-firmware <file>      Flash specified firmware file.
  -l, --load-fpga <file>           Load specified FPGA bitstream.
  -p, --probe                      Probe for devices, print results, then exit.
  -s, --script <file>              Run provided script.
  -b, --batch                      Batch mode - do not enter interactive mode.
  -L, --lib-version                Print libbladeRF version and exit.
  -V, --version                    Print CLI version and exit.
  -h, --help                       Show this help text.

Notes:
  If the -d parameter is not provided, the first available device
  will be used for the provided command, or will be opened prior
  to entering interactive mode.

  Batch mode is implicit for the following options:
     -p, --probe               -h, --help
     -L, --lib-version         -V, --version

ecokees@ubuntu:~/sandbox/bladeRF/linux/apps/bin$ ./bladeRF-cli --version
0.2.0
ecokees@ubuntu:~/sandbox/bladeRF/linux/apps/bin$

So, bladeRF-cli works and I should be able to control my BladeRF-board!!!!!!!

bladeRF> print

Error: No devices are currently opened

bladeRF> open

open: No device specified

bladeRF> probe

bladeRF> version
Inside version
bladeRF> quit
ecokees@ubuntu:~/sandbox/bladeRF/linux/apps/bin$

About power supply for the BladeRF. It seems to be completely run on the USB-power.
I found a set of jumpers (J70) that are placed to have the USB-power feed the board. It is also
possible to use external power.

I can imagine that the FX3-chip on the bladeRF needs to be inited first?

So, go on with the installation from http://forums.nuand.com/forums/viewtopic.pphp?f=9&t=2804

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

I don’t need to make the FX3 image, just download. Last command is:

$ sudo cp bladeRF.img /opt/bladeRf/firmware/

I downloaded bladeRF.img to my shared directory in Windows and then:

ecokees@ubuntu:~/sandbox/bladeRF/linux/apps/bin$ sudo cp /mnt/hgfs/bladeRF/bladeRF.img /opt/bladeRF/firmware/

ecokees@ubuntu:/etc/udev/rules.d$ sudo gedit 10-bladeRF.rules

Well, I still cannot use my BladeRF-board.

I am afraid that windows is hiding the USB-device bladeRF for me.

I don't know what to do now:

  1. just go on and install gnuradio on Ubuntu in VMWare in Windows7 and hoping that I see the bladeRF as a source in gnuradio
  2. install linux on a stick or CD, boot from it and do the whole installation again
  3. trying to figure out where it is going wrong. I pasted almost everything I did in a word-diary, inclusive of all messages I got.
  4. Ask for help on the forum
  5. Go on with libusb and java in Windows, I have done something like this before with the EZUSB-software
I don't know yet. I am afraid that VMWare is causing some problems here with USB. 
I really love to learn and find out what is happening but I also want results finally. My goal is building a GPS-receiver using the FPGA on the BladeRF and Python on the PC. I do not want to become an expert in VMWare/Windows-problem-solving...

I hope some nice guy or girl from the BladeRF community will help me in some way. I am not stuck yet, there are some things to investigate so I don't yet have clear questions to put in the forum.


Linux is daunting, but I will survive: YES I CAN!!








Tuesday, August 20, 2013

Git and Github is great! Nice version control software for my bladeRF software

I was stuck in git last time I tried to get working software for my bladeRF.

The software for the bladeRF is on https://github.com/Nuand/bladeRF

So, you have to use git. Git is all about version control software (VCS). At first git scared me, it was daunting, it looked very complex. But I had to use it. So, after installing the software, play with it and trying to avoid RFM., I had to admit: you have a problem. Tonight I finally did some serious study, found a nice tutorial and finally had success! I cloned the bladeRF software and I now have a working version locally which I can easily keep up to date with git!

I even understand what I am doing now!

This is the URL for help about git:  http://git-scm.com/book/en/Getting-Started

I finally managed to patiently read the tutorial and try some commands. This is great stuff! It is all about RFM. Normally I avoid manuals/tutorials/notes, etc. But this time was different.

I managed to set up git the right way. I installed gitk and git-gui. I configured git (just a matter of typing a username and email-address after having set up an account at github).

Then I finally cloned the bladeRF software to a local directory. Now I had the last version! I made the kernel, the lib and the apps. Now I have my bladeRF-cli

OK, I can't do anything useful with it right now but I am slowly creeping to success!

Next I'll try to build the software using the very clear tutorial in the bladeRF forum.


from my photo-archive: in March 2013 I photographed this
plate in Castrojeriz, Spain. It is about the "route de Santiago".
(I walked, with my dog, about 5 km of this route).




Saturday, August 17, 2013

First steps from git to bladeRF-software

This whole project is becoming quite a challenge!

I installed a window-program to use github and somehow I managed (by accident?) to get a copy of github's bladeRF software to a more local place on my hard disk. I use Windows 7 prof. Studying the software I decided to go for linux. Most of the bladeRF-people seem to do that. Why do it differently? Yes, think differently takes you to a higher place but this is already difficult enough!

I had Ubunti running under VMWare under Windows prof 7.

I managed to mount my bladeRF-directory-tree and could access the files from Ubuntu.

Ubuntu warned me to get about 52 updates. I got the updates and discovered I lost my bladeRF-files. That is to say: I could not access the share anymore.

OK, I had to reinstall VMware-tools.

After that I went to the linux/kernel directory and did what I had to do

I went to the linux/lib directory and libusb was missing.

I installed aptitude and did: sudo apt-get install libusb
I choose for lib 1.0.0

Back to make lib
Lot of errors. Difficult to understand what is happening here.

I had to install teclalib or libtecla and back to lib

Finally go to the directory linux/apps and make apps

Problems: there is not any sign of bin/bladeRF-cli the directory bin is empty

I have to find out what is going wrong.

The main idea for installing software in linux is becoming clear to me:

1. there is an automatic installer: apt-get   OR:
2. there are tar-archives that should be copied to and extracted from /tmp
3. you look for a readme and RFM!
4. you give the command 'make' (yes, without the quotes)
5. you do sort of make install
6. somehow go through the pile of messages to find out if all is OK

Well, thusfar I learned an enormous lot of things about linux. However, the bladeRF-board is still in the box, it is no use connect it to my laptop-USB-3-port if there is no corresponding software running...

Do I need libusb1.0.0 or libusb0.1.0????

A lot of questions.

Plans:
1. I want to make/install the bladeRF demo software running Ubuntu/linux
2. I will install gnuradio in Ubuntu (it more or less runs in Windows already!)

Comments on my ramblings are more than welcome. I can use any suggestion of more experienced users (perhaps almost every bladeRF-owner ?)


big storm: broken mill in a garden in Caminha, Portugal


Tuesday, August 13, 2013

Wrote a Sudoku solver in Python on an iPad

My BladeRF-board is burning in my hands. I want to connect the beast to my laptop, experiment with gnuradio, write some VHDL-code, program the FX3-USB-chip with C-code and eventually write some python-code to control the BladeRF from my laptop. And I need to understand GitHub, become familiar with unix again etc.

Well, I was thinking about where to start now when my wife got that (persistent?) idea to go out for a fortnight and go camping on that nice campsite without electricity and Internet. OK, no BladeRF for a few weeks. But life is about chances, so I took the iPad, found the 12V charger, checked my Smart phone for Internet-access (tethering!) and a few days later we went for the trip.

Between dividing my attention to my wife, our dog and the neighbours, I had ample time for python. Previously I installed Pythonista on the iPad. I had a marvellous fortnight. I spent hours in bed with Pythonista just before sleeping. I did the language tutorial a few times. Read most of the language reference and read some forums on the Internet (yes, tethering on the Smart phone and discovering that you 'burn' a lot of MB's from your 500 MB month-limit). Then I examined the examples from the Pythonista-app. It looked quite simple finally.

I decided to go for a Sudoku-solver. This is medium-difficult project with classes, functions, lists and drawing/animation. Just to get familiar with python.

First I programmed a white tile. I you touch the tile it changes to red, touch it again and it is white again. That is fun! The equivalent of Hello world or a blinking LED!

I programmed an array of 9 * 9 tiles. To make it interesting I programmed the tiles to flip the color of its 4 neighbours if you touch one. Then I had the value increment for every touch. Later I made a small modification to set the value back to 0 after reaching a value of 10.

I changed the graphics to show a subdivision into 9 bigger tiles, each divided into 3 * 3 tiles.

I programmed functions to check for doubles in a row, a column or a 3*3 tile according to the Sudoku-rules.

Finally I made a big green START-button and programmed a solver using backtracking. Believe me, this was the simplest part of the game!

Now I can touch my empty Sudoku and program a challenge from a newspaper. Few minutes later it shows the solution. But more than that it animates the progress. It is fun to watch the solver solve the Sudoku. You see the backtracking to the first tile and going up again to find a solution.

I found some hard Sudoku-problems on the Internet and my python-program could solve them all. The hardest one took more than half an hour, but perhaps it took that long because the iPad switched itself off after so many minutes. Later I changed the setup and got an empty battery after a long walk with the dog ;<((

I sent the python-program to my laptop using email and tried to run it from the python-implementation on the laptop. Nope: 'import scene' does not work. Of course, the class/module Scene is specific for the OS on an iPad, I presume. OK, a pity. If someone wants the code, comment on this article or send me an email. This Sudoku-program is really fun to play with! But quite distracting if you want to do something useful with your life...

I found an enormous lot of Sudoku-implementations on the internet! I knew that already because I programmed a solver in MathCad once and also in java in my worktime before retirement. To learn the language of course (my boss agreed ;>)) to that).

This Sudoku-project taught me a lot about python. Python looks a lot like java, but it is easier perhaps. I am quite surprised that python does not insist in declaring variables. I can't resist to program "x = 1.0" to explicitly declare x to be a floating point variable. The for loop is fantastic! Just write "for i in elem" where elem is a list, an array, a dictionary or whatever datastructure and you get every element in the variable i. From then on you can use i.x for its x-value or whatever attribute. The scope of variables puzzled me in the beginning. I still have some problems with the argument 'self'. In a class every function gets a pointer to itself automagically? I'll try to grasp that later, if I have to.


I sent this photo to my little grandson (he likes big
machines). However he thought it was a picture of
the present he was going to get from us...





Monday, July 29, 2013

BladeRF arrived, just 10 minutes earlier than expected/predicted by FedEx

Ok, I received my BladeRF, in perfect condition and perfect on time!
It was delivered with 2 SMA-cables for RF in/out and a USB3 cable. No CD, no paper docs, not even a "Must read"-letter. This is 2013 and internet, I don't complain.

What are my plans?

I want to give gnuradio a try. I think that gnuradio, python and Windows should work together to get my BladeRF-GNSS-receiver running. I will use Github to keep track of my software-trials.

In the past I used to work with Eclipse and java for software-experiments. For my attempts, have a look at my old blog: http://www.qsl.net/pa1kdg/

I don't want to RUN for a working GNSS-receiver, I bought one for $50, so I always know where I am. Also my smartphone can navigate and I have a Garmin in my car. No, my satisfaction comes from learning, from the process itself. And I am not in a hurry, besides, believe me, as a retired engineer I only have a few hours a day to spend on this hobby!

I want to solve my gnuradio-problems first, after that I will try to download BladeRF software in a local directory on my laptop using Github. I think I will try to play around with the FPGA with Quartus, blinking LEDs etc and meanwhile trying (in vain) to explain to my wife why this is so fun! Later I will perhaps try to get a file with real-world data from BladeRF and process that file with python or gnuradio. Or perhaps from the beginning try to do it with gnuradio in realtime? Perhaps later trying to speed up things with VHDL-coded firmware?



This small reptile (from memory around 12 cm) 
just waited patiently to be photographed in France last year





Tuesday, July 23, 2013

Ordered BladeRF; installed Quartus and GnuRadio on a laptop with Windows 7 prof

I ordered my BladeRF last week and saw today that I was already credited on my bank account. Anyway it is reassuring that my order was noticed at nuand.com...

I downloaded Quartus and checked for support of the FPGA on the BladeRF ==> OK

Then I installed gnuradio. First I installed Python 2.7. I did run Python on an iPad before, but that was Python version 3. For gnuradio you need version 2.7, the latest relase before version 3.

I already noticed a difference between the two pythons: you cannot simply say "print a" in Python 3. You have to write "print(a)"

Quite annoying if you stumble with python for the first time.

Now I have python 2.7 running on the laptop and I must say, it works like a charm. I read the tutorial, well, I skipped a lot of the tutorial but found the differences with other programming languages I used before. Among others: FORTRAN, BASIC, Algol, C, LISP, Pascal, Prolog and lastly Java. I thought java would be the last programming language to learn. But now I understand I will use Python from now on. Still under Windows, no linux yet. I had Debian running under VMWare but it seems my license expired. I have to solve that problem later IF I _must_ use linux. I'll try to use Windows as long as possible for this project.

Reason: my wife also uses the laptop. I invested hours in convincing her to leave MSDOS for Windows. I finally succeeded so we now have one common laptop with Windows 7 prof. I don't want to put my 40 year relation on risk by trying to convince her to go for linux...

Gnuradio is a marvelous discovery! This is exactly what I needed all the time. I looks like what you can do in Simulink with MATLAB. After reading some documentation and looking a some video-tutorials I came up with my first project and it worked almost immediately. To be honest, the example from the tutorial with an oscilloscope, waterfall display and FFT generated a lot of error-messages. I have to solve that problem later. My current hello world-gnuradio-program:


Perhaps the picture is unreadable. I can send a better version if asked for it. The left sink is a noise-generator. This is followed by a filter, a throttle and finally the sink. This output-sink is the loudspeaker on my laptop. Without the filter I hear a hiss, ok, noise. With the lowpass-filter around 800 Hz the hiss sounds as you might expect, no high frequencies anymore.

I was quite satisfied with this result. My wife did not understand my satisfaction, she will never understand why I bought that BladeRF by the way.