8月 302014
 

2014 年 3 月 15 日,春季学期开学后不久的一个周六,清华大学 TUNA 协会在五教 5102 主办了硬件自由日清华站的活动。活动有超过 70 人参加。此次活动的主题为“让软件工程师硬起来”。

下午一点时分组织者和一些观众陆续到场。活动注册沿用电子注册方式,每个人在注册电脑上的 LibreOffice 表格中填写各自的信息,这个表格会转换为 csv 格式,被最后幸运抽奖的程序读取使用。本次活动启用了微博墙实时互动,现场第二块投影幕布由 scateu 提供。

活动正式开始于大约两点。开场时由我(赵涛)主持,并简单介绍硬件自由日活动的背景、缘起和此次活动的日程。之后便开始了正式的主题演讲环节。第一个演讲由造核电站出身但已转型为软件无线电爱好者的前 TUNA 会长王康 (scateu) 带来,题目为“HackRF x GNU Radio”。王康对完全自由开源的 HackRF 板卡以及开源易用的图形化开发平台 GNU Radio 进行了详细介绍,并在现场进行了 DTMF 译码、FM 调制、遥控小车控制信号回放等诸多演示,极大地激起了大家对软件无线电的兴趣。

IMG_0611

紧接着是电子系的汪彧之(bigeagle)带来的用 BeagleBoneBlack 板子搭建路由器的经验分享。他介绍了 BBB 板子的概况,之后详细地介绍了整个搭建流程,从发行版的选取到关键软件的配置。问答环节有同学问到自制路由器偶尔会无线挂掉的问题,bigeagle 解答表示他会利用看门狗(watchdog)程序监测这一问题并适时重启路由器。

IMG_0634

接下来来自计算机系的赵一开(blahgeek)对树梅派(RPi)的各种用途进行了介绍。树梅派作为廉价开源开发板的典型代表,可以被用来做许多有趣的事情。blahgeek 提到了他们用它来实现智能家居的情况。现场没能对小乌龟自动喂食做详细介绍,不过 blahgeek 在个人博客中进行过介绍

IMG_0640

活动的最后一个演讲是由清华大学业余无线电协会前任会长孙忆南带来的对业余无线电的介绍。孙忆南对业余无线电的历史、用途、在中国的发展、以及在清华的发展进行了生动而有趣的介绍。他还介绍了获得业余无线电台执照的流程,现场还展示了若干考试习题。

IMG_0645

五点左右时,活动来到了最后的幸运抽奖环节,我们使用了 bigeagle 提供了一个开源的网页版抽奖应用。活动最后大家合影留念。

IMG_0648

由于有上次自由软件日活动的经验教训,此次活动在前期宣传、现场注册、以及礼品发放上都比较顺利。此外,本次活动组织中由 bigeagle 引入了 trello 这一在线的轻量级项目管理协作工具,组织协调工作更为有序。至于存在的问题,主要就是会后大家都有许多事情要忙,本人迟迟没有把活动报告写出来。

活动演讲的讲稿链接可以在维基页面上找到。活动照片放在 Flickr 上的 TUNA 群组。反馈问卷调查结果的链接也在维基页面。

8月 102014
 

bladeRF 维基上介绍了在 Linux 系统上搭建 bladeRF 环境的步骤,不过原文是英文的,另外其中一些具体选择不尽合理。本文以 Fedora 系统为示例,提供一个中文版的 bladeRF 环境搭建指南,并着重介绍和维基上的不同点。比较可能有一定的时效性,但一些原则应该足够通用。本文的比较基准是当前的维基版本

安装依赖

维基上建议安装 “Development Tools” “Development Libraries” 两个软件包组,但我们只需要其中的一部分软件包,其中有些可能已经安装过了,而像 cvs 等并不必须。如果你像我一样有“洁癖”,不希望安装不需要的软件包,那么可以用如下的命令安装必须的依赖(未严格验证,在我这里绝大多数包都在之前安装过了):

sudo yum install git doxygen gettext glibc-devel ncurses-devel readline-devel zlib-devel boost-devel
sudo yum install libusbx libusbx-devel cmake wget gcc-c++

注意其中是 libusbx 而非 libusb,后者是 0.x 系列的版本,而非 1.x 系列。Debian/Ubuntu 系的用户会注意到软件包命名上的差异 (devel 而非 dev)。

维基上推荐安装 libtecla,以增强 bladeRF-cli 交互模式的编辑功能。不过 Fedora 软件源里目前还没有这个包,所以需要手动下载,解压缩,使用经典的 ./configure; make; sudo make install 三部曲安装。

构建 bladeRF

在终端下进入打算用来放置 bladeRF 源码的目录,用 git 将 bladeRF 的源码库克隆下来:

cd /path/to/bladeRF/directory
git clone https://github.com/Nuand/bladeRF.git

切换到源码目录中的 host 目录,创建一个 build 目录用来存放构建过程的中间文件。这种使用单独的构建目录的方式称为树外构建 (out of tree build),相对于直接在源码目录构建,好处在于生成的中间文件不会分散在源码目录里,方便清理,另外可以用多个构建目录构建出互不干扰的不同参数下的版本。之后切换到构建目录,然后就是标准的 cmake ..; make; sudo make install 三部曲了。注意这里 cmake 时启用了 INSTALL_UDEV_RULES 宏,使得安装时把 udev 规则文件也安装到系统中。

cd bladeRF/host/
mkdir build
cd build
cmake -DINSTALL_UDEV_RULES=ON ../
make
sudo make install

很遗憾的是这里安装的 udev 规则文件使用了 plugdev 群组,不是 Fedora 下的标准做法。可以参考之前的博文修改 udev 规则文件。

为了让新安装的 bladeRF 库文件可以被二进制文件使用,我们需要用 ldconfig 刷新系统动态库的缓存。上面的构建过程会将 bladeRF 安装到 /usr/local 下,而其中的库文件目录 /usr/local/lib{,64} 不在 ldconfig 的默认搜索路径里。所以我们可以将它们添加到 /etc/ld.so.conf 里。添加之后文件内容如下:

/usr/local/lib
/usr/local/lib64
include ld.so.conf.d/*.conf

之后,用 sudo ldconfig 刷新缓存即可。可以用 ldd /usr/local/bin/bladeRF-cli 命令检查 bladeRF 库文件是否被找到。连上 bladeRF 设备,用 bladeRF-cli -p 命令看下是否能够发现设备。更多操作见于另一个维基页

构建 GNU Radio 与 gr-osmosdr

通过上述步骤,就可以操作 bladeRF 板卡了。但是,要想便捷地为 bladeRF 开发软件无线电应用,最好再构建一下 GNU Radio 和 gr-osmosdr。GNU Radio 是一个开源的软件无线电开发平台,提供众多的信号处理模块和简单易用的图形界面开发环境。gr-osmosdr 适配 GNU Radio,为众多硬件板卡(除了 bladeRF 之外还有 HackRF 等)提供一个统一的软件接口。

GNU Radio 依赖比较多,编译安装相对麻烦,一般推荐使用 build-gnuradio 脚本。但是因为其中涉及到从网络下载诸多软件以及编译安装,效率受网速和电脑硬件性能限制,耗时较长。另外,脚本的健壮性不高,所以很容易中途退出。这个脚本很长,但实际上是把整个构建过程划分为几个步骤,放在几个函数里先后执行的。我建议阅读这个 Shell 脚本,每次运行其中的一步或几步,必要时手动完成一些配置。对于新手,这会是一个很好的通过阅读代码学习 Shell 编程的机会。

具体的构建步骤可以在维基或这里找到,这里就不再赘述。只是提几点注意事项:

  • 如果你像我一样,除了 bladeRF 之外,还会使用 Ettus 公司的 USRP 系列设备,那么记得先构建 UHD,然后构建 GNU Radio。
  • build-gnuradio 脚本在 cmake 时,有时用了树外构建,但有时又没用。建议始终用树外构建。
  • 编译 GNU Radio 时,并行 make (make -j N 其中 N 大于 1)时有时会编译失败(竞态条件?),直接 make 就可以正常编译通过,虽然速度会慢很多。什么?make 也会出错?那考虑换一个 git 提交重新编译,并向上游报 BUG 吧。

构建成功 GNU Radio 后,构建 gr-osmosdr 就显得小菜一碟了,标准的 cmake 构建三部曲,项目不大,编译过程也能很快完成。

全部构建完成后,可以使用如下命令用 bladeRF 看一下频谱,检验是否大功告成。其中 FPGA 映像可以从 Nuand 网站下载。此外,最新固件也可以从官网下载。

osmocom_fft -a bladerf=0,fpga=<your FPGA image> -s 2000000 -f 446000000

致谢

本工作由星天科技赞助。

4月 202014
 

Fedora Activity Day (FAD) China 2014 was successfully held at Park Plaza of Beijing Science Park, Beijing on Mar 30 (Sunday). It was organized by Fedora Zhongwen User Group with the help of CSDN. It was under the umbrella of Open Source Technology Conference (OSTC) 2014 initiated by CSDN, being one of three parallel sessions in the afternoon. There were around 600 attendees in total, and about 200 in the FAD session.

I arrived at the venue in the morning with more than 100 Live DVDs and 500 stickers. We distributed them during the Red Hat booth as well as the afternoon session. In the morning there were several keynote speeches and one panel discussion. More details can be found in the CSDN news report.

The afternoon session began at 1:30 pm. Thomas Yao and I served as the hosts of FAD. The first talk was “About Those Python Asynchronous Concurrency Frameworks” by Fantix King, CTO at FlowForge Games, Archlinux x32 committer, and Python programmer. He introduced the concept of concurrency, compared Tornado, Twisted, and Gevent, and then introduced asyncio, the newly available framework in Python 3.4.0.

Python Concurrency Frameworks by Fantix King

Python Concurrency Frameworks by Fantix King

The second talk was “Use Linux Command Line as a Hacker” by Xiaodong Xu (Toy), the webmaster of LinuxToy. He shared a lot of command line tips to fix typos, manipulate shell history, and speed up operations. In the QA session he talked about his opinion on text editor choice and Linux distro choice.

Toy

Toy

The next talk was “Reform the Toolbox: From Open Source Software to Open Source Service” by Daobing Li, the chief architect of Qiniu, who is also a Debian developer. He talked about the achievements of open source cloud service, and shared his vision of future cloud service – cloud in computer room. He also gave suggestions on how developers treat cloud services.

Daobing Li

Daobing Li

Following the talk was “Introduction to HackRF & GNURadio” by Scateu Wang, the creator of hackrf.net and the former leader of TUNA. He demonstrated the ease of using GNU Radio to develop software defined radio applications for DTMF decoding, FM modulation and demodulation, digital audio broadcasting, etc. He also introduced HackRF, the newly created inexpensive hardware peripheral used with GNU Radio.

Scateu Wang

Scateu Wang

The next talk was “Fedora Ambassadors & FUDCon” by myself. I introduced the four foundations of Fedora Project, gave an overview of Fedora Ambassadors project, showed what ambassadors do and how reimbursement works, and then shared the recent progress of organizing FUDCon APAC 2014 to be held in May and welcomed everyone to join.

Alick

Alick

Next Emily Chen, GNOME.Asia founder, senior software engineer in Oracle, gave the talk “Bringing More Women to Free and Open Source Software”. She introduced the Outreach Program for Women initiated by GNOME, talked about how it increases the women participation in open source projects. The annual program provides prize for women participants in similar way with GSoC, but it does not require the applicants to be students, and applicants does not need to write code in the program.

Emily Chen

Emily Chen

The following talk was “Operation and Management of SHLUG” by Thomas Yao, leader of Shanghai Linux User Group (SHLUG), founder of GitCafe.com. Thomas gave an impressive speech without any slides. He talked about the history of SHLUG and shared the experience. He pointed out the pioneering effort of building the first open source mirror site in China, Geekbone, and the importance of keeping the community focus on technique rather than commercial activities. He also shared the interesting stories of Hacking Thursday and Rails Girls.

Thomas Yao

Thomas Yao

After that is the panel discussion on “History and Future of Open Source OS in China”. It was moderated by Thomas Yao, and the panelists are Weijia He from Redflag College of Education, Jianzhong Huang from Redflag R&D, Jack Yu from UbuntuKylin, and Yong Wang from Linux Deepin. They shared their opinions and experiences about Linux Desktop, collaboration of distros, cultivation of open source talents, and open source in education.

Panel Discussion

Panel Discussion

At last, Martin, leader of Beijing Linux User Group (BLUG) gave a lightining speech of introducing BLUG and its activities. Everyone is welcomed and should not worry about their English since there are actually many Chinese there. And it is quite easy to join the event by registering on BLUG website or joining discussion in mailing list.

At night there is the Open Source Night, a social event for free face-to-face discussions. Unfortunately I didn’t attend it. I had dinner with FUDCon and GNOME.Asia organizers and discussed current progress and following tasks.

Overall it is a very good event in my mind. If I have to point out some issues, I’d say there might be too many talks and no time for tea or coffee in between! Besides, my own talk was prepared in a bit hurry, and not practised well beforehand.

The slides links is available on CSDN news. They also provide a Chinese report for FAD. There is a great minute for the meeting by Bojie Li from USTC LUG. The videos and various other materials can be found at this link.