十一 262014

Over one week ago, I attended FAD Phnom Penh 2014 in Cambodia. This Fedora Activitiy Day event was for APAC ambassadors to discuss budget planning, event planning, swag production and so on. Below is my full report of the two-day event.

Day 0 (2014-11-14): Arrival Day

I left Beijing in the afternoon and saw the beautiful sunset on the plane. My flight have an intermediate stop at Guangzhou, and we had to get off the plane their, accepted the custom check, and then went back to the same plane. I arrived at Phnom Penh International Airport at midnight. Although we filled the arrival card on the plane, we later found that we need to fill another health form (for Ebola) before getting the visa on arrival. With the help of Somvannda, I saw the Tuk Tuk driver easily when I came out of the airport, who was holding a nice sign with Fedora logo and my name. It took about half an hour from the airport to the Passion Guesthouse. I must say it was really cool to ride on a Tuk Tuk at midnight in Phnom Penh not only because the temperature was not high, but also because it made me exciting to be in a Tuk Tuk on the flyover! With banners in Chinese catching my eyes from time to time, I find Cambodia is somewhat familiar even though this is my first time to be there.

It was quite late when I arrived at the guesthouse, and I was very surprised to see Somvannda, Tuan, Siddhesh, Danishka still awake. It was so sweet of them to wait for me till the late night.

Day 1 (2014-11-15): Events and Budget

On Saturday morning I met Nisa, Izhar, and Sirko (gnokii), and we began our two-day meeting. We used the #fedora-fad IRC channel to involve remote participants. We also set up a pad on PiratePad, where I was responsible for taking important notes.

The meeting started with Sirko’s notes. He is from Germany, and he was there to help the first ambassador FAD in APAC. He pointed out the major problems with APAC communities in his mind, and offered his suggestions. He emphasized the importance of setting deadlines and installing rules. Then each of us introduced the situation in each country respectively. It seems the common problem is to attract new contributors. There are various reasons for that, such as pirating and unawareness of license, competition from other distributions, and shift of interests to cloud and apps. I think to tackle the problem, we need continuous education and promotion, and in particular we need to stress our core values and main characteristics.

Then we spent the remaining day discussing the events and allocating budget in the next fiscal year. As we can see from the wiki page, there are many events planned in the APAC region, and it is nearly impossible to ensure Fedora presence in every event. Therefore, there were a lot of debates about budget allocation when we went through the long list of events. Sometimes the discussion went off topic but we managed to bring the topic back. After we finished the budget planning, we summed them up and found a big total amount. So it is still necessary to assign different priorities for the events in case of budget cut down. It will be one main job after FAD.

According to the current budget allocation, we will promote Fedora in release parties, SFD, DFD, HFD, Linux Day as usual. We also want to have more not-so-big meetups which are for Fedora contributors and users but not tightly related to the release. Besides, we would like make Barcamp Phnom Penh and COSCUP places where ambassadors in the whole APAC region can meet and discuss.


We were quite tired after the whole day’s meeting, but we got refreshed by the local seafood at Kuch Angkor Restaurant. A friend of Tuan in Cambodia joined the dinner. We talked about a lot of things and enjoyed the Angkor beer very much.

Day 2 (2014-11-16): Other Stuff

The remaining topics were discussed on the second day. We first briefly talked about FAD and FUDCon. One current issue with FUDCon APAC is that the planning phase is too short since decision is made in January and the event happens in May. Sirko suggested that the decision should be made earlier, maybe announced right at the previous FUDCon. This way it is better advertisement and long planning period. We cannot make it work this way for FUDCon APAC 2015 though, which means possible hosts should bid for the next year’s event as soon as possible.

The main topic was swag production actually. We generally agreed that it is better to have central massive production to reduce the cost, and it is good to produce some swags with EMEA. But there are so many counties in APAC and different regulations about shipping. So first we need to collect the cost of production and shipping in each (active) country, and we set the deadline to be January 1st. We also discussed materials (such as banners) tracking and set the same deadline to work out the inventory of materials in APAC.


With APAC credit card holder Izhar on site, we went on to discuss the payapl transaction fee issue. It is a pain that currently ambassdors have to lost some money when getting reimbursed due to transaction fee charged by paypal. Several workarounds were proposed, and hopefully we can make real progress and no longer have this issue in the near future.

Last but not least, we distributed the ambassador Polo shirts. Thanks to the Cambodian team, we finally have Polo shirts for APAC ambassadors. It is really good for identification in offline events, especially those not limited to Fedora. I took along the Polo shirts for Chinese ambassadors who registered on the wiki page, and will distribute them to each owner soon. Those who have not registered on the wiki page, please request your Polo shirt by creating a ticket on the fedora-apac trac.


The last night in Phnom Penh was full of memory. We had two (!) dinners, walked along the river, visited the night market, saw famous sight spots when riding on the Tuk Tuk, and discussed even when we got back to the guesthouse. I wish I could stay longer, but to catch my flight, I left in the beautiful morning of Monday.

I have a busy schedule recently, and now over one week has passed since the FAD. I see it was a really great start for APAC ambassadors to get together, meet face to face, and fulfil important tasks. I look forward to more chances to involve more ambassadors in the region to work together. In this way we can make bigger differences as a whole.


今年 1 月份寒假期间,我借着寒假实践的机会去了一趟河南洛阳。虽然河南是我的家乡,但这是我第一次在河南省内旅行。洛阳得名于洛河之阳,是历史文化名城,东汉、西晋、北魏等朝代先后在这里建都,共有十三朝之多。洛阳牡丹甲天下,不过我们去的时节不对,但是我们还是有幸游览了龙门石窟、白马寺等,品尝了当地的小吃。

22 号晚上,我们组团去洛阳有名的小吃街。小吃街应该是在老城,途中会经过一个城门叫丽景门。小吃街上高高挂起的红灯笼绵延整个街道,很是好看。街上的小摊鳞次栉比,颇为热闹。不过在通信发达的今天,各地的小吃街上的小吃都大同小异,所以具体到吃上没有发现特别有趣的东西。小吃借逛完后,我们觉得不过瘾,于是又去了附近一家颇为有名的餐馆,点了一些风味菜品。路上我们问路,当地人热情地给我们讲路线,但貌似只有我听懂了。说到洛阳名吃,水席不得不提,汤汤水水特别多(这和我家挺不同),都会放不少胡椒(这倒和我家那边类似)。


24 号上午我们去了白马寺。我们住在地方在市中心区域,到白马寺有公交直达。白马寺是佛教寺院,白马指的是当年(东汉)驮经的白马。因为是冬季而且临近春节,所以寺里人烟稀少,可以随意地拍照,我们在寺里找到了可以骑上去的石马。寺内还有一个狄仁杰墓。在寺西侧,新建的东南亚风格佛教建筑大体已经完工,只是还没有正式开放。




25 号是返程日期,小伙伴们陆续踏上了归途,不过我感觉离家较近,不着急走,所以上午我又去参观了洛阳博物馆。由于道路翻修施工,手机地图上查的公交线路停运了,所以去程比较坑,主要就靠步行,很晚才到博物馆。博物馆很新,很大,而我在博物馆里一般脚步很慢,最后一直逛到中午一点。




Last week, I was very honored to get sponsored to participate the Hanoi SFD 2014. I joined the Fedora meetup on Friday and gave a talk on Saturday. Below is the full report.

Day 0 (2014-09-18): Arrival Day

I left Beijing early in the morning and in the afternoon stayed in Hong Kong Airport to transfer. The flight to Hanoi was a bit late, and I arrived at the Hanoi Airport at around 8:00 PM (local time, 9:00 PM in Beijing time). The weather was wet and hot, but the people are nice. It took me some time to find a large shuttle bus, rather than the minibus. On the bus I met a Japanese guy, and it turned out he lived in a hotel not far from mine. So after getting off the bus, we walked to our hotels together most of the way.

It was about 10:00 PM when I arrived at the hotel. I shared a room with Sarup (banas), and he told me they (Thang, Somvannda, Tuan and others) would like to have me together go out for beer. I was a bit tired after the long trip, but after ten minutes’ rest, I joined them. Thang carried me on his motorbike to a street corner nearby, and I met Tuan (for the first time) and Somvannda (for the second time). I was surprised to find many people are there on the street at first. But I soon realized having cool beer outside is the best way to pass the hot night. By cool I mean not only temperature (ice beer), but also the taste (nice beer).

Day 1 (2014-09-19): Fedora Meetup

On Friday morning we went to the VAIP office and had a Fedora APAC ambassador meetup the whole day. The meetup was set up for APAC ambassadors to discuss critical tasks. EMEA has had a lot of similar meetups, but for APAC, it was the first to my knowledge. (It was at least the first in this year.) To include remote participants who cannot make it at Hanoi, we also joined the #fedora-apac IRC channel. There we met gnokii, kushal, FranciscoD, etc. We also set up a pad on PiratePad.

In the morning, we discussed many issues including the budget status, current issues and so on. It seems the major issue is that not many APAC ambassadors are active, and people do not regularly attend meetings. In China, the state is somewhat better: we do have a few active contributors and we managed to have regular IRC meetings and offline activities (release parties every release, yearly FAD, and FUDCon Beijing). In India there is another problem: there might be too many ambassadors and some people tend to use Fedora as a travel agency. We agreed that people need actively participate biweekly meetings and mailing list discussions to get their tickets approved easily, and to be considered as active, one ambassador needs to organize (or help organize) at least one event per year.

We also talked about the FAD Phnom Penh under planning and the ambassador Polo shirts. The FAD planning is generally in good shape. I saw no Taiwan ambassador registered the event but I think they should consider. Regarding the Polo shirts, unfortunately the Fedora logo on the sample shirt is incorrect and needs to be fixed. And the quality of the shirt is not quite high. I am supposed to ask local vendors in China to see if we can get better ones within a reasonable price. We went on to discuss general swag production issues. gnokii suggested that good quality can be produced in Europe for both EMEA and APAC regions. Besides, China can be one good candidate among the locations to store the swag.

I also learned from Tuan about why we APAC folks lose some money when getting reimbursed by paypal while Americans not. The reason is that US paypal accounts have the option to cover the transaction fee by the sender, while other accounts do not. So the fee is charged at the receiver side, causing the loss. To walk around the issue, we might let APAC CC holder izhar set up a US paypal account.

In the afternoon, after a short pizza lunch, we carried on remaining tasks. We spent quite some time in summarizing the budget usage in previous quarters. It was sad to find that none of the planned events in Q2 happened at last. To solve the budget problem, we adjusted the budget allocation for the remaining quarters, and came up with ideas of possible events. After that, we talked about Fedora sessions for the SFD next day. At last, Somvannda asked us to share stories of being an Fedora ambassador. For me, it was the simple idea of organizing regular events to gather existing contributors and attract newcomers, and the idea of starting something by oneself when no one else has started it.


In the evening, we went to see the water puppet show, which is fun and amazing. At dinner we had delicious dishes and noodles, and Saigon beer! But we did not stay up too late at night, since we felt quite tired after one day’s meeting, and we need to prepare for SFD in the next day.

Day 2 (2014-09-20): Hanoi SFD 2014

Saturday was the Software Freedom Day (SFD), a global event to celebrate Free and Open Source Software (FOSS). I organized SFD in Tsinghua University last year, and it is lucky for me to be part of SFD Hanoi this year. Hanoi SFD is organized by VFOSSA, the FOSS association in Vietnam. Fedora was one main sponsor of the event. It was a whole day event held in a university. So many volunteers are students and employees of the university. It was fun that the event begins with volunteers dancing, both in the morning and in the afternoon, and they are so good at it!

In the morning are welcome and keynote sessions in one large lecture hall. Sarup, Somvannda, and I are honored to be introduced as special international guests to the event (in English). They awarded new members and event sponsors in the welcome session. Later in the keynote session, Tuan delivered a speech on seven ways to contribute to Fedora (without coding). Most of the morning sessions were in Vietnamese, and I could only understand a little bit. I brought some Fedora 20 DVDs, stickers, and flyers from China, and they were distributed very soon at the booth.


In the afternoon, we had a dedicated room for Fedora related sessions. First, Thang gave a general introduction of the Fedora Project to the audience in Vietnamese. Then I talked about free and open source software defined radio (FOSS SDR). With a lot of examples, I introduced why we should have FOSS SDR, and how FOSS SDR can enable hacking in the radio frequency. I introduced GNU Radio and various SDR hardware such as HackRF and bladeRF to show how FOSS and open hardware play well with each other. Since the talk was in English, and the topic is not so familiar, the main purpose of the talk was to show the power of FOSS and open hardware, and to encourage the audience to try out and contribute to FOSS projects.


Later on, Sarup delivered a FOSS 101 talk. He talked about why we should choose FOSS, how newcomers join and contribute to Fedora, and main communication tools of FOSS communities. Then he gave an introduction on Git and version control concepts. I helped demonstrate the git operations, and Trang helped translate for easy understanding.

At around 4:00 PM, we gathered to one room again. There was a panel Q&A session followed by the lucky draw. The panel session was quite interactive, and the audience raised many questions. One interesting thing is that the panel speakers voted for the best question and there was an award for that questioner. Then in the lucky draw, it turned out we foreigners were not so lucky. None of us was chosen. But lucky draw is always fun for everyone.

In the evening, we had dinner with the organizers and volunteers of SFD. We drank beer and toast to each other. I even learned how to toast in Vietnamese!

Day 3 (2014-09-21): One Day Tour

On Sunday, Somvannda and Sarup left for the airport early in the morning. My flight was around at 7:00 PM, so I took a one day tour in Hanoi. I visited Quang Truong Ba Dinh (Ba Dinh Square), Ho Chi Minh’s Stilt House, Ho Chi Minh Museum, One Pillar Pagoda, the Flag Tower, Hanoi Cathedral, and so on. The sight spots are relatively near to each other, so I travelled around mostly by walking. I had lunch at Quan An Ngon, a popular restaurant in Hanoi, and bought some candies and gifts to bring back to China. In the afternoon, on the way back to the airport, I also walked by the Ho Hoan Kiem (Hoan Kiem Lake). The sight spots are nice, and the food is delicious. So I enjoyed the trip to Hanoi a lot. Plus the warm support and help from Tuan, Thang, Somvannda, Sarup, and others, the days in Hanoi are quite memorable to me.


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

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

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


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


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




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


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

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


有时候我们希望在构建时能够在命令行添加一些宏定义,改变程序行为。一个典型应用示例是代码里通过检查是否定义了 DEBUG 宏,来决定是否输出调试信息。编译器一般提供命令行选项支持这种做法,例如使用 gcc 时可以在命令行添加 -D 选项,定义一些宏:

gcc -DDEBUG=1 a.c

不过,大型项目一般都需要自动化构建工具,如 GNU Autotools 或者 CMake。使用它们后,我们无法直接修改编译命令,但它们提供了替代方案。对于 Autotools,它可以识别 CPPFLAGS 等环境变量,从而我们可以在命令行上添加宏定义,例如:

CPPFLAGS="-DDEBUG=1" ./configure

此外,我们还可以先 export CPPFLAGS="-DDEBUG=1",再用 ./configure 命令。注意这里 CPPFLAGS 的 CPP 指的是 C 预处理器 (C Preprocessor),不是 C++,其中只应该设置 -I-D-U 等影响预处理器的选项。Autotools 支持 CFLAGSCXXFLAGSLDFLAGS 环境变量,分别用来指定 C 编译链接时、C++ 编译链接时、以及仅在链接时有效的选项。

目前许多项目已经使用 CMake 来构建。CMake 支持 CFLAGSCXXFLAGSLDFLAGS 等,但遗憾的是唯独不支持 CPPFLAGS。也就是说,CMake 会无视 CPPFLAGS 环境变量的值。Aron Xu 为此报了一个 BUG,不过因为没人志愿去做,所以一直没有修复。许多人可能会以为,可以用类似 cmake .. -DVAR=VALUE 的方式来添加宏定义,但这是无效的。这样一来,如果想在命令行上指定宏定义,只能复用 CFLAGS 或者 CXXFLAGS 变量。这基本可以工作,因为一般情况下预处理和编译是同一个命令进行的。

CMake 中标准的添加宏定义方法是使用 ADD_DEFINITIONS(-DMACRO)(参考文档),不过这需要修改 CMakeLists.txt 文件。如果想要在命令行上定制宏的开关或取值,那么可以像这里一样,定义一个 CMake 选项:

OPTION(DEFINE_MACRO "Option description" ON) # Enabled by default



之后,就可以用 cmake -DDEFINE_MACRO=OFF .. 调整宏的开关或取值了。

最后值得一提的是,如果代码里已经有了宏定义语句,那么通过命令行修改其取值是不可能的。编译器会警告宏被重复定义,而且生效的是源文件中的定义。想要重新定义,只能随后 #undef#define。这将不得不通过修改代码来实现。


本文介绍 C++ 中传统枚举类型存在的作用域不受限等问题,随后列举经典的限定其作用域的做法,最后给出新标准 C++11 下的解决方案。


传统的枚举类型在 C 语言中就有,C++ 中行为和 C 中一致,常被用来定义有类型的常量。一个典型的枚举类型定义如下:

enum Color { RED, BLUE };

C++ 发明人 Bjarne Stroustrup 总结这种枚举有如下问题

  • 作用域不受限 (unscoped),枚举变量的作用域不受限,会暴露给领近的代码作用域(如果在最外层则为全局作用域),容易引起命名冲突。例如如下代码是无法编译通过的:

    enum Color { RED, BLUE };
    enum Feeling { EXCITED, BLUE };
  • 会隐式转换为 int。这是 C 中的默认行为,但是和“有类型的常量”的初衷是不符合的。比如上面例子中 EXCITED == RED 会返回真(gcc 编译会有警告),这其实是不合常理的。

  • 用来表征枚举变量的实际类型不能明确指定,从而无法支持枚举类型的前向声明。


解决作用域不受限带来的命名冲突问题的一个简单方法是,给枚举变量命名时加前缀,如上面例子改成 COLOR_BLUE 以及 FEELING_BLUE。一般说来,为了一致性我们会把所有常量统一加上前缀。但是这样定义枚举变量的代码就显得累赘。C 程序中可能不得不这样做。不过 C++ 程序员恐怕都不喜欢这种方法。替代方案是命名空间:

namespace Color { enum Type { RED, YELLOW, BLUE }; };

这样之后就可以用 Color::Type c = Color::RED; 来定义新的枚举变量了。如果 using namespace Color 后,前缀还可以省去,使得代码简化。不过,因为命名空间是可以随后被扩充内容的,所以它提供的作用域封闭性不高。在大项目中,还是有可能不同人给不同的东西起同样的枚举类型名。


struct Color { enum Type { RED, YELLOW, BLUE }; };


C++11 的枚举类

上面的做法解决了第一个问题,但对于后两个仍无能为力。庆幸的是,C++11 标准中引入了“枚举类”(enum class),可以较好地解决上述问题。它使用如下语法定义:

enum class Color { RED, BLACK };


Color c = Color::RED;

类限制了其作用域,避免了命名冲突。同时也避免了隐式类型转换。也就是说,枚举类即是作用域受限的 (scoped),又是强类型的 (strongly typed) 枚举。至于第三个问题,C++11 标准允许指定存储类型:

enum class Color : char { RED, BLUE };

上面例子使用 char 来存储这个枚举类。缺省情况下使用 int。这样枚举就可以进行前向声明了:

enum class Color : char ;   // forward declaration
void foo (Color *p);
// ...
enum class Color : char { RED, BLUE }; // definition





使用 bladeRF 板卡时我们会遇到两个“镜像”:固件 (firmware) 镜像与 FPGA 镜像。二者是两个不同的概念。但是业界叫法不一,有时候会把二者混为一谈。一般而言,固件指的是嵌入到硬件设备中的软件,存放在只读存储器 (ROM) 或者闪存 (flash) 中,一般不易修改,修改的操作称为“刷新”(flashing)。固件这个名词最初和微代码相关,不过 bladeRF 里源代码是嵌入式 C 程序。FPGA 全名为可编程门阵列,其门电路、寄存器连接可以编程重构,其源程序一般是硬件描述语言 (HDL),通过综合 (synthesis) 等步骤得到二进制文件。在 bladeRF 板卡上,FPGA 只是一块 Altera 芯片。在没有内置非挥发存储时,FPGA 镜像需要每次上电时重新加载,bladeRF 就是这种情况。所以在拿到板卡时,上面已有固件,但还没有 FPGA 镜像。下面本文会具体说明在使用 bladeRF 时如何刷新固件、加载/更新 FPGA 镜像、以及如何自动加载 FPGA 镜像。注意,有时为了避免混淆,会称 FPGA 镜像为 FPGA 比特流 (bitstream),或者 FPGA 配置(因为它就是配置了门电路等组件的连接)。


注意:刷新固件前请先取消 FPGA 自动加载,以避免可能的冲突。FPGA 自动加载的细节参见下文。

Nuand 官方提供固件的源码,我们可以自行编译,不过这需要一套嵌入式开发工具链。Nuand 也提供构建好的固件镜像,可以直接下载使用。要刷新固件,只需在命令行执行:

bladeRF-cli -f bladeRF_fw_vX.Y.Z.img -v verbose

其中 X.Y.Z 为具体的版本号。命令完成后,需要断电重启了 bladeRF。然后可以用 bladeRF-cli 工具检查:

$ bladeRF-cli -e version

  bladeRF-cli version:        0.11.1-git-c631100
  libbladeRF version:         0.16.2-git-c631100

  Firmware version:           1.7.1-git-ca697ee
  FPGA version:               Unknown (FPGA not loaded)

看下其中 Firmware version(固件版本)是否更新。

事实上,还有另外一种刷新固件的方法,是通过进入设备的启动加载 (Bootloader) 模式(类似 Android 的 Recovery),输入一些命令完成的。不过这种方式步骤繁琐,一般不推荐使用,建议在上述简单方法遇到错误时考虑采用。具体步骤参加维基

加载 FPGA 镜像

注意到上面的示例中,FPGA version(FPGA 版本)显示为 Unknown(未知),FPGA 未加载。目前 bladeRF 使用两种 FPGA。要加载正确的 FPGA 镜像,首先需要确定手头 bladeRF 板卡的 FPGA 尺寸。它可以根据当初购买的价格判断,但更靠谱的方法是使用命令行查看:

$ bladeRF-cli -i
bladeRF> info

  Serial #:                 4f977f01eec48f5068c2ee3aeba41ba9
  VCTCXO DAC calibration:   0x8b63
  FPGA size:                40 KLE
  FPGA loaded:              yes
  USB bus:                  4
  USB address:              5
  USB speed:                SuperSpeed
  Backend:                  libusb
  Instance:                 0

交互模式下用 info 命令,或者直接在命令行下 bladeRF-cli -e info,在输出中寻找 FPGA size,就可以看到 FPGA 尺寸信息。这里示例显示板卡使用 40 KLE FPGA。事实上,FPGA 尺寸还可以通过查看 FPGA 芯片上的 EP4CExxxF23C8N 字样中 xxx 的部分来获得。

Nuand 官方提供了预先构建的 FPGA 镜像,免除用户手工编译之苦。40 KLE FPGA 对应 hostedx40.rbf 文件,以此类推。要加载 FPGA 镜像,只需使用命令 bladeRF-cli -l /path/to/fpga/file,或者交互模式下 load fpga /path/to/fpga/file,其中 /path/to/fpga/file 为 FPGA 镜像所在路径。FPGA 镜像成功加载后,板卡上的三个 LED 灯会亮起,交互模式下 version 命令可以看到 FPGA 版本不再是未知。

不过,正如前文所说,每次重新加电后,FPGA 镜像都需要重新加载。下面说下如何自动加载 FPGA 镜像。

自动加载 FPGA 镜像

bladeRF 维基上提供了两种自动加载 FPGA 镜像的方法。第一种方法基于主机软件,libbladeRF 在打开设备时,会在如下目录自动搜索合适的 FPGA 镜像:

  • $HOME/.config/Nuand/bladeRF/
  • $HOME/.Nuand/bladeRF/
  • /etc/Nuand/bladeRF/
  • /usr/share/Nuand/bladeRF/

只需将下载的 FPGA 镜像文件放在上述目录之一(没有可以新建之),即可实现 FPGA 镜像的自动加载。

另一种方式是将 FPGA 镜像写入设备的 SPI 闪存。这种方式的好处是写入后就不再依赖主机,从而可以实现脱机运行。不过这种方式比较慢,加载 x40 镜像需要大约 4 秒钟。注意绝对不要在加载完成,三个 LED 灯亮起前试图使用设备。要使用这种方式,需要执行下面命令:

bladeRF-cli -L /path/to/fpga/file


前面提到,刷新固件时最好取消自动加载。对于第一种方法,只需把 FPGA 镜像文件临时移走。第二种方法,则需要执行命令 bladeRF-cli -L X,以擦除写入的 FPGA 镜像。




今年 7 月 19–20 日,台湾的开源社区大会 COSCUP 2014 在台北召开。我有幸以演讲者的身份第一次参加到了活动当中,所见所闻颇丰。


什么时间第一次听说 COSCUP 我已经记不清楚了。可以确定的是 emily 在 4 月份的一次 IRC 会议里提起过。tonghui 应该也提到过若干次。在大家的口中,COSCUP 非常有趣,台湾人很有娱乐精神。于是在今年的 COSCUP 征集演讲时,我投了两个话题,最终很幸运有一个被接收。FUDCon 期间,Max 也极力推荐我去 COSCUP 体验一下,liangsuilong 特别提到和 zerng07 等位于台湾的 Fedora 社区成员会面交流,他们也会参加 COSCUP 活动。此外,我对台湾自由行盘算多时,这正好是一个顺道去台湾旅行的机会,而 COSCUP 时间正好和实验室假期安排一致。基于以上原因,我下定决心去参加 COSCUP,之后顺便台湾自由行,即使后来得知大会不提供机票住宿的报销。

第 0 天:7 月 18 日


因为机票要自费,所以最终订了一个在香港中转一次的航班。去程是深夜出发,感谢宝哥开车送我去首都国际机场。安检时查出带的洗头膏和沐浴露超量(200 mL,超出 100 mL 限制),只能免费寄存在机场,等回程时取走。航班延误了大约两个小时,应该与香港方面的天气情况有关。延误使得到香港时已经天亮,于是在香港机场吃了早饭。VISA 信用卡不知为何用不了,而且没有预备港币,还好可以付人民币找港币。

到达台北桃园机场已经是中午时分。排队过边检、换台币,发现机场已经不办青壮卡了。我住宿订在南港安乐旅社,过去要先坐一个小时的巴士。赶上了 12 点多出发去南港的客运巴士,巴士报站的是标准的台湾男声,温文尔雅。巴士终点是南港展览馆,我还进去逛了逛,不过没看到什么展览,倒是有一个会场有许多日本人在聚会。出来后依着旅社事先给的路线提示寻找,不过第一次真的没找到。当时还没办手机卡,在机场没有注意到办卡地点,再去找就只能做一个小时后的一班巴士了。不过走着走着看到路边有个中华电信的营业厅,于是决定先把手机卡办了。办的十天不限流量的 3G 卡,要 500 新台币;另外为了能打电话发短信,又充了 100 新台币值,后来证明这个充多了用处不大。办卡的女生太温柔礼貌了,我刚等了十秒钟就跟我说让您久等了,这着实让我一惊。

有了手机卡,有了 3G 网络,Google 地图终于可以派上用场了。最终找到旅社时,感慨他们家的门面招牌太小太不起眼了。不过他们是一家正宗的国际青旅,条件设施相当不错。住下后的下午没有出门,主要是休息一下,另外上网预订了去花莲的火车票,查了去演讲者晚宴的路线。


演讲者晚宴在钱唐村,从我住的地方可以坐捷运过去,我顺道办了悠游卡。出捷运后还要走一会儿,路上经过了诚品敦南店,还能望到 101 大楼。还没看到餐厅招牌,就已经看到了从上海前来参会的 Thomas Yao。后来得知这是一家上海菜馆,饭菜很不错,不过 Thomas 的心情很复杂。进门领了胸牌 (Badge),看到了 tonghui。在吃好喝好的同是,还认识了 COSCUP 主办方议程方面的组织者、大会主持人 Richard Lin,以及我的演讲所在分会场的主持人 Penk,见到了 PCManX, fourdollars 等大神。比较囧的是一开始把 g0v 的村长误认成了大妈,二人发型初看挺像的 XD 从晚宴回住处的途中,我去了国父纪念馆,近距离拍摄了 101 大楼。

第 1 天:7 月 19 日

COSCUP 正式活动于周末两天在中研院举行。周六我早起在住处附近吃过早饭后搭公车(大陆称公交)前往会场。刚开始搞错了方向,耽误了些时间,不过也了解到台湾的公车是需要摆手才会到站停车的。到会场后找到演讲者签到处,很快拿到了会议袋,内有一本议程册和一件 Polo 衫和若干宣传页。COSCUP 并行演讲有 7 个之多,人文馆一层楼的会议室装不下,以至于一半的演讲在另外一个楼,名叫学术活动中心。好在 keynote 时全场地联播,各个分会场都可以实时看到主会场的画面,能够有效地分流观众。我的演讲安排在学术活动中心的一个房间,并且就在 keynote 之后,所以我提前去那个楼了。

九点多些,活动正式开幕,Richard 是主持。他介绍今年参会一千多人,但门票开票后 10 秒钟就被抢光,可谓秒杀,COSCUP 受欢迎程度可见一斑。Richard 还指出 COSCUP 不仅仅是技术分享,更重要的是提供遇到社区中的人,和大家面对面交流的机会。之后是题为 Maker 《自造世代》的 keynote,但与传统形式有很大不同,这个 keynote 先是播放 Maker 电影片段,然后是主持人和电影团队、开源人士进行小组讨论 (panel discussion)。Maker 大陆翻译为创客,台湾翻译为自造者。Maker 和开源有许多关联,这也是主办方将今年主题定为 Make Things Happen 的原因。

keynote 行将结束时,我就前往 H3 会议室,准备我的演讲了。H3 是个小会议室,挺容易坐满的。我的主题是 Fedora.next: What’s Next?,开始前我先做了个小调查,发现在场听说过、用过 Fedora 的用户还不少。在演讲中我还是先简单介绍了 Fedora 项目及其四项基本点,然后介绍了 Fedora.next 这一架构提案的缘起、内容、以及当前进展情况。Fedora.next 目前仍是一个比较新的概念,这个演讲的主要目的是让中文社区的朋友更紧密地跟进说英语的核心社区,为社区未来发展做出更多更为核心的贡献。

问答环节有提问问到 Fedora 会不会有类似某些发行版那样的长期支持版 (LTS)。我的回答是目前看来没有。这和 Fedora 相对更追求新鲜特性 (Feature)、敢为人先 (First) 的特点有关。RHEL、CentOS 等 Fedora 衍生版则更多关注稳定性。历史上有一个 Fedora Legacy 项目来对旧版本的 Fedora 进行持续支持,不过后来因为缺乏人力和兴趣,已经不再继续。不过,最近的 Fedora 贡献者大会 Flock 2014 上,Fedora Workstation 工作组的 Christian Schaller 提到要打造真正的 ABI,这也许会在将来改善 Fedora 的长时稳定性。


之后我发放了 Fedora 的小礼品——一些胸章和徽章 (pins and buttons)给现场听众。这些小礼品最初在欧洲生产,由 tuanta 带到越南,然后在 FUDCon 时寄到北京,再被我带到台湾,相当有纪念意义。我也受到了 COSCUP 给演讲者准备的礼物,是一个体验活字印刷的盒子,非常精美。值得一提的是,COSCUP 会让演讲者现场签一个授权协议,用 CC 协议授权自己的讲稿和录像。

茶歇时间,我找到 zerng07 等人,边聊天边逛展台(摊位)。大会展台巨多,分布在不同楼以及不同楼层。主办方搞起了所谓大地游戏,逛展台时刷自己的胸牌,然后刷够一定数量后可以领取一个礼品,这也刺激了大家逛展台的兴趣,增进了和不同社区交流讨论的机会。Mozilla、Ubuntu 等的台湾社区颇为壮大,展台布置地也很赞,礼品多多活动多多。来自大陆的赞助商 GitCafe 也有一个活跃的展台,不过他们需要和不太了解的观众解释他们不是卖咖啡的 :D。值得一提的是,一些赞助商看似和技术、开源没什么关系,却也在展台上兴致勃勃地卖茶、卖饮料,足见 COSCUP 已经辐射到传统的开源圈子以外,有着更广泛的关注和参与。在展台处碰到了 Max,顺利实现了 GNOME.Asia 视频的“人肉转运”。几天之后,Max 就把他们悉数上传到了 Youtube 上。

午餐由 COSCUP 统一提供,两个发放点,一千多人秩序井然地排队。队伍绕了整个楼层一周,据说排到了别的楼层,阵势丝毫不亚于清华电子系学生节排队。午餐就是大陆习惯称呼的盒饭,在台湾叫便当。菜品比较丰富,味道也不错。午饭时和大家聊,大家一致认为中研院是一个非常好的场地。事实上两年前的 COSCUP 也是在这里举办。饭后亲眼见到餐余垃圾的细致分类,印象深刻。

一天之中,除了茶歇和午餐,剩余时间主要就是赶场听报告了。在两层座位加过道都坐满了的大会议室里,PCMan 讲到 LXQt 是开源社区的成功合并 (merge) 而非分支 (fork),而他本人是个医生,开源只是业余爱好。法律专业老师葛冬梅为大家讲解如何确定开源项目的许可证信息,特殊情况该如何处理。Kito Cheng 生动地描述开源编译器,主要是 clang 和 gcc,之间的“竞赛”,所在的小会议室在开讲前就已爆棚。来自赞助商 Google 的演讲题目直到最后才揭晓,是由其工程师吴光哲介绍刚刚发布的 Noto Sans CJK 字体制作过程的点滴,中型会议室也是人满为患。下午最后一场,我听了高村长 (clkao) 的 g0v 村情咨文。

到了晚上,COSCUP 安排了分社区的 BoF(Bird of Feather,同类人聚会)环节,并且提供了皮萨可乐。我参加了 Fedora 社区的聚会,和台湾地区的 Fedora 中文用户边吃边聊。Fedora 在台湾的社区不大,影响力相对较小,成员都比较年轻,多为学生,发展新成员也较多依靠朋友推介,优点是有兴趣有热情方便组织活动,缺点是社区参与受学业影响较大。这一点和大陆的情况颇为类似。因为人数不多,人力有限,所以台湾社区成员的精力主要集中在中文字体、输入法、本地化等中文用户最关心的问题上。相比起来,大陆这边贡献更为多元。另外,虽然台湾社区成员也参与 Fedora 中文列表的讨论,但他们似乎主要通过 Fedora 中文用户组在 Facebook 上的社群页来在线交流,而大陆用户很少参与其中,这使得两边交流目前比较有限。希望今后两边能有更多交流,在台湾地区大家的活力能够让 Fedora 为更多的人所知所用。

BoF 结束后,Max 请我和 tonghui 去他们住处附近的宁夏夜市,体验台北小吃。最初我们大陆团计划去师大夜市,不过得知那里的夜市氛围已大不如前。宁夏夜市位于宁夏街,一条不长的街道,但路两边小吃店和小吃摊琳琅满目。Max 带我们体验了炒粉(?)、豆花、还有记不清名字的带馅丸子,我们纷纷表示很好吃,并未事先没有预留肚子表示遗憾。据了解,台北小吃可以吃到晚上两三点,相应地公车和捷运的末班也都较晚,不由感慨台湾人民夜生活之幸福。


因为我在台湾要待的日期不多,所以周日我就没有参与 COSCUP 的活动,而是选择了台北一日游。不过单就这一天,COSCUP 已经给我留下了很深的感受。总体说来,COSCUP 作为一个社区大会,汇聚了许多台湾的开源社区,促进了社区成员之间的交流,已经显示出了对更广泛人群的吸引力。从演讲话题来讲,话题征集不只强调甚至一定程度上弱化技术,更为关注社区建设和发展。另外开源被赋予了更多的内涵和外延,除了传统的开源技术社区话题外,还有不少开放政府、开放数据的主题。台湾当地的演讲者参与开源大多是兴趣驱动,演讲幽默风趣、生动好玩,(据说闪电演讲都会各种表演乃至杂耍,)演讲效果自然上乘。相对于技术交流为主的演讲,COSCUP 更注重让大家通过面对面的机会交友和交流,这对社区的发展壮大是有益的。反观大陆,我以为还没有一个能和 COSCUP 相提并论的社区大会。上半年的 GNOME.Asia 和 FUDCon APAC 合办,是一次很好的经历,但是在参与社区的数目、活动规模等方面还有一定差距。这和活动本身定位有关系,毕竟他们本身面向的人群是自己社区,面向的地域是整个亚洲/亚太而非中国。COSCUP 的成功,也许得益于台湾地域较小,交通相对廉价,人民(这里主要是程序员)生活水平较高。不过这不是大陆地区(或者整个华语地区)没有如此社区大会的借口。COSCUP 在议程、志愿者、展台等方面为大陆的社区活动提供了可以借鉴的经验。在其帮助下,通过社区群策群力,相信大陆地区真正意义上的社区大会可以梦想成真。


Note: This is a press style report of FUDCon APAC 2014, which summarizes the event highlights. Don’t miss the links to slides, videos, and photos!

FUDCon APAC 2014 was successfully held at Conference Center at New Main Building of Beihang University, Beijing, China during May 23 to 25, 2014. This year the event was held together with GNOME.Asia Summit, an annual conference for GNOME users and developers in Asia. It turns out to be a rather exciting experience of mutually beneficial cooperation of free and open source communities. In total, GNOME.Asia and FUDCon APAC 2014 attracted more than 500 registrants, and among them over 300 attended the event.

There were 52 speakers in total and among them 22 are for FUDCon. Thanks to the help with the community budget, many non-local speakers joined the event and made FUDCon Beijing a big gather up for the Fedora community. The speakers delivered a wide range of topics about free and open source technologies and communities presented in keynote speeches and five parallel tracks. Richard Stallman gave a keynote speech on Computing, Freedom, and Privacy, which is the favorite speech according to the feedback survey. Talks in FUDCon tracks cover various subprojects of Fedora, as well as new application introduction and community building discussion. The links to all slides are available at the wiki page. As for the videos, they are currently available at the GNOME.Asia channel on Youtube. The Fedora Videos team is working to make them available on Fedora channel.

There were about 50 volunteers at the event. They were recruited from the local universities and companies. They showed great enthusiam and did amazing jobs to make the event well organized. Two of them, Tong Hui from GNOME and Zamir Sun from Fedora, were each awarded the prize of best volunteer, a hand fan full of wishes in various languages written by the attendees.

It is worth pointing out that about ten percent of the attendees are women. Many of them are active volunteers and talented speakers. Still more women contributors are expected in free and open source communities. And there was a dedicated session, Fedora Women initiated by Nitesh, to discuss the issue and possible solutions.

FUDCon is not just about technical sessions. It is also about meeting friends and having fun. FUDPub was organized as a welcome party, and there was a celebration party with delicious buffet on Sunday evening. On Saturday there were sports games including football, baseketball, and ping-pong. These social events helped the attendees enjoy the conference and the community.

Special thanks go to the sponsors. FUDCon was sponsored by 7 companies and 5 local communities. The success would be impossible without their generous support. There were 14 booths for sponsoring companies and local communities at the joint event. Attendees enjoyed hanging around the booths for discussion, and many swags were distributed at the booths.

Photos and Reports from various attendees are aggregated on the wiki page. The FUDCon Beijing Badge has been created and is in the process of collecting FAS usernames at the current writing.



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
sudo make install

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

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

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