Rasberry Pi 2 + Minibian + Gnuradio + GR-Osmosdr GNURadio block + Hackrf

Just self reminder for me to get some SDR stuffs onto minibian. The focus is to get stuffs to work in CLI so I can convinient ssh to it and record stuffs on interesting freq when having it in my backpack and analyse it later (for this you will only need apt-get install hackrf and use hackrf_transfer) or potentially open garage doors or run some funky gnuradio text-base scripts. Nothing special. This is not a minimalistic build as I'm using apt-get for most of the stuffs, no special compile from source and configure --disable-bullshits.

So the end goal is getting these stuffs install: hackrf toolkit, gr-osmosdr (which integrate hackrf with gnuradio) and gnuradio itself.

Minibian!

Download minibian and tar -zxvf 2016-03-12-jessie-minibian.tar.gz to a folder.

Insert my SD card and run mount to check what is the partition being mounted for my SD card (/dev/disk3s1) and umount it using diskutil. (umount maynot work.. it's MAC thingo).

┌────[santrancisco@sans-MacBook-Pro]
└───>[/Users/santrancisco] $ mount
/dev/disk1 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)  
map -hosts on /net (autofs, nosuid, automounted, nobrowse)  
map auto_home on /home (autofs, automounted, nobrowse)  
/dev/disk2s9 on /Volumes/Pentest (hfs, local, nodev, nosuid, journaled, noowners, mounted by santrancisco)
/dev/disk3s1 on /Volumes/EOS_DIGITAL (msdos, local, nodev, nosuid, noowners)
┌────[santrancisco@sans-MacBook-Pro]
└───>[/Users/santrancisco/Documents/share/workspace/rasberryPi] $ sudo diskutil unmount /dev/disk3s1

Now, let's dd it with the minibian image we downloaded.

┌────[santrancisco@sans-MacBook-Pro]
└───>[/Users/santrancisco/Documents/share/workspace/rasberryPi] $ sudo dd bs=1m if=2016-03-12-jessie-minibian.img of=/dev/rdisk3                                                                          
794+0 records in  
794+0 records out  
832569344 bytes transferred in 78.871389 secs (10556038 bytes/sec)  

Cool beans! Let's insert it to our rasberrypi and fire it up!

Before we are doing anything, let's resize the 2nd partition to have more space for our shitz.

You can use fdisk on live partition like i did below. Note that when you create the new partition, MAKE SURE your starting sector is the same as the previous one (mine was 125056)

Command (m for help): p  
Disk /dev/mmcblk0: 14.9 GiB, 15931539456 bytes, 31116288 sectors  
Units: sectors of 1 * 512 = 512 bytes  
Sector size (logical/physical): 512 bytes / 512 bytes  
I/O size (minimum/optimal): 512 bytes / 512 bytes  
Disklabel type: dos  
Disk identifier: 0x00000000

Device         Boot  Start     End Sectors  Size Id Type  
/dev/mmcblk0p1          16  125055  125040 61.1M  b W95 FAT32
/dev/mmcblk0p2      125056 1626111 1501056  733M 83 Linux


Command (m for help): d  
Partition number (1,2, default 2): 2

Partition 2 has been deleted.

Command (m for help): p  
Disk /dev/mmcblk0: 14.9 GiB, 15931539456 bytes, 31116288 sectors  
Units: sectors of 1 * 512 = 512 bytes  
Sector size (logical/physical): 512 bytes / 512 bytes  
I/O size (minimum/optimal): 512 bytes / 512 bytes  
Disklabel type: dos  
Disk identifier: 0x00000000

Device         Boot Start    End Sectors  Size Id Type  
/dev/mmcblk0p1         16 125055  125040 61.1M  b W95 FAT32


Command (m for help): n  
Partition type  
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p  
Partition number (2-4, default 2): 2  
First sector (125056-31116287, default 126976): 125056  
Last sector, +sectors or +size{K,M,G,T,P} (125056-31116287, default 31116287): +8G

Created a new partition 2 of type 'Linux' and of size 8 GiB.

After writting the change and reboot for it to take affect, you may notice df -h still gives you the old size of the partition. In this case, you will need to execute resize2fs /dev/mmcblk0p2 to expand it out to 8gb.

From man resize2fs:

The  resize2fs program does not manipulate the size of partitions.  If you wish to enlarge a filesystem, you must make sure you can expand the size of the underlying partition first.  This can be done using fdisk(8) by deleting the partition and recreating it with a larger size or using lvextend(8), if you're  using  the  logical volume  manager lvm(8).  

Install shitz!

Now we need git, g++, libboost, gnuradio, cmake and hackrf toolkit so this will take a while to download and install :) Well this will probably install GUI and shitz but that's not what i'm interested in, really.

apt-get update; apt-get install g++ cmake git  
apt-get install libboost-all-dev  
apt-get install gnuradio gnuradio-dev  
apt-get install liblog4cpp5-dev  
apt-get install hackrf libhackrf-dev  

Because the version for gnuradio in repository is a little old (3.7.5), and the latest update seems to only relevant to bladrf, I checked out 1 revision back and was able to compile gr-osmosdr with no problem.

git clone git://git.osmocom.org/gr-osmosdr  
git checkout d230397957603a026c688dd462d349f8dcb645c8  
mkdir build  
cd build  
cmake ..  
make  
make install  
ldconfig  

For now, let's record 96.9 channel and see if it works.

root@minibian:~/hackrf# hackrf_transfer -s 4 -f 96900000  -r test.bin  
call hackrf_sample_rate_set(4 Hz/0.000 MHz)  
call hackrf_baseband_filter_bandwidth_set(1750000 Hz/1.750 MHz)  
call hackrf_set_freq(96900000 Hz/96.900 MHz)  
Stop with Ctrl-C  
 3.1 MiB / 1.001 sec =  3.1 MiB/second
 2.9 MiB / 1.001 sec =  2.9 MiB/second
 3.1 MiB / 1.001 sec =  3.1 MiB/second
 0.5 MiB / 0.106 sec =  5.0 MiB/second

Wow.. for ~8s the size of the file was 21mb. I will need to expand my sdcard soon. This is enough to go into bars, have a beer and replay the electronic coasters signal for laugh though.

More test will need to be done later.

References
http://sdr.osmocom.org/trac/wiki/GrOsmoSDR
https://www.raspberrypi.org/documentation/installation/installing-images/mac.md
https://minibianpi.wordpress.com/category/release/

comments powered by Disqus