ZYNQ MPSOC 软件无线电开发[软件部分(4)] - 配置rootfs、安装GNU Radio和x11转发
ZYNQ MPSOC 软件无线电开发[软件部分(3)] - 生成Petalinux SDK并在主机进行交叉编译、ADDA demo测试
ZYNQ MPSOC 软件无线电开发[软件部分(2)] - 在Petalinux工程中添加驱动程序与自启动脚本
ZYNQ MPSOC 软件无线电开发[软件部分(1)] - 导出Vivado硬件设计并构建基本的Petalinux工程
现在对adda的适配和测试已经完成。下一步将配置rootfs和gnuradio。
板载的linux和在计算机上运行的linux没有什么本质差异,仅仅是平台的不同。gnuradio的调试需要使用图形界面,因此至少需要在板子上实现x11和qt。如果使用板载的视频口,还需要另外配置matchbox一类的桌面环境。对于板载开发,可选的配置还有在板子上配置编译链、远程gdb,等等。
1. 配置rootfs
在petalinux工程目录执行
petalinux-config -c rootfs
进入Petalinux Package Groups,以packagegroup-petalinux为例:
当我们不知道这个package group的内容时,方向键选择help可以查看包的帮助:
它会告诉你选中这个包将会安装下列的程序到你的rootfs中:
Petalinux Package Groups中是打包好的一系列程序,选中这个包其实和你自己在主菜单的Filesystem Package里选中这一些程序的效果是一样的。
一般来说,为了保证gnuradio正常启动、编译自建模块,你至少需要安装下列项:
其他配置内容就看自己的需求,我启用的package包括:
对于packagegroup-petalinux-qt:
另外包括:
Filesystem Packages -> misc -> gdb -> gdbserver
Filesystem Packages -> libs -> libmali-xlnx
如果感觉包太多不好找,可以按下/
键,会调出搜索功能。
配置完成后save、exit,编译并更新到板上。
petalinux-build
petalinux-package --boot --u-boot --fpga --fsbl --force
sudo cp ./images/linux/boot.scr /media/xlnxdev-2020-1/BOOT/
sudo cp ./images/linux/BOOT.BIN /media/xlnxdev-2020-1/BOOT/
sudo cp ./images/linux/image.ub /media/xlnxdev-2020-1/BOOT/
sudo rm -rf /media/xlnxdev-2020-1/root/*
sudo tar -zxvf ./images/linux/rootfs.tar.gz -C /media/xlnxdev-2020-1/root/
sudo sync
2. 安装GnuRadio
从这里开始,主机和开发板将会频繁地交换文件,建议在开发板和主机之间连接网线并使用nfs传输文件,而且ssh也需要连接网线才能工作。
对于我的nfs挂载命令:
mkdir /media/nfs
mount -t nfs 192.168.50.2:/home/xlnxdev-2020-1/peta_prj /media/nfs
nfs的相关命令内容请参考其他blog。
下面我们将在开发板上安装gnuradio。
InstallingGR -GNU Radio
这一部分应该是我们所使用的安装方法,在开发板上直接安装RadioConda,省时省力且不需要编译。
Installation using radioconda (recommended) - CondaInstall - GNU Radio
此后,我们只需要配置bash让conda环境自动加载,即可完成gnuradio的运行、开发环境。
下载radioconda:
Github Release - ryanvolz/radioconda
选择Linux aarch64
下载完成后,拷贝到开发板的~/
目录下。如果你的网络环境可以访问github且rootfs配置了wget(默认应该是有的),也可以直接在开发板上下载。
安装radioconda。
cp /media/nfs/nfswork/radioconda-2024.01.26-Linux-aarch64.sh ~
cd ~
chmod +x ./radioconda*.sh
./radioconda*.sh
运行后会问你是否接受条款,选择yes,之后是安装目录,我选择安装到/opt/conda下:
Welcome to radioconda 2024.01.26
In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>
Radioconda installer code uses BSD-3-Clause license as stated below.
Binary packages that come with radioconda have their own licensing terms
and by installing radioconda you agree to the licensing terms of individual
packages as well. These additional licenses can be found in the
pkgs/<pkg-name>/info/licenses folder of your radioconda installation.
=============================================================================
Copyright (c) 2021, Ryan Volz
All rights reserved.
......
Do you accept the license terms? [yes|no]
>>> yes
radioconda will now be installed into this location:
/home/root/radioconda
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/home/root/radioconda] >>> /opt/conda
PREFIX=/opt/conda
最后结束时,conda会询问你要不要将启动信息写入.bashrc
,这里输入yes
Do you wish to update your shell profile to automatically initialize conda?
This will activate conda on startup and change the command prompt when activated.
If you'd prefer that conda's base environment not be activated on startup,
run the following command when conda is activated:
conda config --set auto_activate_base false
You can undo this by running `conda init --reverse $SHELL`? [yes|no]
[yes] >>> yes
现在conda的启动信息已经写到~/.bashrc
里面了,但是并不能自动加载,有下面两个原因:
1.默认终端为sh,当前终端可以使用echo $0
查看:
echo $0
-sh
将其切换到bash:
usermod --shell /bin/bash root
2.缺少.profile
用户登录时会自动执行~/.profile
里的内容,一般来说~/.bashrc
是由其加载的,在~/
目录下建立~/.profile
:
vim ~/.profile
写入以下内容:
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
现在可以重启试一下了。
reboot
登录后可以看到终端的提示长这个样子,前面多了个(base)
:
说明conda已经启动了。
3. x11转发、远程运行gnuradio
x11转发只需要修改/etc/ssh/ssh_config:
vim /etc/ssh/ssh_config
确保一下几行存在且没有被注释:
Host *
ForwardAgent yes
ForwardX11 yes
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes
保存退出并重启。
reboot
现在,在主机上通过ssh连接到开发板,-X
代表启用X11转发:
ssh -X root@192.168.50.40
开发板的ip地址可以通过ifconfig获得:
如果正常连接会有以下输出:
root@192.168.50.40's password:
xauth: file /home/root/.Xauthority does not exist
(base) root@petalinux:~#
如果你遇到了这种情况:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
SHA256:BXaACxX2MbMHbK4fqUlF4MEp3ZuMPMQSm1mG6xpJGX0.
Please contact your system administrator.
说明你以前连接过这个ip地址,RSA密钥记录的是那台设备的,清除一下就好了:
ssh-keygen-R 192.168.50.40
测试grc的图形界面:
gnuradio-companion
在这里启动的gnuradio就是远端的。