Ubuntu 20.04でのPybombsによるGNU Radio 3.9.2.0のビルド

2021/09/10 9:42 PM

この記事での手順に引き続いて,Ubuntu 20.04においてPybombsによるGNU Radio 3.9.2.0のビルドを行った.独自拡張を行ったGRCのブロックを卒業研究などで扱っているため,Pybombsを用いてソースからビルドした状態でGNU Radioを利用したい,という事情がある.前提条件は,下記の通り.

  • 先の記事の手順により,PybombsはUbuntuマシンにインストールずみ
  • 先の記事で GNU Radio 3.8.3.1をインストールしたユーザとは異なるユーザのホームディレクトリ以下にGNU Radio 3.9.2.0をインストールする
  • GNU Radio 3.9.2.0をインストールするユーザ名はUSRP,インストール先は ~/gr39 (/home/usrp/gr39)とする

まず,下記のWebページに目を通した.

https://wiki.gnuradio.org/index.php/InstallingGR

https://wiki.gnuradio.org/index.php/GNU_Radio_3.9_OOT_Module_Porting_Guide#Pybind11_Python_Bindings

https://github.com/gnuradio/pybombs

後は,以下の手順を実行していく.

$ sudo apt-get install -y python3-pygccxml
$ sudo apt install pybind11-dev
$ rm -rf .pybombs gr39      (以前に試行錯誤したビルド記録を消す)
$ mkdir gr39

現在ではVOLK(Vector-Optimized Library of Kernels)は GNU Radioに必須だそうだ.GNU Radio 3.9をフルスクラッチでソースからビルドする際には,まずVOLKをインストールせよ,と取れる表現をドキュメントで見かけたので,Pybombsでもビルドを指定する.

$ pybombs recipes add gr-volk git+https://github.com/gnuradio/volk.git    を入力する
[INFO] Prefix Python version is: 3.8.10
[INFO] PyBOMBS Version 2.3.4
Cloning into 'gr-volk'...
remote: Enumerating objects: 9821, done.
remote: Counting objects: 100% (220/220), done.
remote: Compressing objects: 100% (108/108), done.
remote: Total 9821 (delta 108), reused 198 (delta 99), pack-reused 9601
Receiving objects: 100% (9821/9821), 2.81 MiB | 23.43 MiB/s, done.
Resolving deltas: 100% (6697/6697), done.

同様に,GNU Radioのビルドを指定する.

$ pybombs recipes add gr-recipes git+https://github.com/gnuradio/gr-recipes.git    を入力する
[INFO] Prefix Python version is: 3.8.10
[INFO] PyBOMBS Version 2.3.4
Cloning into 'gr-recipes'...
remote: Enumerating objects: 1924, done.
remote: Counting objects: 100% (92/92), done.
remote: Compressing objects: 100% (64/64), done.
remote: Total 1924 (delta 59), reused 47 (delta 28), pack-reused 1832
Receiving objects: 100% (1924/1924), 388.88 KiB | 9.97 MiB/s, done.
Resolving deltas: 100% (1549/1549), done.
$ pybombs recipes add gr-etcetera git+https://github.com/gnuradio/gr-etcetera.git    を入力する
[INFO] Prefix Python version is: 3.8.10
[INFO] PyBOMBS Version 2.3.4
Cloning into 'gr-etcetera'...
remote: Enumerating objects: 593, done.
remote: Counting objects: 100% (114/114), done.
remote: Compressing objects: 100% (91/91), done.
remote: Total 593 (delta 68), reused 43 (delta 23), pack-reused 479

次に,gitrev を v3.9.2.0 にセットする.

$ pybombs config --package gnuradio gitrev v3.9.2.0    を入力する
[INFO] Prefix Python version is: 3.8.10
[INFO] PyBOMBS Version 2.3.4
[INFO] Using config file: /home/usrp/.pybombs/config.yml
Setting keys for packages gnuradio:
gitrev: v3.9.2.0

いよいよビルドに取り掛かる.古いマシンにUbuntu20.04を新規にインストールしてテストしているので,気長に待つ.

$ pybombs prefix init /home/usrp/gr39 -a myprefix -R gnuradio-default    を入力する
[INFO] Prefix Python version is: 3.8.10
[INFO] PyBOMBS Version 2.3.4
[INFO] Prefix Python version is: 3.8.10
[INFO] Creating new config file /home/usrp/gr39/.pybombs/config.yml
[INFO] Prefix Python version is: 3.8.10
[INFO] Installing default packages for prefix...
[INFO] 
  - gnuradio
[INFO] Phase 1: Creating install tree and installing binary packages:
Install tree:
|
\- gnuradio
   |
   +- uhd
   |
   \- libvolk
[INFO] Phase 1 complete: All binary dependencies installed.
[INFO] Phase 2: Recursively installing source packages to prefix:
[INFO] Installing package: libvolk
Cloning into 'libvolk'...
remote: Enumerating objects: 9821, done.
remote: Counting objects: 100% (220/220), done.
remote: Compressing objects: 100% (108/108), done.
remote: Total 9821 (delta 108), reused 198 (delta 99), pack-reused 9601
Receiving objects: 100% (9821/9821), 2.81 MiB | 11.29 MiB/s, done.
Resolving deltas: 100% (6698/6698), done.
Submodule 'cpu_features' (https://github.com/google/cpu_features.git) registered for path 'cpu_features'
Cloning into '/home/usrp/gr39/src/libvolk/cpu_features'...
remote: Enumerating objects: 1303, done.        
remote: Counting objects: 100% (240/240), done.        
remote: Compressing objects: 100% (135/135), done.        
remote: Total 1303 (delta 134), reused 167 (delta 95), pack-reused 1063        
Receiving objects: 100% (1303/1303), 420.35 KiB | 755.00 KiB/s, done.
Resolving deltas: 100% (847/847), done.
Submodule path 'cpu_features': checked out 'a8397ba4591237c17d18e4acc091f5f3ebe7391e'
Configuring: (100%) [==============================================================================================]
Building:    (100%) [==============================================================================================]
Installing:  (100%) [==============================================================================================]
[INFO] Installation successful.
[INFO] Installing package: uhd
Cloning into 'uhd'...
remote: Enumerating objects: 105363, done.
remote: Counting objects: 100% (5860/5860), done.
remote: Compressing objects: 100% (1942/1942), done.
remote: Total 105363 (delta 3961), reused 5725 (delta 3869), pack-reused 99503
Receiving objects: 100% (105363/105363), 133.02 MiB | 22.87 MiB/s, done.
Resolving deltas: 100% (81260/81260), done.
Configuring: (100%) [==============================================================================================]
Building:    (100%) [==============================================================================================]
Installing:  (100%) [==============================================================================================]
[INFO] Installation successful.
[INFO] Installing package: gnuradio
Cloning into 'gnuradio'...
remote: Enumerating objects: 175277, done.
remote: Counting objects: 100% (221/221), done.
remote: Compressing objects: 100% (117/117), done.
remote: Total 175277 (delta 119), reused 166 (delta 104), pack-reused 175056
Receiving objects: 100% (175277/175277), 59.91 MiB | 8.25 MiB/s, done.
Resolving deltas: 100% (136711/136711), done.
Submodule 'volk' (https://github.com/gnuradio/volk.git) registered for path 'volk'
Cloning into '/home/usrp/gr39/src/gnuradio/volk'...
remote: Enumerating objects: 9821, done.        
remote: Counting objects: 100% (220/220), done.        
remote: Compressing objects: 100% (108/108), done.        
remote: Total 9821 (delta 108), reused 198 (delta 99), pack-reused 9601        
Receiving objects: 100% (9821/9821), 2.81 MiB | 5.54 MiB/s, done.
Resolving deltas: 100% (6698/6698), done.
Submodule path 'volk': checked out '1299d72c396a88fd2679adfd7a919ac00d2cf678'
warning: unable to rmdir 'volk': ディレクトリは空ではありません
Note: switching to 'v3.9.2.0'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at c98adfbdb v3.9.2.0
Configuring: (100%) [==============================================================================================]
Building:    (100%) [==============================================================================================]
Installing:  (100%) [==============================================================================================]
[INFO] Installation successful.
[INFO] Phase 2 complete: All source packages installed.                  

ビルドが完了した.パスを通して試しにGNU Radio Companion(GRC)を起動してみる.

$ source ~/gr39/setup_env.sh
$ gnuradio-companion

以下のようにGRCが無事起動した.以上のビルド手順が正しいか,やや不安もある.動作確認はこれから.

先の記事と併せ,一台のUbuntu20.04マシンで,あるユーザでログインしたときには GNU Radio 3.8.xを使用し,別のユーザでログインした際には GNU Radio 3.9.x を使用する,というように異なるバージョンのGNU Radioを共存させられるので,テスト環境を作る際に便利だ.

Pybombsによるビルド・インストールでは,/usr/localのようなシステム領域にGNU Radioをインストールせず,ユーザのホームディレクトリ以下にインストールすることが一般的である.このため,パスの切り替えだけで同一のユーザで GNU Radio 3.8.x と3.9.xとを共存することもできるのだが,個別の設定などが生じることもありうるので,「ログインするユーザによって切り替え」という方法は,わかりやすくて良い.