The second day of COSCUP 2015 was August 16, Sunday. Since we had FreedomKnight and zerng07 at the booth, and we did not find very intersting talks in the early morning, tonghuix and I gave ourselves a bit more rest and did not get up quite early. We both found the talks this year were not as attractive as last year. Part of the reason might be that this year’s theme “Open Culture” is kind of too general and it is not easy to talk about it. Or in a sense it is align with COSCUP’s philosoph “more social than tech”, which means it is more a chance of letting open source people to meet than diving into specific technical topics.

Around the booth we found some interesting swags that might be useful for future Fedora events. One is the retractable network cable as shown in the middle figure above. Such cables were distributed in COSCUP previously as gifts. I think it is quite nice because: 1) it is so useful that one can start to use it directly at the venue; 2) the central circular part is perfect for branding logo etc.; 3) it is not expensive and can be cheap with mass production. Another nice swag is shown in the rightmost figure above, a toy moe girl (optionally, with a toy laptop). As soon as she appeared on our neighboring booth, a crowd of people and cameras came around the booth. Westerners might not understand, but moe culture is quite popular among East Asia countries, and it is getting mainstream. For example, in Taiwan you can find quite a few moe girls on various posters in public. Besides, ".moe" has become a registrable top-level domain name. Since she is so eye-catching, I guess it is worth trying to make one for Fedora. Regarding design, the Fedora moe girl might be a good starting point.

At the booth I also discussed with FreedomKnight and zerng07 about Fedora community development. zerng07 is getting busier with his work, and they are trying to develop a new ambassador. It seems that currently the Taiwan contributors prefer to use the Facebook group of Fedora Chinese community for discussion. I encourage them to keep an eye on our mailing lists and attend weekly IRC meetings, where activities are more visible to the Chinese community and the whole Fedora community. I also encourage them to go outside for better communication and cooperation. When the local community grows strong enough, Taiwan can be a good candidate for FUDCon APAC.

At around 15:00 PM, almost all attendees gathered into the large hall to listent to jserv‘s last speech “Retrospect on Taiwan Open Source Ecosystem”. jserv is a long term open source contributor in Taiwan, and he has contributed talks to COSCUP for all the ten years. In the morning I caught up with his experience sharing of open source in education. To encourage new contributors, he decided this talk to be his last speech in COSCUP. In the talk, he introduced the history of open source development in Taiwan and showed quite a few impressive early projects by Taiwan open source contributors. He also motivated the young generation in Taiwan to contribute more to open source in the world.

After that was the lightning talk session. In COSCUP, a lightning talk can be not a “talk” at all, because all kinds of performance are also welcome. I had learnt the rule for a while, but this time I finally had the chance to hear an ocarina show as a lightning talk by a COSCUP volunteer! Why ocarina show? Simply because others learnt that he can play ocarina during face-to-face discussion.

At last, after a short closing speech from the lead organizer came the group photo session. All volunteers were invited on stage. An unmanned aerial vehicle (UAV) was used for taking photos, which was really cool. By the way it was also cool when the UAV flew over your head!

All in all, I enjoyed the two days of COSCUP very much. Looking into the future, I believe COSCUP can continue to be a great chance for Fedora Chinese community to gather up. Besides, non-Chinese contributors are also welcome to join to take the opportunity to meet face-to-face and get things done.


A few days ago I had the chance to attend COSCUP in Taiwan for the second time. This time I was lucky to get travel subsidy from Fedora APAC’s event budget. Below is my event report for day 1 (Aug 15, Saturday).

The venue of COSCUP 2015 is Academia Sinica, which is the same as in last year. But this time I stayed in a hotel not quite near the venue, sharing room with another Fedora ambassador tonghuix. So in the morning of day 1, we got up early and caught the Taipei MRT (Massive Rapid Transit) train. For the last mile to the venue, we took a taxi with FreedomKnight, a Fedora ambassador in Taiwan, and his girlfriend, who we happened to meet near our destination MRT station.

We arrived at the venue at about 8:30 AM, and it was about to allow registration. Quite a lot of attendees had already queued up before the gate. Shortly after that we registered by scanning the QR code. Then we looked for the booth location and set up the booth. FreedomKnight brought some Fedora 21 DVDs and I brought the badge reel which tonghuix carried from Beijing to Taipei. I tried a few ideas of placing these DVDs and settled down to a “4F” form. People started to visit our booth before we finished the preparation!

I spent the whole morning around our booth, talking with interested people about Fedora. Some of them were not familiar with Fedora, so I introduced to them that Fedora is an Linux distro similar as Ubuntu and openSUSE, but with special stress on our “Four Foundations” (aka 4F). Quite a few visitors had previous experience with Fedora, or current work experience with testing their company products on (somewhat old releases of) Fedora. I talked about Fedora.next with them and encouraged them to try out (or let their companies to try out) newer Fedora versions. Besides, we also met several guys who had used Fedora a lot but had not quite joined the local community, and I invited them to the Fedora BoF (Bird of a Feather) at night.

FreedomKnight’s girlfriend was also around our booth and helped out a lot. COSCUP continued to organize the “Dadi” game: every booth had a unique seal; anyone who had collected all booth seal stamps gained a chance in the lucky draw. There was a RPM packaging workshop which was proposed by the other Fedora ambassador in Taiwan, zerng07. Unfortunately zerng07 was not able to arrive on time due to work emergencies. FreedomKnight took the place and delivered the session.

In the afternoon, there were a workshop by tonghuix about how to use XMPP to chat, and I was asked to help with the demo. We demonstrated how to use free and open source XMPP clients both on Linux desktop and Android cellphone to chat, with and without OTR (off the record) encryption. I also took a few photos for the session.

Then at around 16:00 PM, tonghuix gave an impressive lecture on free software community management. He took many little stories from the book Zhuang Zi as examples to illustrate how and why certain management practices succeed or fail. He summarized the Tao of free software community management as “Three-Self”, which can be roughly translated as “Freedom (aka Self-will or Self-choice), Self-governance, Self-organization”.

When the day’s session almost came to an end, zerng07 finally arrived. We had him and some other Fedora community members for the BoF session in the evening. The total number of people for Fedora BoF was about ten. During the BoF we discussed the interesting differences of languages and education between mainland China and Taiwan, as well as their impact on software localization and overall cooperation of Fedora Chinese community. The Chinese glossary might need to be revived. More interaction is needed to facilitate cooperation, and more awareness and support from the whole Fedora project are also required.


Fedora 21 Release Party Chongqing was successfully held in Go On Cafe on Jan 24, 2015. This was the first time for Fedora Release Party to be in Chongqing to my knowledge. It was organized as a joint event with Chongqing LUG’s monthly meetup. There were about 15 attendees. Most of them were from Chongqing, while I was from Beijing, and another guy was from Chengdu. This was also my first time to visit Chongqing.

The event started around 14:00 and was hosted by Linjie Lyu from Chongqing University. She asked everyone to have a self-introduction first. It turned out we had more or less equal number of company employees and university students. Among them, we had hillwood, an openSUSE contributor, who live broadcast the whole event on weibo.

The first talk was given by Lingyu Zhu. He introduced QEMU and KVM virtualization, and talked about memory balloon and virtual machine migration in details. He demonstrated the common usage of QEMU command line interface a lot during his talk. At last, he revealed the hacks to boot up an ancient system, Red Hat Linux 6.2, with a modern Linux kernel (v3.16) in QEMU.

Then, I talked about "What’s New in Fedora?". I didn’t find current Fedora users in the audience, but some of them had past experience of using Fedora. I introduced the main characteristics of Fedora, the Fedora.next proposal, Fedora 21 features, and Fedora Chinese User Group. In the Q&A session, we discussed about stability of desktop distribution, the role of Fedora Server, and so on.

Next, hillwood gave a lightning talk on his view of "open source". He argued that "open source" is not just "making the source code public". It also means the way of development. In particularly, It means the awareness of making the software compatible among multiple Linux distributions.

At the event we had free coffee. I also distributed the Fedora DVDs and stickers. After the event, we had a group dinner, and enjoyed ourselves while discussing various topics.

Before ending the report, I would like to share some of my observations about open source in Chongqing. Compared with Beijing, the community size is smaller in Chongqing. Part of the reason is that there are fewer IT companies with open source business. At the same time, the current companies find it difficult to find suitable employees and they often need to train new employees themselves first. Besides, there are also a similar phenomenon with Beijing: the business and/or university districts lie in distant locations. The community needs to shift between different venues to reach out to newcomers, and people need to travel some time to get together. However, there are also good news. Chongqing LUG has regular meetups, and there are active members organizing events and promoting free and open source. We think it is beneficial to involve more interested students and more outside speakers in the future.

Click here for the Chinese report by Chongqing LUG and more photos!

十一 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 镜像。